New OO build to fix a TypeError

pull/1/head
yflory 4 years ago
parent 2dc6a9d457
commit 8e6fd05e43

@ -20067,59 +20067,59 @@ this.CheckFootnote(X,Y,CurPage);if(isInText&&null!=oHyperlink&&(Y<=this.Pages[Cu
Asc.c_oAscMouseMoveDataTypes.Common;if(isInText&&(null!=oHyperlink||bPageRefLink)&&true===AscCommon.global_keyboardEvent.CtrlKey)this.DrawingDocument.SetCursorType("pointer",MMData);else this.DrawingDocument.SetCursorType("text",MMData);var Bounds=this.Pages[CurPage].Bounds;if(true===this.Lock.Is_Locked()&&X<Bounds.Right&&X>Bounds.Left&&Y>Bounds.Top&&Y<Bounds.Bottom&&this.LogicDocument&&!this.LogicDocument.IsViewModeInReview()){var _X=this.Pages[CurPage].X;var _Y=this.Pages[CurPage].Y;var MMData=
new AscCommon.CMouseMoveData;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,this.Get_AbsolutePage(CurPage),text_transform);MMData.X_abs=Coords.X-5;MMData.Y_abs=Coords.Y;MMData.Type=Asc.c_oAscMouseMoveDataTypes.LockedObject;MMData.UserId=this.Lock.Get_UserId();MMData.HaveChanges=this.Lock.Have_Changes();MMData.LockedObjectType=c_oAscMouseMoveLockedObjectType.Common;editor.sync_MouseMoveCallback(MMData)}};Paragraph.prototype.Document_CreateFontMap=function(FontMap){if(true===this.FontMap.NeedRecalc){this.FontMap.Map=
{};this.private_CompileParaPr();var FontScheme=this.Get_Theme().themeElements.fontScheme;var CurTextPr=this.CompiledPr.Pr.TextPr.Copy();CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);CurTextPr.Merge(this.TextPr.Value);CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Create_FontMap(this.FontMap.Map);this.FontMap.NeedRecalc=false}for(var Key in this.FontMap.Map)FontMap[Key]=this.FontMap.Map[Key]};
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Get_AllFontNames(AllFonts)};Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=
this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,
false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=
StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=
arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&this.bFromDocument){if(!this.LogicDocument)return;
var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:
0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=
0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();
this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&
Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof
CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=
undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?
true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);
this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=
FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=
FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=
FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=
true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,
Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;
if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&
this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=
Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;
W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();
if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-
this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);
NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();
this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;
var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=
ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&
Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,
0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=
0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,
oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=
function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=
g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=
0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=
function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/
LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;
TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();
var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();
if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=
this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+
1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);
NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;
ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=
false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,
oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,
false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();
NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,
Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;
this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();
return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);
bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)if(this.Content[Index]&&typeof this.Content[Index].Get_AllFontNames==="function")this.Content[Index].Get_AllFontNames(AllFonts)};
Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===
this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;
if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();
for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&
this.bFromDocument){if(!this.LogicDocument)return;var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();
var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==
Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,
true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();
if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;
if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=
function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=
FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=
NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=
FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;
this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=
function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,
Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=
Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=
oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=
Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();
if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-
this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);
var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);
if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=
H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();
while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();
var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=
function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=
this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=
DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,
0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=
oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,
Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||
null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=
g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();
if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();
var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=
new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);
this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=
Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=
true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;
oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,
false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();
this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,
false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];
this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,
ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;
this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
true;break}case AscDFH.historyitem_Paragraph_Shd_Value:case AscDFH.historyitem_Paragraph_Shd_Color:case AscDFH.historyitem_Paragraph_Shd_Unifill:case AscDFH.historyitem_Paragraph_Shd:{if(this.Parent){var oDrawingShape=this.Parent.Is_DrawingShape(true);if(oDrawingShape&&oDrawingShape.getObjectType&&oDrawingShape.getObjectType()===AscDFH.historyitem_type_Shape)if(oDrawingShape.chekBodyPrTransform(oDrawingShape.getBodyPr())||oDrawingShape.checkContentWordArt(oDrawingShape.getDocContent()))bNeedRecalc=
true;if(this.Parent.IsTableHeader())bNeedRecalc=true}break}case AscDFH.historyitem_Paragraph_SectionPr:{if(this.Parent instanceof CDocument){this.Parent.UpdateContentIndexing();var nSectionIndex=this.Parent.GetSectionIndexByElementIndex(this.GetIndex());var oFirstElement=this.Parent.GetFirstElementInSection(nSectionIndex);if(oFirstElement)this.Parent.Refresh_RecalcData2(oFirstElement.GetIndex(),oFirstElement.private_GetRelativePageIndex(0))}break}case AscDFH.historyitem_Paragraph_PrChange:{if(Data instanceof
CChangesParagraphPrChange&&Data.IsChangedNumbering())bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_SuppressLineNumbers:{History.AddLineNumbersToRecalculateData();break}}if(true===bNeedRecalc){var Prev=this.Get_DocumentPrev();if(0===CurPage&&null!=Prev&&type_Paragraph===Prev.GetType()&&true===Prev.Get_CompiledPr2(false).ParaPr.KeepNext)Prev.Refresh_RecalcData2(Prev.Pages.length-1);return this.Refresh_RecalcData2(CurPage)}};Paragraph.prototype.Refresh_RecalcData2=function(CurPage){if(!CurPage)CurPage=

@ -19395,59 +19395,59 @@ this.CheckFootnote(X,Y,CurPage);if(isInText&&null!=oHyperlink&&(Y<=this.Pages[Cu
Asc.c_oAscMouseMoveDataTypes.Common;if(isInText&&(null!=oHyperlink||bPageRefLink)&&true===AscCommon.global_keyboardEvent.CtrlKey)this.DrawingDocument.SetCursorType("pointer",MMData);else this.DrawingDocument.SetCursorType("text",MMData);var Bounds=this.Pages[CurPage].Bounds;if(true===this.Lock.Is_Locked()&&X<Bounds.Right&&X>Bounds.Left&&Y>Bounds.Top&&Y<Bounds.Bottom&&this.LogicDocument&&!this.LogicDocument.IsViewModeInReview()){var _X=this.Pages[CurPage].X;var _Y=this.Pages[CurPage].Y;var MMData=
new AscCommon.CMouseMoveData;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,this.Get_AbsolutePage(CurPage),text_transform);MMData.X_abs=Coords.X-5;MMData.Y_abs=Coords.Y;MMData.Type=Asc.c_oAscMouseMoveDataTypes.LockedObject;MMData.UserId=this.Lock.Get_UserId();MMData.HaveChanges=this.Lock.Have_Changes();MMData.LockedObjectType=c_oAscMouseMoveLockedObjectType.Common;editor.sync_MouseMoveCallback(MMData)}};Paragraph.prototype.Document_CreateFontMap=function(FontMap){if(true===this.FontMap.NeedRecalc){this.FontMap.Map=
{};this.private_CompileParaPr();var FontScheme=this.Get_Theme().themeElements.fontScheme;var CurTextPr=this.CompiledPr.Pr.TextPr.Copy();CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);CurTextPr.Merge(this.TextPr.Value);CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Create_FontMap(this.FontMap.Map);this.FontMap.NeedRecalc=false}for(var Key in this.FontMap.Map)FontMap[Key]=this.FontMap.Map[Key]};
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Get_AllFontNames(AllFonts)};Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=
this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,
false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=
StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=
arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&this.bFromDocument){if(!this.LogicDocument)return;
var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:
0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=
0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();
this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&
Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof
CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=
undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?
true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);
this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=
FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=
FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=
FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=
true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,
Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;
if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&
this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=
Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;
W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();
if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-
this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);
NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();
this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;
var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=
ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&
Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,
0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=
0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,
oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=
function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=
g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=
0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=
function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/
LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;
TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();
var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();
if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=
this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+
1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);
NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;
ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=
false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,
oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,
false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();
NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,
Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;
this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();
return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);
bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)if(this.Content[Index]&&typeof this.Content[Index].Get_AllFontNames==="function")this.Content[Index].Get_AllFontNames(AllFonts)};
Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===
this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;
if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();
for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&
this.bFromDocument){if(!this.LogicDocument)return;var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();
var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==
Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,
true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();
if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;
if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=
function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=
FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=
NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=
FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;
this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=
function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,
Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=
Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=
oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=
Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();
if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-
this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);
var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);
if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=
H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();
while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();
var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=
function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=
this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=
DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,
0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=
oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,
Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||
null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=
g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();
if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();
var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=
new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);
this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=
Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=
true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;
oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,
false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();
this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,
false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];
this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,
ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;
this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
true;break}case AscDFH.historyitem_Paragraph_Shd_Value:case AscDFH.historyitem_Paragraph_Shd_Color:case AscDFH.historyitem_Paragraph_Shd_Unifill:case AscDFH.historyitem_Paragraph_Shd:{if(this.Parent){var oDrawingShape=this.Parent.Is_DrawingShape(true);if(oDrawingShape&&oDrawingShape.getObjectType&&oDrawingShape.getObjectType()===AscDFH.historyitem_type_Shape)if(oDrawingShape.chekBodyPrTransform(oDrawingShape.getBodyPr())||oDrawingShape.checkContentWordArt(oDrawingShape.getDocContent()))bNeedRecalc=
true;if(this.Parent.IsTableHeader())bNeedRecalc=true}break}case AscDFH.historyitem_Paragraph_SectionPr:{if(this.Parent instanceof CDocument){this.Parent.UpdateContentIndexing();var nSectionIndex=this.Parent.GetSectionIndexByElementIndex(this.GetIndex());var oFirstElement=this.Parent.GetFirstElementInSection(nSectionIndex);if(oFirstElement)this.Parent.Refresh_RecalcData2(oFirstElement.GetIndex(),oFirstElement.private_GetRelativePageIndex(0))}break}case AscDFH.historyitem_Paragraph_PrChange:{if(Data instanceof
CChangesParagraphPrChange&&Data.IsChangedNumbering())bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_SuppressLineNumbers:{History.AddLineNumbersToRecalculateData();break}}if(true===bNeedRecalc){var Prev=this.Get_DocumentPrev();if(0===CurPage&&null!=Prev&&type_Paragraph===Prev.GetType()&&true===Prev.Get_CompiledPr2(false).ParaPr.KeepNext)Prev.Refresh_RecalcData2(Prev.Pages.length-1);return this.Refresh_RecalcData2(CurPage)}};Paragraph.prototype.Refresh_RecalcData2=function(CurPage){if(!CurPage)CurPage=

@ -14733,59 +14733,59 @@ this.CheckFootnote(X,Y,CurPage);if(isInText&&null!=oHyperlink&&(Y<=this.Pages[Cu
Asc.c_oAscMouseMoveDataTypes.Common;if(isInText&&(null!=oHyperlink||bPageRefLink)&&true===AscCommon.global_keyboardEvent.CtrlKey)this.DrawingDocument.SetCursorType("pointer",MMData);else this.DrawingDocument.SetCursorType("text",MMData);var Bounds=this.Pages[CurPage].Bounds;if(true===this.Lock.Is_Locked()&&X<Bounds.Right&&X>Bounds.Left&&Y>Bounds.Top&&Y<Bounds.Bottom&&this.LogicDocument&&!this.LogicDocument.IsViewModeInReview()){var _X=this.Pages[CurPage].X;var _Y=this.Pages[CurPage].Y;var MMData=
new AscCommon.CMouseMoveData;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,this.Get_AbsolutePage(CurPage),text_transform);MMData.X_abs=Coords.X-5;MMData.Y_abs=Coords.Y;MMData.Type=Asc.c_oAscMouseMoveDataTypes.LockedObject;MMData.UserId=this.Lock.Get_UserId();MMData.HaveChanges=this.Lock.Have_Changes();MMData.LockedObjectType=c_oAscMouseMoveLockedObjectType.Common;editor.sync_MouseMoveCallback(MMData)}};Paragraph.prototype.Document_CreateFontMap=function(FontMap){if(true===this.FontMap.NeedRecalc){this.FontMap.Map=
{};this.private_CompileParaPr();var FontScheme=this.Get_Theme().themeElements.fontScheme;var CurTextPr=this.CompiledPr.Pr.TextPr.Copy();CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);CurTextPr.Merge(this.TextPr.Value);CurTextPr.Document_CreateFontMap(this.FontMap.Map,FontScheme);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Create_FontMap(this.FontMap.Map);this.FontMap.NeedRecalc=false}for(var Key in this.FontMap.Map)FontMap[Key]=this.FontMap.Map[Key]};
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)this.Content[Index].Get_AllFontNames(AllFonts)};Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=
this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,
false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=
StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=
arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&this.bFromDocument){if(!this.LogicDocument)return;
var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:
0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=
0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();
this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&
Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof
CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=
undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?
true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);
this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=
FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=
FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=
FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=
true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,
Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;
if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&
this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=
Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;
W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();
if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-
this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);
NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();
this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;
var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=
ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&
Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,
0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=
0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,
oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=
function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=
g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=
0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=
function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/
LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;
TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();
var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();
if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=
this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+
1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);
NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;
ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=
false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,
oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,
false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();
NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,
Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;
this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();
return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);
bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
Paragraph.prototype.Document_CreateFontCharMap=function(FontCharMap){};Paragraph.prototype.Document_Get_AllFontNames=function(AllFonts){this.TextPr.Value.Document_Get_AllFontNames(AllFonts);if(this.Pr.Bullet)this.Pr.Bullet.Get_AllFontNames(AllFonts);if(this.Pr.DefaultRunPr)this.Pr.DefaultRunPr.Document_Get_AllFontNames(AllFonts);var Count=this.Content.length;for(var Index=0;Index<Count;Index++)if(this.Content[Index]&&typeof this.Content[Index].Get_AllFontNames==="function")this.Content[Index].Get_AllFontNames(AllFonts)};
Paragraph.prototype.Document_UpdateRulersState=function(){if(this.CalculatedFrame){var oFrame=this.CalculatedFrame;this.Parent.DrawingDocument.Set_RulerState_Paragraph({L:oFrame.L2,T:oFrame.T2,R:oFrame.L2+oFrame.W2,B:oFrame.T2+oFrame.H2,PageIndex:this.GetStartPageAbsolute(),Frame:this},false)}else if(this.Parent instanceof CDocument)if(this.LogicDocument)this.LogicDocument.Document_UpdateRulersStateBySection()};Paragraph.prototype.Document_UpdateInterfaceState=function(){var StartPos,EndPos;if(true===
this.Selection.Use){StartPos=this.Get_ParaContentPos(true,true);EndPos=this.Get_ParaContentPos(true,false)}else{var CurPos=this.Get_ParaContentPos(false,false);StartPos=CurPos;EndPos=CurPos}if(this.LogicDocument&&true===this.LogicDocument.Spelling.Use&&(selectionflag_Numbering!==this.Selection.Flag&&selectionflag_NumberingCur!==this.Selection.Flag))this.SpellChecker.Document_UpdateInterfaceState(StartPos,EndPos);if(true===this.Selection.Use){var StartPos=this.Selection.StartPos;var EndPos=this.Selection.EndPos;
if(StartPos>EndPos){StartPos=this.Selection.EndPos;EndPos=this.Selection.StartPos}for(var CurPos=StartPos;CurPos<=EndPos;CurPos++){var Element=this.Content[CurPos];if(true!==Element.IsSelectionEmpty()&&Element.Document_UpdateInterfaceState)Element.Document_UpdateInterfaceState()}}else{var CurType=this.Content[this.CurPos.ContentPos].Type;if(this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState)this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState()}var arrComplexFields=this.GetCurrentComplexFields();
for(var nIndex=0,nCount=arrComplexFields.length;nIndex<nCount;++nIndex){var oInstruction=arrComplexFields[nIndex].GetInstruction();if(oInstruction&&fieldtype_HYPERLINK===oInstruction.GetType()){var oHyperProps=new Asc.CHyperlinkProperty;oHyperProps.put_ToolTip(oInstruction.GetToolTip());oHyperProps.put_Value(oInstruction.GetValue());oHyperProps.put_Text(this.LogicDocument?this.LogicDocument.GetComplexFieldTextValue(arrComplexFields[nIndex]):null);oHyperProps.put_InternalHyperlink(oInstruction);editor.sync_HyperlinkPropCallback(oHyperProps)}}if(editor&&
this.bFromDocument){if(!this.LogicDocument)return;var TrackManager=this.LogicDocument.GetTrackRevisionsManager();if(this.Pages.length<=0&&this.Lines.length<=0)return;var ContentPos=this.Get_ParaContentPos(this.Selection.Use,true);var ParaPos=this.Get_ParaPosByContentPos(ContentPos);if(this.Pages.length<=ParaPos.Page||this.Lines.length<=ParaPos.Line)return;var Page_abs=this.Get_AbsolutePage(ParaPos.Page);var _Y=this.Pages[ParaPos.Page].Y+this.Lines[ParaPos.Line].Top;var TextTransform=this.Get_ParentTextTransform();
var _X=this.LogicDocument?this.LogicDocument.Get_PageLimits(Page_abs).XLimit:0;var Coords=this.DrawingDocument.ConvertCoordsToCursorWR(_X,_Y,Page_abs,TextTransform);if(false===this.Selection.Use){var Changes=TrackManager.GetElementChanges(this.GetId());if(Changes.length>0)for(var ChangeIndex=0,ChangesCount=Changes.length;ChangeIndex<ChangesCount;ChangeIndex++){var Change=Changes[ChangeIndex];var Type=Change.get_Type();if(c_oAscRevisionsChangeType.TextAdd!==Type&&c_oAscRevisionsChangeType.TextRem!==
Type&&c_oAscRevisionsChangeType.TextPr!==Type||StartPos.Compare(Change.get_StartPos())>=0&&StartPos.Compare(Change.get_EndPos())<=0){Change.put_InternalPos(_X,_Y,Page_abs);TrackManager.AddVisibleChange(Change)}}}}};Paragraph.prototype.PreDelete=function(){for(var Index=0;Index<this.Content.length;Index++){var Item=this.Content[Index];if(Item.PreDelete)Item.PreDelete();if(this.LogicDocument)if(para_Comment===Item.Type&&true===this.LogicDocument.RemoveCommentsOnPreDelete)this.LogicDocument.RemoveComment(Item.CommentId,
true,false);else if(para_Bookmark===Item.Type)this.LogicDocument.GetBookmarksManager().SetNeedUpdate(true)}this.RemoveSelection();this.UpdateDocumentOutline();if(undefined!==this.Get_SectionPr()&&this.LogicDocument)this.Set_SectionPr(undefined)};Paragraph.prototype.Document_SetThisElementCurrent=function(bUpdateStates){this.Parent.Update_ContentIndexing();this.Parent.Set_CurrentElement(this.Index,bUpdateStates)};Paragraph.prototype.Is_ThisElementCurrent=function(){var Parent=this.Parent;Parent.Update_ContentIndexing();
if(docpostype_Content===Parent.GetDocPosType()&&false===Parent.Selection.Use&&this.Index===Parent.CurPos.ContentPos&&Parent.Content[this.Index]===this)return this.Parent.Is_ThisElementCurrent();return false};Paragraph.prototype.Is_Inline=function(){if(this.bFromDocument===false)return true;var PrevElement=this.Get_DocumentPrev();if(true===this.Is_Empty()&&undefined!==this.Get_SectionPr()&&null!==PrevElement&&(type_Paragraph!==PrevElement.Get_Type()||undefined===PrevElement.Get_SectionPr()))return true;
if(undefined===this.Parent||!(this.Parent instanceof CDocument)&&(undefined===this.Parent.Parent||!(this.Parent.Parent instanceof CHeaderFooter)))return true;if(undefined!=this.Pr.FramePr&&Asc.c_oAscYAlign.Inline!==this.Pr.FramePr.YAlign)return false;return true};Paragraph.prototype.IsInline=function(){return this.Is_Inline()};Paragraph.prototype.GetFramePr=function(){return this.Get_CompiledPr2(false).ParaPr.FramePr};Paragraph.prototype.Get_FramePr=function(){return this.GetFramePr()};Paragraph.prototype.Set_FramePr=
function(FramePr,bDelete){var FramePr_old=this.Pr.FramePr;if(undefined===bDelete)bDelete=false;if(true===bDelete){this.Pr.FramePr=undefined;this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,undefined));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true);return}var FrameParas=this.Internal_Get_FrameParagraphs();if(true===FramePr.FromDropCapMenu&&1===FrameParas.length){var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=
FramePr.DropCap){var OldLines=NewFramePr.Lines;NewFramePr.Init_Default_DropCap(FramePr.DropCap===Asc.c_oAscDropCap.Drop?true:false);NewFramePr.Lines=OldLines}if(undefined!=FramePr.Lines){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;this.Set_Spacing({LineRule:linerule_Exact,Line:FramePr.Lines*LineH},false);this.Update_DropCapByLines(this.Internal_CalculateTextPr(this.Internal_GetStartPos()),FramePr.Lines,LineH,LineTA,LineTD,Before);NewFramePr.Lines=FramePr.Lines}if(undefined!=FramePr.FontFamily){var FF=new ParaTextPr({RFonts:{Ascii:{Name:FramePr.FontFamily.Name,Index:-1}}});this.SelectAll();this.Add(FF);this.RemoveSelection()}if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;this.Pr.FramePr=
NewFramePr}else{var NewFramePr=FramePr_old?FramePr_old.Copy():new CFramePr;if(undefined!=FramePr.H)NewFramePr.H=FramePr.H;if(undefined!=FramePr.HAnchor)NewFramePr.HAnchor=FramePr.HAnchor;if(undefined!=FramePr.HRule)NewFramePr.HRule=FramePr.HRule;if(undefined!=FramePr.HSpace)NewFramePr.HSpace=FramePr.HSpace;if(undefined!=FramePr.Lines)NewFramePr.Lines=FramePr.Lines;if(undefined!=FramePr.VAnchor)NewFramePr.VAnchor=FramePr.VAnchor;if(undefined!=FramePr.VSpace)NewFramePr.VSpace=FramePr.VSpace;NewFramePr.W=
FramePr.W;if(undefined!=FramePr.X){NewFramePr.X=FramePr.X;NewFramePr.XAlign=undefined}if(undefined!=FramePr.XAlign){NewFramePr.XAlign=FramePr.XAlign;NewFramePr.X=undefined}if(undefined!=FramePr.Y){NewFramePr.Y=FramePr.Y;NewFramePr.YAlign=undefined}if(undefined!=FramePr.YAlign){NewFramePr.YAlign=FramePr.YAlign;NewFramePr.Y=undefined}if(undefined!==FramePr.Wrap)if(false===FramePr.Wrap)NewFramePr.Wrap=wrap_NotBeside;else if(true===FramePr.Wrap)NewFramePr.Wrap=wrap_Around;else NewFramePr.Wrap=FramePr.Wrap;
this.Pr.FramePr=NewFramePr}if(undefined!=FramePr.Brd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Borders(FramePr.Brd)}if(undefined!=FramePr.Shd){var Count=FrameParas.length;for(var Index=0;Index<Count;Index++)FrameParas[Index].Set_Shd(FramePr.Shd)}this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,FramePr_old,this.Pr.FramePr));this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FramePr2=
function(FramePr){this.private_AddPrChange();History.Add(new CChangesParagraphFramePr(this,this.Pr.FramePr,FramePr));this.Pr.FramePr=FramePr;this.CompiledPr.NeedRecalc=true;this.private_UpdateTrackRevisionOnChangeParaPr(true)};Paragraph.prototype.Set_FrameParaPr=function(Para){Para.CopyPr(this);Para.Set_Ind({FirstLine:0},false);this.Set_Spacing({After:0},false);this.Set_Ind({Right:0},false);this.RemoveNumPr()};Paragraph.prototype.Get_FrameBounds=function(FrameX,FrameY,FrameW,FrameH){var X0=FrameX,
Y0=FrameY,X1=FrameX+FrameW,Y1=FrameY+FrameH;var Paras=this.Internal_Get_FrameParagraphs();var Count=Paras.length;var FramePr=this.Get_FramePr();if(0>=Count)return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0};for(var Index=0;Index<Count;Index++){var Para=Paras[Index];var ParaPr=Para.Get_CompiledPr2(false).ParaPr;var Brd=ParaPr.Brd;var _X0=FrameX;if(undefined!==Brd.Left&&border_None!==Brd.Left.Value)_X0-=Brd.Left.Size+Brd.Left.Space+1;if(_X0<X0)X0=_X0;var _X1=FrameX+FrameW;if(undefined!==Brd.Right&&border_None!==Brd.Right.Value){_X1=
Math.max(_X1,_X1-ParaPr.Ind.Right);_X1+=Brd.Right.Size+Brd.Right.Space+1}if(_X1>X1)X1=_X1}var _Y1=Y1;var BottomBorder=Paras[Count-1].Get_CompiledPr2(false).ParaPr.Brd.Bottom;if(undefined!==BottomBorder&&border_None!==BottomBorder.Value)_Y1+=BottomBorder.Size+BottomBorder.Space;if(_Y1>Y1&&(Asc.linerule_Auto===FramePr.HRule||Asc.linerule_AtLeast===FramePr.HRule&&FrameH>=FramePr.H))Y1=_Y1;return{X:X0,Y:Y0,W:X1-X0,H:Y1-Y0}};Paragraph.prototype.SetCalculatedFrame=function(oFrame){this.CalculatedFrame=
oFrame;oFrame.AddParagraph(this)};Paragraph.prototype.GetCalculatedFrame=function(){return this.CalculatedFrame};Paragraph.prototype.Internal_Get_FrameParagraphs=function(){if(this.CalculatedFrame&&this.CalculatedFrame.GetParagraphs().length>0)return this.CalculatedFrame.GetParagraphs();var FrameParas=[];var FramePr=this.Get_FramePr();if(undefined===FramePr)return FrameParas;FrameParas.push(this);var Prev=this.Get_DocumentPrev();while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=
Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===FramePr.Compare(PrevFramePr)){FrameParas.push(Prev);Prev=Prev.Get_DocumentPrev()}else break}else break;var Next=this.Get_DocumentNext();while(null!=Next)if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined!=NextFramePr&&true===FramePr.Compare(NextFramePr)){FrameParas.push(Next);Next=Next.Get_DocumentNext()}else break}else break;return FrameParas};Paragraph.prototype.Is_LineDropCap=function(){var FrameParas=this.Internal_Get_FrameParagraphs();
if(1!==FrameParas.length||1!==this.Lines.length)return false;return true};Paragraph.prototype.Get_LineDropCapWidth=function(){var W=this.Lines[0].Ranges[0].W;var ParaPr=this.Get_CompiledPr2(false).ParaPr;W+=ParaPr.Ind.Left+ParaPr.Ind.FirstLine;return W};Paragraph.prototype.Change_Frame=function(X,Y,W,H,PageIndex){if(!this.LogicDocument||!this.CalculatedFrame||!this.CalculatedFrame.GetFramePr())return;var FramePr=this.CalculatedFrame.GetFramePr();if(Math.abs(Y-this.CalculatedFrame.T2)<.001&&Math.abs(X-
this.CalculatedFrame.L2)<.001&&Math.abs(W-this.CalculatedFrame.W2)<.001&&Math.abs(H-this.CalculatedFrame.H2)<.001&&PageIndex===this.CalculatedFrame.PageIndex)return;var FrameParas=this.Internal_Get_FrameParagraphs();if(false===this.LogicDocument.Document_Is_SelectionLocked(AscCommon.changestype_None,{Type:AscCommon.changestype_2_ElementsArray_and_Type,Elements:FrameParas,CheckType:AscCommon.changestype_Paragraph_Content})){this.LogicDocument.StartAction(AscDFH.historydescription_Document_ParagraphChangeFrame);
var NewFramePr=FramePr.Copy();if(Math.abs(X-this.CalculatedFrame.L2)>.001){NewFramePr.X=X+(this.CalculatedFrame.L-this.CalculatedFrame.L2);NewFramePr.XAlign=undefined;NewFramePr.HAnchor=Asc.c_oAscHAnchor.Page}if(Math.abs(Y-this.CalculatedFrame.T2)>.001){NewFramePr.Y=Y+(this.CalculatedFrame.T-this.CalculatedFrame.T2);NewFramePr.YAlign=undefined;NewFramePr.VAnchor=Asc.c_oAscVAnchor.Page}if(Math.abs(W-this.CalculatedFrame.W2)>.001)NewFramePr.W=W-Math.abs(this.CalculatedFrame.W2-this.CalculatedFrame.W);
if(Math.abs(H-this.CalculatedFrame.H2)>.001)if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap&&1===FrameParas.length){var PageH=this.LogicDocument.Get_PageLimits(PageIndex).YLimit;var _H=Math.min(H,PageH);NewFramePr.Lines=this.Update_DropCapByHeight(_H);NewFramePr.HRule=linerule_Exact;NewFramePr.H=H-Math.abs(this.CalculatedFrame.H2-this.CalculatedFrame.H)}else{if(H<=this.CalculatedFrame.H2)NewFramePr.HRule=linerule_Exact;else NewFramePr.HRule=Asc.linerule_AtLeast;NewFramePr.H=
H}var Count=FrameParas.length;for(var Index=0;Index<Count;Index++){var Para=FrameParas[Index];Para.Set_FramePr(NewFramePr,false)}this.LogicDocument.Recalculate();this.LogicDocument.UpdateInterface();this.LogicDocument.UpdateRulers();this.LogicDocument.UpdateTracks();this.LogicDocument.FinalizeAction()}};Paragraph.prototype.Supplement_FramePr=function(FramePr){if(undefined!=FramePr.DropCap&&Asc.c_oAscDropCap.None!=FramePr.DropCap){var _FramePr=this.Get_FramePr();var FirstFramePara=this;var Prev=FirstFramePara.Get_DocumentPrev();
while(null!=Prev)if(type_Paragraph===Prev.GetType()){var PrevFramePr=Prev.Get_FramePr();if(undefined!=PrevFramePr&&true===_FramePr.Compare(PrevFramePr)){FirstFramePara=Prev;Prev=Prev.Get_DocumentPrev()}else break}else break;var TextPr=FirstFramePara.GetFirstRunPr();if(undefined===TextPr.RFonts||undefined===TextPr.RFonts.Ascii)TextPr=this.Get_CompiledPr2(false).TextPr;FramePr.FontFamily={Name:TextPr.RFonts.Ascii.Name,Index:TextPr.RFonts.Ascii.Index}}var FrameParas=this.Internal_Get_FrameParagraphs();
var Count=FrameParas.length;var ParaPr=FrameParas[0].Get_CompiledPr2(false).ParaPr.Copy();for(var Index=1;Index<Count;Index++){var TempPr=FrameParas[Index].Get_CompiledPr2(false).ParaPr;ParaPr=ParaPr.Compare(TempPr)}FramePr.Brd=ParaPr.Brd;FramePr.Shd=ParaPr.Shd};Paragraph.prototype.CanAddDropCap=function(){for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){var bResult=this.Content[nPos].CanAddDropCap();if(null!==bResult)return bResult}return false};Paragraph.prototype.Get_TextForDropCap=
function(DropCapText,UseContentPos,ContentPos,Depth){var EndPos=true===UseContentPos?ContentPos.Get(Depth):this.Content.length-1;for(var Pos=0;Pos<=EndPos;Pos++){this.Content[Pos].Get_TextForDropCap(DropCapText,true===UseContentPos&&Pos===EndPos?true:false,ContentPos,Depth+1);if(true===DropCapText.Mixed&&(true===DropCapText.Check||DropCapText.Runs.length>0))return}};Paragraph.prototype.Split_DropCap=function(NewParagraph){var DropCapText=new CParagraphGetDropCapText;if(true==this.Selection.Use&&this.Parent.IsSelectedSingleElement()){var SelSP=
this.Get_ParaContentPos(true,true);var SelEP=this.Get_ParaContentPos(true,false);if(0<=SelSP.Compare(SelEP))SelEP=SelSP;DropCapText.Check=true;this.Get_TextForDropCap(DropCapText,true,SelEP,0);DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,true,SelEP,0)}else{DropCapText.Mixed=true;DropCapText.Check=false;this.Get_TextForDropCap(DropCapText,false)}var Count=DropCapText.Text.length;var PrevRun=null;var CurrRun=null;for(var Pos=0,ParaPos=0,RunPos=0;Pos<Count;Pos++){if(PrevRun!==DropCapText.Runs[Pos]){PrevRun=
DropCapText.Runs[Pos];CurrRun=new ParaRun(NewParagraph);CurrRun.Set_Pr(DropCapText.Runs[Pos].Pr.Copy());NewParagraph.Internal_Content_Add(ParaPos++,CurrRun,false);RunPos=0}CurrRun.Add_ToContent(RunPos++,DropCapText.Text[Pos],false)}if(Count>0)return DropCapText.Runs[Count-1].Get_CompiledPr(true);return null};Paragraph.prototype.SelectFirstLetter=function(){var oStartPos=new CParagraphContentPos;var oEndPos=new CParagraphContentPos;for(var nPos=0,nCount=this.Content.length;nPos<nCount;++nPos){oStartPos.Update(nPos,
0);oEndPos.Update(nPos,0);if(this.Content[nPos].GetFirstRunElementPos(para_Text,oStartPos,oEndPos,1)){this.StartSelectionFromCurPos();this.SetSelectionContentPos(oStartPos,oEndPos,false);this.Document_SetThisElementCurrent();return true}}return false};Paragraph.prototype.CheckSelectionForDropCap=function(){var oSelectionStart=this.Get_ParaContentPos(true,true);var oSelectionEnd=this.Get_ParaContentPos(true,false);if(0<=oSelectionStart.Compare(oSelectionEnd))oSelectionEnd=oSelectionStart;var nEndPos=
oSelectionEnd.Get(0);for(var nPos=0;nPos<=nEndPos;++nPos)if(!this.Content[nPos].CheckSelectionForDropCap(nPos===nEndPos,oSelectionEnd,1))return false;return true};Paragraph.prototype.Update_DropCapByLines=function(TextPr,Count,LineH,LineTA,LineTD,Before){if(null===TextPr)return;this.Set_Spacing({Before:Before,After:0,LineRule:linerule_Exact,Line:Count*LineH-.001},false);var FontSize=72;TextPr.FontSize=FontSize;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var EmHeight=THeight;var NewEmHeight=(Count-1)*LineH+LineTA;var Koef=NewEmHeight/EmHeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,
1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*(LineH*Count)/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,
Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection()};Paragraph.prototype.Update_DropCapByHeight=function(_Height){var AnchorPara=this.Get_FrameAnchorPara();if(null===AnchorPara||AnchorPara.Lines.length<=0)return 1;var Before=AnchorPara.Get_CompiledPr().ParaPr.Spacing.Before;var LineH=AnchorPara.Lines[0].Bottom-AnchorPara.Lines[0].Top-Before;var LineTA=AnchorPara.Lines[0].Metrics.TextAscent2;var LineTD=AnchorPara.Lines[0].Metrics.TextDescent+
AnchorPara.Lines[0].Metrics.LineGap;var Height=_Height-Before;this.Set_Spacing({LineRule:linerule_Exact,Line:Height},false);var LinesCount=Math.ceil(Height/LineH);var TextPr=this.Internal_CalculateTextPr(this.Internal_GetStartPos());g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TMetrics);var TDescent=TMetrics.Descent;var TAscent=TMetrics.Ascent;var THeight=0;if(null===TAscent||
null===TDescent)THeight=g_oTextMeasurer.GetHeight();else THeight=-TDescent+TAscent;var Koef=(Height-LineTD)/THeight;var NewFontSize=TextPr.FontSize*Koef;TextPr.FontSize=parseInt(NewFontSize*2)/2;g_oTextMeasurer.SetTextPr(TextPr,this.Get_Theme());g_oTextMeasurer.SetFontSlot(fontslot_ASCII,1);var TNewMetrics={Ascent:null,Descent:null};this.private_RecalculateTextMetrics(TNewMetrics);var TNewDescent=TNewMetrics.Descent;var TNewAscent=TNewMetrics.Ascent;var TNewHeight=0;if(null===TNewAscent||null===TNewDescent)TNewHeight=
g_oTextMeasurer.GetHeight();else TNewHeight=-TNewDescent+TNewAscent;var Descent=g_oTextMeasurer.GetDescender();var Ascent=g_oTextMeasurer.GetAscender();var Dy=Descent*Height/(Ascent-Descent)+TNewHeight-TNewAscent+LineTD;var PTextPr=new ParaTextPr({RFonts:{Ascii:{Name:TextPr.RFonts.Ascii.Name,Index:-1}},FontSize:TextPr.FontSize,Position:Dy});this.SelectAll();this.Add(PTextPr);this.RemoveSelection();return LinesCount};Paragraph.prototype.Get_FrameAnchorPara=function(){var FramePr=this.Get_FramePr();
if(undefined===FramePr)return null;var Next=this.Get_DocumentNext();while(null!=Next){if(type_Paragraph===Next.GetType()){var NextFramePr=Next.Get_FramePr();if(undefined===NextFramePr||false===FramePr.Compare(NextFramePr))return Next}Next=Next.Get_DocumentNext()}return Next};Paragraph.prototype.Split=function(NewParagraph){if(!NewParagraph)NewParagraph=new Paragraph(this.DrawingDocument,this.Parent);NewParagraph.DeleteCommentOnRemove=false;this.DeleteCommentOnRemove=false;this.RemoveSelection();NewParagraph.RemoveSelection();
var ContentPos=this.Get_ParaContentPos(false,false);var CurPos=ContentPos.Get(0);var TextPr=this.Get_TextPr(ContentPos);var oLogicDocument=this.GetLogicDocument();var oStyles=oLogicDocument&&oLogicDocument.GetStyles?oLogicDocument.GetStyles():null;if(oStyles&&(TextPr.RStyle===oStyles.GetDefaultEndnoteReference()||TextPr.RStyle===oStyles.GetDefaultFootnoteReference())){TextPr=TextPr.Copy();TextPr.RStyle=undefined}var NewElement=this.Content[CurPos].Split(ContentPos,1);if(null===NewElement){NewElement=
new ParaRun(NewParagraph);NewElement.Set_Pr(TextPr.Copy())}var NewContent=this.Content.slice(CurPos+1);this.Internal_Content_Remove2(CurPos+1,this.Content.length-CurPos-1);var EndRun=new ParaRun(this);EndRun.Add_ToContent(0,new ParaEnd);this.Internal_Content_Add(this.Content.length,EndRun);NewParagraph.Internal_Content_Remove2(0,NewParagraph.Content.length);NewParagraph.Internal_Content_Concat(NewContent);NewParagraph.Internal_Content_Add(0,NewElement);NewParagraph.Correct_Content();this.CopyPr(NewParagraph);
this.TextPr.Clear_Style();this.TextPr.Apply_TextPr(TextPr);var SectPr=this.Get_SectionPr();if(undefined!==SectPr){this.Set_SectionPr(undefined);NewParagraph.Set_SectionPr(SectPr)}this.MoveCursorToEndPos(false,false);NewParagraph.MoveCursorToStartPos(false);NewParagraph.DeleteCommentOnRemove=true;this.DeleteCommentOnRemove=true;return NewParagraph};Paragraph.prototype.Concat=function(Para,isUseConcatedStyle){this.DeleteCommentOnRemove=false;Para.DeleteCommentOnRemove=false;this.Remove_ParaEnd();var NearPosCount=
Para.NearPosArray.length;for(var Pos=0;Pos<NearPosCount;Pos++){var ParaNearPos=Para.NearPosArray[Pos];ParaNearPos.Classes[0]=this;ParaNearPos.NearPos.Paragraph=this;ParaNearPos.NearPos.ContentPos.Data[0]+=this.Content.length;this.NearPosArray.push(ParaNearPos)}this.Internal_Content_Concat(Para.Content);Para.ClearContent();this.Set_SectionPr(undefined);var SectPr=Para.Get_SectionPr();if(undefined!==SectPr){Para.Set_SectionPr(undefined);this.Set_SectionPr(SectPr)}this.DeleteCommentOnRemove=true;Para.DeleteCommentOnRemove=
true;if(true===isUseConcatedStyle)Para.CopyPr(this)};Paragraph.prototype.ConcatBefore=function(oPara){this.DeleteCommentOnRemove=false;oPara.DeleteCommentOnRemove=false;oPara.Remove_ParaEnd();for(var nPos=0,nCount=this.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=this.NearPosArray[nPos];oParaNearPos.NearPos.ContentPos.Data[0]+=oPara.Content.length}for(var nPos=0,nCount=oPara.NearPosArray.length;nPos<nCount;++nPos){var oParaNearPos=oPara.NearPosArray[nPos];oParaNearPos.Classes[0]=this;
oParaNearPos.NearPos.Paragraph=this;this.NearPosArray.push(oParaNearPos)}for(var nPos=0,nCount=oPara.Content.length;nPos<nCount;++nPos)this.AddToContent(nPos,oPara.Content[nPos]);oPara.ClearContent();oPara.Set_SectionPr(undefined);this.DeleteCommentOnRemove=true;oPara.DeleteCommentOnRemove=true;oPara.CopyPr(this)};Paragraph.prototype.Continue=function(NewParagraph){var TextPr;if(this.IsEmpty())TextPr=this.TextPr.Value.Copy();else{var EndPos=this.Get_EndPos2(false);var CurPos=this.Get_ParaContentPos(false,
false);this.Set_ParaContentPos(EndPos,true,-1,-1);TextPr=this.Get_TextPr(this.Get_ParaContentPos(false,false)).Copy();this.Set_ParaContentPos(CurPos,false,-1,-1,false);TextPr.HighLight=highlight_None;var oStyles;if(this.bFromDocument&&this.LogicDocument&&(oStyles=this.LogicDocument.GetStyles())&&(TextPr.RStyle===oStyles.GetDefaultFootnoteReference()||TextPr.RStyle===oStyles.GetDefaultEndnoteReference()))TextPr.RStyle=undefined}this.CopyPr(NewParagraph);if(!this.HaveNumbering()&&!this.Lock.Is_Locked()){this.TextPr.Clear_Style();
this.TextPr.Apply_TextPr(TextPr)}NewParagraph.Internal_Content_Add(0,new ParaRun(NewParagraph));NewParagraph.Correct_Content();NewParagraph.MoveCursorToStartPos(false);for(var Pos=0,Count=NewParagraph.Content.length;Pos<Count;Pos++)if(para_Run===NewParagraph.Content[Pos].Type)NewParagraph.Content[Pos].Set_Pr(TextPr.Copy())};Paragraph.prototype.GetSelectionState=function(){var ParaState={};ParaState.CurPos={X:this.CurPos.X,Y:this.CurPos.Y,Line:this.CurPos.Line,ContentPos:this.Get_ParaContentPos(false,
false),RealX:this.CurPos.RealX,RealY:this.CurPos.RealY,PagesPos:this.CurPos.PagesPos};ParaState.Selection={Start:this.Selection.Start,Use:this.Selection.Use,StartPos:0,EndPos:0,Flag:this.Selection.Flag};if(true===this.Selection.Use){ParaState.Selection.StartPos=this.Get_ParaContentPos(true,true);ParaState.Selection.EndPos=this.Get_ParaContentPos(true,false)}return[ParaState]};Paragraph.prototype.SetSelectionState=function(State,StateIndex){if(State.length<=0)return;var ParaState=State[StateIndex];
this.CurPos.X=ParaState.CurPos.X;this.CurPos.Y=ParaState.CurPos.Y;this.CurPos.Line=ParaState.CurPos.Line;this.CurPos.RealX=ParaState.CurPos.RealX;this.CurPos.RealY=ParaState.CurPos.RealY;this.CurPos.PagesPos=ParaState.CurPos.PagesPos;this.Set_ParaContentPos(ParaState.CurPos.ContentPos,true,-1,-1);this.RemoveSelection();this.Selection.Start=ParaState.Selection.Start;this.Selection.Use=ParaState.Selection.Use;this.Selection.Flag=ParaState.Selection.Flag;if(true===this.Selection.Use)this.Set_SelectionContentPos(ParaState.Selection.StartPos,
ParaState.Selection.EndPos)};Paragraph.prototype.Get_ParentObject_or_DocumentPos=function(){this.Parent.Update_ContentIndexing();return this.Parent.Get_ParentObject_or_DocumentPos(this.Index)};Paragraph.prototype.Refresh_RecalcData=function(Data){var Type=Data.Type;var bNeedRecalc=false;var CurPage=0;switch(Type){case AscDFH.historyitem_Paragraph_AddItem:case AscDFH.historyitem_Paragraph_RemoveItem:{for(CurPage=this.Pages.length-1;CurPage>0;CurPage--)if(Data.Pos>this.Lines[this.Pages[CurPage].StartLine].Get_StartPos())break;
this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_Numbering:case AscDFH.historyitem_Paragraph_PStyle:case AscDFH.historyitem_Paragraph_Pr:case AscDFH.historyitem_Paragraph_PresentationPr_Bullet:case AscDFH.historyitem_Paragraph_PresentationPr_Level:{this.RecalcInfo.Set_Type_0(pararecalc_0_All);bNeedRecalc=true;this.CompiledPr.NeedRecalc=true;this.Recalc_RunsCompiledPr();break}case AscDFH.historyitem_Paragraph_Align:case AscDFH.historyitem_Paragraph_DefaultTabSize:case AscDFH.historyitem_Paragraph_Ind_First:case AscDFH.historyitem_Paragraph_Ind_Left:case AscDFH.historyitem_Paragraph_Ind_Right:case AscDFH.historyitem_Paragraph_ContextualSpacing:case AscDFH.historyitem_Paragraph_KeepLines:case AscDFH.historyitem_Paragraph_KeepNext:case AscDFH.historyitem_Paragraph_PageBreakBefore:case AscDFH.historyitem_Paragraph_Spacing_Line:case AscDFH.historyitem_Paragraph_Spacing_LineRule:case AscDFH.historyitem_Paragraph_Spacing_Before:case AscDFH.historyitem_Paragraph_Spacing_After:case AscDFH.historyitem_Paragraph_Spacing_AfterAutoSpacing:case AscDFH.historyitem_Paragraph_Spacing_BeforeAutoSpacing:case AscDFH.historyitem_Paragraph_WidowControl:case AscDFH.historyitem_Paragraph_Tabs:case AscDFH.historyitem_Paragraph_Borders_Between:case AscDFH.historyitem_Paragraph_Borders_Bottom:case AscDFH.historyitem_Paragraph_Borders_Left:case AscDFH.historyitem_Paragraph_Borders_Right:case AscDFH.historyitem_Paragraph_Borders_Top:case AscDFH.historyitem_Paragraph_FramePr:{bNeedRecalc=
true;break}case AscDFH.historyitem_Paragraph_Shd_Value:case AscDFH.historyitem_Paragraph_Shd_Color:case AscDFH.historyitem_Paragraph_Shd_Unifill:case AscDFH.historyitem_Paragraph_Shd:{if(this.Parent){var oDrawingShape=this.Parent.Is_DrawingShape(true);if(oDrawingShape&&oDrawingShape.getObjectType&&oDrawingShape.getObjectType()===AscDFH.historyitem_type_Shape)if(oDrawingShape.chekBodyPrTransform(oDrawingShape.getBodyPr())||oDrawingShape.checkContentWordArt(oDrawingShape.getDocContent()))bNeedRecalc=
true;if(this.Parent.IsTableHeader())bNeedRecalc=true}break}case AscDFH.historyitem_Paragraph_SectionPr:{if(this.Parent instanceof CDocument){this.Parent.UpdateContentIndexing();var nSectionIndex=this.Parent.GetSectionIndexByElementIndex(this.GetIndex());var oFirstElement=this.Parent.GetFirstElementInSection(nSectionIndex);if(oFirstElement)this.Parent.Refresh_RecalcData2(oFirstElement.GetIndex(),oFirstElement.private_GetRelativePageIndex(0))}break}case AscDFH.historyitem_Paragraph_PrChange:{if(Data instanceof
CChangesParagraphPrChange&&Data.IsChangedNumbering())bNeedRecalc=true;break}case AscDFH.historyitem_Paragraph_SuppressLineNumbers:{History.AddLineNumbersToRecalculateData();break}}if(true===bNeedRecalc){var Prev=this.Get_DocumentPrev();if(0===CurPage&&null!=Prev&&type_Paragraph===Prev.GetType()&&true===Prev.Get_CompiledPr2(false).ParaPr.KeepNext)Prev.Refresh_RecalcData2(Prev.Pages.length-1);return this.Refresh_RecalcData2(CurPage)}};Paragraph.prototype.Refresh_RecalcData2=function(CurPage){if(!CurPage)CurPage=

Loading…
Cancel
Save