|
|
|
@ -8425,87 +8425,88 @@ oThis.loadImageCallBackCounterMax)oThis.LoadImagesWithCallbackEnd()};oImage.Imag
|
|
|
|
|
this.loadImageCallBackArgs);this.loadImageCallBack=null;this.loadImageCallBackArgs=null;this.loadImageCallBackCounterMax=0;this.loadImageCallBackCounter=0}}var g_flow_anchor=new Image;g_flow_anchor.asc_complete=false;g_flow_anchor.onload=function(){g_flow_anchor.asc_complete=true};g_flow_anchor.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPBAMAAADNDVhEAAAAIVBMVEUAAAANDQ0NDQ0NDQ0NDQ0NDQ0AAAANDQ0NDQ0NDQ0NDQ1jk7YPAAAACnRSTlMAGkD4mb9c5s9TDghpXQAAAFZJREFUCNdjYGBgW8YABlxcIBLBZ1gAEfZa5QWiGRkWMAIpAaA4iHQE0YwODEtANMsChkIwv4BBWQBICyswMC1iWADEDAzKoUuDFUAGNC9uABvIaQkkABpxD6lFb9lRAAAAAElFTkSuQmCC";
|
|
|
|
|
var g_flow_anchor2=new Image;g_flow_anchor2.asc_complete=false;g_flow_anchor2.onload=function(){g_flow_anchor2.asc_complete=true};g_flow_anchor2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABoAAAAeCAMAAAAFBf7qAAAAOVBMVEUAAAAAAAAAAAAAAAAJCQkAAAAJCQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJCQknI0ZQAAAAEnRSTlMAx9ITlAfyPHxn68yecTAl5qt6y0BvAAAAt0lEQVQoz8WS0QrDIAxFk0ajtlXb+/8fuzAprltg7Gnn4aIcvAgJTSSoBiGPoIAGV60qoquvIIL110IJgPONmKIlMI73MiwGRoZvahbKVSizcDKU8QeVPDXEIr6ShVB9VUEn2FOMkwL8VwjUtuypvDWiHeVTFeyWkZHfVQZHGm4XMhKQyJB9GKMxuHQSBlioF7u2q7kzgO2AcWwW3F8mWRmGKgyu91mK1Tzh4ixVVkBzJI/EnGjyACbfCaO3eIWRAAAAAElFTkSuQmCC";
|
|
|
|
|
window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].g_font_loader=new CGlobalFontLoader;window["AscCommon"].g_image_loader=new CGlobalImageLoader;window["AscCommon"].g_flow_anchor=g_flow_anchor;window["AscCommon"].g_flow_anchor2=g_flow_anchor2})(window,window.document);"use strict";(function(window,undefined){var FOREIGN_CURSOR_LABEL_HIDETIME=1500;function CCollaborativeChanges(){this.m_pData=null;this.m_oColor=null}CCollaborativeChanges.prototype.Set_Data=function(pData){this.m_pData=
|
|
|
|
|
pData};CCollaborativeChanges.prototype.Set_Color=function(oColor){this.m_oColor=oColor};CCollaborativeChanges.prototype.Set_FromUndoRedo=function(Class,Data,Binary){if(!Class.Get_Id)return false;this.m_pData=this.private_SaveData(Binary);return true};CCollaborativeChanges.prototype.Apply_Data=function(){var CollaborativeEditing=AscCommon.CollaborativeEditing;var Reader=this.private_LoadData(this.m_pData);var ClassId=Reader.GetString2();var Class=AscCommon.g_oTableId.Get_ById(ClassId);if(!Class)return false;
|
|
|
|
|
var nReaderPos=Reader.GetCurPos();var nChangesType=Reader.GetLong();var fChangesClass=AscDFH.changesFactory[nChangesType];if(fChangesClass){var oChange=new fChangesClass(Class);oChange.ReadFromBinary(Reader);if(true===CollaborativeEditing.private_AddOverallChange(oChange))oChange.Load(this.m_oColor);return true}else{CollaborativeEditing.private_AddOverallChange(this.m_pData);Reader.Seek2(nReaderPos);if(!Class.Load_Changes)return false;return Class.Load_Changes(Reader,null,this.m_oColor)}};CCollaborativeChanges.prototype.private_LoadData=
|
|
|
|
|
function(szSrc){return this.GetStream(szSrc,0,szSrc.length)};CCollaborativeChanges.prototype.GetStream=function(szSrc,offset,srcLen){var nWritten=0;var index=-1+offset;var dst_len="";while(true){index++;var _c=szSrc.charCodeAt(index);if(_c==";".charCodeAt(0)){index++;break}dst_len+=String.fromCharCode(_c)}var dstLen=parseInt(dst_len);var pointer=AscFonts.g_memory.Alloc(dstLen);var stream=new AscCommon.FT_Stream2(pointer.data,dstLen);stream.obj=pointer.obj;var dstPx=stream.data;if(window.chrome)while(index<
|
|
|
|
|
srcLen){var dwCurr=0;var i;var nBits=0;for(i=0;i<4;i++){if(index>=srcLen)break;var nCh=AscFonts.DecodeBase64Char(szSrc.charCodeAt(index++));if(nCh==-1){i--;continue}dwCurr<<=6;dwCurr|=nCh;nBits+=6}dwCurr<<=24-nBits;for(i=0;i<nBits/8;i++){dstPx[nWritten++]=(dwCurr&16711680)>>>16;dwCurr<<=8}}else{var p=AscFonts.b64_decode;while(index<srcLen){var dwCurr=0;var i;var nBits=0;for(i=0;i<4;i++){if(index>=srcLen)break;var nCh=p[szSrc.charCodeAt(index++)];if(nCh==undefined){i--;continue}dwCurr<<=6;dwCurr|=
|
|
|
|
|
nCh;nBits+=6}dwCurr<<=24-nBits;for(i=0;i<nBits/8;i++){dstPx[nWritten++]=(dwCurr&16711680)>>>16;dwCurr<<=8}}}return stream};CCollaborativeChanges.prototype.private_SaveData=function(Binary){var Writer=AscCommon.History.BinaryWriter;var Pos=Binary.Pos;var Len=Binary.Len;return Len+";"+Writer.GetBase64Memory2(Pos,Len)};function CCollaborativeEditingBase(){this.m_nUseType=1;this.m_aUsers=[];this.m_aChanges=[];this.m_aNeedUnlock=[];this.m_aNeedUnlock2=[];this.m_aNeedLock=[];this.m_aLinkData=[];this.m_aEndActions=
|
|
|
|
|
[];this.m_bGlobalLock=0;this.m_bGlobalLockSelection=0;this.m_aCheckLocks=[];this.m_aCheckLocksInstance=[];this.m_aNewObjects=[];this.m_aNewImages=[];this.m_aDC={};this.m_aChangedClasses={};this.m_oMemory=null;this.m_aCursorsToUpdate={};this.m_aCursorsToUpdateShortId={};this.m_bFast=false;this.m_oLogicDocument=null;this.m_aDocumentPositions=new CDocumentPositionsManager;this.m_aForeignCursorsPos=new CDocumentPositionsManager;this.m_aForeignCursors={};this.m_aForeignCursorsId={};this.m_nAllChangesSavedIndex=
|
|
|
|
|
0;this.m_aAllChanges=[];this.m_aOwnChangesIndexes=[];this.m_oOwnChanges=[]}CCollaborativeEditingBase.prototype.Clear=function(){this.m_nUseType=1;this.m_aUsers=[];this.m_aChanges=[];this.m_aNeedUnlock=[];this.m_aNeedUnlock2=[];this.m_aNeedLock=[];this.m_aLinkData=[];this.m_aEndActions=[];this.m_aCheckLocks=[];this.m_aCheckLocksInstance=[];this.m_aNewObjects=[];this.m_aNewImages=[]};CCollaborativeEditingBase.prototype.Set_Fast=function(bFast){this.m_bFast=bFast;if(false===bFast){this.Remove_AllForeignCursors();
|
|
|
|
|
this.RemoveMyCursorFromOthers()}};CCollaborativeEditingBase.prototype.Is_Fast=function(){return this.m_bFast};CCollaborativeEditingBase.prototype.Is_SingleUser=function(){return 1===this.m_nUseType};CCollaborativeEditingBase.prototype.getCollaborativeEditing=function(){return!this.Is_SingleUser()};CCollaborativeEditingBase.prototype.Start_CollaborationEditing=function(){this.m_nUseType=-1};CCollaborativeEditingBase.prototype.End_CollaborationEditing=function(){if(this.m_nUseType<=0)this.m_nUseType=
|
|
|
|
|
0};CCollaborativeEditingBase.prototype.Add_User=function(UserId){if(-1===this.Find_User(UserId))this.m_aUsers.push(UserId)};CCollaborativeEditingBase.prototype.Find_User=function(UserId){var Len=this.m_aUsers.length;for(var Index=0;Index<Len;Index++)if(this.m_aUsers[Index]===UserId)return Index;return-1};CCollaborativeEditingBase.prototype.Remove_User=function(UserId){var Pos=this.Find_User(UserId);if(-1!=Pos)this.m_aUsers.splice(Pos,1)};CCollaborativeEditingBase.prototype.Add_Changes=function(Changes){this.m_aChanges.push(Changes)};
|
|
|
|
|
CCollaborativeEditingBase.prototype.Add_Unlock=function(LockClass){this.m_aNeedUnlock.push(LockClass)};CCollaborativeEditingBase.prototype.Add_Unlock2=function(Lock){this.m_aNeedUnlock2.push(Lock);editor._onUpdateDocumentCanSave()};CCollaborativeEditingBase.prototype.Have_OtherChanges=function(){return 0<this.m_aChanges.length};CCollaborativeEditingBase.prototype.Apply_Changes=function(){var OtherChanges=this.m_aChanges.length>0;if(true===OtherChanges){AscFonts.IsCheckSymbols=true;editor.WordControl.m_oLogicDocument.StopRecalculate();
|
|
|
|
|
editor.WordControl.m_oLogicDocument.EndPreview_MailMergeResult();editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.ApplyChanges);var DocState=this.private_SaveDocumentState();this.Clear_NewImages();this.Apply_OtherChanges();this.Lock_NeedLock();this.private_RestoreDocumentState(DocState);this.OnStart_Load_Objects();AscFonts.IsCheckSymbols=false}};CCollaborativeEditingBase.prototype.Apply_OtherChanges=function(){AscCommon.g_oIdCounter.Set_Load(true);if(this.m_aChanges.length>
|
|
|
|
|
0)this.private_CollectOwnChanges();var _count=this.m_aChanges.length;for(var i=0;i<_count;i++){if(window["NATIVE_EDITOR_ENJINE"]===true&&window["native"]["CheckNextChange"])if(!window["native"]["CheckNextChange"]())break;var Changes=this.m_aChanges[i];Changes.Apply_Data()}this.private_ClearChanges();this.Apply_LinkData();this.Check_MergeData();this.OnEnd_ReadForeignChanges();AscCommon.g_oIdCounter.Set_Load(false)};CCollaborativeEditingBase.prototype.getOwnLocksLength=function(){return this.m_aNeedUnlock2.length};
|
|
|
|
|
CCollaborativeEditingBase.prototype.Send_Changes=function(){};CCollaborativeEditingBase.prototype.Release_Locks=function(){};CCollaborativeEditingBase.prototype.CheckWaitingImages=function(aImages){};CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges=function(aImages){var rData={},oApi=editor||Asc["editor"],i;if(!oApi)return;rData["c"]="pathurls";rData["data"]=[];for(i=0;i<aImages.length;++i)rData["data"].push(aImages[i]);var aImagesToLoad=[].concat(AscCommon.CollaborativeEditing.m_aNewImages);
|
|
|
|
|
this.CheckWaitingImages(aImagesToLoad);AscCommon.CollaborativeEditing.m_aNewImages.length=0;if(false===oApi.isSaveFonts_Images)oApi.isSaveFonts_Images=true;AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad)};CCollaborativeEditingBase.prototype.SendImagesCallback=function(aImages){var oApi=editor||Asc["editor"];oApi.pre_Save(aImages)};CCollaborativeEditingBase.prototype.CollectImagesFromChanges=function(){var oApi=editor||Asc["editor"];var aImages=[],sImagePath,i,sImageFromChanges,oThemeUrls=
|
|
|
|
|
{};var aNewImages=this.m_aNewImages;var oMap={};for(i=0;i<aNewImages.length;++i){sImageFromChanges=aNewImages[i];if(oMap[sImageFromChanges])continue;oMap[sImageFromChanges]=1;if(sImageFromChanges.indexOf("theme")===0&&oApi.ThemeLoader)oThemeUrls[sImageFromChanges]=oApi.ThemeLoader.ThemesUrlAbs+sImageFromChanges;else if(0===sImageFromChanges.indexOf("http:")||0===sImageFromChanges.indexOf("data:")||0===sImageFromChanges.indexOf("https:")||0===sImageFromChanges.indexOf("file:")||0===sImageFromChanges.indexOf("ftp:"));
|
|
|
|
|
else{sImagePath=AscCommon.g_oDocumentUrls.mediaPrefix+sImageFromChanges;if(!AscCommon.g_oDocumentUrls.getUrl(sImagePath))aImages.push(sImagePath)}}AscCommon.g_oDocumentUrls.addUrls(oThemeUrls);return aImages};CCollaborativeEditingBase.prototype.OnStart_Load_Objects=function(){this.Set_GlobalLock(true);this.Set_GlobalLockSelection(true);var aImages=this.CollectImagesFromChanges();if(aImages.length>0)this.SendImagesUrlsFromChanges(aImages);else{this.SendImagesCallback([].concat(this.m_aNewImages));
|
|
|
|
|
this.m_aNewImages.length=0}};CCollaborativeEditingBase.prototype.OnEnd_Load_Objects=function(){};CCollaborativeEditingBase.prototype.Clear_LinkData=function(){this.m_aLinkData.length=0};CCollaborativeEditingBase.prototype.Add_LinkData=function(Class,LinkData){this.m_aLinkData.push({Class:Class,LinkData:LinkData})};CCollaborativeEditingBase.prototype.Apply_LinkData=function(){var Count=this.m_aLinkData.length;for(var Index=0;Index<Count;Index++){var Item=this.m_aLinkData[Index];Item.Class.Load_LinkData(Item.LinkData)}this.Clear_LinkData()};
|
|
|
|
|
CCollaborativeEditingBase.prototype.Check_MergeData=function(){};CCollaborativeEditingBase.prototype.Get_GlobalLock=function(){return 0===this.m_bGlobalLock?false:true};CCollaborativeEditingBase.prototype.Set_GlobalLock=function(isLock){if(isLock)this.m_bGlobalLock++;else this.m_bGlobalLock=Math.max(0,this.m_bGlobalLock-1)};CCollaborativeEditingBase.prototype.Set_GlobalLockSelection=function(isLock){if(isLock)this.m_bGlobalLockSelection++;else this.m_bGlobalLockSelection=Math.max(0,this.m_bGlobalLockSelection-
|
|
|
|
|
1)};CCollaborativeEditingBase.prototype.Get_GlobalLockSelection=function(){return 0===this.m_bGlobalLockSelection?false:true};CCollaborativeEditingBase.prototype.OnStart_CheckLock=function(){this.m_aCheckLocks.length=0;this.m_aCheckLocksInstance.length=0};CCollaborativeEditingBase.prototype.Add_CheckLock=function(oItem){this.m_aCheckLocks.push(oItem);this.m_aCheckLocksInstance.push(oItem)};CCollaborativeEditingBase.prototype.OnEnd_CheckLock=function(){};CCollaborativeEditingBase.prototype.OnCallback_AskLock=
|
|
|
|
|
function(result){};CCollaborativeEditingBase.prototype.OnStartCheckLockInstance=function(){this.m_aCheckLocksInstance.length=0};CCollaborativeEditingBase.prototype.OnEndCheckLockInstance=function(){var isLocked=false;for(var nIndex=0,nCount=this.m_aCheckLocksInstance.length;nIndex<nCount;++nIndex)if(true===this.m_aCheckLocksInstance[nIndex]){isLocked=true;break}if(isLocked){var nCount=this.m_aCheckLocksInstance.length;this.m_aCheckLocks.splice(this.m_aCheckLocks.length-nCount,nCount)}this.m_aCheckLocksInstance.length=
|
|
|
|
|
0;return isLocked};CCollaborativeEditingBase.prototype.Reset_NeedLock=function(){this.m_aNeedLock={}};CCollaborativeEditingBase.prototype.Add_NeedLock=function(Id,sUser){this.m_aNeedLock[Id]=sUser};CCollaborativeEditingBase.prototype.Remove_NeedLock=function(Id){delete this.m_aNeedLock[Id]};CCollaborativeEditingBase.prototype.Lock_NeedLock=function(){for(var Id in this.m_aNeedLock){var Class=AscCommon.g_oTableId.Get_ById(Id);if(null!=Class){var Lock=Class.Lock;Lock.Set_Type(AscCommon.locktype_Other,
|
|
|
|
|
false);if(Class.getObjectType&&Class.getObjectType()===AscDFH.historyitem_type_Slide)editor.WordControl.m_oLogicDocument.DrawingDocument.UnLockSlide&&editor.WordControl.m_oLogicDocument.DrawingDocument.UnLockSlide(Class.num);Lock.Set_UserId(this.m_aNeedLock[Id])}}this.Reset_NeedLock()};CCollaborativeEditingBase.prototype.Clear_NewObjects=function(){this.m_aNewObjects.length=0};CCollaborativeEditingBase.prototype.Add_NewObject=function(Class){this.m_aNewObjects.push(Class);Class.FromBinary=true};CCollaborativeEditingBase.prototype.Clear_EndActions=
|
|
|
|
|
function(){this.m_aEndActions.length=0};CCollaborativeEditingBase.prototype.Add_EndActions=function(Class,Data){this.m_aEndActions.push({Class:Class,Data:Data})};CCollaborativeEditingBase.prototype.OnEnd_ReadForeignChanges=function(){var Count=this.m_aNewObjects.length;for(var Index=0;Index<Count;Index++){var Class=this.m_aNewObjects[Index];Class.FromBinary=false}Count=this.m_aEndActions.length;for(var Index=0;Index<Count;Index++){var Item=this.m_aEndActions[Index];Item.Class.Process_EndLoad(Item.Data)}this.Clear_EndActions();
|
|
|
|
|
this.Clear_NewObjects()};CCollaborativeEditingBase.prototype.Clear_NewImages=function(){this.m_aNewImages.length=0};CCollaborativeEditingBase.prototype.Add_NewImage=function(Url){this.m_aNewImages.push(Url)};CCollaborativeEditingBase.prototype.Add_NewDC=function(Class){var Id=Class.Get_Id();this.m_aDC[Id]=Class};CCollaborativeEditingBase.prototype.Clear_DCChanges=function(){for(var Id in this.m_aDC)this.m_aDC[Id].Clear_ContentChanges();this.m_aDC={}};CCollaborativeEditingBase.prototype.Refresh_DCChanges=
|
|
|
|
|
function(){for(var Id in this.m_aDC)this.m_aDC[Id].Refresh_ContentChanges();this.Clear_DCChanges()};CCollaborativeEditingBase.prototype.AddPosExtChanges=function(Item,ChangeObject){};CCollaborativeEditingBase.prototype.RefreshPosExtChanges=function(){};CCollaborativeEditingBase.prototype.RewritePosExtChanges=function(changesArr,scale,Binary_Writer){};CCollaborativeEditingBase.prototype.RefreshPosExtChanges=function(){};CCollaborativeEditingBase.prototype.Add_ChangedClass=function(Class){var Id=Class.Get_Id();
|
|
|
|
|
this.m_aChangedClasses[Id]=Class};CCollaborativeEditingBase.prototype.Clear_CollaborativeMarks=function(bRepaint){for(var Id in this.m_aChangedClasses)this.m_aChangedClasses[Id].Clear_CollaborativeMarks();this.m_aChangedClasses={};if(true===bRepaint){editor.WordControl.m_oLogicDocument.DrawingDocument.ClearCachePages();editor.WordControl.m_oLogicDocument.DrawingDocument.FirePaint()}};CCollaborativeEditingBase.prototype.Add_ForeignCursorToUpdate=function(UserId,CursorInfo,UserShortId){this.m_aCursorsToUpdate[UserId]=
|
|
|
|
|
CursorInfo;this.m_aCursorsToUpdateShortId[UserId]=UserShortId};CCollaborativeEditingBase.prototype.Refresh_ForeignCursors=function(){if(!this.m_oLogicDocument)return;for(var UserId in this.m_aCursorsToUpdate){var CursorInfo=this.m_aCursorsToUpdate[UserId];this.m_oLogicDocument.Update_ForeignCursor(CursorInfo,UserId,false,this.m_aCursorsToUpdateShortId[UserId]);if(this.Add_ForeignCursorToShow)this.Add_ForeignCursorToShow(UserId)}this.m_aCursorsToUpdate={};this.m_aCursorsToUpdateShortId={}};CCollaborativeEditingBase.prototype.Clear_DocumentPositions=
|
|
|
|
|
function(){this.m_aDocumentPositions.Clear_DocumentPositions()};CCollaborativeEditingBase.prototype.Add_DocumentPosition=function(DocumentPos){this.m_aDocumentPositions.Add_DocumentPosition(DocumentPos)};CCollaborativeEditingBase.prototype.Add_ForeignCursor=function(UserId,DocumentPos,UserShortId){this.m_aForeignCursorsPos.Remove_DocumentPosition(this.m_aCursorsToUpdate[UserId]);this.m_aForeignCursors[UserId]=DocumentPos;this.m_aForeignCursorsPos.Add_DocumentPosition(DocumentPos);this.m_aForeignCursorsId[UserId]=
|
|
|
|
|
UserShortId};CCollaborativeEditingBase.prototype.Remove_ForeignCursor=function(UserId){this.m_aForeignCursorsPos.Remove_DocumentPosition(this.m_aCursorsToUpdate[UserId]);delete this.m_aForeignCursors[UserId]};CCollaborativeEditingBase.prototype.Remove_AllForeignCursors=function(){};CCollaborativeEditingBase.prototype.RemoveMyCursorFromOthers=function(){};CCollaborativeEditingBase.prototype.Update_DocumentPositionsOnAdd=function(Class,Pos){this.m_aDocumentPositions.Update_DocumentPositionsOnAdd(Class,
|
|
|
|
|
Pos);this.m_aForeignCursorsPos.Update_DocumentPositionsOnAdd(Class,Pos)};CCollaborativeEditingBase.prototype.Update_DocumentPositionsOnRemove=function(Class,Pos,Count){this.m_aDocumentPositions.Update_DocumentPositionsOnRemove(Class,Pos,Count);this.m_aForeignCursorsPos.Update_DocumentPositionsOnRemove(Class,Pos,Count)};CCollaborativeEditingBase.prototype.OnStart_SplitRun=function(SplitRun,SplitPos){this.m_aDocumentPositions.OnStart_SplitRun(SplitRun,SplitPos);this.m_aForeignCursorsPos.OnStart_SplitRun(SplitRun,
|
|
|
|
|
SplitPos)};CCollaborativeEditingBase.prototype.OnEnd_SplitRun=function(NewRun){this.m_aDocumentPositions.OnEnd_SplitRun(NewRun);this.m_aForeignCursorsPos.OnEnd_SplitRun(NewRun)};CCollaborativeEditingBase.prototype.Update_DocumentPosition=function(DocPos){this.m_aDocumentPositions.Update_DocumentPosition(DocPos)};CCollaborativeEditingBase.prototype.Update_ForeignCursorsPositions=function(){};CCollaborativeEditingBase.prototype.InitMemory=function(){if(!this.m_oMemory)this.m_oMemory=new AscCommon.CMemory};
|
|
|
|
|
CCollaborativeEditingBase.prototype.private_SaveDocumentState=function(){var LogicDocument=editor.WordControl.m_oLogicDocument;var DocState;if(true!==this.Is_Fast()){DocState=LogicDocument.Get_SelectionState2();this.m_aCursorsToUpdate={}}else DocState=LogicDocument.Save_DocumentStateBeforeLoadChanges();return DocState};CCollaborativeEditingBase.prototype.private_RestoreDocumentState=function(DocState){var LogicDocument=editor.WordControl.m_oLogicDocument;if(true!==this.Is_Fast())LogicDocument.Set_SelectionState2(DocState);
|
|
|
|
|
else{LogicDocument.Load_DocumentStateAfterLoadChanges(DocState);this.Refresh_ForeignCursors()}};CCollaborativeEditingBase.prototype.WatchDocumentPositionsByState=function(DocState){this.Clear_DocumentPositions();if(DocState.Pos)this.Add_DocumentPosition(DocState.Pos);if(DocState.StartPos)this.Add_DocumentPosition(DocState.StartPos);if(DocState.EndPos)this.Add_DocumentPosition(DocState.EndPos);if(DocState.FootnotesStart&&DocState.FootnotesStart.Pos)this.Add_DocumentPosition(DocState.FootnotesStart.Pos);
|
|
|
|
|
if(DocState.FootnotesStart&&DocState.FootnotesStart.StartPos)this.Add_DocumentPosition(DocState.FootnotesStart.StartPos);if(DocState.FootnotesStart&&DocState.FootnotesStart.EndPos)this.Add_DocumentPosition(DocState.FootnotesStart.EndPos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.Pos)this.Add_DocumentPosition(DocState.FootnotesEnd.Pos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.StartPos)this.Add_DocumentPosition(DocState.FootnotesEnd.StartPos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.EndPos)this.Add_DocumentPosition(DocState.FootnotesEnd.EndPos)};
|
|
|
|
|
CCollaborativeEditingBase.prototype.UpdateDocumentPositionsByState=function(DocState){if(DocState.Pos)this.Update_DocumentPosition(DocState.Pos);if(DocState.StartPos)this.Update_DocumentPosition(DocState.StartPos);if(DocState.EndPos)this.Update_DocumentPosition(DocState.EndPos);if(DocState.FootnotesStart&&DocState.FootnotesStart.Pos)this.Update_DocumentPosition(DocState.FootnotesStart.Pos);if(DocState.FootnotesStart&&DocState.FootnotesStart.StartPos)this.Update_DocumentPosition(DocState.FootnotesStart.StartPos);
|
|
|
|
|
if(DocState.FootnotesStart&&DocState.FootnotesStart.EndPos)this.Update_DocumentPosition(DocState.FootnotesStart.EndPos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.Pos)this.Update_DocumentPosition(DocState.FootnotesEnd.Pos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.StartPos)this.Update_DocumentPosition(DocState.FootnotesEnd.StartPos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.EndPos)this.Update_DocumentPosition(DocState.FootnotesEnd.EndPos)};CCollaborativeEditingBase.prototype.private_ClearChanges=
|
|
|
|
|
function(){this.m_aChanges=[]};CCollaborativeEditingBase.prototype.private_CollectOwnChanges=function(){};CCollaborativeEditingBase.prototype.private_AddOverallChange=function(oChange){return true};CCollaborativeEditingBase.prototype.private_ClearChanges=function(){this.m_aChanges=[];this.m_oOwnChanges=[]};CCollaborativeEditingBase.prototype.private_CollectOwnChanges=function(){var StartPoint=null===AscCommon.History.SavedIndex?0:AscCommon.History.SavedIndex+1;var LastPoint=-1;if(this.m_nUseType<=
|
|
|
|
|
0)LastPoint=AscCommon.History.Points.length-1;else LastPoint=AscCommon.History.Index;for(var PointIndex=StartPoint;PointIndex<=LastPoint;PointIndex++){var Point=AscCommon.History.Points[PointIndex];for(var Index=0;Index<Point.Items.length;Index++){var Item=Point.Items[Index];this.m_oOwnChanges.push(Item.Data)}}};CCollaborativeEditingBase.prototype.private_AddOverallChange=function(oChange,isSave){for(var nIndex=0,nCount=this.m_oOwnChanges.length;nIndex<nCount;++nIndex)if(oChange&&oChange.Merge&&false===
|
|
|
|
|
oChange.Merge(this.m_oOwnChanges[nIndex]))return false;if(false!==isSave)this.m_aAllChanges.push(oChange);return true};CCollaborativeEditingBase.prototype.private_OnSendOwnChanges=function(arrChanges,nDeleteIndex){if(null!==nDeleteIndex)this.m_aAllChanges.length=this.m_nAllChangesSavedIndex+nDeleteIndex;else this.m_nAllChangesSavedIndex=this.m_aAllChanges.length;if(arrChanges.length>0){this.m_aOwnChangesIndexes.push({Position:this.m_aAllChanges.length,Count:arrChanges.length});this.m_aAllChanges=
|
|
|
|
|
this.m_aAllChanges.concat(arrChanges)}};CCollaborativeEditingBase.prototype.Undo=function(){if(true===this.Get_GlobalLock())return;if(this.m_aOwnChangesIndexes.length<=0)return false;var arrChanges=[];var oIndexes=this.m_aOwnChangesIndexes[this.m_aOwnChangesIndexes.length-1];var nPosition=oIndexes.Position;var nCount=oIndexes.Count;for(var nIndex=nCount-1;nIndex>=0;--nIndex){var oChange=this.m_aAllChanges[nPosition+nIndex];if(!oChange)continue;var oClass=oChange.GetClass();if(oChange.IsContentChange()){var _oChange=
|
|
|
|
|
oChange.Copy();if(this.private_CommutateContentChanges(_oChange,nPosition+nCount))arrChanges.push(_oChange);oChange.SetReverted(true)}else{var _oChange=oChange;if(this.private_CommutatePropertyChanges(oClass,_oChange,nPosition+nCount))arrChanges.push(_oChange)}}this.m_aOwnChangesIndexes.length=this.m_aOwnChangesIndexes.length-1;var arrReverseChanges=[];for(var nIndex=0,nCount=arrChanges.length;nIndex<nCount;++nIndex){var oReverseChange=arrChanges[nIndex].CreateReverseChange();if(oReverseChange){arrReverseChanges.push(oReverseChange);
|
|
|
|
|
oReverseChange.SetReverted(true)}}var oLogicDocument=this.m_oLogicDocument;oLogicDocument.DrawingDocument.EndTrackTable(null,true);oLogicDocument.TurnOffCheckChartSelection();var DocState=this.private_SaveDocumentState();var mapDrawings={};for(var nIndex=0,nCount=arrReverseChanges.length;nIndex<nCount;++nIndex){var oClass=arrReverseChanges[nIndex].GetClass();if(oClass&&oClass.parent&&oClass.parent instanceof AscCommonWord.ParaDrawing)mapDrawings[oClass.parent.Get_Id()]=oClass.parent;arrReverseChanges[nIndex].Load();
|
|
|
|
|
this.m_aAllChanges.push(arrReverseChanges[nIndex])}var mapDocumentContents={};var mapParagraphs={};var mapRuns={};var mapTables={};var mapGrObjects={};var mapSlides={};var mapLayouts={};var bChangedLayout=false;var bAddSlides=false;var mapAddedSlides={};for(var nIndex=0,nCount=arrReverseChanges.length;nIndex<nCount;++nIndex){var oChange=arrReverseChanges[nIndex];var oClass=oChange.GetClass();if(oClass instanceof AscCommonWord.CDocument||oClass instanceof AscCommonWord.CDocumentContent)mapDocumentContents[oClass.Get_Id()]=
|
|
|
|
|
oClass;else if(oClass instanceof AscCommonWord.Paragraph)mapParagraphs[oClass.Get_Id()]=oClass;else if(oClass.IsParagraphContentElement&&true===oClass.IsParagraphContentElement()&&true===oChange.IsContentChange()&&oClass.GetParagraph()){mapParagraphs[oClass.GetParagraph().Get_Id()]=oClass.GetParagraph();if(oClass instanceof AscCommonWord.ParaRun)mapRuns[oClass.Get_Id()]=oClass}else if(oClass instanceof AscCommonWord.ParaDrawing)mapDrawings[oClass.Get_Id()]=oClass;else if(oClass instanceof AscCommonWord.ParaRun)mapRuns[oClass.Get_Id()]=
|
|
|
|
|
oClass;else if(oClass instanceof AscCommonWord.CTable)mapTables[oClass.Get_Id()]=oClass;else if(oClass instanceof AscFormat.CShape||oClass instanceof AscFormat.CImageShape||oClass instanceof AscFormat.CChartSpace||oClass instanceof AscFormat.CGroupShape||oClass instanceof AscFormat.CGraphicFrame)mapGrObjects[oClass.Get_Id()]=oClass;else if(typeof AscCommonSlide!=="undefined")if(AscCommonSlide.Slide&&oClass instanceof AscCommonSlide.Slide)mapSlides[oClass.Get_Id()]=oClass;else if(AscCommonSlide.SlideLayout&&
|
|
|
|
|
oClass instanceof AscCommonSlide.SlideLayout){mapLayouts[oClass.Get_Id()]=oClass;bChangedLayout=true}else if(AscCommonSlide.CPresentation&&oClass instanceof AscCommonSlide.CPresentation)if(oChange.Type===AscDFH.historyitem_Presentation_RemoveSlide||oChange.Type===AscDFH.historyitem_Presentation_AddSlide){bAddSlides=true;for(var i=0;i<oChange.Items.length;++i)mapAddedSlides[oChange.Items[i].Get_Id()]=oChange.Items[i]}}var oHistory=AscCommon.History;oHistory.CreateNewPointForCollectChanges();if(bAddSlides)for(var i=
|
|
|
|
|
oLogicDocument.Slides.length-1;i>-1;--i)if(mapAddedSlides[oLogicDocument.Slides[i].Get_Id()]&&!oLogicDocument.Slides[i].Layout)oLogicDocument.removeSlide(i);for(var sId in mapSlides)if(mapSlides.hasOwnProperty(sId))mapSlides[sId].correctContent();if(bChangedLayout)for(var i=oLogicDocument.Slides.length-1;i>-1;--i){var Layout=oLogicDocument.Slides[i].Layout;if(!Layout||mapLayouts[Layout.Get_Id()])if(!oLogicDocument.Slides[i].CheckLayout())oLogicDocument.removeSlide(i)}for(var sId in mapGrObjects){var oShape=
|
|
|
|
|
mapGrObjects[sId];if(!oShape.checkCorrect()){oShape.setBDeleted(true);if(oShape.group)oShape.group.removeFromSpTree(oShape.Get_Id());else if(AscFormat.Slide&&oShape.parent instanceof AscFormat.Slide)oShape.parent.removeFromSpTreeById(oShape.Get_Id());else if(AscCommonWord.ParaDrawing&&oShape.parent instanceof AscCommonWord.ParaDrawing)mapDrawings[oShape.parent.Get_Id()]=oShape.parent}else if(oShape.resetGroups)oShape.resetGroups()}var oDrawing;for(var sId in mapDrawings)if(mapDrawings.hasOwnProperty(sId)){oDrawing=
|
|
|
|
|
mapDrawings[sId];if(!oDrawing.CheckCorrect()){var oParentParagraph=oDrawing.Get_ParentParagraph();oDrawing.PreDelete();oDrawing.Remove_FromDocument(false);if(oParentParagraph)mapParagraphs[oParentParagraph.Get_Id()]=oParentParagraph}}for(var sId in mapRuns)if(mapRuns.hasOwnProperty(sId)){var oRun=mapRuns[sId];for(var nIndex=oRun.Content.length-1;nIndex>-1;--nIndex)if(oRun.Content[nIndex]instanceof AscCommonWord.ParaDrawing)if(!oRun.Content[nIndex].CheckCorrect()){oRun.Remove_FromContent(nIndex,1,
|
|
|
|
|
false);if(oRun.Paragraph)mapParagraphs[oRun.Paragraph.Get_Id()]=oRun.Paragraph}}for(var sId in mapTables){var oTable=mapTables[sId];for(var nCurRow=oTable.Content.length-1;nCurRow>=0;--nCurRow){var oRow=oTable.Get_Row(nCurRow);if(oRow.Get_CellsCount()<=0)oTable.private_RemoveRow(nCurRow)}if(oTable.Parent instanceof AscCommonWord.CDocument||oTable.Parent instanceof AscCommonWord.CDocumentContent)mapDocumentContents[oTable.Parent.Get_Id()]=oTable.Parent}for(var sId in mapDocumentContents){var oDocumentContent=
|
|
|
|
|
mapDocumentContents[sId];var nContentLen=oDocumentContent.Content.length;for(var nIndex=nContentLen-1;nIndex>=0;--nIndex){var oElement=oDocumentContent.Content[nIndex];if((AscCommonWord.type_Paragraph===oElement.GetType()||AscCommonWord.type_Table===oElement.GetType())&&oElement.Content.length<=0)oDocumentContent.Remove_FromContent(nIndex,1)}nContentLen=oDocumentContent.Content.length;if(nContentLen<=0||AscCommonWord.type_Paragraph!==oDocumentContent.Content[nContentLen-1].GetType()){var oNewParagraph=
|
|
|
|
|
new AscCommonWord.Paragraph(oLogicDocument.Get_DrawingDocument(),oDocumentContent,0,0,0,0,0,false);oDocumentContent.Add_ToContent(nContentLen,oNewParagraph)}}for(var sId in mapParagraphs){var oParagraph=mapParagraphs[sId];oParagraph.CheckParaEnd();oParagraph.Correct_Content(null,null,true)}var oBinaryWriter=AscCommon.History.BinaryWriter;var aSendingChanges=[];for(var nIndex=0,nCount=arrReverseChanges.length;nIndex<nCount;++nIndex){var oReverseChange=arrReverseChanges[nIndex];var oChangeClass=oReverseChange.GetClass();
|
|
|
|
|
var nBinaryPos=oBinaryWriter.GetCurPosition();oBinaryWriter.WriteString2(oChangeClass.Get_Id());oBinaryWriter.WriteLong(oReverseChange.Type);oReverseChange.WriteToBinary(oBinaryWriter);var nBinaryLen=oBinaryWriter.GetCurPosition()-nBinaryPos;var oChange=new AscCommon.CCollaborativeChanges;oChange.Set_FromUndoRedo(oChangeClass,oReverseChange,{Pos:nBinaryPos,Len:nBinaryLen});aSendingChanges.push(oChange.m_pData)}var oHistoryPoint=oHistory.Points[oHistory.Points.length-1];for(var nIndex=0,nCount=oHistoryPoint.Items.length;nIndex<
|
|
|
|
|
nCount;++nIndex){var oReverseChange=oHistoryPoint.Items[nIndex].Data;var oChangeClass=oReverseChange.GetClass();var oChange=new AscCommon.CCollaborativeChanges;oChange.Set_FromUndoRedo(oChangeClass,oReverseChange,{Pos:oHistoryPoint.Items[nIndex].Binary.Pos,Len:oHistoryPoint.Items[nIndex].Binary.Len});aSendingChanges.push(oChange.m_pData);arrReverseChanges.push(oHistoryPoint.Items[nIndex].Data)}oHistory.Remove_LastPoint();this.Clear_DCChanges();editor.CoAuthoringApi.saveChanges(aSendingChanges,null,
|
|
|
|
|
null,false,this.getCollaborativeEditing());this.private_RestoreDocumentState(DocState);oLogicDocument.TurnOnCheckChartSelection();this.private_RecalculateDocument(AscCommon.History.Get_RecalcData(null,arrReverseChanges));oLogicDocument.Document_UpdateSelectionState();oLogicDocument.Document_UpdateInterfaceState();oLogicDocument.Document_UpdateRulersState()};CCollaborativeEditingBase.prototype.CanUndo=function(){return this.m_aOwnChangesIndexes.length<=0?false:true};CCollaborativeEditingBase.prototype.private_CommutateContentChanges=
|
|
|
|
|
function(oChange,nStartPosition){var arrActions=oChange.ConvertToSimpleActions();var arrCommutateActions=[];for(var nActionIndex=arrActions.length-1;nActionIndex>=0;--nActionIndex){var oAction=arrActions[nActionIndex];var oResult=oAction;for(var nIndex=nStartPosition,nOverallCount=this.m_aAllChanges.length;nIndex<nOverallCount;++nIndex){var oTempChange=this.m_aAllChanges[nIndex];if(!oTempChange)continue;if(oChange.IsRelated(oTempChange)&&true!==oTempChange.IsReverted()){var arrOtherActions=oTempChange.ConvertToSimpleActions();
|
|
|
|
|
for(var nIndex2=0,nOtherActionsCount2=arrOtherActions.length;nIndex2<nOtherActionsCount2;++nIndex2){var oOtherAction=arrOtherActions[nIndex2];if(false===this.private_Commutate(oAction,oOtherAction)){arrOtherActions.splice(nIndex2,1);oResult=null;break}}oTempChange.ConvertFromSimpleActions(arrOtherActions)}if(!oResult)break}if(null!==oResult)arrCommutateActions.push(oResult)}if(arrCommutateActions.length>0)oChange.ConvertFromSimpleActions(arrCommutateActions);else return false;return true};CCollaborativeEditingBase.prototype.private_Commutate=
|
|
|
|
|
function(oActionL,oActionR){if(oActionL.Add)if(oActionR.Add)if(oActionL.Pos>=oActionR.Pos)oActionL.Pos++;else oActionR.Pos--;else if(oActionL.Pos>oActionR.Pos)oActionL.Pos--;else if(oActionL.Pos===oActionR.Pos)return false;else oActionR.Pos--;else if(oActionR.Add)if(oActionL.Pos>=oActionR.Pos)oActionL.Pos++;else oActionR.Pos++;else if(oActionL.Pos>oActionR.Pos)oActionL.Pos--;else oActionR.Pos++;return true};CCollaborativeEditingBase.prototype.private_CommutatePropertyChanges=function(oClass,oChange,
|
|
|
|
|
nStartPosition){if(oChange.CheckCorrect&&!oChange.CheckCorrect())return false;return true};CCollaborativeEditingBase.prototype.private_RecalculateDocument=function(oRecalcData){};function CDocumentPositionsManager(){this.m_aDocumentPositions=[];this.m_aDocumentPositionsSplit=[];this.m_aDocumentPositionsMap=[]}CDocumentPositionsManager.prototype.Clear_DocumentPositions=function(){this.m_aDocumentPositions=[];this.m_aDocumentPositionsSplit=[];this.m_aDocumentPositionsMap=[]};CDocumentPositionsManager.prototype.Add_DocumentPosition=
|
|
|
|
|
function(Position){this.m_aDocumentPositions.push(Position)};CDocumentPositionsManager.prototype.Update_DocumentPositionsOnAdd=function(Class,Pos){for(var PosIndex=0,PosCount=this.m_aDocumentPositions.length;PosIndex<PosCount;++PosIndex){var DocPos=this.m_aDocumentPositions[PosIndex];for(var ClassPos=0,ClassLen=DocPos.length;ClassPos<ClassLen;++ClassPos){var _Pos=DocPos[ClassPos];if(Class===_Pos.Class&&undefined!==_Pos.Position&&(_Pos.Position>Pos||_Pos.Position===Pos&&!(Class instanceof AscCommonWord.ParaRun))){_Pos.Position++;
|
|
|
|
|
break}}}};CDocumentPositionsManager.prototype.Update_DocumentPositionsOnRemove=function(Class,Pos,Count){for(var PosIndex=0,PosCount=this.m_aDocumentPositions.length;PosIndex<PosCount;++PosIndex){var DocPos=this.m_aDocumentPositions[PosIndex];for(var ClassPos=0,ClassLen=DocPos.length;ClassPos<ClassLen;++ClassPos){var _Pos=DocPos[ClassPos];if(Class===_Pos.Class&&undefined!==_Pos.Position){if(_Pos.Position>Pos+Count)_Pos.Position-=Count;else if(_Pos.Position>=Pos){_Pos.Position=Pos;_Pos.Deleted=true}break}}}};
|
|
|
|
|
CDocumentPositionsManager.prototype.OnStart_SplitRun=function(SplitRun,SplitPos){this.m_aDocumentPositionsSplit=[];for(var PosIndex=0,PosCount=this.m_aDocumentPositions.length;PosIndex<PosCount;++PosIndex){var DocPos=this.m_aDocumentPositions[PosIndex];for(var ClassPos=0,ClassLen=DocPos.length;ClassPos<ClassLen;++ClassPos){var _Pos=DocPos[ClassPos];if(SplitRun===_Pos.Class&&_Pos.Position&&_Pos.Position>=SplitPos)this.m_aDocumentPositionsSplit.push({DocPos:DocPos,NewRunPos:_Pos.Position-SplitPos})}}};
|
|
|
|
|
CDocumentPositionsManager.prototype.OnEnd_SplitRun=function(NewRun){if(!NewRun)return;for(var PosIndex=0,PosCount=this.m_aDocumentPositionsSplit.length;PosIndex<PosCount;++PosIndex){var NewDocPos=[];NewDocPos.push({Class:NewRun,Position:this.m_aDocumentPositionsSplit[PosIndex].NewRunPos});this.m_aDocumentPositions.push(NewDocPos);this.m_aDocumentPositionsMap.push({StartPos:this.m_aDocumentPositionsSplit[PosIndex].DocPos,EndPos:NewDocPos})}};CDocumentPositionsManager.prototype.Update_DocumentPosition=
|
|
|
|
|
function(DocPos){var NewDocPos=DocPos;for(var PosIndex=0,PosCount=this.m_aDocumentPositionsMap.length;PosIndex<PosCount;++PosIndex)if(this.m_aDocumentPositionsMap[PosIndex].StartPos===NewDocPos)NewDocPos=this.m_aDocumentPositionsMap[PosIndex].EndPos;if(NewDocPos!==DocPos&&NewDocPos.length===1&&NewDocPos[0].Class instanceof AscCommonWord.ParaRun){var Run=NewDocPos[0].Class;var Para=Run.GetParagraph();if(AscCommonWord.CanUpdatePosition(Para,Run)){DocPos.length=0;Run.GetDocumentPositionFromObject(DocPos);
|
|
|
|
|
DocPos.push({Class:Run,Position:NewDocPos[0].Position})}}else if(DocPos.length>0&&DocPos[DocPos.length-1].Class instanceof AscCommonWord.ParaRun){var Run=DocPos[DocPos.length-1].Class;var RunPos=DocPos[DocPos.length-1].Position;var Para=Run.GetParagraph();if(AscCommonWord.CanUpdatePosition(Para,Run)){DocPos.length=0;Run.GetDocumentPositionFromObject(DocPos);DocPos.push({Class:Run,Position:RunPos})}}};CDocumentPositionsManager.prototype.Remove_DocumentPosition=function(DocPos){for(var Pos=0,Count=
|
|
|
|
|
this.m_aDocumentPositions.length;Pos<Count;++Pos)if(this.m_aDocumentPositions[Pos]===DocPos){this.m_aDocumentPositions.splice(Pos,1);return}};window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].FOREIGN_CURSOR_LABEL_HIDETIME=FOREIGN_CURSOR_LABEL_HIDETIME;window["AscCommon"].CCollaborativeChanges=CCollaborativeChanges;window["AscCommon"].CCollaborativeEditingBase=CCollaborativeEditingBase;window["AscCommon"].CDocumentPositionsManager=CDocumentPositionsManager})(window);"use strict";(function(window,
|
|
|
|
|
undefined){var g_dKoef_mm_to_pix=AscCommon.g_dKoef_mm_to_pix;function CBounds(){this.L=0;this.T=0;this.R=0;this.B=0;this.isAbsL=false;this.isAbsT=false;this.isAbsR=false;this.isAbsB=false;this.AbsW=-1;this.AbsH=-1;this.SetParams=function(_l,_t,_r,_b,abs_l,abs_t,abs_r,abs_b,absW,absH){this.L=_l;this.T=_t;this.R=_r;this.B=_b;this.isAbsL=abs_l;this.isAbsT=abs_t;this.isAbsR=abs_r;this.isAbsB=abs_b;this.AbsW=absW;this.AbsH=absH}}function CAbsolutePosition(){this.L=0;this.T=0;this.R=0;this.B=0}var g_anchor_left=
|
|
|
|
|
1;var g_anchor_top=2;var g_anchor_right=4;var g_anchor_bottom=8;function CControl(){this.Bounds=new CBounds;this.Anchor=g_anchor_left|g_anchor_top;this.Name=null;this.Parent=null;this.TabIndex=null;this.HtmlElement=null;this.AbsolutePosition=new CBounds;this.Resize=function(_width,_height,api){if(null==this.Parent||null==this.HtmlElement)return;var _x=0;var _y=0;var _r=0;var _b=0;var hor_anchor=this.Anchor&5;var ver_anchor=this.Anchor&10;if(g_anchor_left==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;
|
|
|
|
|
else _x=this.Bounds.L*_width/1E3;if(-1!=this.Bounds.AbsW)_r=_x+this.Bounds.AbsW;else if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else if(g_anchor_right==hor_anchor){if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3;if(-1!=this.Bounds.AbsW)_x=_r-this.Bounds.AbsW;else if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3}else if((g_anchor_left|g_anchor_right)==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=
|
|
|
|
|
this.Bounds.L*_width/1E3;if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else{_x=this.Bounds.L;_r=this.Bounds.R}if(g_anchor_top==ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(-1!=this.Bounds.AbsH)_b=_y+this.Bounds.AbsH;else if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3}else if(g_anchor_bottom==ver_anchor){if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3;if(-1!=
|
|
|
|
|
this.Bounds.AbsH)_y=_b-this.Bounds.AbsH;else if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3}else if((g_anchor_top|g_anchor_bottom)==ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3}else{_y=this.Bounds.T;_b=this.Bounds.B}if(_r<_x)_r=_x;if(_b<_y)_b=_y;this.AbsolutePosition.L=_x;this.AbsolutePosition.T=_y;this.AbsolutePosition.R=_r;this.AbsolutePosition.B=_b;
|
|
|
|
|
this.HtmlElement.style.left=(_x*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.top=(_y*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.width=((_r-_x)*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.height=((_b-_y)*g_dKoef_mm_to_pix+.5>>0)+"px";if(api!==undefined&&api.CheckRetinaElement&&api.CheckRetinaElement(this.HtmlElement)){var _W=(_r-_x)*g_dKoef_mm_to_pix+.5>>0;var _H=(_b-_y)*g_dKoef_mm_to_pix+.5>>0;this.HtmlElement.width=AscCommon.AscBrowser.convertToRetinaValue(_W,true);this.HtmlElement.height=
|
|
|
|
|
AscCommon.AscBrowser.convertToRetinaValue(_H,true)}else{this.HtmlElement.width=(_r-_x)*g_dKoef_mm_to_pix+.5>>0;this.HtmlElement.height=(_b-_y)*g_dKoef_mm_to_pix+.5>>0}};this.GetCSS_width=function(){return(this.AbsolutePosition.R-this.AbsolutePosition.L)*g_dKoef_mm_to_pix+.5>>0};this.GetCSS_height=function(){return(this.AbsolutePosition.B-this.AbsolutePosition.T)*g_dKoef_mm_to_pix+.5>>0}}function CControlContainer(){this.Bounds=new CBounds;this.Anchor=g_anchor_left|g_anchor_top;this.Name=null;this.Parent=
|
|
|
|
|
null;this.TabIndex=null;this.HtmlElement=null;this.AbsolutePosition=new CBounds;this.Controls=[];this.AddControl=function(ctrl){ctrl.Parent=this;this.Controls[this.Controls.length]=ctrl};this.Resize=function(_width,_height,api){if(null==this.Parent){this.AbsolutePosition.L=0;this.AbsolutePosition.T=0;this.AbsolutePosition.R=_width;this.AbsolutePosition.B=_height;if(null!=this.HtmlElement){var lCount=this.Controls.length;for(var i=0;i<lCount;i++)this.Controls[i].Resize(_width,_height,api)}return}var _x=
|
|
|
|
|
0;var _y=0;var _r=0;var _b=0;var hor_anchor=this.Anchor&5;var ver_anchor=this.Anchor&10;if(g_anchor_left==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(-1!=this.Bounds.AbsW)_r=_x+this.Bounds.AbsW;else if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else if(g_anchor_right==hor_anchor){if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3;if(-1!=this.Bounds.AbsW)_x=_r-this.Bounds.AbsW;else if(this.Bounds.isAbsL)_x=
|
|
|
|
|
this.Bounds.L;else _x=this.Bounds.L*_width/1E3}else if((g_anchor_left|g_anchor_right)==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else{_x=this.Bounds.L;_r=this.Bounds.R}if(g_anchor_top==ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(-1!=this.Bounds.AbsH)_b=_y+this.Bounds.AbsH;else if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*
|
|
|
|
|
_height/1E3}else if(g_anchor_bottom==ver_anchor){if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3;if(-1!=this.Bounds.AbsH)_y=_b-this.Bounds.AbsH;else if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3}else if((g_anchor_top|g_anchor_bottom)==ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3}else{_y=this.Bounds.T;_b=this.Bounds.B}if(_r<
|
|
|
|
|
_x)_r=_x;if(_b<_y)_b=_y;this.AbsolutePosition.L=_x;this.AbsolutePosition.T=_y;this.AbsolutePosition.R=_r;this.AbsolutePosition.B=_b;this.HtmlElement.style.left=(_x*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.top=(_y*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.width=((_r-_x)*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.height=((_b-_y)*g_dKoef_mm_to_pix+.5>>0)+"px";var lCount=this.Controls.length;for(var i=0;i<lCount;i++)this.Controls[i].Resize(_r-_x,_b-_y,api)};this.GetCSS_width=
|
|
|
|
|
function(){return(this.AbsolutePosition.R-this.AbsolutePosition.L)*g_dKoef_mm_to_pix+.5>>0};this.GetCSS_height=function(){return(this.AbsolutePosition.B-this.AbsolutePosition.T)*g_dKoef_mm_to_pix+.5>>0}}function CreateControlContainer(name){var ctrl=new CControlContainer;ctrl.Name=name;ctrl.HtmlElement=document.getElementById(name);return ctrl}function CreateControl(name){var ctrl=new CControl;ctrl.Name=name;ctrl.HtmlElement=document.getElementById(name);return ctrl}window["AscCommon"]=window["AscCommon"]||
|
|
|
|
|
{};window["AscCommon"].g_anchor_left=g_anchor_left;window["AscCommon"].g_anchor_top=g_anchor_top;window["AscCommon"].g_anchor_right=g_anchor_right;window["AscCommon"].g_anchor_bottom=g_anchor_bottom;window["AscCommon"].CreateControlContainer=CreateControlContainer;window["AscCommon"].CreateControl=CreateControl})(window);"use strict";(function(window,undefined){var AscBrowser=AscCommon.AscBrowser;var TRACK_CIRCLE_RADIUS=5;var TRACK_RECT_SIZE2=4;var TRACK_RECT_SIZE=8;var TRACK_RECT_SIZE_CT=6;var TRACK_DISTANCE_ROTATE=
|
|
|
|
|
25;var TRACK_DISTANCE_ROTATE2=25;var TRACK_ADJUSTMENT_SIZE=10;var TRACK_WRAPPOINTS_SIZE=6;var IMAGE_ROTATE_TRACK_W=21;var bIsUseImageRotateTrack=true;if(bIsUseImageRotateTrack){window.g_track_rotate_marker=new Image;window.g_track_rotate_marker;window.g_track_rotate_marker.asc_complete=false;window.g_track_rotate_marker.onload=function(){window.g_track_rotate_marker.asc_complete=true};window.g_track_rotate_marker.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAMAAACeyVWkAAAAVFBMVEUAAAD///////////////////////////////////////////////////////98fHy2trb09PTT09OysrKqqqqJiYng4ODr6+uamprGxsbi4uKGhoYjgM0eAAAADnRSTlMAy00k7/z0jbeuMzDljsugwZgAAACpSURBVBjTdZHbEoMgDESDAl6bgIqX9v//s67UYpm6D0xyYMImoaiuUr3pVdVRUtnwqaY8YaE5SRcfaPgqc+DSIh7WIGGaEVoUqRGN4oZlcDIiqYlaPjQz5CNu6cFJwLiuSO3nlLBDrKhn3l4rcnH4NcAdGd5EZMfCsoMFBxM6CD57G+u6vC48PMVnHtrYhP/x+7+3cw7zdJnD3cyA7QXa4nYXaW+a9Xdvb6zqE5Jb7LmzAAAAAElFTkSuQmCC";
|
|
|
|
|
pData};CCollaborativeChanges.prototype.Set_Color=function(oColor){this.m_oColor=oColor};CCollaborativeChanges.prototype.Set_FromUndoRedo=function(Class,Data,Binary){if(!Class.Get_Id)return false;this.m_pData=this.private_SaveData(Binary);return true};CCollaborativeChanges.prototype.Apply_Data=function(){var CollaborativeEditing=AscCommon.CollaborativeEditing;if(this.m_pData&&this.m_pData.type==="cp_theme"){clearTimeout(window.CP_theme_to);var data=this.m_pData;window.CP_theme_to=setTimeout(function(){window.parent.APP.remoteTheme();
|
|
|
|
|
window.editor.ChangeTheme(data.id,null,true)});return true}var Reader=this.private_LoadData(this.m_pData);var ClassId=Reader.GetString2();var Class=AscCommon.g_oTableId.Get_ById(ClassId);if(!Class)return false;var nReaderPos=Reader.GetCurPos();var nChangesType=Reader.GetLong();var fChangesClass=AscDFH.changesFactory[nChangesType];if(fChangesClass){var oChange=new fChangesClass(Class);oChange.ReadFromBinary(Reader);if(true===CollaborativeEditing.private_AddOverallChange(oChange))oChange.Load(this.m_oColor);
|
|
|
|
|
return true}else{CollaborativeEditing.private_AddOverallChange(this.m_pData);Reader.Seek2(nReaderPos);if(!Class.Load_Changes)return false;return Class.Load_Changes(Reader,null,this.m_oColor)}};CCollaborativeChanges.prototype.private_LoadData=function(szSrc){return this.GetStream(szSrc,0,szSrc.length)};CCollaborativeChanges.prototype.GetStream=function(szSrc,offset,srcLen){var nWritten=0;var index=-1+offset;var dst_len="";while(true){index++;var _c=szSrc.charCodeAt(index);if(_c==";".charCodeAt(0)){index++;
|
|
|
|
|
break}dst_len+=String.fromCharCode(_c)}var dstLen=parseInt(dst_len);var pointer=AscFonts.g_memory.Alloc(dstLen);var stream=new AscCommon.FT_Stream2(pointer.data,dstLen);stream.obj=pointer.obj;var dstPx=stream.data;if(window.chrome)while(index<srcLen){var dwCurr=0;var i;var nBits=0;for(i=0;i<4;i++){if(index>=srcLen)break;var nCh=AscFonts.DecodeBase64Char(szSrc.charCodeAt(index++));if(nCh==-1){i--;continue}dwCurr<<=6;dwCurr|=nCh;nBits+=6}dwCurr<<=24-nBits;for(i=0;i<nBits/8;i++){dstPx[nWritten++]=(dwCurr&
|
|
|
|
|
16711680)>>>16;dwCurr<<=8}}else{var p=AscFonts.b64_decode;while(index<srcLen){var dwCurr=0;var i;var nBits=0;for(i=0;i<4;i++){if(index>=srcLen)break;var nCh=p[szSrc.charCodeAt(index++)];if(nCh==undefined){i--;continue}dwCurr<<=6;dwCurr|=nCh;nBits+=6}dwCurr<<=24-nBits;for(i=0;i<nBits/8;i++){dstPx[nWritten++]=(dwCurr&16711680)>>>16;dwCurr<<=8}}}return stream};CCollaborativeChanges.prototype.private_SaveData=function(Binary){var Writer=AscCommon.History.BinaryWriter;var Pos=Binary.Pos;var Len=Binary.Len;
|
|
|
|
|
return Len+";"+Writer.GetBase64Memory2(Pos,Len)};function CCollaborativeEditingBase(){this.m_nUseType=1;this.m_aUsers=[];this.m_aChanges=[];this.m_aNeedUnlock=[];this.m_aNeedUnlock2=[];this.m_aNeedLock=[];this.m_aLinkData=[];this.m_aEndActions=[];this.m_bGlobalLock=0;this.m_bGlobalLockSelection=0;this.m_aCheckLocks=[];this.m_aCheckLocksInstance=[];this.m_aNewObjects=[];this.m_aNewImages=[];this.m_aDC={};this.m_aChangedClasses={};this.m_oMemory=null;this.m_aCursorsToUpdate={};this.m_aCursorsToUpdateShortId=
|
|
|
|
|
{};this.m_bFast=false;this.m_oLogicDocument=null;this.m_aDocumentPositions=new CDocumentPositionsManager;this.m_aForeignCursorsPos=new CDocumentPositionsManager;this.m_aForeignCursors={};this.m_aForeignCursorsId={};this.m_nAllChangesSavedIndex=0;this.m_aAllChanges=[];this.m_aOwnChangesIndexes=[];this.m_oOwnChanges=[]}CCollaborativeEditingBase.prototype.Clear=function(){this.m_nUseType=1;this.m_aUsers=[];this.m_aChanges=[];this.m_aNeedUnlock=[];this.m_aNeedUnlock2=[];this.m_aNeedLock=[];this.m_aLinkData=
|
|
|
|
|
[];this.m_aEndActions=[];this.m_aCheckLocks=[];this.m_aCheckLocksInstance=[];this.m_aNewObjects=[];this.m_aNewImages=[]};CCollaborativeEditingBase.prototype.Set_Fast=function(bFast){this.m_bFast=bFast;if(false===bFast){this.Remove_AllForeignCursors();this.RemoveMyCursorFromOthers()}};CCollaborativeEditingBase.prototype.Is_Fast=function(){return this.m_bFast};CCollaborativeEditingBase.prototype.Is_SingleUser=function(){return 1===this.m_nUseType};CCollaborativeEditingBase.prototype.getCollaborativeEditing=
|
|
|
|
|
function(){return!this.Is_SingleUser()};CCollaborativeEditingBase.prototype.Start_CollaborationEditing=function(){this.m_nUseType=-1};CCollaborativeEditingBase.prototype.End_CollaborationEditing=function(){if(this.m_nUseType<=0)this.m_nUseType=0};CCollaborativeEditingBase.prototype.Add_User=function(UserId){if(-1===this.Find_User(UserId))this.m_aUsers.push(UserId)};CCollaborativeEditingBase.prototype.Find_User=function(UserId){var Len=this.m_aUsers.length;for(var Index=0;Index<Len;Index++)if(this.m_aUsers[Index]===
|
|
|
|
|
UserId)return Index;return-1};CCollaborativeEditingBase.prototype.Remove_User=function(UserId){var Pos=this.Find_User(UserId);if(-1!=Pos)this.m_aUsers.splice(Pos,1)};CCollaborativeEditingBase.prototype.Add_Changes=function(Changes){this.m_aChanges.push(Changes)};CCollaborativeEditingBase.prototype.Add_Unlock=function(LockClass){this.m_aNeedUnlock.push(LockClass)};CCollaborativeEditingBase.prototype.Add_Unlock2=function(Lock){this.m_aNeedUnlock2.push(Lock);editor._onUpdateDocumentCanSave()};CCollaborativeEditingBase.prototype.Have_OtherChanges=
|
|
|
|
|
function(){return 0<this.m_aChanges.length};CCollaborativeEditingBase.prototype.Apply_Changes=function(){var OtherChanges=this.m_aChanges.length>0;if(true===OtherChanges){AscFonts.IsCheckSymbols=true;editor.WordControl.m_oLogicDocument.StopRecalculate();editor.WordControl.m_oLogicDocument.EndPreview_MailMergeResult();editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction,Asc.c_oAscAsyncAction.ApplyChanges);var DocState=this.private_SaveDocumentState();this.Clear_NewImages();this.Apply_OtherChanges();
|
|
|
|
|
this.Lock_NeedLock();this.private_RestoreDocumentState(DocState);this.OnStart_Load_Objects();AscFonts.IsCheckSymbols=false}};CCollaborativeEditingBase.prototype.Apply_OtherChanges=function(){AscCommon.g_oIdCounter.Set_Load(true);if(this.m_aChanges.length>0)this.private_CollectOwnChanges();var _count=this.m_aChanges.length;for(var i=0;i<_count;i++){if(window["NATIVE_EDITOR_ENJINE"]===true&&window["native"]["CheckNextChange"])if(!window["native"]["CheckNextChange"]())break;var Changes=this.m_aChanges[i];
|
|
|
|
|
Changes.Apply_Data()}this.private_ClearChanges();this.Apply_LinkData();this.Check_MergeData();this.OnEnd_ReadForeignChanges();AscCommon.g_oIdCounter.Set_Load(false)};CCollaborativeEditingBase.prototype.getOwnLocksLength=function(){return this.m_aNeedUnlock2.length};CCollaborativeEditingBase.prototype.Send_Changes=function(){};CCollaborativeEditingBase.prototype.Release_Locks=function(){};CCollaborativeEditingBase.prototype.CheckWaitingImages=function(aImages){};CCollaborativeEditingBase.prototype.SendImagesUrlsFromChanges=
|
|
|
|
|
function(aImages){var rData={},oApi=editor||Asc["editor"],i;if(!oApi)return;rData["c"]="pathurls";rData["data"]=[];for(i=0;i<aImages.length;++i)rData["data"].push(aImages[i]);var aImagesToLoad=[].concat(AscCommon.CollaborativeEditing.m_aNewImages);this.CheckWaitingImages(aImagesToLoad);AscCommon.CollaborativeEditing.m_aNewImages.length=0;if(false===oApi.isSaveFonts_Images)oApi.isSaveFonts_Images=true;AscCommon.CollaborativeEditing.SendImagesCallback(aImagesToLoad)};CCollaborativeEditingBase.prototype.SendImagesCallback=
|
|
|
|
|
function(aImages){var oApi=editor||Asc["editor"];oApi.pre_Save(aImages)};CCollaborativeEditingBase.prototype.CollectImagesFromChanges=function(){var oApi=editor||Asc["editor"];var aImages=[],sImagePath,i,sImageFromChanges,oThemeUrls={};var aNewImages=this.m_aNewImages;var oMap={};for(i=0;i<aNewImages.length;++i){sImageFromChanges=aNewImages[i];if(oMap[sImageFromChanges])continue;oMap[sImageFromChanges]=1;if(sImageFromChanges.indexOf("theme")===0&&oApi.ThemeLoader)oThemeUrls[sImageFromChanges]=oApi.ThemeLoader.ThemesUrlAbs+
|
|
|
|
|
sImageFromChanges;else if(0===sImageFromChanges.indexOf("http:")||0===sImageFromChanges.indexOf("data:")||0===sImageFromChanges.indexOf("https:")||0===sImageFromChanges.indexOf("file:")||0===sImageFromChanges.indexOf("ftp:"));else{sImagePath=AscCommon.g_oDocumentUrls.mediaPrefix+sImageFromChanges;if(!AscCommon.g_oDocumentUrls.getUrl(sImagePath))aImages.push(sImagePath)}}AscCommon.g_oDocumentUrls.addUrls(oThemeUrls);return aImages};CCollaborativeEditingBase.prototype.OnStart_Load_Objects=function(){this.Set_GlobalLock(true);
|
|
|
|
|
this.Set_GlobalLockSelection(true);var aImages=this.CollectImagesFromChanges();if(aImages.length>0)this.SendImagesUrlsFromChanges(aImages);else{this.SendImagesCallback([].concat(this.m_aNewImages));this.m_aNewImages.length=0}};CCollaborativeEditingBase.prototype.OnEnd_Load_Objects=function(){};CCollaborativeEditingBase.prototype.Clear_LinkData=function(){this.m_aLinkData.length=0};CCollaborativeEditingBase.prototype.Add_LinkData=function(Class,LinkData){this.m_aLinkData.push({Class:Class,LinkData:LinkData})};
|
|
|
|
|
CCollaborativeEditingBase.prototype.Apply_LinkData=function(){var Count=this.m_aLinkData.length;for(var Index=0;Index<Count;Index++){var Item=this.m_aLinkData[Index];Item.Class.Load_LinkData(Item.LinkData)}this.Clear_LinkData()};CCollaborativeEditingBase.prototype.Check_MergeData=function(){};CCollaborativeEditingBase.prototype.Get_GlobalLock=function(){return 0===this.m_bGlobalLock?false:true};CCollaborativeEditingBase.prototype.Set_GlobalLock=function(isLock){if(isLock)this.m_bGlobalLock++;else this.m_bGlobalLock=
|
|
|
|
|
Math.max(0,this.m_bGlobalLock-1)};CCollaborativeEditingBase.prototype.Set_GlobalLockSelection=function(isLock){if(isLock)this.m_bGlobalLockSelection++;else this.m_bGlobalLockSelection=Math.max(0,this.m_bGlobalLockSelection-1)};CCollaborativeEditingBase.prototype.Get_GlobalLockSelection=function(){return 0===this.m_bGlobalLockSelection?false:true};CCollaborativeEditingBase.prototype.OnStart_CheckLock=function(){this.m_aCheckLocks.length=0;this.m_aCheckLocksInstance.length=0};CCollaborativeEditingBase.prototype.Add_CheckLock=
|
|
|
|
|
function(oItem){this.m_aCheckLocks.push(oItem);this.m_aCheckLocksInstance.push(oItem)};CCollaborativeEditingBase.prototype.OnEnd_CheckLock=function(){};CCollaborativeEditingBase.prototype.OnCallback_AskLock=function(result){};CCollaborativeEditingBase.prototype.OnStartCheckLockInstance=function(){this.m_aCheckLocksInstance.length=0};CCollaborativeEditingBase.prototype.OnEndCheckLockInstance=function(){var isLocked=false;for(var nIndex=0,nCount=this.m_aCheckLocksInstance.length;nIndex<nCount;++nIndex)if(true===
|
|
|
|
|
this.m_aCheckLocksInstance[nIndex]){isLocked=true;break}if(isLocked){var nCount=this.m_aCheckLocksInstance.length;this.m_aCheckLocks.splice(this.m_aCheckLocks.length-nCount,nCount)}this.m_aCheckLocksInstance.length=0;return isLocked};CCollaborativeEditingBase.prototype.Reset_NeedLock=function(){this.m_aNeedLock={}};CCollaborativeEditingBase.prototype.Add_NeedLock=function(Id,sUser){this.m_aNeedLock[Id]=sUser};CCollaborativeEditingBase.prototype.Remove_NeedLock=function(Id){delete this.m_aNeedLock[Id]};
|
|
|
|
|
CCollaborativeEditingBase.prototype.Lock_NeedLock=function(){for(var Id in this.m_aNeedLock){var Class=AscCommon.g_oTableId.Get_ById(Id);if(null!=Class){var Lock=Class.Lock;Lock.Set_Type(AscCommon.locktype_Other,false);if(Class.getObjectType&&Class.getObjectType()===AscDFH.historyitem_type_Slide)editor.WordControl.m_oLogicDocument.DrawingDocument.UnLockSlide&&editor.WordControl.m_oLogicDocument.DrawingDocument.UnLockSlide(Class.num);Lock.Set_UserId(this.m_aNeedLock[Id])}}this.Reset_NeedLock()};CCollaborativeEditingBase.prototype.Clear_NewObjects=
|
|
|
|
|
function(){this.m_aNewObjects.length=0};CCollaborativeEditingBase.prototype.Add_NewObject=function(Class){this.m_aNewObjects.push(Class);Class.FromBinary=true};CCollaborativeEditingBase.prototype.Clear_EndActions=function(){this.m_aEndActions.length=0};CCollaborativeEditingBase.prototype.Add_EndActions=function(Class,Data){this.m_aEndActions.push({Class:Class,Data:Data})};CCollaborativeEditingBase.prototype.OnEnd_ReadForeignChanges=function(){var Count=this.m_aNewObjects.length;for(var Index=0;Index<
|
|
|
|
|
Count;Index++){var Class=this.m_aNewObjects[Index];Class.FromBinary=false}Count=this.m_aEndActions.length;for(var Index=0;Index<Count;Index++){var Item=this.m_aEndActions[Index];Item.Class.Process_EndLoad(Item.Data)}this.Clear_EndActions();this.Clear_NewObjects()};CCollaborativeEditingBase.prototype.Clear_NewImages=function(){this.m_aNewImages.length=0};CCollaborativeEditingBase.prototype.Add_NewImage=function(Url){this.m_aNewImages.push(Url)};CCollaborativeEditingBase.prototype.Add_NewDC=function(Class){var Id=
|
|
|
|
|
Class.Get_Id();this.m_aDC[Id]=Class};CCollaborativeEditingBase.prototype.Clear_DCChanges=function(){for(var Id in this.m_aDC)this.m_aDC[Id].Clear_ContentChanges();this.m_aDC={}};CCollaborativeEditingBase.prototype.Refresh_DCChanges=function(){for(var Id in this.m_aDC)this.m_aDC[Id].Refresh_ContentChanges();this.Clear_DCChanges()};CCollaborativeEditingBase.prototype.AddPosExtChanges=function(Item,ChangeObject){};CCollaborativeEditingBase.prototype.RefreshPosExtChanges=function(){};CCollaborativeEditingBase.prototype.RewritePosExtChanges=
|
|
|
|
|
function(changesArr,scale,Binary_Writer){};CCollaborativeEditingBase.prototype.RefreshPosExtChanges=function(){};CCollaborativeEditingBase.prototype.Add_ChangedClass=function(Class){var Id=Class.Get_Id();this.m_aChangedClasses[Id]=Class};CCollaborativeEditingBase.prototype.Clear_CollaborativeMarks=function(bRepaint){for(var Id in this.m_aChangedClasses)this.m_aChangedClasses[Id].Clear_CollaborativeMarks();this.m_aChangedClasses={};if(true===bRepaint){editor.WordControl.m_oLogicDocument.DrawingDocument.ClearCachePages();
|
|
|
|
|
editor.WordControl.m_oLogicDocument.DrawingDocument.FirePaint()}};CCollaborativeEditingBase.prototype.Add_ForeignCursorToUpdate=function(UserId,CursorInfo,UserShortId){this.m_aCursorsToUpdate[UserId]=CursorInfo;this.m_aCursorsToUpdateShortId[UserId]=UserShortId};CCollaborativeEditingBase.prototype.Refresh_ForeignCursors=function(){if(!this.m_oLogicDocument)return;for(var UserId in this.m_aCursorsToUpdate){var CursorInfo=this.m_aCursorsToUpdate[UserId];this.m_oLogicDocument.Update_ForeignCursor(CursorInfo,
|
|
|
|
|
UserId,false,this.m_aCursorsToUpdateShortId[UserId]);if(this.Add_ForeignCursorToShow)this.Add_ForeignCursorToShow(UserId)}this.m_aCursorsToUpdate={};this.m_aCursorsToUpdateShortId={}};CCollaborativeEditingBase.prototype.Clear_DocumentPositions=function(){this.m_aDocumentPositions.Clear_DocumentPositions()};CCollaborativeEditingBase.prototype.Add_DocumentPosition=function(DocumentPos){this.m_aDocumentPositions.Add_DocumentPosition(DocumentPos)};CCollaborativeEditingBase.prototype.Add_ForeignCursor=
|
|
|
|
|
function(UserId,DocumentPos,UserShortId){this.m_aForeignCursorsPos.Remove_DocumentPosition(this.m_aCursorsToUpdate[UserId]);this.m_aForeignCursors[UserId]=DocumentPos;this.m_aForeignCursorsPos.Add_DocumentPosition(DocumentPos);this.m_aForeignCursorsId[UserId]=UserShortId};CCollaborativeEditingBase.prototype.Remove_ForeignCursor=function(UserId){this.m_aForeignCursorsPos.Remove_DocumentPosition(this.m_aCursorsToUpdate[UserId]);delete this.m_aForeignCursors[UserId]};CCollaborativeEditingBase.prototype.Remove_AllForeignCursors=
|
|
|
|
|
function(){};CCollaborativeEditingBase.prototype.RemoveMyCursorFromOthers=function(){};CCollaborativeEditingBase.prototype.Update_DocumentPositionsOnAdd=function(Class,Pos){this.m_aDocumentPositions.Update_DocumentPositionsOnAdd(Class,Pos);this.m_aForeignCursorsPos.Update_DocumentPositionsOnAdd(Class,Pos)};CCollaborativeEditingBase.prototype.Update_DocumentPositionsOnRemove=function(Class,Pos,Count){this.m_aDocumentPositions.Update_DocumentPositionsOnRemove(Class,Pos,Count);this.m_aForeignCursorsPos.Update_DocumentPositionsOnRemove(Class,
|
|
|
|
|
Pos,Count)};CCollaborativeEditingBase.prototype.OnStart_SplitRun=function(SplitRun,SplitPos){this.m_aDocumentPositions.OnStart_SplitRun(SplitRun,SplitPos);this.m_aForeignCursorsPos.OnStart_SplitRun(SplitRun,SplitPos)};CCollaborativeEditingBase.prototype.OnEnd_SplitRun=function(NewRun){this.m_aDocumentPositions.OnEnd_SplitRun(NewRun);this.m_aForeignCursorsPos.OnEnd_SplitRun(NewRun)};CCollaborativeEditingBase.prototype.Update_DocumentPosition=function(DocPos){this.m_aDocumentPositions.Update_DocumentPosition(DocPos)};
|
|
|
|
|
CCollaborativeEditingBase.prototype.Update_ForeignCursorsPositions=function(){};CCollaborativeEditingBase.prototype.InitMemory=function(){if(!this.m_oMemory)this.m_oMemory=new AscCommon.CMemory};CCollaborativeEditingBase.prototype.private_SaveDocumentState=function(){var LogicDocument=editor.WordControl.m_oLogicDocument;var DocState;if(true!==this.Is_Fast()){DocState=LogicDocument.Get_SelectionState2();this.m_aCursorsToUpdate={}}else DocState=LogicDocument.Save_DocumentStateBeforeLoadChanges();return DocState};
|
|
|
|
|
CCollaborativeEditingBase.prototype.private_RestoreDocumentState=function(DocState){var LogicDocument=editor.WordControl.m_oLogicDocument;if(true!==this.Is_Fast())LogicDocument.Set_SelectionState2(DocState);else{LogicDocument.Load_DocumentStateAfterLoadChanges(DocState);this.Refresh_ForeignCursors()}};CCollaborativeEditingBase.prototype.WatchDocumentPositionsByState=function(DocState){this.Clear_DocumentPositions();if(DocState.Pos)this.Add_DocumentPosition(DocState.Pos);if(DocState.StartPos)this.Add_DocumentPosition(DocState.StartPos);
|
|
|
|
|
if(DocState.EndPos)this.Add_DocumentPosition(DocState.EndPos);if(DocState.FootnotesStart&&DocState.FootnotesStart.Pos)this.Add_DocumentPosition(DocState.FootnotesStart.Pos);if(DocState.FootnotesStart&&DocState.FootnotesStart.StartPos)this.Add_DocumentPosition(DocState.FootnotesStart.StartPos);if(DocState.FootnotesStart&&DocState.FootnotesStart.EndPos)this.Add_DocumentPosition(DocState.FootnotesStart.EndPos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.Pos)this.Add_DocumentPosition(DocState.FootnotesEnd.Pos);
|
|
|
|
|
if(DocState.FootnotesEnd&&DocState.FootnotesEnd.StartPos)this.Add_DocumentPosition(DocState.FootnotesEnd.StartPos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.EndPos)this.Add_DocumentPosition(DocState.FootnotesEnd.EndPos)};CCollaborativeEditingBase.prototype.UpdateDocumentPositionsByState=function(DocState){if(DocState.Pos)this.Update_DocumentPosition(DocState.Pos);if(DocState.StartPos)this.Update_DocumentPosition(DocState.StartPos);if(DocState.EndPos)this.Update_DocumentPosition(DocState.EndPos);
|
|
|
|
|
if(DocState.FootnotesStart&&DocState.FootnotesStart.Pos)this.Update_DocumentPosition(DocState.FootnotesStart.Pos);if(DocState.FootnotesStart&&DocState.FootnotesStart.StartPos)this.Update_DocumentPosition(DocState.FootnotesStart.StartPos);if(DocState.FootnotesStart&&DocState.FootnotesStart.EndPos)this.Update_DocumentPosition(DocState.FootnotesStart.EndPos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.Pos)this.Update_DocumentPosition(DocState.FootnotesEnd.Pos);if(DocState.FootnotesEnd&&DocState.FootnotesEnd.StartPos)this.Update_DocumentPosition(DocState.FootnotesEnd.StartPos);
|
|
|
|
|
if(DocState.FootnotesEnd&&DocState.FootnotesEnd.EndPos)this.Update_DocumentPosition(DocState.FootnotesEnd.EndPos)};CCollaborativeEditingBase.prototype.private_ClearChanges=function(){this.m_aChanges=[]};CCollaborativeEditingBase.prototype.private_CollectOwnChanges=function(){};CCollaborativeEditingBase.prototype.private_AddOverallChange=function(oChange){return true};CCollaborativeEditingBase.prototype.private_ClearChanges=function(){this.m_aChanges=[];this.m_oOwnChanges=[]};CCollaborativeEditingBase.prototype.private_CollectOwnChanges=
|
|
|
|
|
function(){var StartPoint=null===AscCommon.History.SavedIndex?0:AscCommon.History.SavedIndex+1;var LastPoint=-1;if(this.m_nUseType<=0)LastPoint=AscCommon.History.Points.length-1;else LastPoint=AscCommon.History.Index;for(var PointIndex=StartPoint;PointIndex<=LastPoint;PointIndex++){var Point=AscCommon.History.Points[PointIndex];for(var Index=0;Index<Point.Items.length;Index++){var Item=Point.Items[Index];this.m_oOwnChanges.push(Item.Data)}}};CCollaborativeEditingBase.prototype.private_AddOverallChange=
|
|
|
|
|
function(oChange,isSave){for(var nIndex=0,nCount=this.m_oOwnChanges.length;nIndex<nCount;++nIndex)if(oChange&&oChange.Merge&&false===oChange.Merge(this.m_oOwnChanges[nIndex]))return false;if(false!==isSave)this.m_aAllChanges.push(oChange);return true};CCollaborativeEditingBase.prototype.private_OnSendOwnChanges=function(arrChanges,nDeleteIndex){if(null!==nDeleteIndex)this.m_aAllChanges.length=this.m_nAllChangesSavedIndex+nDeleteIndex;else this.m_nAllChangesSavedIndex=this.m_aAllChanges.length;if(arrChanges.length>
|
|
|
|
|
0){this.m_aOwnChangesIndexes.push({Position:this.m_aAllChanges.length,Count:arrChanges.length});this.m_aAllChanges=this.m_aAllChanges.concat(arrChanges)}};CCollaborativeEditingBase.prototype.Undo=function(){if(true===this.Get_GlobalLock())return;if(this.m_aOwnChangesIndexes.length<=0)return false;var arrChanges=[];var oIndexes=this.m_aOwnChangesIndexes[this.m_aOwnChangesIndexes.length-1];var nPosition=oIndexes.Position;var nCount=oIndexes.Count;for(var nIndex=nCount-1;nIndex>=0;--nIndex){var oChange=
|
|
|
|
|
this.m_aAllChanges[nPosition+nIndex];if(!oChange)continue;var oClass=oChange.GetClass();if(oChange.IsContentChange()){var _oChange=oChange.Copy();if(this.private_CommutateContentChanges(_oChange,nPosition+nCount))arrChanges.push(_oChange);oChange.SetReverted(true)}else{var _oChange=oChange;if(this.private_CommutatePropertyChanges(oClass,_oChange,nPosition+nCount))arrChanges.push(_oChange)}}this.m_aOwnChangesIndexes.length=this.m_aOwnChangesIndexes.length-1;var arrReverseChanges=[];for(var nIndex=
|
|
|
|
|
0,nCount=arrChanges.length;nIndex<nCount;++nIndex){var oReverseChange=arrChanges[nIndex].CreateReverseChange();if(oReverseChange){arrReverseChanges.push(oReverseChange);oReverseChange.SetReverted(true)}}var oLogicDocument=this.m_oLogicDocument;oLogicDocument.DrawingDocument.EndTrackTable(null,true);oLogicDocument.TurnOffCheckChartSelection();var DocState=this.private_SaveDocumentState();var mapDrawings={};for(var nIndex=0,nCount=arrReverseChanges.length;nIndex<nCount;++nIndex){var oClass=arrReverseChanges[nIndex].GetClass();
|
|
|
|
|
if(oClass&&oClass.parent&&oClass.parent instanceof AscCommonWord.ParaDrawing)mapDrawings[oClass.parent.Get_Id()]=oClass.parent;arrReverseChanges[nIndex].Load();this.m_aAllChanges.push(arrReverseChanges[nIndex])}var mapDocumentContents={};var mapParagraphs={};var mapRuns={};var mapTables={};var mapGrObjects={};var mapSlides={};var mapLayouts={};var bChangedLayout=false;var bAddSlides=false;var mapAddedSlides={};for(var nIndex=0,nCount=arrReverseChanges.length;nIndex<nCount;++nIndex){var oChange=arrReverseChanges[nIndex];
|
|
|
|
|
var oClass=oChange.GetClass();if(oClass instanceof AscCommonWord.CDocument||oClass instanceof AscCommonWord.CDocumentContent)mapDocumentContents[oClass.Get_Id()]=oClass;else if(oClass instanceof AscCommonWord.Paragraph)mapParagraphs[oClass.Get_Id()]=oClass;else if(oClass.IsParagraphContentElement&&true===oClass.IsParagraphContentElement()&&true===oChange.IsContentChange()&&oClass.GetParagraph()){mapParagraphs[oClass.GetParagraph().Get_Id()]=oClass.GetParagraph();if(oClass instanceof AscCommonWord.ParaRun)mapRuns[oClass.Get_Id()]=
|
|
|
|
|
oClass}else if(oClass instanceof AscCommonWord.ParaDrawing)mapDrawings[oClass.Get_Id()]=oClass;else if(oClass instanceof AscCommonWord.ParaRun)mapRuns[oClass.Get_Id()]=oClass;else if(oClass instanceof AscCommonWord.CTable)mapTables[oClass.Get_Id()]=oClass;else if(oClass instanceof AscFormat.CShape||oClass instanceof AscFormat.CImageShape||oClass instanceof AscFormat.CChartSpace||oClass instanceof AscFormat.CGroupShape||oClass instanceof AscFormat.CGraphicFrame)mapGrObjects[oClass.Get_Id()]=oClass;
|
|
|
|
|
else if(typeof AscCommonSlide!=="undefined")if(AscCommonSlide.Slide&&oClass instanceof AscCommonSlide.Slide)mapSlides[oClass.Get_Id()]=oClass;else if(AscCommonSlide.SlideLayout&&oClass instanceof AscCommonSlide.SlideLayout){mapLayouts[oClass.Get_Id()]=oClass;bChangedLayout=true}else if(AscCommonSlide.CPresentation&&oClass instanceof AscCommonSlide.CPresentation)if(oChange.Type===AscDFH.historyitem_Presentation_RemoveSlide||oChange.Type===AscDFH.historyitem_Presentation_AddSlide){bAddSlides=true;for(var i=
|
|
|
|
|
0;i<oChange.Items.length;++i)mapAddedSlides[oChange.Items[i].Get_Id()]=oChange.Items[i]}}var oHistory=AscCommon.History;oHistory.CreateNewPointForCollectChanges();if(bAddSlides)for(var i=oLogicDocument.Slides.length-1;i>-1;--i)if(mapAddedSlides[oLogicDocument.Slides[i].Get_Id()]&&!oLogicDocument.Slides[i].Layout)oLogicDocument.removeSlide(i);for(var sId in mapSlides)if(mapSlides.hasOwnProperty(sId))mapSlides[sId].correctContent();if(bChangedLayout)for(var i=oLogicDocument.Slides.length-1;i>-1;--i){var Layout=
|
|
|
|
|
oLogicDocument.Slides[i].Layout;if(!Layout||mapLayouts[Layout.Get_Id()])if(!oLogicDocument.Slides[i].CheckLayout())oLogicDocument.removeSlide(i)}for(var sId in mapGrObjects){var oShape=mapGrObjects[sId];if(!oShape.checkCorrect()){oShape.setBDeleted(true);if(oShape.group)oShape.group.removeFromSpTree(oShape.Get_Id());else if(AscFormat.Slide&&oShape.parent instanceof AscFormat.Slide)oShape.parent.removeFromSpTreeById(oShape.Get_Id());else if(AscCommonWord.ParaDrawing&&oShape.parent instanceof AscCommonWord.ParaDrawing)mapDrawings[oShape.parent.Get_Id()]=
|
|
|
|
|
oShape.parent}else if(oShape.resetGroups)oShape.resetGroups()}var oDrawing;for(var sId in mapDrawings)if(mapDrawings.hasOwnProperty(sId)){oDrawing=mapDrawings[sId];if(!oDrawing.CheckCorrect()){var oParentParagraph=oDrawing.Get_ParentParagraph();oDrawing.PreDelete();oDrawing.Remove_FromDocument(false);if(oParentParagraph)mapParagraphs[oParentParagraph.Get_Id()]=oParentParagraph}}for(var sId in mapRuns)if(mapRuns.hasOwnProperty(sId)){var oRun=mapRuns[sId];for(var nIndex=oRun.Content.length-1;nIndex>
|
|
|
|
|
-1;--nIndex)if(oRun.Content[nIndex]instanceof AscCommonWord.ParaDrawing)if(!oRun.Content[nIndex].CheckCorrect()){oRun.Remove_FromContent(nIndex,1,false);if(oRun.Paragraph)mapParagraphs[oRun.Paragraph.Get_Id()]=oRun.Paragraph}}for(var sId in mapTables){var oTable=mapTables[sId];for(var nCurRow=oTable.Content.length-1;nCurRow>=0;--nCurRow){var oRow=oTable.Get_Row(nCurRow);if(oRow.Get_CellsCount()<=0)oTable.private_RemoveRow(nCurRow)}if(oTable.Parent instanceof AscCommonWord.CDocument||oTable.Parent instanceof
|
|
|
|
|
AscCommonWord.CDocumentContent)mapDocumentContents[oTable.Parent.Get_Id()]=oTable.Parent}for(var sId in mapDocumentContents){var oDocumentContent=mapDocumentContents[sId];var nContentLen=oDocumentContent.Content.length;for(var nIndex=nContentLen-1;nIndex>=0;--nIndex){var oElement=oDocumentContent.Content[nIndex];if((AscCommonWord.type_Paragraph===oElement.GetType()||AscCommonWord.type_Table===oElement.GetType())&&oElement.Content.length<=0)oDocumentContent.Remove_FromContent(nIndex,1)}nContentLen=
|
|
|
|
|
oDocumentContent.Content.length;if(nContentLen<=0||AscCommonWord.type_Paragraph!==oDocumentContent.Content[nContentLen-1].GetType()){var oNewParagraph=new AscCommonWord.Paragraph(oLogicDocument.Get_DrawingDocument(),oDocumentContent,0,0,0,0,0,false);oDocumentContent.Add_ToContent(nContentLen,oNewParagraph)}}for(var sId in mapParagraphs){var oParagraph=mapParagraphs[sId];oParagraph.CheckParaEnd();oParagraph.Correct_Content(null,null,true)}var oBinaryWriter=AscCommon.History.BinaryWriter;var aSendingChanges=
|
|
|
|
|
[];for(var nIndex=0,nCount=arrReverseChanges.length;nIndex<nCount;++nIndex){var oReverseChange=arrReverseChanges[nIndex];var oChangeClass=oReverseChange.GetClass();var nBinaryPos=oBinaryWriter.GetCurPosition();oBinaryWriter.WriteString2(oChangeClass.Get_Id());oBinaryWriter.WriteLong(oReverseChange.Type);oReverseChange.WriteToBinary(oBinaryWriter);var nBinaryLen=oBinaryWriter.GetCurPosition()-nBinaryPos;var oChange=new AscCommon.CCollaborativeChanges;oChange.Set_FromUndoRedo(oChangeClass,oReverseChange,
|
|
|
|
|
{Pos:nBinaryPos,Len:nBinaryLen});aSendingChanges.push(oChange.m_pData)}var oHistoryPoint=oHistory.Points[oHistory.Points.length-1];for(var nIndex=0,nCount=oHistoryPoint.Items.length;nIndex<nCount;++nIndex){var oReverseChange=oHistoryPoint.Items[nIndex].Data;var oChangeClass=oReverseChange.GetClass();var oChange=new AscCommon.CCollaborativeChanges;oChange.Set_FromUndoRedo(oChangeClass,oReverseChange,{Pos:oHistoryPoint.Items[nIndex].Binary.Pos,Len:oHistoryPoint.Items[nIndex].Binary.Len});aSendingChanges.push(oChange.m_pData);
|
|
|
|
|
arrReverseChanges.push(oHistoryPoint.Items[nIndex].Data)}oHistory.Remove_LastPoint();this.Clear_DCChanges();editor.CoAuthoringApi.saveChanges(aSendingChanges,null,null,false,this.getCollaborativeEditing());this.private_RestoreDocumentState(DocState);oLogicDocument.TurnOnCheckChartSelection();this.private_RecalculateDocument(AscCommon.History.Get_RecalcData(null,arrReverseChanges));oLogicDocument.Document_UpdateSelectionState();oLogicDocument.Document_UpdateInterfaceState();oLogicDocument.Document_UpdateRulersState()};
|
|
|
|
|
CCollaborativeEditingBase.prototype.CanUndo=function(){return this.m_aOwnChangesIndexes.length<=0?false:true};CCollaborativeEditingBase.prototype.private_CommutateContentChanges=function(oChange,nStartPosition){var arrActions=oChange.ConvertToSimpleActions();var arrCommutateActions=[];for(var nActionIndex=arrActions.length-1;nActionIndex>=0;--nActionIndex){var oAction=arrActions[nActionIndex];var oResult=oAction;for(var nIndex=nStartPosition,nOverallCount=this.m_aAllChanges.length;nIndex<nOverallCount;++nIndex){var oTempChange=
|
|
|
|
|
this.m_aAllChanges[nIndex];if(!oTempChange)continue;if(oChange.IsRelated(oTempChange)&&true!==oTempChange.IsReverted()){var arrOtherActions=oTempChange.ConvertToSimpleActions();for(var nIndex2=0,nOtherActionsCount2=arrOtherActions.length;nIndex2<nOtherActionsCount2;++nIndex2){var oOtherAction=arrOtherActions[nIndex2];if(false===this.private_Commutate(oAction,oOtherAction)){arrOtherActions.splice(nIndex2,1);oResult=null;break}}oTempChange.ConvertFromSimpleActions(arrOtherActions)}if(!oResult)break}if(null!==
|
|
|
|
|
oResult)arrCommutateActions.push(oResult)}if(arrCommutateActions.length>0)oChange.ConvertFromSimpleActions(arrCommutateActions);else return false;return true};CCollaborativeEditingBase.prototype.private_Commutate=function(oActionL,oActionR){if(oActionL.Add)if(oActionR.Add)if(oActionL.Pos>=oActionR.Pos)oActionL.Pos++;else oActionR.Pos--;else if(oActionL.Pos>oActionR.Pos)oActionL.Pos--;else if(oActionL.Pos===oActionR.Pos)return false;else oActionR.Pos--;else if(oActionR.Add)if(oActionL.Pos>=oActionR.Pos)oActionL.Pos++;
|
|
|
|
|
else oActionR.Pos++;else if(oActionL.Pos>oActionR.Pos)oActionL.Pos--;else oActionR.Pos++;return true};CCollaborativeEditingBase.prototype.private_CommutatePropertyChanges=function(oClass,oChange,nStartPosition){if(oChange.CheckCorrect&&!oChange.CheckCorrect())return false;return true};CCollaborativeEditingBase.prototype.private_RecalculateDocument=function(oRecalcData){};function CDocumentPositionsManager(){this.m_aDocumentPositions=[];this.m_aDocumentPositionsSplit=[];this.m_aDocumentPositionsMap=
|
|
|
|
|
[]}CDocumentPositionsManager.prototype.Clear_DocumentPositions=function(){this.m_aDocumentPositions=[];this.m_aDocumentPositionsSplit=[];this.m_aDocumentPositionsMap=[]};CDocumentPositionsManager.prototype.Add_DocumentPosition=function(Position){this.m_aDocumentPositions.push(Position)};CDocumentPositionsManager.prototype.Update_DocumentPositionsOnAdd=function(Class,Pos){for(var PosIndex=0,PosCount=this.m_aDocumentPositions.length;PosIndex<PosCount;++PosIndex){var DocPos=this.m_aDocumentPositions[PosIndex];
|
|
|
|
|
for(var ClassPos=0,ClassLen=DocPos.length;ClassPos<ClassLen;++ClassPos){var _Pos=DocPos[ClassPos];if(Class===_Pos.Class&&undefined!==_Pos.Position&&(_Pos.Position>Pos||_Pos.Position===Pos&&!(Class instanceof AscCommonWord.ParaRun))){_Pos.Position++;break}}}};CDocumentPositionsManager.prototype.Update_DocumentPositionsOnRemove=function(Class,Pos,Count){for(var PosIndex=0,PosCount=this.m_aDocumentPositions.length;PosIndex<PosCount;++PosIndex){var DocPos=this.m_aDocumentPositions[PosIndex];for(var ClassPos=
|
|
|
|
|
0,ClassLen=DocPos.length;ClassPos<ClassLen;++ClassPos){var _Pos=DocPos[ClassPos];if(Class===_Pos.Class&&undefined!==_Pos.Position){if(_Pos.Position>Pos+Count)_Pos.Position-=Count;else if(_Pos.Position>=Pos){_Pos.Position=Pos;_Pos.Deleted=true}break}}}};CDocumentPositionsManager.prototype.OnStart_SplitRun=function(SplitRun,SplitPos){this.m_aDocumentPositionsSplit=[];for(var PosIndex=0,PosCount=this.m_aDocumentPositions.length;PosIndex<PosCount;++PosIndex){var DocPos=this.m_aDocumentPositions[PosIndex];
|
|
|
|
|
for(var ClassPos=0,ClassLen=DocPos.length;ClassPos<ClassLen;++ClassPos){var _Pos=DocPos[ClassPos];if(SplitRun===_Pos.Class&&_Pos.Position&&_Pos.Position>=SplitPos)this.m_aDocumentPositionsSplit.push({DocPos:DocPos,NewRunPos:_Pos.Position-SplitPos})}}};CDocumentPositionsManager.prototype.OnEnd_SplitRun=function(NewRun){if(!NewRun)return;for(var PosIndex=0,PosCount=this.m_aDocumentPositionsSplit.length;PosIndex<PosCount;++PosIndex){var NewDocPos=[];NewDocPos.push({Class:NewRun,Position:this.m_aDocumentPositionsSplit[PosIndex].NewRunPos});
|
|
|
|
|
this.m_aDocumentPositions.push(NewDocPos);this.m_aDocumentPositionsMap.push({StartPos:this.m_aDocumentPositionsSplit[PosIndex].DocPos,EndPos:NewDocPos})}};CDocumentPositionsManager.prototype.Update_DocumentPosition=function(DocPos){var NewDocPos=DocPos;for(var PosIndex=0,PosCount=this.m_aDocumentPositionsMap.length;PosIndex<PosCount;++PosIndex)if(this.m_aDocumentPositionsMap[PosIndex].StartPos===NewDocPos)NewDocPos=this.m_aDocumentPositionsMap[PosIndex].EndPos;if(NewDocPos!==DocPos&&NewDocPos.length===
|
|
|
|
|
1&&NewDocPos[0].Class instanceof AscCommonWord.ParaRun){var Run=NewDocPos[0].Class;var Para=Run.GetParagraph();if(AscCommonWord.CanUpdatePosition(Para,Run)){DocPos.length=0;Run.GetDocumentPositionFromObject(DocPos);DocPos.push({Class:Run,Position:NewDocPos[0].Position})}}else if(DocPos.length>0&&DocPos[DocPos.length-1].Class instanceof AscCommonWord.ParaRun){var Run=DocPos[DocPos.length-1].Class;var RunPos=DocPos[DocPos.length-1].Position;var Para=Run.GetParagraph();if(AscCommonWord.CanUpdatePosition(Para,
|
|
|
|
|
Run)){DocPos.length=0;Run.GetDocumentPositionFromObject(DocPos);DocPos.push({Class:Run,Position:RunPos})}}};CDocumentPositionsManager.prototype.Remove_DocumentPosition=function(DocPos){for(var Pos=0,Count=this.m_aDocumentPositions.length;Pos<Count;++Pos)if(this.m_aDocumentPositions[Pos]===DocPos){this.m_aDocumentPositions.splice(Pos,1);return}};window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].FOREIGN_CURSOR_LABEL_HIDETIME=FOREIGN_CURSOR_LABEL_HIDETIME;window["AscCommon"].CCollaborativeChanges=
|
|
|
|
|
CCollaborativeChanges;window["AscCommon"].CCollaborativeEditingBase=CCollaborativeEditingBase;window["AscCommon"].CDocumentPositionsManager=CDocumentPositionsManager})(window);"use strict";(function(window,undefined){var g_dKoef_mm_to_pix=AscCommon.g_dKoef_mm_to_pix;function CBounds(){this.L=0;this.T=0;this.R=0;this.B=0;this.isAbsL=false;this.isAbsT=false;this.isAbsR=false;this.isAbsB=false;this.AbsW=-1;this.AbsH=-1;this.SetParams=function(_l,_t,_r,_b,abs_l,abs_t,abs_r,abs_b,absW,absH){this.L=_l;
|
|
|
|
|
this.T=_t;this.R=_r;this.B=_b;this.isAbsL=abs_l;this.isAbsT=abs_t;this.isAbsR=abs_r;this.isAbsB=abs_b;this.AbsW=absW;this.AbsH=absH}}function CAbsolutePosition(){this.L=0;this.T=0;this.R=0;this.B=0}var g_anchor_left=1;var g_anchor_top=2;var g_anchor_right=4;var g_anchor_bottom=8;function CControl(){this.Bounds=new CBounds;this.Anchor=g_anchor_left|g_anchor_top;this.Name=null;this.Parent=null;this.TabIndex=null;this.HtmlElement=null;this.AbsolutePosition=new CBounds;this.Resize=function(_width,_height,
|
|
|
|
|
api){if(null==this.Parent||null==this.HtmlElement)return;var _x=0;var _y=0;var _r=0;var _b=0;var hor_anchor=this.Anchor&5;var ver_anchor=this.Anchor&10;if(g_anchor_left==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(-1!=this.Bounds.AbsW)_r=_x+this.Bounds.AbsW;else if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else if(g_anchor_right==hor_anchor){if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3;if(-1!=
|
|
|
|
|
this.Bounds.AbsW)_x=_r-this.Bounds.AbsW;else if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3}else if((g_anchor_left|g_anchor_right)==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else{_x=this.Bounds.L;_r=this.Bounds.R}if(g_anchor_top==ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(-1!=this.Bounds.AbsH)_b=_y+this.Bounds.AbsH;
|
|
|
|
|
else if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3}else if(g_anchor_bottom==ver_anchor){if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3;if(-1!=this.Bounds.AbsH)_y=_b-this.Bounds.AbsH;else if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3}else if((g_anchor_top|g_anchor_bottom)==ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;
|
|
|
|
|
else _b=this.Bounds.B*_height/1E3}else{_y=this.Bounds.T;_b=this.Bounds.B}if(_r<_x)_r=_x;if(_b<_y)_b=_y;this.AbsolutePosition.L=_x;this.AbsolutePosition.T=_y;this.AbsolutePosition.R=_r;this.AbsolutePosition.B=_b;this.HtmlElement.style.left=(_x*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.top=(_y*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.width=((_r-_x)*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.height=((_b-_y)*g_dKoef_mm_to_pix+.5>>0)+"px";if(api!==undefined&&api.CheckRetinaElement&&
|
|
|
|
|
api.CheckRetinaElement(this.HtmlElement)){var _W=(_r-_x)*g_dKoef_mm_to_pix+.5>>0;var _H=(_b-_y)*g_dKoef_mm_to_pix+.5>>0;this.HtmlElement.width=AscCommon.AscBrowser.convertToRetinaValue(_W,true);this.HtmlElement.height=AscCommon.AscBrowser.convertToRetinaValue(_H,true)}else{this.HtmlElement.width=(_r-_x)*g_dKoef_mm_to_pix+.5>>0;this.HtmlElement.height=(_b-_y)*g_dKoef_mm_to_pix+.5>>0}};this.GetCSS_width=function(){return(this.AbsolutePosition.R-this.AbsolutePosition.L)*g_dKoef_mm_to_pix+.5>>0};this.GetCSS_height=
|
|
|
|
|
function(){return(this.AbsolutePosition.B-this.AbsolutePosition.T)*g_dKoef_mm_to_pix+.5>>0}}function CControlContainer(){this.Bounds=new CBounds;this.Anchor=g_anchor_left|g_anchor_top;this.Name=null;this.Parent=null;this.TabIndex=null;this.HtmlElement=null;this.AbsolutePosition=new CBounds;this.Controls=[];this.AddControl=function(ctrl){ctrl.Parent=this;this.Controls[this.Controls.length]=ctrl};this.Resize=function(_width,_height,api){if(null==this.Parent){this.AbsolutePosition.L=0;this.AbsolutePosition.T=
|
|
|
|
|
0;this.AbsolutePosition.R=_width;this.AbsolutePosition.B=_height;if(null!=this.HtmlElement){var lCount=this.Controls.length;for(var i=0;i<lCount;i++)this.Controls[i].Resize(_width,_height,api)}return}var _x=0;var _y=0;var _r=0;var _b=0;var hor_anchor=this.Anchor&5;var ver_anchor=this.Anchor&10;if(g_anchor_left==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(-1!=this.Bounds.AbsW)_r=_x+this.Bounds.AbsW;else if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=
|
|
|
|
|
this.Bounds.R*_width/1E3}else if(g_anchor_right==hor_anchor){if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3;if(-1!=this.Bounds.AbsW)_x=_r-this.Bounds.AbsW;else if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3}else if((g_anchor_left|g_anchor_right)==hor_anchor){if(this.Bounds.isAbsL)_x=this.Bounds.L;else _x=this.Bounds.L*_width/1E3;if(this.Bounds.isAbsR)_r=_width-this.Bounds.R;else _r=this.Bounds.R*_width/1E3}else{_x=this.Bounds.L;_r=this.Bounds.R}if(g_anchor_top==
|
|
|
|
|
ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(-1!=this.Bounds.AbsH)_b=_y+this.Bounds.AbsH;else if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3}else if(g_anchor_bottom==ver_anchor){if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3;if(-1!=this.Bounds.AbsH)_y=_b-this.Bounds.AbsH;else if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3}else if((g_anchor_top|g_anchor_bottom)==
|
|
|
|
|
ver_anchor){if(this.Bounds.isAbsT)_y=this.Bounds.T;else _y=this.Bounds.T*_height/1E3;if(this.Bounds.isAbsB)_b=_height-this.Bounds.B;else _b=this.Bounds.B*_height/1E3}else{_y=this.Bounds.T;_b=this.Bounds.B}if(_r<_x)_r=_x;if(_b<_y)_b=_y;this.AbsolutePosition.L=_x;this.AbsolutePosition.T=_y;this.AbsolutePosition.R=_r;this.AbsolutePosition.B=_b;this.HtmlElement.style.left=(_x*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.top=(_y*g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.width=((_r-_x)*
|
|
|
|
|
g_dKoef_mm_to_pix+.5>>0)+"px";this.HtmlElement.style.height=((_b-_y)*g_dKoef_mm_to_pix+.5>>0)+"px";var lCount=this.Controls.length;for(var i=0;i<lCount;i++)this.Controls[i].Resize(_r-_x,_b-_y,api)};this.GetCSS_width=function(){return(this.AbsolutePosition.R-this.AbsolutePosition.L)*g_dKoef_mm_to_pix+.5>>0};this.GetCSS_height=function(){return(this.AbsolutePosition.B-this.AbsolutePosition.T)*g_dKoef_mm_to_pix+.5>>0}}function CreateControlContainer(name){var ctrl=new CControlContainer;ctrl.Name=name;
|
|
|
|
|
ctrl.HtmlElement=document.getElementById(name);return ctrl}function CreateControl(name){var ctrl=new CControl;ctrl.Name=name;ctrl.HtmlElement=document.getElementById(name);return ctrl}window["AscCommon"]=window["AscCommon"]||{};window["AscCommon"].g_anchor_left=g_anchor_left;window["AscCommon"].g_anchor_top=g_anchor_top;window["AscCommon"].g_anchor_right=g_anchor_right;window["AscCommon"].g_anchor_bottom=g_anchor_bottom;window["AscCommon"].CreateControlContainer=CreateControlContainer;window["AscCommon"].CreateControl=
|
|
|
|
|
CreateControl})(window);"use strict";(function(window,undefined){var AscBrowser=AscCommon.AscBrowser;var TRACK_CIRCLE_RADIUS=5;var TRACK_RECT_SIZE2=4;var TRACK_RECT_SIZE=8;var TRACK_RECT_SIZE_CT=6;var TRACK_DISTANCE_ROTATE=25;var TRACK_DISTANCE_ROTATE2=25;var TRACK_ADJUSTMENT_SIZE=10;var TRACK_WRAPPOINTS_SIZE=6;var IMAGE_ROTATE_TRACK_W=21;var bIsUseImageRotateTrack=true;if(bIsUseImageRotateTrack){window.g_track_rotate_marker=new Image;window.g_track_rotate_marker;window.g_track_rotate_marker.asc_complete=
|
|
|
|
|
false;window.g_track_rotate_marker.onload=function(){window.g_track_rotate_marker.asc_complete=true};window.g_track_rotate_marker.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABUAAAAVCAMAAACeyVWkAAAAVFBMVEUAAAD///////////////////////////////////////////////////////98fHy2trb09PTT09OysrKqqqqJiYng4ODr6+uamprGxsbi4uKGhoYjgM0eAAAADnRSTlMAy00k7/z0jbeuMzDljsugwZgAAACpSURBVBjTdZHbEoMgDESDAl6bgIqX9v//s67UYpm6D0xyYMImoaiuUr3pVdVRUtnwqaY8YaE5SRcfaPgqc+DSIh7WIGGaEVoUqRGN4oZlcDIiqYlaPjQz5CNu6cFJwLiuSO3nlLBDrKhn3l4rcnH4NcAdGd5EZMfCsoMFBxM6CD57G+u6vC48PMVnHtrYhP/x+7+3cw7zdJnD3cyA7QXa4nYXaW+a9Xdvb6zqE5Jb7LmzAAAAAElFTkSuQmCC";
|
|
|
|
|
window.g_track_rotate_marker2=new Image;window.g_track_rotate_marker2;window.g_track_rotate_marker2.asc_complete=false;window.g_track_rotate_marker2.onload=function(){window.g_track_rotate_marker2.asc_complete=true};window.g_track_rotate_marker2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAMAAAC7IEhfAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////////////+Tk5Obm5v8/PzAwMD5+fmWlpbt7e3k5OSfn5/z8/PLy8vn5+fExMSsrKyqqqrf39+vr6+9vb2urq7c3NxSmuRpAAAAE3RSTlMA+u2XA+PTrId4WBwTN7EKtLY4iqQP6AAAAWhJREFUOMudVe2SgjAMLN+goN51CxTLp3r3/m943BAqIJTR/RU6O02yTRY2g5tEgW9blu0HUeKyLRxDj0/ghcdVWuxYfAHLiV95B5uvwD4saK7DN+DMSj1f+CYu58l9J27A6XnnJG9R3ZWU6l4Vk+y6D310baHRXvUxdRSP/aYZILJbmebFLRNAlo69x7PEeQdZ5Xz8qiS6fJr8aOnEquATFApdSsr/v1HINUo+Q6nwoDDspfH4JmoJ6shzWcINaNBSlLCI6uvLfyXmAlR2xIKBB/A1ZKiGIGA+8QCtphBawRt+hsBnNvE0M0OPZmwcijRnFvE0U6CuIcbrIUlJRnJL9L0YifTQCgU3p/aH4I7fnWaCIajwMMszCl5A7Aj+TWctGuMT6qG4QtbGodBj9oAyjpke3LSDYXCXq9A8V6GZrsLGcqXlcrneW9elAQgpxdwA3rcUdv4ymdQHtrdvpPvW/LHZ7/8+/gBTWGFPbAkGiAAAAABJRU5ErkJggg==";
|
|
|
|
|
TRACK_DISTANCE_ROTATE2=18}function COverlay(){this.m_oControl=null;this.m_oContext=null;this.min_x=65535;this.min_y=65535;this.max_x=-65535;this.max_y=-65535;this.m_bIsShow=false;this.m_bIsAlwaysUpdateOverlay=false;this.m_oHtmlPage=null;this.DashLineColor="#000000";this.ClearAll=false;this.IsRetina=false;this.IsCellEditor=false}COverlay.prototype={init:function(context,controlName,x,y,w_pix,h_pix,w_mm,h_mm){this.m_oContext=context;this.m_oControl=AscCommon.CreateControl(controlName);this.m_oHtmlPage=
|
|
|
|
|
new AscCommon.CHtmlPage;this.m_oHtmlPage.init(x,y,w_pix,h_pix,w_mm,h_mm)},Clear:function(){if(null==this.m_oContext){this.m_oContext=this.m_oControl.HtmlElement.getContext("2d");this.m_oContext.imageSmoothingEnabled=false;this.m_oContext.mozImageSmoothingEnabled=false;this.m_oContext.oImageSmoothingEnabled=false;this.m_oContext.webkitImageSmoothingEnabled=false}this.SetBaseTransform();this.m_oContext.beginPath();if(this.max_x!=-65535&&this.max_y!=-65535)if(this.ClearAll===true){this.m_oContext.clearRect(0,
|
|
|
|
|