From 6050cb5e1f212fc9a1f9cdbf52ef598ad083dc6f Mon Sep 17 00:00:00 2001 From: KirillovIlya Date: Tue, 13 Feb 2024 20:44:23 +0300 Subject: [PATCH] [de] Improve the view of the document in reading mode --- word/Editor/Layout/Base.js | 6 +++--- word/Editor/Layout/PrintView.js | 3 ++- word/Editor/Layout/ReadView.js | 25 ++++++++++++++----------- word/Editor/Paragraph.js | 9 ++++++--- word/Editor/Table.js | 4 ++-- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/word/Editor/Layout/Base.js b/word/Editor/Layout/Base.js index 9945b819ed..3ae8089542 100644 --- a/word/Editor/Layout/Base.js +++ b/word/Editor/Layout/Base.js @@ -165,11 +165,11 @@ return 1; }; /** - * @returns {boolean} + * @returns {number} */ - CDocumentLayoutBase.prototype.isZeroIndents = function() + CDocumentLayoutBase.prototype.calculateIndent = function(ind, sectPr) { - return false; + return ind; }; //--------------------------------------------------------export---------------------------------------------------- AscWord.CDocumentLayoutBase = CDocumentLayoutBase; diff --git a/word/Editor/Layout/PrintView.js b/word/Editor/Layout/PrintView.js index ea2f399cc1..72cb457820 100644 --- a/word/Editor/Layout/PrintView.js +++ b/word/Editor/Layout/PrintView.js @@ -170,7 +170,8 @@ }; CDocumentPrintView.prototype.GetSectionByPos = function(nContentIndex) { - return this.SectionsInfo.Get_SectPr(nContentIndex).SectPr; + let sectInfo = this.SectionsInfo.Get_SectPr(nContentIndex); + return sectInfo ? sectInfo.SectPr : null; }; CDocumentPrintView.prototype.GetSectionInfo = function(nContentIndex) { diff --git a/word/Editor/Layout/ReadView.js b/word/Editor/Layout/ReadView.js index 24b4ae489c..6e50df40be 100644 --- a/word/Editor/Layout/ReadView.js +++ b/word/Editor/Layout/ReadView.js @@ -43,13 +43,13 @@ function CDocumentReadView(oLogicDocument) { AscWord.CDocumentLayoutBase.call(this, oLogicDocument); - + this.W = 297; this.H = 210; this.Scale = 1; this.SectPr = null; this.SectInfo = null; - + let oThis = this; AscCommon.ExecuteNoHistory(function() { @@ -57,6 +57,7 @@ oThis.SectInfo = new CDocumentSectionsInfoElement(oThis.SectPr, 0); }, oLogicDocument); } + CDocumentReadView.prototype = Object.create(AscWord.CDocumentLayoutBase.prototype); CDocumentReadView.prototype.constructor = CDocumentReadView; CDocumentReadView.prototype.IsReadMode = function() @@ -68,9 +69,9 @@ this.W = nW; this.H = nH; this.Scale = nScale; - + let oSectPr = this.SectPr; - + AscCommon.ExecuteNoHistory(function() { oSectPr.SetPageSize(nW, nH); @@ -96,7 +97,6 @@ CDocumentReadView.prototype.GetPageContentFrame = function(nPageAbs, oSectPr) { let oFrame = this.SectPr.GetContentFrame(0); - return { X : oFrame.Left, Y : oFrame.Top, @@ -107,7 +107,6 @@ CDocumentReadView.prototype.GetColumnContentFrame = function(nPageAbs, nColumnAbs, oSectPr) { let oFrame = oSectPr.GetContentFrame(nPageAbs); - return { X : oFrame.Left, Y : oFrame.Top, @@ -141,20 +140,24 @@ { let nW = oSectPr.GetPageWidth(); let nH = oSectPr.GetPageHeight(); - + let nCoef = 1; if (this.W < nW) nCoef = this.W / nW; - + if (this.H < nH) nCoef = Math.min(this.H / nH, nCoef); - + return nCoef; }; - CDocumentReadView.prototype.isZeroIndents = function() + CDocumentReadView.prototype.calculateIndent = function(ind, sectPr) { - return true; + if (ind > 0 && sectPr) + return ind * this.W / sectPr.GetPageWidth(); + + return Math.max(ind, -2); }; + //--------------------------------------------------------export---------------------------------------------------- window['AscWord'].CDocumentReadView = CDocumentReadView; diff --git a/word/Editor/Paragraph.js b/word/Editor/Paragraph.js index 9598f7e51e..ec1816b6e0 100644 --- a/word/Editor/Paragraph.js +++ b/word/Editor/Paragraph.js @@ -10854,10 +10854,13 @@ Paragraph.prototype.Internal_CompileParaPr2 = function() Pr.ParaPr.NumPr = undefined; let logicDocument = this.GetLogicDocument(); - if (logicDocument && logicDocument.IsDocumentEditor() && logicDocument.Layout.isZeroIndents()) + if (logicDocument && logicDocument.IsDocumentEditor()) { - Pr.ParaPr.Ind.Left = 0; - Pr.ParaPr.Ind.Right = 0; + let sectPr = this.Get_SectPr(); + let left = Pr.ParaPr.Ind.Left; + Pr.ParaPr.Ind.Left = logicDocument.Layout.calculateIndent(Pr.ParaPr.Ind.Left, sectPr); + Pr.ParaPr.Ind.Right = logicDocument.Layout.calculateIndent(Pr.ParaPr.Ind.Right, sectPr); + Pr.ParaPr.Ind.FirstLine = logicDocument.Layout.calculateIndent(left + Pr.ParaPr.Ind.FirstLine, sectPr) - Pr.ParaPr.Ind.Left; } return Pr; diff --git a/word/Editor/Table.js b/word/Editor/Table.js index b0f7becce7..ce49505b9c 100644 --- a/word/Editor/Table.js +++ b/word/Editor/Table.js @@ -8537,8 +8537,8 @@ CTable.prototype.Internal_Compile_Pr = function() Pr.TablePr.Merge(this.Pr); let logicDocument = this.GetLogicDocument(); - if (logicDocument && logicDocument.IsDocumentEditor() && logicDocument.Layout.isZeroIndents()) - Pr.TablePr.TableInd = 0; + if (logicDocument && logicDocument.IsDocumentEditor()) + Pr.TablePr.TableInd = logicDocument.Layout.calculateIndent(Pr.TablePr.TableInd, this.Get_SectPr()); return Pr; };