From 048f203862b6da611a93654770489f2f6fb857af Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Mon, 30 Sep 2024 13:04:50 +0700 Subject: [PATCH 1/7] Fix bug #70530 --- pdf/src/document.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pdf/src/document.js b/pdf/src/document.js index 918708927f..ff65fa6ee5 100644 --- a/pdf/src/document.js +++ b/pdf/src/document.js @@ -4213,6 +4213,7 @@ var CPresentation = CPresentation || function(){}; return; } + Asc.editor.canSave = false; this.StartAction(AscDFH.historydescription_Pdf_EditPage); let oDrDoc = this.GetDrawingDocument(); @@ -4306,6 +4307,7 @@ var CPresentation = CPresentation || function(){}; _t.Viewer.paint(function() { _t.Viewer.thumbnails._repaintPage(nPage); }); + Asc.editor.canSave = true; }; if(aUrls.length > 0) { AscCommon.sendImgUrls(Asc.editor, aUrls, function (data) { From 0e1b71896b2cc2a73bb9702d1fc898e670bf7b7f Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Mon, 30 Sep 2024 15:09:48 +0700 Subject: [PATCH 2/7] Fix bug #70560 --- common/Drawings/Format/Image.js | 2 +- pdf/src/history/documentChanges.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/Drawings/Format/Image.js b/common/Drawings/Format/Image.js index 05d0e5a524..d2eb020eed 100644 --- a/common/Drawings/Format/Image.js +++ b/common/Drawings/Format/Image.js @@ -495,7 +495,7 @@ CImageShape.prototype.recalculateGeometry = function () { this.calcGeometry = null; - if (isRealObject(this.spPr.geometry)) { + if (isRealObject(this.spPr && this.spPr.geometry)) { this.calcGeometry = this.spPr.geometry; } else { var hierarchy = this.getHierarchy(); diff --git a/pdf/src/history/documentChanges.js b/pdf/src/history/documentChanges.js index 59c43c3d4a..039950b744 100644 --- a/pdf/src/history/documentChanges.js +++ b/pdf/src/history/documentChanges.js @@ -814,7 +814,9 @@ CChangesPDFDocumentRecognizePage.prototype.private_SetValue = function(bRecogniz let nPage = this.Page; oFile.pages[nPage].isConvertedToShapes = bRecognize; - delete oDoc.Viewer.drawingPages[nPage].Image; + if (oDoc.Viewer.drawingPages[nPage]) { + delete oDoc.Viewer.drawingPages[nPage].Image; + } oDoc.Viewer.paint(function() { oDoc.Viewer.thumbnails._repaintPage(nPage); From 6c53444af7d79bb33d2e75271dac3cc4226e99c2 Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Mon, 30 Sep 2024 16:07:13 +0700 Subject: [PATCH 3/7] Fix bug #70553 --- pdf/src/document.js | 3 ++- pdf/src/viewer.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pdf/src/document.js b/pdf/src/document.js index ff65fa6ee5..f29be0593c 100644 --- a/pdf/src/document.js +++ b/pdf/src/document.js @@ -2331,7 +2331,8 @@ var CPresentation = CPresentation || function(){}; } }); - oViewer.resize(); + oViewer.resize(true); + oViewer.paint(); }; /** * Adds an interactive field to document. diff --git a/pdf/src/viewer.js b/pdf/src/viewer.js index 26b979ac64..08e358b54d 100644 --- a/pdf/src/viewer.js +++ b/pdf/src/viewer.js @@ -763,7 +763,7 @@ _t.startTimer(); } - if (_t.isStarted && _t.pageDetector && _t.IsOpenFormsInProgress == false) { + if (_t.isStarted && _t.pageDetector && !oDoc.fontLoader.isWorking() && _t.IsOpenFormsInProgress == false) { _t.sendEvent("onFileOpened"); _t.sendEvent("onPagesCount", _t.file.pages.length); @@ -4299,7 +4299,7 @@ if (this.scrollY >= this.scrollMaxY) this.scrollY = this.scrollMaxY; - if (this.zoomCoordinate && this.isDocumentContentReady) + if (this.zoomCoordinate && this.isDocumentContentReady && Asc.editor.isDocumentLoadComplete) { var newPoint = this.ConvertCoordsToCursor(this.zoomCoordinate.x, this.zoomCoordinate.y, this.zoomCoordinate.index); // oldsize используется чтобы при смене ориентации экрана был небольшой скролл From c66286305526123dd2f8eda6f9efb2cab8e2a944 Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Mon, 30 Sep 2024 17:02:31 +0700 Subject: [PATCH 4/7] [pdf] Fixed check forms align --- pdf/src/forms/combobox.js | 10 ++++++++-- pdf/src/forms/text.js | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/pdf/src/forms/combobox.js b/pdf/src/forms/combobox.js index cf4abe2c4c..a1118a657d 100644 --- a/pdf/src/forms/combobox.js +++ b/pdf/src/forms/combobox.js @@ -82,6 +82,10 @@ if (this.IsNeedRecalc() == false) return; + if (this.IsNeedCheckAlign()) { + this.CheckAlignInternal(); + } + if (this.GetTextSize() == 0) { if (null == this.getFormRelRect()) { this.CalculateContentClipRect(); @@ -324,7 +328,7 @@ this.content.MoveCursorToStartPos(); if (!Asc.editor.getDocumentRenderer().IsOpenFormsInProgress) - this.CheckAlignInternal(); + this.SetNeedCheckAlign(true); }; CComboBoxField.prototype.SetCurIdxs = function(aIdxs) { if (this.IsWidget()) { @@ -515,7 +519,7 @@ // когда выравнивание посередине или справа, то после того // как ширина контента будет больше чем размер формы, выравнивание становится слева, пока текста вновь не станет меньше чем размер формы aFields.forEach(function(field) { - field.CheckAlignInternal(); + field.SetNeedCheckAlign(true); }); this.SetNeedCommit(false); @@ -784,6 +788,8 @@ CComboBoxField.prototype.onMouseUp = AscPDF.CTextField.prototype.onMouseUp; CComboBoxField.prototype.OnContentChange = AscPDF.CTextField.prototype.OnContentChange; CComboBoxField.prototype.UpdateSelectionByEvent = AscPDF.CTextField.prototype.UpdateSelectionByEvent; + CComboBoxField.prototype.SetNeedCheckAlign = AscPDF.CTextField.prototype.SetNeedCheckAlign; + CComboBoxField.prototype.IsNeedCheckAlign = AscPDF.CTextField.prototype.IsNeedCheckAlign; window["AscPDF"].CComboBoxField = CComboBoxField; })(); diff --git a/pdf/src/forms/text.js b/pdf/src/forms/text.js index 027d809a47..d5e6881e6b 100644 --- a/pdf/src/forms/text.js +++ b/pdf/src/forms/text.js @@ -530,6 +530,10 @@ if (this.IsNeedRecalc() == false) return; + if (this.IsNeedCheckAlign()) { + this.CheckAlignInternal(); + } + this.RecalcMeasureContent(); if (this.GetTextSize() == 0) { @@ -1015,6 +1019,8 @@ return true; }; CTextField.prototype.CheckAlignInternal = function() { + this.SetNeedCheckAlign(false); + // если выравнивание по центру или справа, то оно должно переключаться на left если ширина контента выходит за пределы формы // вызывается на момент коммита формы if ([AscPDF.ALIGN_TYPE.center, AscPDF.ALIGN_TYPE.right].includes(this.GetAlign())) { @@ -1022,26 +1028,28 @@ if (this.IsTextOutOfForm(this.content).hor) { if (this.content.GetAlign() != AscPDF.ALIGN_TYPE.left) { this.content.SetAlign(AscPDF.ALIGN_TYPE.left); - this.SetNeedRecalc(true); } } else if (this.content.GetAlign() != this.GetAlign()) { this.content.SetAlign(this.GetAlign()); - this.SetNeedRecalc(true); } if (this.IsTextOutOfForm(this.contentFormat).hor) { if (this.contentFormat.GetAlign() != AscPDF.ALIGN_TYPE.left) { this.contentFormat.SetAlign(AscPDF.ALIGN_TYPE.left); - this.SetNeedRecalc(true); } } else if (this.contentFormat.GetAlign() != this.GetAlign()) { this.contentFormat.SetAlign(this.GetAlign()); - this.SetNeedRecalc(true); } } }; + CTextField.prototype.SetNeedCheckAlign = function(bCheck) { + this._needCheckAlign = bCheck; + }; + CTextField.prototype.IsNeedCheckAlign = function() { + return this._needCheckAlign; + }; CTextField.prototype.InsertChars = function(aChars) { this.content.EnterText(aChars); }; @@ -1158,7 +1166,7 @@ // когда выравнивание посередине или справа, то после того // как ширина контента будет больше чем размер формы, выравнивание становится слева, пока текста вновь не станет меньше чем размер формы aFields.forEach(function(field) { - field.CheckAlignInternal(); + field.SetNeedCheckAlign(true); }); this.SetNeedCommit(false); From 53fb442eb985df1083cb10cd4a695693817d04de Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Mon, 30 Sep 2024 19:21:00 +0700 Subject: [PATCH 5/7] Fix bug #70416 --- pdf/src/document.js | 6 +++++- pdf/src/viewer.js | 38 ++++++++++++++++++++++++++++---------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/pdf/src/document.js b/pdf/src/document.js index f29be0593c..b9e402caa3 100644 --- a/pdf/src/document.js +++ b/pdf/src/document.js @@ -230,7 +230,11 @@ var CPresentation = CPresentation || function(){}; let oFile = this.Viewer.file; for (let i = 0; i < oFile.pages.length; i++) { - let oPage = this.Viewer.drawingPages[i]; + let oPage = this.Viewer.drawingPages[i]; + if (!oPage) { + continue; + } + let nAngle = this.Viewer.getPageRotate(i); let oPageTr = new AscCommon.CMatrix(); diff --git a/pdf/src/viewer.js b/pdf/src/viewer.js index 08e358b54d..1388501782 100644 --- a/pdf/src/viewer.js +++ b/pdf/src/viewer.js @@ -2713,6 +2713,8 @@ oDrDoc.m_lDrawingEnd = lEndPage; this.startVisiblePage = lStartPage; this.endVisiblePage = lEndPage; + + this.updatePageDetector(); }; this._paint = function() { @@ -2752,8 +2754,6 @@ ctx.strokeStyle = AscCommon.GlobalSkin.PageOutline; ctx.lineWidth = lineW; - this.pageDetector = new CCurrentPageDetector(this.canvas.width, this.canvas.height); - let isStretchPaint = this.isStretchPaint(); if (this.isClearPages) isStretchPaint = false; @@ -2875,14 +2875,6 @@ if (this.Api.watermarkDraw) this.Api.watermarkDraw.Draw(ctx, x, y, w, h); - - if (this.isLandscapePage(i)) { - let x = ((xCenter * AscCommon.AscBrowser.retinaPixelRatio) >> 0) - (h >> 1); - this.pageDetector.addPage(i, x, y, h, w); - } - else { - this.pageDetector.addPage(i, x, y, w, h); - } } this.isClearPages = false; @@ -2905,6 +2897,32 @@ // Обязательно делаем в конце, т.к. во время отрисовки происходит пересчет this._checkTargetUpdate(); }; + this.updatePageDetector = function() { + this.pageDetector = new CCurrentPageDetector(this.canvas.width, this.canvas.height); + + let yPos = this.scrollY >> 0; + let xCenter = this.width >> 1; + + for (let i = this.startVisiblePage; i <= this.endVisiblePage; i++) + { + let page = this.drawingPages[i]; + if (!page) + break; + + let w = AscCommon.AscBrowser.convertToRetinaValue(page.W, true); + let h = AscCommon.AscBrowser.convertToRetinaValue(page.H, true); + let x = ((xCenter * AscCommon.AscBrowser.retinaPixelRatio) >> 0) - (w >> 1); + let y = ((page.Y - yPos) * AscCommon.AscBrowser.retinaPixelRatio) >> 0; + + if (this.isLandscapePage(i)) { + let x = ((xCenter * AscCommon.AscBrowser.retinaPixelRatio) >> 0) - (h >> 1); + this.pageDetector.addPage(i, x, y, h, w); + } + else { + this.pageDetector.addPage(i, x, y, w, h); + } + } + }; this.isStretchPaint = function() { return this.Api.WordControl.NoneRepaintPages; }; From adb45252cad33a7e165d352b9858e0944216cc22 Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Mon, 30 Sep 2024 19:32:35 +0700 Subject: [PATCH 6/7] Fix bug #70541 --- pdf/src/annotations/freeText.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pdf/src/annotations/freeText.js b/pdf/src/annotations/freeText.js index caca8a2f15..07cede19e4 100644 --- a/pdf/src/annotations/freeText.js +++ b/pdf/src/annotations/freeText.js @@ -117,6 +117,8 @@ return; } + AscCommon.History.Add(new CChangesPDFFreeTextRotate(this, this._rotate, nAngle)); + let oBodyPr = oTxShape.txBody.bodyPr; switch (nAngle) { From a1042f215ef8cbec52bd313a7ae4e851440ba12c Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Mon, 30 Sep 2024 19:51:04 +0700 Subject: [PATCH 7/7] Fix bug #70573 --- pdf/src/forms/apiFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdf/src/forms/apiFunctions.js b/pdf/src/forms/apiFunctions.js index ce8e2a2487..ecb3264f26 100644 --- a/pdf/src/forms/apiFunctions.js +++ b/pdf/src/forms/apiFunctions.js @@ -156,7 +156,7 @@ let nSelEnd = oDoc.event["selEnd"]; function isValidNumber(str) { - return !isNaN(str) && isFinite(str); + return !isNaN(str) && isFinite(str) && false == /\s/.test(str); } let sNewValue = sValue.slice(0, nSelStart) + sChange + sValue.slice(nSelEnd);