From d5ba42c5ab5bc6814c3680e0e8699fe08a060bf4 Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Tue, 17 Oct 2023 17:14:26 +0800 Subject: [PATCH] Fix bug #64668 --- pdf/src/document.js | 28 +++++++++++++++++++++++++++- pdf/src/forms/combobox.js | 2 ++ pdf/src/forms/listbox.js | 8 +++++++- pdf/src/viewer.js | 8 +++----- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/pdf/src/document.js b/pdf/src/document.js index 107ad3d7f0..c44d0e737e 100644 --- a/pdf/src/document.js +++ b/pdf/src/document.js @@ -1120,6 +1120,7 @@ var CPresentation = CPresentation || function(){}; CPDFDoc.prototype.DoUndo = function() { let oViewer = editor.getDocumentRenderer(); + this.TurnOffHistory(); if (AscCommon.History.Can_Undo()) { this.currInkInDrawingProcess = null; @@ -1176,6 +1177,7 @@ var CPresentation = CPresentation || function(){}; CPDFDoc.prototype.DoRedo = function() { let oViewer = editor.getDocumentRenderer(); + this.TurnOffHistory(); if (AscCommon.History.Can_Redo()) { this.currInkInDrawingProcess = null; @@ -1301,7 +1303,31 @@ var CPresentation = CPresentation || function(){}; CPDFDoc.prototype.GetActionsQueue = function() { return this.actionsInfo; }; - + + CPDFDoc.prototype.EscapeForm = function() { + let oViewer = editor.getDocumentRenderer(); + + if (this.activeForm && this.activeForm.IsNeedDrawHighlight() == false) { + if (this.activeForm.GetType() == AscPDF.FIELD_TYPES.listbox) { + this.activeForm.UndoNotAppliedChanges(); + } + else if (this.History.Index != -1) { + let oHistoryPoint = this.History.Points[this.History.Index]; + if (oHistoryPoint.Additional.FormFilling == this.activeForm && oHistoryPoint.Additional.CanUnion != false) { + this.activeForm.UndoNotAppliedChanges(); + } + } + + if (this.activeForm.IsChanged() == false) + this.activeForm.SetDrawFromStream(true); + + this.activeForm.AddToRedraw(); + this.activeForm.SetDrawHighlight(true); + oViewer.Api.WordControl.m_oDrawingDocument.TargetEnd(); + oViewer._paint(); + } + }; + /** * Adds a new page to the active document. * @memberof CPDFDoc diff --git a/pdf/src/forms/combobox.js b/pdf/src/forms/combobox.js index 0ff8b60eb2..f6cb65d220 100644 --- a/pdf/src/forms/combobox.js +++ b/pdf/src/forms/combobox.js @@ -636,6 +636,8 @@ CComboBoxField.prototype.CalcDocPos = AscPDF.CTextField.prototype.CalcDocPos; CComboBoxField.prototype.GetCalcOrderIndex = AscPDF.CTextField.prototype.GetCalcOrderIndex; CComboBoxField.prototype.SetCalcOrderIndex = AscPDF.CTextField.prototype.SetCalcOrderIndex; + CComboBoxField.prototype.UndoNotAppliedChanges = AscPDF.CTextField.prototype.UndoNotAppliedChanges; + CComboBoxField.prototype.UnionLastHistoryPoints = AscPDF.CTextField.prototype.UnionLastHistoryPoints; window["AscPDF"].CComboBoxField = CComboBoxField; })(); diff --git a/pdf/src/forms/listbox.js b/pdf/src/forms/listbox.js index 88f1612045..07bcc65b81 100644 --- a/pdf/src/forms/listbox.js +++ b/pdf/src/forms/listbox.js @@ -779,7 +779,13 @@ } } }; - + CListBoxField.prototype.UndoNotAppliedChanges = function() { + this.SetValue(this.GetApiValue()); + this.SetNeedRecalc(true); + this.AddToRedraw(); + this.SetNeedCommit(false); + }; + function TurnOffHistory() { if (AscCommon.History.IsOn() == true) AscCommon.History.TurnOff(); diff --git a/pdf/src/viewer.js b/pdf/src/viewer.js index d6fff6267c..f28d485dd4 100644 --- a/pdf/src/viewer.js +++ b/pdf/src/viewer.js @@ -2993,11 +2993,9 @@ { this.Api.sync_MarkerFormatCallback(false); } - else if (oDoc.activeForm) - { - // to do отмена ввода - } - + + oDoc.EscapeForm(); + editor.sync_HideComment(); } else if (e.KeyCode === 32) // Space