diff --git a/Word/Editor/Paragraph.js b/Word/Editor/Paragraph.js index 693051585f2913b313ad714531ab2488e4eff365..92843c3d21d843765191b17b124e7ab85ef110aa 100644 --- a/Word/Editor/Paragraph.js +++ b/Word/Editor/Paragraph.js @@ -2772,7 +2772,7 @@ Paragraph.prototype = var Elem = new ParaMath(); //Elem.Set_Paragraph(this); Elem.Root.Load_FromMenu(Item.Menu, this); - Elem.Root.SetRunEmptyToContent(true); + Elem.Root.Correct_Content(true); // ДобавлÑем гиперÑÑылку в Ñодержимое параграфа this.Internal_Content_Add( CurPos + 1, Elem ); diff --git a/Word/Editor/Run.js b/Word/Editor/Run.js index 2a52d1a59f9e8a2c0c82da4064174685ff950f75..2b71174bffedf42315d2996cf44e3315199787d9 100644 --- a/Word/Editor/Run.js +++ b/Word/Editor/Run.js @@ -6751,6 +6751,9 @@ ParaRun.prototype.Load_Changes = function(Reader, Reader2, Color) if ( undefined !== this.Paragraph && null !== this.Paragraph ) this.Paragraph.RecalcInfo.Set_Type_0_Spell( pararecalc_0_Spell_All ); + if (para_Math_Run === this.Type && undefined !== this.Parent && null !== this.Parent && null !== this.Parent.ParaMath) + this.Parent.ParaMath.SetNeedResize(); + break; } @@ -6775,9 +6778,12 @@ ParaRun.prototype.Load_Changes = function(Reader, Reader2, Color) this.RecalcInfo.Measure = true; - if ( undefined !== this.Paragraph && null !== this.Paragraph ) + if (undefined !== this.Paragraph && null !== this.Paragraph) this.Paragraph.RecalcInfo.Set_Type_0_Spell( pararecalc_0_Spell_All ); + if (para_Math_Run === this.Type && undefined !== this.Parent && null !== this.Parent && null !== this.Parent.ParaMath) + this.Parent.ParaMath.SetNeedResize(); + break; } diff --git a/Word/Math/accent.js b/Word/Math/accent.js index 6f07802f7dc081c85abdbe181a902557eb4aebdb..306650cfb39cda97be5580bdb6639c050ef871a9 100644 --- a/Word/Math/accent.js +++ b/Word/Math/accent.js @@ -461,6 +461,7 @@ function CAccent(props) ///////////////// + this.baseContent = new CMathContent(); this.operator = new COperator(OPER_ACCENT); CAccent.superclass.constructor.call(this); @@ -477,8 +478,7 @@ CAccent.prototype.init = function(props) this.setProperties(props); this.setDimension(1, 1); - this.setContent(); - + this.elements[0][0] = this.baseContent; this.elements[0][0].SetDot(true); } CAccent.prototype.setChr = function(chr) @@ -660,36 +660,35 @@ CAccent.prototype.Refresh_RecalcData = function(Data) } CAccent.prototype.Write_ToBinary2 = function( Writer ) { - Writer.WriteLong( historyitem_type_acc ); - Writer.WriteString2( this.getBase().Id ); + Writer.WriteLong(historyitem_type_acc); + + Writer.WriteString2(this.Id); + Writer.WriteString2(this.baseContent.Id); this.CtrPrp.Write_ToBinary(Writer); - - var StartPos = Writer.GetCurPosition(); - Writer.Skip(4); - var Flags = 0; - if ( undefined != this.Pr.chr ) + + if (undefined !== this.Pr.chr) { - Writer.WriteLong(this.Pr.chr); - Flags |= 1; - } - var EndPos = Writer.GetCurPosition(); - Writer.Seek( StartPos ); - Writer.WriteLong( Flags ); - Writer.Seek( EndPos ); + Writer.WriteBool(true); + Writer.WriteLong(this.Pr.chr); + } + else + Writer.WriteBool(false); } CAccent.prototype.Read_FromBinary2 = function( Reader ) { - var props = {ctrPrp: new CTextPr()}; - var arrElems = []; - - arrElems.push(g_oTableId.Get_ById( Reader.GetString2())); + this.Id = Reader.GetString2(); + this.baseContent = g_oTableId.Get_ById(Reader.GetString2()); + var props = {ctrPrp: new CTextPr()}; props.ctrPrp.Read_FromBinary(Reader); - - var Flags = Reader.GetLong(); - if ( Flags & 1 ) - props.chr = Reader.GetLong(); - - this.fillMathComposition (props, arrElems); -} \ No newline at end of file + + if (true === Reader.GetBool()) + props.chr = Reader.GetLong(); + + this.init(props); +} +CAccent.prototype.Get_Id = function() +{ + return this.Id; +}; \ No newline at end of file diff --git a/Word/Math/base.js b/Word/Math/base.js index 7cf5171c04d5e6586f369b454d61a9f04e834faa..5a683c5f74dc7d7c21da454d3b610c56c304996d 100644 --- a/Word/Math/base.js +++ b/Word/Math/base.js @@ -781,6 +781,13 @@ CMathBase.prototype = if(!this.elements[i][j].IsJustDraw()) this.elements[i][j].SetRunEmptyToContent(bAll); }, + Correct_Content: function(bInnerCorrection) + { + for(var i=0; i < this.nRow; i++) + for(var j = 0; j < this.nCol; j++) + if(!this.elements[i][j].IsJustDraw()) + this.elements[i][j].Correct_Content(bInnerCorrection); + }, Selection_Remove: function() { var start_X = this.SelectStart.X, diff --git a/Word/Math/borderBox.js b/Word/Math/borderBox.js index 1e8efb18aad322ed1064227dc6e8c9030a10e5d4..acafb3f2f0b09a48346ceeea2b130734852431a3 100644 --- a/Word/Math/borderBox.js +++ b/Word/Math/borderBox.js @@ -2,6 +2,8 @@ function CBorderBox(props) { + CBorderBox.superclass.constructor.call(this); + this.Id = g_oIdCounter.Get_NewId(); this.kind = MATH_BORDER_BOX; @@ -19,7 +21,7 @@ function CBorderBox(props) strikeV: false }; - CMathBase.call(this); + this.baseContent = new CMathContent(); if(props !== null && typeof(props) !== "undefined") this.init(props); @@ -35,7 +37,7 @@ CBorderBox.prototype.init = function(props) CBorderBox.prototype.fillContent = function() { this.setDimension(1, 1); - this.setContent(); + this.elements[0][0] = this.baseContent; } CBorderBox.prototype.setProperties = function(props) { @@ -302,14 +304,6 @@ CBorderBox.prototype.getBase = function() { return this.elements[0][0]; } -CBorderBox.prototype.fillMathComposition = function(props, contents /*array*/) -{ - this.setProperties(props); - this.fillContent(); - - // Base - this.elements[0][0] = contents[0]; -} CBorderBox.prototype.getPropsForWrite = function() { /*var props = {}; @@ -340,8 +334,9 @@ CBorderBox.prototype.Refresh_RecalcData = function(Data) } CBorderBox.prototype.Write_ToBinary2 = function( Writer ) { - Writer.WriteLong( historyitem_type_borderBox ); - Writer.WriteString2( this.getBase().Id ); + Writer.WriteLong(historyitem_type_borderBox); + Writer.WriteString2(this.Id); + Writer.WriteString2(this.baseContent.Id); this.CtrPrp.Write_ToBinary(Writer); @@ -395,12 +390,11 @@ CBorderBox.prototype.Write_ToBinary2 = function( Writer ) } CBorderBox.prototype.Read_FromBinary2 = function( Reader ) { - var props = {ctrPrp: new CTextPr()}; - var arrElems = []; - - arrElems.push(g_oTableId.Get_ById( Reader.GetString2())); - - props.ctrPrp.Read_FromBinary(Reader); + this.Id = Reader.GetString2(); + this.baseContent = g_oTableId.Get_ById(Reader.GetString2()); + + var props = {ctrPrp: new CTextPr()}; + props.ctrPrp.Read_FromBinary(Reader); var Flags = Reader.GetLong(); if ( Flags & 1 ) @@ -419,8 +413,8 @@ CBorderBox.prototype.Read_FromBinary2 = function( Reader ) props.strikeTLBR = Reader.GetBool(); if ( Flags & 128 ) props.strikeV = Reader.GetBool(); - - this.fillMathComposition (props, arrElems); + + this.init(props); } CBorderBox.prototype.Get_Id = function() { @@ -428,9 +422,10 @@ CBorderBox.prototype.Get_Id = function() } - function CBox(props) { + CBox.superclass.constructor.call(this); + this.Id = g_oIdCounter.Get_NewId(); this.kind = MATH_BOX; @@ -443,7 +438,7 @@ function CBox(props) brk: false }; - CMathBase.call(this); + this.baseContent = new CMathContent(); if(props !== null && typeof(props) !== "undefined") this.init(props); @@ -459,7 +454,7 @@ CBox.prototype.init = function(props) CBox.prototype.fillContent = function() { this.setDimension(1, 1); - this.setContent(); + this.elements[0][0] = this.baseContent; } CBox.prototype.setProperties = function(props) { @@ -482,14 +477,6 @@ CBox.prototype.setProperties = function(props) this.RecalcInfo.bProps = true; } -CBox.prototype.fillMathComposition = function(props, contents /*array*/) -{ - this.setProperties(props); - this.fillContent(); - - // Base - this.elements[0][0] = contents[0]; -} CBox.prototype.getBase = function() { return this.elements[0][0]; @@ -510,8 +497,9 @@ CBox.prototype.Refresh_RecalcData = function(Data) } CBox.prototype.Write_ToBinary2 = function( Writer ) { - Writer.WriteLong( historyitem_type_box ); - Writer.WriteString2( this.getBase().Id ); + Writer.WriteLong(historyitem_type_box); + Writer.WriteString2(this.Id); + Writer.WriteString2(this.baseContent.Id); this.CtrPrp.Write_ToBinary(Writer); @@ -550,11 +538,10 @@ CBox.prototype.Write_ToBinary2 = function( Writer ) } CBox.prototype.Read_FromBinary2 = function( Reader ) { - var props = {ctrPrp: new CTextPr()}; - var arrElems = []; - - arrElems.push(g_oTableId.Get_ById( Reader.GetString2())); + this.Id = Reader.GetString2(); + this.baseContent = g_oTableId.Get_ById(Reader.GetString2()); + var props = {ctrPrp: new CTextPr()}; props.ctrPrp.Read_FromBinary(Reader); var Flags = Reader.GetLong(); @@ -568,8 +555,8 @@ CBox.prototype.Read_FromBinary2 = function( Reader ) props.noBreak = Reader.GetBool(); if ( Flags & 16 ) props.opEmu = Reader.GetBool(); - - this.fillMathComposition (props, arrElems); + + this.init(props); } CBox.prototype.Get_Id = function() { @@ -578,6 +565,8 @@ CBox.prototype.Get_Id = function() function CBar(props) { + CBar.superclass.constructor.call(this); + this.Id = g_oIdCounter.Get_NewId(); this.kind = MATH_BAR; @@ -586,11 +575,11 @@ function CBar(props) pos: LOCATION_BOT }; + this.baseContent = new CMathContent(); + //this.loc = LOCATION_BOT; this.operator = new COperator(OPER_BAR); - CCharacter.call(this); - if(props !== null && typeof(props) !== "undefined") this.init(props); @@ -605,7 +594,7 @@ CBar.prototype.init = function(props) CBar.prototype.fillContent = function() { this.setDimension(1, 1); - this.setContent(); + this.elements[0][0] = this.baseContent; } CBar.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) { @@ -650,14 +639,6 @@ CBar.prototype.setProperties = function(props) this.RecalcInfo.bProps = true; } -CBar.prototype.fillMathComposition = function(props, contents /*array*/) -{ - this.setProperties(props); - this.fillContent(); - - // Base - this.elements[0][0] = contents[0]; -} CBar.prototype.getPropsForWrite = function() { return this.Pr; @@ -674,8 +655,9 @@ CBar.prototype.Refresh_RecalcData = function(Data) } CBar.prototype.Write_ToBinary2 = function( Writer ) { - Writer.WriteLong( historyitem_type_bar ); - Writer.WriteString2( this.getBase().Id ); + Writer.WriteLong(historyitem_type_bar); + Writer.WriteString2(this.Id); + Writer.WriteString2(this.baseContent.Id); this.CtrPrp.Write_ToBinary(Writer); @@ -695,18 +677,17 @@ CBar.prototype.Write_ToBinary2 = function( Writer ) } CBar.prototype.Read_FromBinary2 = function( Reader ) { - var props = {ctrPrp: new CTextPr()}; - var arrElems = []; - - arrElems.push(g_oTableId.Get_ById( Reader.GetString2())); + this.Id = Reader.GetString2(); + this.baseContent = g_oTableId.Get_ById(Reader.GetString2()); + var props = {ctrPrp: new CTextPr()}; props.ctrPrp.Read_FromBinary(Reader); var Flags = Reader.GetLong(); if ( Flags & 1 ) props.pos = Reader.GetLong(); - - this.fillMathComposition (props, arrElems); + + this.init(props); } CBar.prototype.Get_Id = function() { @@ -715,8 +696,9 @@ CBar.prototype.Get_Id = function() function CPhantom(props) { + CPhantom.superclass.constructor.call(this); + this.Id = g_oIdCounter.Get_NewId(); - CMathBase.call(this); this.Pr = { @@ -727,6 +709,8 @@ function CPhantom(props) zeroWid: false }; + this.baseContent = new CMathContent(); + if(props !== null && typeof(props) !== "undefined") this.init(props); @@ -741,7 +725,7 @@ CPhantom.prototype.init = function(props) CPhantom.prototype.fillContent = function() { this.setDimension(1, 1); - this.setContent(); + this.elements[0][0] = this.baseContent; } CPhantom.prototype.getBase = function() { @@ -769,14 +753,6 @@ CPhantom.prototype.setProperties = function(props) this.RecalcInfo.bProps = true; } -CPhantom.prototype.fillMathComposition = function(props, contents /*array*/) -{ - this.setProperties(props); - this.fillContent(); - - // Base - this.elements[0][0] = contents[0]; -} CPhantom.prototype.getPropsForWrite = function() { return this.Pr; @@ -793,8 +769,9 @@ CPhantom.prototype.Refresh_RecalcData = function(Data) } CPhantom.prototype.Write_ToBinary2 = function( Writer ) { - Writer.WriteLong( historyitem_type_phant ); - Writer.WriteString2( this.getBase().Id ); + Writer.WriteLong(historyitem_type_phant); + Writer.WriteString2(this.Id); + Writer.WriteString2(this.baseContent.Id); this.CtrPrp.Write_ToBinary(Writer); @@ -833,11 +810,10 @@ CPhantom.prototype.Write_ToBinary2 = function( Writer ) } CPhantom.prototype.Read_FromBinary2 = function( Reader ) { + this.Id = Reader.GetString2(); + this.baseContent = g_oTableId.Get_ById(Reader.GetString2()); + var props = {ctrPrp: new CTextPr()}; - var arrElems = []; - - arrElems.push(g_oTableId.Get_ById( Reader.GetString2())); - props.ctrPrp.Read_FromBinary(Reader); var Flags = Reader.GetLong(); @@ -851,8 +827,8 @@ CPhantom.prototype.Read_FromBinary2 = function( Reader ) props.zeroDesc = Reader.GetBool(); if ( Flags & 16 ) props.zeroWid = Reader.GetBool(); - - this.fillMathComposition (props, arrElems); + + this.init(props); } CPhantom.prototype.Get_Id = function() { diff --git a/Word/Math/degree.js b/Word/Math/degree.js index 31df2849f4437bf625df46750ed88322f65daf2a..88180ce310590fb11fc0aa78c5c977f291fa1206 100644 --- a/Word/Math/degree.js +++ b/Word/Math/degree.js @@ -2,6 +2,8 @@ function CDegree(props, bInside) { + CDegree.superclass.constructor.call(this); + this.Id = g_oIdCounter.Get_NewId(); this.kind = MATH_DEGREE; @@ -13,7 +15,8 @@ function CDegree(props, bInside) type: DEGREE_SUPERSCRIPT }; - CMathBase.call(this, bInside); + this.baseContent = new CMathContent(); + this.iterContent = new CMathContent(); if(props !== null && typeof(props) !== "undefined") this.init(props); @@ -29,7 +32,8 @@ CDegree.prototype.init = function(props) CDegree.prototype.fillContent = function() { this.setDimension(1, 2); - this.setContent(); + this.elements[0][0] = this.baseContent; + this.elements[0][1] = this.iterContent; }; CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize) { @@ -277,17 +281,6 @@ CDegree.prototype.setProperties = function(props) this.RecalcInfo.bProps = true; }; -CDegree.prototype.fillMathComposition = function(props, contents /*array*/) -{ - this.setProperties(props); - this.fillContent(); - - // Base - this.elements[0][0] = contents[0]; - - // Iterator - this.elements[0][1] = contents[1]; -}; CDegree.prototype.setBase = function(base) { this.elements[0][0] = base; @@ -312,26 +305,25 @@ CDegree.prototype.Refresh_RecalcData = function(Data) }; CDegree.prototype.Write_ToBinary2 = function( Writer ) { - Writer.WriteLong( historyitem_type_deg ); - Writer.WriteString2( this.getBase().Id ); - Writer.WriteString2( this.getLowerIterator().Id ); + Writer.WriteLong(historyitem_type_deg); + Writer.WriteString2(this.Id); + Writer.WriteString2(this.baseContent.Id); + Writer.WriteString2(this.iterContent.Id); this.CtrPrp.Write_ToBinary(Writer); Writer.WriteLong( this.Pr.type ); - }; CDegree.prototype.Read_FromBinary2 = function( Reader ) { - var props = {ctrPrp: new CTextPr()}; - var arrElems = []; - - arrElems.push(g_oTableId.Get_ById( Reader.GetString2())); - arrElems.push(g_oTableId.Get_ById( Reader.GetString2())); + this.Id = Reader.GetLong(); + this.baseContent = g_oTableId.Get_ById(Reader.GetLong()); + this.iterContent = g_oTableId.Get_ById(Reader.GetLong()); + var props = {ctrPrp: new CTextPr()}; props.ctrPrp.Read_FromBinary(Reader); props.type = Reader.GetLong(); - this.fillMathComposition (props, arrElems); + this.init(props); }; CDegree.prototype.Get_Id = function() { diff --git a/Word/Math/mathContent.js b/Word/Math/mathContent.js index ed6f8bbaae4a9a5d2856795e76f13d89ea34e6c0..02a2adfcaeff8ffb9d9cb119f129f4d7c24d0035 100644 --- a/Word/Math/mathContent.js +++ b/Word/Math/mathContent.js @@ -1793,8 +1793,17 @@ CMathContent.prototype = } }, - Correct_Content : function() + Correct_Content : function(bInnerCorrection) { + if (true === bInnerCorrection) + { + for (var nPos = 0, nCount = this.content.length; nPos < nCount; nPos++) + { + if (para_Math_Composition === this.content[nPos].Type) + this.content[nPos].Correct_Content(true); + } + } + this.SetRunEmptyToContent(false); // УдалÑем лишние пуÑтые раны @@ -1820,7 +1829,12 @@ CMathContent.prototype = if(para_Math_Run === oCurrElement.Type) oCurrElement.Math_Correct_Content(); + } + // ЕÑли в контенте ничего нет, тогда добавлÑем пуÑтой ран + if (this.content.length < 1) + { + this.Add_ToContent(0, new ParaRun(null, true)); } if (this.content.length == 1)