From 14001a3de5566e7fb0a325885d0380ab2608693f Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Thu, 16 Jan 2025 16:36:46 +0700 Subject: [PATCH] For bug #72500 --- pdf/src/CollaborativeEditing.js | 5 ++++- pdf/src/GraphicObjects.js | 2 +- pdf/src/document.js | 34 ++++++++++++++++++++++++++++++--- pdf/src/drawings/shape.js | 5 ----- pdf/src/viewer.js | 6 ++++++ 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/pdf/src/CollaborativeEditing.js b/pdf/src/CollaborativeEditing.js index b9d7757cbe..3ed5568ba0 100644 --- a/pdf/src/CollaborativeEditing.js +++ b/pdf/src/CollaborativeEditing.js @@ -327,9 +327,12 @@ CPDFCollaborativeEditing.prototype.Release_Locks = function() { } }; CPDFCollaborativeEditing.prototype._PreUndo = function() { - return null; + return this.private_SaveDocumentState() }; CPDFCollaborativeEditing.prototype._PostUndo = function(state, changes) { + let logicDocument = this.m_oLogicDocument; + this.private_RestoreDocumentState(state); + logicDocument.History.Get_RecalcData(null, changes) }; //--------------------------------------------------------export---------------------------------------------------- diff --git a/pdf/src/GraphicObjects.js b/pdf/src/GraphicObjects.js index 21507f7f0c..9394f8470e 100644 --- a/pdf/src/GraphicObjects.js +++ b/pdf/src/GraphicObjects.js @@ -1354,7 +1354,6 @@ return bRet; }; - CGraphicObjects.prototype.loadDocumentStateAfterLoadChanges = function() {}; CGraphicObjects.prototype.saveDocumentState = function(){}; CGraphicObjects.prototype.getAllRasterImagesOnPage = function(pageIndex) { @@ -1396,6 +1395,7 @@ CGraphicObjects.prototype.getDrawingsPasteShift = AscFormat.DrawingObjectsController.prototype.getDrawingsPasteShift; CGraphicObjects.prototype.removeCallback = AscFormat.DrawingObjectsController.prototype.removeCallback; CGraphicObjects.prototype.getAllSingularDrawings = AscFormat.DrawingObjectsController.prototype.getAllSingularDrawings; + CGraphicObjects.prototype.loadDocumentStateAfterLoadChanges = AscFormat.DrawingObjectsController.prototype.loadDocumentStateAfterLoadChanges; CGraphicObjects.prototype.startRecalculate = function() {}; diff --git a/pdf/src/document.js b/pdf/src/document.js index 6d1edde57d..3d5dea58ae 100644 --- a/pdf/src/document.js +++ b/pdf/src/document.js @@ -5628,8 +5628,30 @@ var CPresentation = CPresentation || function(){}; CPDFDoc.prototype.PauseRecalculate = function() {}; CPDFDoc.prototype.EndPreview_MailMergeResult = function() {}; CPDFDoc.prototype.Get_SelectionState2 = function() {}; - CPDFDoc.prototype.Save_DocumentStateBeforeLoadChanges = function() {}; - CPDFDoc.prototype.Load_DocumentStateAfterLoadChanges = function() {}; + CPDFDoc.prototype.Save_DocumentStateBeforeLoadChanges = function() { + let State = {}; + + State.activeObject = this.GetActiveObject(); + + State.Pos = []; + State.StartPos = []; + State.EndPos = []; + + this.GetController().Save_DocumentStateBeforeLoadChanges(State); + this.RemoveSelection(); + + this.CollaborativeEditing.WatchDocumentPositionsByState(State); + + return State; + }; + CPDFDoc.prototype.Load_DocumentStateAfterLoadChanges = function(State) { + this.CollaborativeEditing.UpdateDocumentPositionsByState(State); + + this.RemoveSelection(); + this.SetMouseDownObject(State.activeObject) + + this.GetController().Load_DocumentStateAfterLoadChanges(State); + }; CPDFDoc.prototype.Check_MergeData = function() {}; CPDFDoc.prototype.Set_SelectionState2 = function() {}; CPDFDoc.prototype.ResumeRecalculate = function() {}; @@ -6129,7 +6151,13 @@ var CPresentation = CPresentation || function(){}; CPDFDoc.prototype.Document_UpdateUndoRedoState = function() { this.UpdateUndoRedo(); }; - CPDFDoc.prototype.RecalculateCurPos = function() {}; + CPDFDoc.prototype.RecalculateCurPos = function() { + let oAcitveObj = this.GetActiveObject(); + let oContent = oAcitveObj ? oAcitveObj.GetDocContent() : null; + if (oContent) { + oContent.RecalculateCurPos(); + } + }; CPDFDoc.prototype.HaveRevisionChanges = function() {}; CPDFDoc.prototype.ContinueSpellCheck = function() {}; CPDFDoc.prototype.ContinueTrackRevisions = function() {}; diff --git a/pdf/src/drawings/shape.js b/pdf/src/drawings/shape.js index 7189bb3a00..b28a3e887b 100644 --- a/pdf/src/drawings/shape.js +++ b/pdf/src/drawings/shape.js @@ -86,11 +86,6 @@ if (this.IsNeedRecalc() == false) return; - let oContent = this.GetDocContent(); - if (oContent) { - oContent.RecalculateCurPos(); - } - this.recalculateTransform(); this.updateTransformMatrix(); this.recalculate(); diff --git a/pdf/src/viewer.js b/pdf/src/viewer.js index 5731f56e9d..5fa39ade12 100644 --- a/pdf/src/viewer.js +++ b/pdf/src/viewer.js @@ -127,6 +127,12 @@ AscFormat.InitClass(CPageInfo, AscFormat.CBaseNoIdObject, AscDFH.historyitem_type_Pdf_Page); CPageInfo.prototype.constructor = CPageInfo; + Object.defineProperty(CPageInfo.prototype, "PageNum", { + get: function () { + return this.GetIndex(); + } + }); + CPageInfo.prototype.RedrawDrawings = function() { let oViewer = Asc.editor.getDocumentRenderer(); let _t = this;