Commit 47115f37 authored by Anna Pavlova's avatar Anna Pavlova Committed by Alexander.Trofimov

Файлы с SVN : branch Math_ForcedBreak

parent 9ff89124
......@@ -12,7 +12,7 @@ function CMathPropertiesSettings()
this.brkBin = null;
this.defJc = null;
this.dispDef = null;
this.dispDef = null; // свойство: применять/ не применять paragraph settings (в тч defJc)
this.intLim = null;
this.naryLim = null;
......@@ -22,22 +22,41 @@ function CMathPropertiesSettings()
this.wrapIndent = null;
this.wrapRight = null;
this.smallFrac = null;
// не реализовано //
this.brkBinSub = null;
this.interSp = null;
// for minus operator
// when brkBin is set to repeat
this.brkBinSub = null;
this.intraSp = null;
//***** WORD IGNORES followings parameters *****//
// mathFont: в качестве font поддерживается только Cambria Math
// остальные шрифты возможно будут поддержаны MS Word в будущем
this.mathFont = null;
// Default font for math zones
// Gives a drop-down list of math fonts that can be used as the default math font to be used in the document.
// Currently only Cambria Math has thorough math support, but others such as the STIX fonts are coming soon.
// http://blogs.msdn.com/b/murrays/archive/2008/10/27/default-document-math-properties.aspx
// http://msdn.microsoft.com/en-us/library/ff529906(v=office.12).aspx
// Word ignores the interSp attribute and fails to write it back out.
this.interSp = null;
// http://msdn.microsoft.com/en-us/library/ff529301(v=office.12).aspx
// Word does not implement this feature and does not write the intraSp element.
this.intraSp = null;
// http://msdn.microsoft.com/en-us/library/ff533406(v=office.12).aspx
this.postSp = null;
this.preSp = null;
this.smallFrac = null;
// RichEdit Hot Keys
// http://blogs.msdn.com/b/murrays/archive/2013/10/30/richedit-hot-keys.aspx
//*********************//
}
......@@ -51,6 +70,7 @@ CMathPropertiesSettings.prototype.SetDefaultPr = function()
this.lMargin = 0;
this.naryLim = NARY_UndOvr;
this.rMargin = 0;
this.smallFrac = false;
this.wrapIndent = 25; // mm
this.wrapRight = false;
};
......@@ -85,6 +105,9 @@ CMathPropertiesSettings.prototype.Merge = function(Pr)
if(Pr.wrapRight !== null && Pr.wrapRight !== undefined)
this.wrapRight = Pr.wrapRight;
if(Pr.smallFrac !== null && Pr.smallFrac !== undefined)
this.smallFrac = Pr.smallFrac;
};
CMathPropertiesSettings.prototype.Copy = function()
{
......@@ -376,6 +399,11 @@ CMathSettings.prototype.Get_WrapRight = function()
this.SetCompiledPr();
return this.CompiledPr.wrapRight;
};
CMathSettings.prototype.Get_SmallFrac = function()
{
this.SetCompiledPr();
return this.CompiledPr.smallFrac;
};
CMathSettings.prototype.Load_Settings = function()
{
var Settings = {};
......@@ -605,6 +633,7 @@ function CMathMenuSettings(oMathPr)
this.RightMargin = oMathPr.rMargin/10;
this.WrapIndent = oMathPr.wrapIndent/10;
this.WrapRight = oMathPr.wrapRight;
this.SmallFraction = oMathPr.smallFrac;
}
else
{
......@@ -617,6 +646,7 @@ function CMathMenuSettings(oMathPr)
this.RightMargin = undefined;
this.WrapIndent = undefined;
this.WrapRight = undefined;
this.SmallFraction = undefined;
}
}
CMathMenuSettings.prototype.get_BreakBin = function(){ return this.BrkBin;};
......@@ -637,6 +667,8 @@ CMathMenuSettings.prototype.get_WrapIndent = function(){return this.WrapIndent;}
CMathMenuSettings.prototype.put_WrapIndent = function(WrapIndent){this.WrapIndent = WrapIndent;};
CMathMenuSettings.prototype.get_WrapRight = function(){ return this.WrapRight;};
CMathMenuSettings.prototype.put_WrapRight = function(WrapRight){ this.WrapRight = WrapRight;};
CMathMenuSettings.prototype.get_SmallFraction = function() {return this.SmallFraction;};
CMathMenuSettings.prototype.put_SmallFraction = function(SmallFrac) {this.SmallFraction = SmallFrac;};
window["CMathMenuSettings"] = CMathMenuSettings;
CMathMenuSettings.prototype["get_BreakBin"] = CMathMenuSettings.prototype.get_BreakBin;
......@@ -657,6 +689,8 @@ CMathMenuSettings.prototype["get_WrapIndent"] = CMathMenuSettings.prototype
CMathMenuSettings.prototype["put_WrapIndent"] = CMathMenuSettings.prototype.put_WrapIndent;
CMathMenuSettings.prototype["get_WrapRight"] = CMathMenuSettings.prototype.get_WrapRight;
CMathMenuSettings.prototype["put_WrapRight"] = CMathMenuSettings.prototype.put_WrapRight;
CMathMenuSettings.prototype["get_SmallFraction"] = CMathMenuSettings.prototype.get_SmallFraction;
CMathMenuSettings.prototype["put_SmallFraction"] = CMathMenuSettings.prototype.put_SmallFraction;
function Get_WordDocumentDefaultMathSettings()
......@@ -1213,6 +1247,7 @@ ParaMath.prototype.Add = function(Item)
this.Get_ParaContentPos(false, false, ContentPos);
var TextPr = this.Root.GetMathTextPrForMenu(ContentPos, 0);
var bPlh = oContent.IsPlaceholder();
// Нам нужно разделить данный Run на 2 части
var RightRun = Run.Split2(Run.State.ContentPos);
......@@ -1227,18 +1262,16 @@ ParaMath.prototype.Add = function(Item)
oContent.Correct_ContentCurPos();
var lng2 = oContent.Content.length;
var Pos_ApplyTextPr =
{
StartPos: StartPos + 1,
EndPos: StartPos + lng2 - lng
};
TextPr.RFonts.Set_All("Cambria Math", -1);
if (true === TrackRevisions)
LogicDocument.Set_TrackRevisions(false);
oContent.Apply_TextPr(TextPr, undefined, false, Pos_ApplyTextPr);
if(bPlh)
oContent.Apply_TextPr(TextPr, undefined, true);
else
oContent.Apply_TextPr(TextPr, undefined, false, StartPos + 1, StartPos + lng2 - lng);
if (true === TrackRevisions)
LogicDocument.Set_TrackRevisions(true);
......@@ -2685,106 +2718,6 @@ ParaMath.prototype.GetPlh = function(oMeasure, font)
return oMeasure.Measure2Code(0x2B1A).Height;
};
ParaMath.prototype.SetMathProperties = function(props)
{
//***** FOR FORMULA *****//
// В документации везде, где нет примера использования свояства, означает, что Word не поддерживает это свойство !
if(props.naryLim == NARY_UndOvr || props.naryLim == NARY_SubSup)
this.MathPr.naryLim = props.naryLim;
if(props.intLim == NARY_UndOvr || props.intLim == NARY_SubSup)
this.MathPr.intLim = props.intLim;
if(props.brkBin == BREAK_BEFORE || props.brkBin == BREAK_AFTER || props.brkBin == BREAK_REPEAT)
this.MathPr.brkBin = props.brkBin;
// for minus operator
// when brkBin is set to repeat
if(props.brkSubBin == BREAK_MIN_MIN || props.brkSubBin == BREAK_PLUS_MIN || props.brkSubBin == BREAK_MIN_PLUS)
this.MathPr.brkSubBin = props.brkSubBin;
// в случае если smallFrac = true,
if(props.smallFrac == true || props.smallFrac == false)
this.MathPr.smallFrac = props.smallFrac;
if(props.wrapIndent + 0 == props.wrapIndent && isNaN(props.wrapIndent)) // проверка на число
this.MathPr.wrapIndent = props.wrapIndent/1440;
//******** check for element 0x1FFD - 0xA721 *******//
// This element specifies the right justification of the wrapped line of an instance of mathematical text
// Instance : Arrows 0x2190-0x21B3, 0x21B6, 0x21B7, 0x21BA-0x21E9, 0x21F4-0x21FF,
// 0x3D, 0x2234 - 0x2237, 0x2239, 0x223B - 0x228B, 0x228F - 0x2292, 0x22A2 - 0x22B9,
// 0x22C8-0x22CD, 0x22D0, 0x22D1, 0x22D5 - 0x22EE,0x22F0-0x22FF, 0x27F0 - 0x297F (arrows and fishes), 0x29CE - 0x29D5
// 0x2A66 - 0x2AF0 (equals), 0x2AF2-0x2AF3, 0x2AF7 - 0x2AFA
if(props.wrapRight == true || props.wrapRight == false)
this.MathPr.wrapRight = props.wrapRight;
//***** FOR DOCUMENT *****//
// defaultJc
// выравнивание формулы в документе
this.MathPr.defJc = props.defJc;
// dispDef
// свойство: применять/ не применять paragraph settings (в тч defaultJc)
this.MathPr.dispDef = props.dispDef;
// added to paragraph settings for margins
// rMargin
// lMargin
this.MathPr.lMargin = props.lMargin;
this.MathPr.rMargin = props.rMargin;
//***** НЕПОДДЕРЖИВАЕМЫЕ Вордом свойства *****//
// mathFont: в качестве font поддерживается только Cambria Math
// остальные шрифты возможно будут поддержаны MS в будущем
this.MathPr.mathFont = props.mathFont;
// Default font for math zones
// Gives a drop-down list of math fonts that can be used as the default math font to be used in the document.
// Currently only Cambria Math has thorough math support, but others such as the STIX fonts are coming soon.
// http://blogs.msdn.com/b/murrays/archive/2008/10/27/default-document-math-properties.aspx
//***** FOR FORMULA *****//
// http://msdn.microsoft.com/en-us/library/ff529906(v=office.12).aspx
// Word ignores the interSp attribute and fails to write it back out.
this.MathPr.interSp = props.interSp;
// http://msdn.microsoft.com/en-us/library/ff529301(v=office.12).aspx
// Word does not implement this feature and does not write the intraSp element.
this.MathPr.intraSp = intraSp;
//***** FOR DOCUMENT *****//
// http://msdn.microsoft.com/en-us/library/ff533406(v=office.12).aspx
// Word ignores and discards postSp
this.MathPr.postSp = props.postSp;
this.MathPr.preSp = props.preSp;
// RichEdit Hot Keys
// http://blogs.msdn.com/b/murrays/archive/2013/10/30/richedit-hot-keys.aspx
};
ParaMath.prototype.GetMathPr = function()
{
return this.MathPr;
};
ParaMath.prototype.Get_Default_TPrp = function()
{
return this.DefaultTextPr;
......
......@@ -23,7 +23,6 @@ function CMathBase(bInside)
this.CtrPrp = new CTextPr();
this.CompiledCtrPrp = new CTextPr();
this.TextPrControlLetter = new CTextPr();
//this.CtrPr = new CCtrPr();
this.ArgSize = new CMathArgSize();
......
......@@ -85,12 +85,14 @@ CDegreeBase.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsI
var ArgSzDegr = ArgSize.Copy();
ArgSzDegr.Decrease();
var RPIDegr = RPI.Copy();
RPIDegr.bDecreasedComp = true;
this.bNaryInline = RPI.bNaryInline;
this.iterContent.PreRecalc(this, ParaMath, ArgSzDegr, RPIDegr);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.iterContent.PreRecalc(this, ParaMath, ArgSzDegr, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
CDegreeBase.prototype.Resize = function(oMeasure, RPI)
{
......@@ -536,11 +538,13 @@ CIterators.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsIn
this.Set_CompiledCtrPrp(Parent, ParaMath, RPI);
var RPI_ITER = RPI.Copy();
RPI_ITER.bDecreasedComp = true;
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.iterUp.PreRecalc(this, ParaMath, ArgSzIters, RPI);
this.iterDn.PreRecalc(this, ParaMath, ArgSzIters, RPI);
this.iterUp.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
this.iterDn.PreRecalc(this, ParaMath, ArgSzIters, RPI_ITER);
RPI.bDecreasedComp = bDecreasedComp;
};
CIterators.prototype.recalculateSize = function(oMeasure, dH, ascent)
{
......
......@@ -303,7 +303,12 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
var ArgSzNumDen = ArgSize.Copy();
if(RPI.bInline == true && (this.Pr.type === BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)) // уменьшае размер числителя и знаменателя
var oMathSettings = Get_WordDocumentDefaultMathSettings();
var bInlineBarFaction = RPI.bInline == true && (this.Pr.type === BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION),
bReduceSize = (RPI.bSmallFraction || RPI.bDecreasedComp == true) && true == oMathSettings.Get_SmallFrac();
if(bInlineBarFaction || bReduceSize) // уменьшае размер числителя и знаменателя
{
ArgSzNumDen.Decrease(); // для контентов числителя и знаменателя
this.ArgSize.SetValue(-1); // для CtrPrp
......@@ -322,17 +327,24 @@ CFraction.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInf
this.ApplyProperties(RPI);
var NewRPI = RPI.Copy();
var bDecreasedComp = RPI.bDecreasedComp,
bSmallFraction = RPI.bSmallFraction;
if(this.Pr.type !== LINEAR_FRACTION)
NewRPI.bDecreasedComp = true;
RPI.bDecreasedComp = true;
RPI.bSmallFraction = true;
// setGaps обязательно после того как смержили CtrPrp (Set_CompiledCtrPrp)
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
this.Denominator.PreRecalc(this, ParaMath, ArgSzNumDen, NewRPI);
this.Numerator.PreRecalc(this, ParaMath, ArgSzNumDen, RPI);
this.Denominator.PreRecalc(this, ParaMath, ArgSzNumDen, RPI);
RPI.bDecreasedComp = bDecreasedComp;
RPI.bSmallFraction = bSmallFraction;
};
CFraction.prototype.recalculateSize = function(oMeasure)
{
......
......@@ -87,10 +87,12 @@ CLimitPrimary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, Gap
var ArgSzIter = ArgSize.Copy();
ArgSzIter.Decrease();
var NewRPI = RPI.Copy();
NewRPI.bDecreasedComp = true;
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, NewRPI);
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
CLimitPrimary.prototype.Resize = function(oMeasure, RPI)
{
......@@ -343,10 +345,12 @@ CMathFunc.prototype.init = function(props)
};
CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
var NewRPI = RPI.Copy();
NewRPI.bMathFunc = true;
var bMathFunc = RPI.bMathFunc;
RPI.bMathFunc = true;
CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
CMathFunc.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
RPI.bMathFunc = bMathFunc;
};
CMathFunc.prototype.GetLastElement = function()
{
......
......@@ -10,22 +10,8 @@ function CRPI()
this.bMathFunc = false;
this.bRecalcCtrPrp = false; // пересчет ctrPrp нужен, когда на Undo и тп изменился размер первого Run, а ctrPrp уже для мат объектов пересчитались
this.bCorrect_ConvertFontSize = false;
this.bSmallFraction = false;
}
CRPI.prototype.Copy = function()
{
var RPI = new CRPI();
RPI.bInline = this.bInline;
RPI.bDecreasedComp = this.bDecreasedComp;
RPI.bChangeInline = this.bChangeInline;
RPI.bNaryInline = this.bNaryInline;
RPI.bEqArray = this.bEqArray;
RPI.bMathFunc = this.bMathFunc;
RPI.bRecalcCtrPrp = this.bRecalcCtrPrp;
RPI.bCorrect_ConvertFontSize = this.bCorrect_ConvertFontSize;
return RPI;
};
CRPI.prototype.MergeMathInfo = function(MathInfo)
{
this.bInline = MathInfo.bInline || (MathInfo.bInternalRanges == true && MathInfo.bStartRanges == false);
......@@ -1307,10 +1293,9 @@ CMathContent.prototype.Correct_Content = function(bInnerCorrection)
{
bEmptyContent = false;
}
}
if(bEmptyContent)
if(bEmptyContent == true && this.bRoot == false)
{
this.Content[0].fillPlaceholders();
this.Content[0].Recalc_CompiledPr(true);
......@@ -1473,7 +1458,7 @@ CMathContent.prototype.GetMathTextPrForMenu = function(ContentPos, Depth)
return this.Content[pos].GetMathTextPrForMenu(ContentPos, Depth + 1);
};
CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll, PosForMenu)
CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll, StartPos, EndPos)
{
if ( true === ApplyToAll )
{
......@@ -1484,10 +1469,10 @@ CMathContent.prototype.Apply_TextPr = function(TextPr, IncFontSize, ApplyToAll,
{
var StartPos, EndPos, bMenu = false;
if(PosForMenu !== undefined)
if(StartPos !== undefined && EndPos !== undefined)
{
StartPos = PosForMenu.StartPos;
EndPos = PosForMenu.EndPos;
StartPos = StartPos;
EndPos = EndPos;
bMenu = true;
}
......
......@@ -1323,17 +1323,15 @@ CEqArray.prototype.getColsCount = function()
};
CEqArray.prototype.Resize = function(oMeasure, RPI)
{
// на случай, чтобы не затереть массив
//var CurrAmperWPoints = RPI.AmperWPoints,
// CurrEqArray = RPI.bEqArray;
var NewRPI = RPI.Copy();
NewRPI.bEqArray = true;
var bEqArray = RPI.bEqArray;
RPI.bEqArray = true;
for(var i = 0; i < this.nRow; i++)
this.elements[i][0].Resize(oMeasure, NewRPI);
this.elements[i][0].Resize(oMeasure, RPI);
this.recalculateSize(oMeasure);
RPI.bEqArray = bEqArray;
};
CEqArray.prototype.getMetrics = function()
{
......@@ -1343,7 +1341,6 @@ CEqArray.prototype.getMetrics = function()
// нумерация начинается с нуля, поэтому все четные точки идут с нечетными номерами в массиве
//var lngW = RPI.Widths.length; // this.nRow
var EndWidths = 0;
var even, // четная точка
......
......@@ -305,12 +305,14 @@ CNary.prototype.private_GetLimLoc = function()
};
CNary.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{
var NewRPI = RPI.Copy();
var bNaryInline = RPI.bNaryInline;
if(RPI.bInline || RPI.bDecreasedComp)
NewRPI.bNaryInline = true;
RPI.bNaryInline = true;
CNary.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, NewRPI, GapsInfo);
CNary.superclass.PreRecalc.call(this, Parent, ParaMath, ArgSize, RPI, GapsInfo);
RPI.bNaryInline = bNaryInline;
};
CNary.prototype.getSign = function(chrCode, chrType)
{
......@@ -871,11 +873,14 @@ CNaryUnd.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzUnd = ArgSize.Copy();
ArgSzUnd.Decrease();
var RPIUnd = RPI.Copy();
RPIUnd.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzUnd, RPIUnd);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzUnd, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
CNaryUnd.prototype.setBase = function(base)
{
......@@ -909,11 +914,14 @@ CNaryOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzOvr = ArgSize.Copy();
ArgSzOvr.Decrease();
var RPIOvr = RPI.Copy();
RPIOvr.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSize, RPI);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSzOvr, RPIOvr);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[1][0].PreRecalc(this, ParaMath, ArgSzOvr, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
CNaryOvr.prototype.recalculateSize = function()
{
......@@ -976,13 +984,16 @@ CNaryUndOvr.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
var ArgSzIter = ArgSize.Copy();
ArgSzIter.Decrease();
var RPI_Iter = RPI.Copy();
RPI_Iter.bDecreasedComp = true;
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzIter, RPI);
this.elements[0][0].PreRecalc(this, ParaMath, ArgSzIter, RPI_Iter);
this.elements[1][0].PreRecalc(this, ParaMath, ArgSize, RPI);
this.elements[2][0].PreRecalc(this, ParaMath, ArgSzIter, RPI_Iter);
this.elements[2][0].PreRecalc(this, ParaMath, ArgSzIter, RPI);
RPI.bDecreasedComp = bDecreasedComp;
};
CNaryUndOvr.prototype.recalculateSize = function()
{
......
......@@ -418,9 +418,16 @@ CRadical.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo
var ArgSzIter = new CMathArgSize();
ArgSzIter.SetValue(-2);
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
this.RealBase.PreRecalc(this, ParaMath, ArgSize, RPI);
var bDecreasedComp = RPI.bDecreasedComp;
RPI.bDecreasedComp = true;
this.Iterator.PreRecalc(this, ParaMath, ArgSzIter, RPI);
RPI.bDecreasedComp = bDecreasedComp;
if(this.bInside == false)
GapsInfo.setGaps(this, this.TextPrControlLetter.FontSize);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment