From 48cd155f7d2b3012fc6fd6696c7c72546d437b7b Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 29 Jun 2023 14:31:38 +0500 Subject: [PATCH 01/42] [se] Init for read colbreaks/rowbreaks --- cell/model/Serialize.js | 56 +++++++++++++++++-------------- cell/model/WorkbookElems.js | 66 +++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 24 deletions(-) diff --git a/cell/model/Serialize.js b/cell/model/Serialize.js index a8004bb99b..747ff2fe39 100644 --- a/cell/model/Serialize.js +++ b/cell/model/Serialize.js @@ -8244,18 +8244,17 @@ res = this.bcr.Read1(length, function(t, l) { return oThis.ReadHeaderFooter(t, l, oWorksheet.headerFooter); }); - // Disable HeaderFooter opening to prevent file corruption - // } else if (c_oSerWorksheetsTypes.RowBreaks === type) { - // oWorksheet.rowBreaks = {count: null, manualBreakCount: null, breaks: []}; - // res = this.bcr.Read1(length, function (t, l) { - // return oThis.ReadRowColBreaks(t, l, oWorksheet.rowBreaks); - // }); - // } else if (c_oSerWorksheetsTypes.ColBreaks === type) { - // oWorksheet.colBreaks = {count: null, manualBreakCount: null, breaks: []}; - // res = this.bcr.Read1(length, function (t, l) { - // return oThis.ReadRowColBreaks(t, l, oWorksheet.colBreaks); - // }); - // } else if (c_oSerWorksheetsTypes.LegacyDrawingHF === type) { + } else if (c_oSerWorksheetsTypes.RowBreaks === type) { + oWorksheet.rowBreaks = new AscCommonExcel.CRowColBreaks(); + res = this.bcr.Read1(length, function (t, l) { + return oThis.ReadRowColBreaks(t, l, oWorksheet.rowBreaks); + }); + } else if (c_oSerWorksheetsTypes.ColBreaks === type) { + oWorksheet.colBreaks = new AscCommonExcel.CRowColBreaks(); + res = this.bcr.Read1(length, function (t, l) { + return oThis.ReadRowColBreaks(t, l, oWorksheet.colBreaks); + }); + //} else if (c_oSerWorksheetsTypes.LegacyDrawingHF === type) { // oWorksheet.legacyDrawingHF = { // drawings: [], cfe: null, cff: null, cfo: null, che: null, chf: null, cho: null, lfe: null, // lff: null, lfo: null, lhe: null, lhf: null, lho: null, rfe: null, rff: null, rfo: null, rhe: null, @@ -9895,34 +9894,43 @@ return res; }; this.ReadRowColBreaks = function (type, length, breaks) { - var oThis = this; - var res = c_oSerConstants.ReadOk; + let oThis = this; + let res = c_oSerConstants.ReadOk; + let val; if (c_oSer_RowColBreaks.Count === type) { - breaks.count = this.stream.GetLong(); + val = this.stream.GetLong(); + breaks.setCount(val); } else if (c_oSer_RowColBreaks.ManualBreakCount === type) { - breaks.manualBreakCount = this.stream.GetLong(); + val = this.stream.GetLong(); + breaks.setManualBreakCount(val); } else if (c_oSer_RowColBreaks.Break === type) { - var brk = {id: null, man: null, max: null, min: null, pt: null}; + var brk = new AscCommonExcel.CRowColBreak(); res = this.bcr.Read1(length, function(t, l) { return oThis.ReadRowColBreak(t, l, brk); }); - breaks.breaks.push(brk); + breaks.pushBreak(brk); } else res = c_oSerConstants.ReadUnknown; return res; }; this.ReadRowColBreak = function (type, length, brk) { - var res = c_oSerConstants.ReadOk; + let res = c_oSerConstants.ReadOk; + let val; if (c_oSer_RowColBreaks.Id === type) { - brk.id = this.stream.GetLong(); + val = this.stream.GetLong(); + brk.setId(val); } else if (c_oSer_RowColBreaks.Man === type) { - brk.man = this.stream.GetBool(); + val = this.stream.GetBool(); + brk.setMan(val); } else if (c_oSer_RowColBreaks.Max === type) { - brk.max = this.stream.GetLong(); + val = this.stream.GetLong(); + brk.setMax(val); } else if (c_oSer_RowColBreaks.Min === type) { - brk.min = this.stream.GetLong(); + val = this.stream.GetLong(); + brk.setMin(val); } else if (c_oSer_RowColBreaks.Pt === type) { - brk.pt = this.stream.GetBool(); + val = this.stream.GetBool(); + brk.setPt(val); } else res = c_oSerConstants.ReadUnknown; return res; diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index a0e42ee33a..741e05d735 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15499,6 +15499,69 @@ QueryTableField.prototype.clone = function() { } }; + function CRowColBreaks(/*ws*/) { + this.count = null; + this.manualBreakCount = null; + this.breaks = []; + + return this; + } + CRowColBreaks.prototype.clone = function () { + var res = new CRowColBreaks(); + res.count = this.count; + res.manualBreakCount = this.count; + + for (let i = 0 ; i < this.breaks.length; i++) { + res.breaks.push(this.breaks[i].clone()); + } + + return res; + }; + CRowColBreaks.prototype.setCount = function (val) { + this.count = val; + }; + CRowColBreaks.prototype.setManualBreakCount = function (val) { + this.manualBreakCount = val; + }; + CRowColBreaks.prototype.pushBreak = function (val) { + this.breaks.push(val); + }; + + + function CRowColBreak(/*ws*/) { + this.id = null; + this.man = null; + this.max = null; + this.min = null; + this.pt = null; + + return this; + } + CRowColBreak.prototype.clone = function () { + var res = new CRowColBreak(); + res.id = this.id; + res.man = this.man; + res.max = this.max; + res.min = this.min; + res.pt = this.pt; + + return res; + }; + CRowColBreak.prototype.setId = function (val) { + this.id = val; + }; + CRowColBreak.prototype.setMan = function (val) { + this.man = val; + }; + CRowColBreak.prototype.setMax = function (val) { + this.max = val; + }; + CRowColBreak.prototype.setMin = function (val) { + this.min = val; + }; + CRowColBreak.prototype.setPt = function (val) { + this.pt = val; + }; @@ -15973,5 +16036,8 @@ QueryTableField.prototype.clone = function() { prot["asc_getValue"] = prot.asc_getValue; prot["asc_getFormula"] = prot.asc_getFormula; + window["AscCommonExcel"].CRowColBreaks = CRowColBreaks; + window["AscCommonExcel"].CRowColBreak = CRowColBreak; + })(window); From 612d818e3886c9a15eaffa0d9f5c6f4cf93ab43c Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 29 Jun 2023 16:42:43 +0500 Subject: [PATCH 02/42] [se] By init --- cell/model/Serialize.js | 2 +- cell/model/WorkbookElems.js | 42 +++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/cell/model/Serialize.js b/cell/model/Serialize.js index 747ff2fe39..b121e26ca9 100644 --- a/cell/model/Serialize.js +++ b/cell/model/Serialize.js @@ -9904,7 +9904,7 @@ val = this.stream.GetLong(); breaks.setManualBreakCount(val); } else if (c_oSer_RowColBreaks.Break === type) { - var brk = new AscCommonExcel.CRowColBreak(); + var brk = new AscCommonExcel.CBreak(); res = this.bcr.Read1(length, function(t, l) { return oThis.ReadRowColBreak(t, l, brk); }); diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 741e05d735..97593efd98 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15526,9 +15526,18 @@ QueryTableField.prototype.clone = function() { CRowColBreaks.prototype.pushBreak = function (val) { this.breaks.push(val); }; + CRowColBreaks.prototype.getCount = function () { + return this.count; + }; + CRowColBreaks.prototype.getManualBreakCount = function () { + return this.manualBreakCount; + }; + CRowColBreaks.prototype.getBreaks = function () { + return this.breaks; + }; - function CRowColBreak(/*ws*/) { + function CBreak(/*ws*/) { this.id = null; this.man = null; this.max = null; @@ -15537,8 +15546,8 @@ QueryTableField.prototype.clone = function() { return this; } - CRowColBreak.prototype.clone = function () { - var res = new CRowColBreak(); + CBreak.prototype.clone = function () { + var res = new CBreak(); res.id = this.id; res.man = this.man; res.max = this.max; @@ -15547,21 +15556,36 @@ QueryTableField.prototype.clone = function() { return res; }; - CRowColBreak.prototype.setId = function (val) { + CBreak.prototype.setId = function (val) { this.id = val; }; - CRowColBreak.prototype.setMan = function (val) { + CBreak.prototype.setMan = function (val) { this.man = val; }; - CRowColBreak.prototype.setMax = function (val) { + CBreak.prototype.setMax = function (val) { this.max = val; }; - CRowColBreak.prototype.setMin = function (val) { + CBreak.prototype.setMin = function (val) { this.min = val; }; - CRowColBreak.prototype.setPt = function (val) { + CBreak.prototype.setPt = function (val) { this.pt = val; }; + CBreak.prototype.getId = function () { + return this.id; + }; + CBreak.prototype.getMan = function () { + return this.man; + }; + CBreak.prototype.getMax = function () { + return this.max; + }; + CBreak.prototype.getMin = function () { + return this.min; + }; + CBreak.prototype.getPt = function () { + return this.pt; + }; @@ -16037,7 +16061,7 @@ QueryTableField.prototype.clone = function() { prot["asc_getFormula"] = prot.asc_getFormula; window["AscCommonExcel"].CRowColBreaks = CRowColBreaks; - window["AscCommonExcel"].CRowColBreak = CRowColBreak; + window["AscCommonExcel"].CBreak = CBreak; })(window); From 334d524537d351fbf866887749fdbc2df97eaf9b Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 29 Jun 2023 16:55:48 +0500 Subject: [PATCH 03/42] [se] Fix --- cell/model/WorkbookElems.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 97593efd98..f5c32aec01 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -13710,6 +13710,22 @@ QueryTableField.prototype.clone = function() { this.init(); }; + CHeaderFooter.prototype.isEmpty = function () { + if (this.alignWithMargins === null && + this.differentFirst === null && + this.differentOddEven === null && + this.scaleWithDoc === null && + this.evenFooter === null && + this.evenHeader === null && + this.firstFooter === null && + this.firstHeader === null && + this.oddFooter === null && + this.oddHeader === null) { + return true; + } + return false; + }; + function CHeaderFooterData(str) { this.str = str; From 269591a633a9a954d6206a5986167406989db8ed Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Mon, 3 Jul 2023 18:23:02 +0500 Subject: [PATCH 04/42] [se] Init view --- cell/model/WorkbookElems.js | 13 ++++ cell/view/WorksheetView.js | 117 ++++++++++++++++++------------------ 2 files changed, 73 insertions(+), 57 deletions(-) diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index f5c32aec01..765016e75b 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15551,6 +15551,16 @@ QueryTableField.prototype.clone = function() { CRowColBreaks.prototype.getBreaks = function () { return this.breaks; }; + CRowColBreaks.prototype.isBreak = function (index) { + if (this.count > 0) { + for (let i = 0; i < this.breaks.length; i++) { + if (this.breaks[i].isBreak(index)) { + return true; + } + } + } + return false; + }; function CBreak(/*ws*/) { @@ -15602,6 +15612,9 @@ QueryTableField.prototype.clone = function() { CBreak.prototype.getPt = function () { return this.pt; }; + CBreak.prototype.isBreak = function (index) { + return this.id === index; + }; diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 9f7a8d960d..34b30337f3 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -2107,13 +2107,13 @@ return; } - var vector_koef = AscCommonExcel.vector_koef / this.getZoom(); + let vector_koef = AscCommonExcel.vector_koef / this.getZoom(); if (AscCommon.AscBrowser.isCustomScaling()) { //vector_koef /= AscCommon.AscBrowser.retinaPixelRatio; } - var isOnlyFirstPage = adjustPrint && adjustPrint.isOnlyFirstPage; - var pageMargins, pageSetup, pageGridLines, pageHeadings; + let isOnlyFirstPage = adjustPrint && adjustPrint.isOnlyFirstPage; + let pageMargins, pageSetup, pageGridLines, pageHeadings; if (pageOptions) { pageMargins = pageOptions.asc_getPageMargins(); pageSetup = pageOptions.asc_getPageSetup(); @@ -2121,9 +2121,9 @@ pageHeadings = pageOptions.asc_getHeadings(); } - var bFitToWidth = false; - var bFitToHeight = false; - var pageWidth, pageHeight, pageOrientation, scale; + let bFitToWidth = false; + let bFitToHeight = false; + let pageWidth, pageHeight, pageOrientation, scale; if (pageSetup instanceof asc_CPageSetup) { pageWidth = pageSetup.asc_getWidth(); pageHeight = pageSetup.asc_getHeight(); @@ -2136,11 +2136,11 @@ scale = printScale / 100; } else { //scale пока всегда берём из модели - var pageSetupModel = this.model.PagePrintOptions ? this.model.PagePrintOptions.pageSetup : null; + let pageSetupModel = this.model.PagePrintOptions ? this.model.PagePrintOptions.pageSetup : null; scale = pageSetupModel ? pageSetupModel.asc_getScale() / 100 : 1; } - var pageLeftField, pageRightField, pageTopField, pageBottomField; + let pageLeftField, pageRightField, pageTopField, pageBottomField; if (pageMargins) { pageLeftField = Math.max(pageMargins.asc_getLeft(), c_oAscPrintDefaultSettings.MinPageLeftField); pageRightField = Math.max(pageMargins.asc_getRight(), c_oAscPrintDefaultSettings.MinPageRightField); @@ -2148,17 +2148,17 @@ pageBottomField = Math.max(pageMargins.asc_getBottom(), c_oAscPrintDefaultSettings.MinPageBottomField); } - var t = this; - var _getColumnWidth = function (index) { - var defaultWidth = t._getWidthForPrint(index); + let t = this; + let _getColumnWidth = function (index) { + let defaultWidth = t._getWidthForPrint(index); if (defaultWidth) { return defaultWidth; } return t._getColumnWidth(index); }; - var _getRowHeight = function (index) { - var defaultHeight = t._getHeightForPrint(index); + let _getRowHeight = function (index) { + let defaultHeight = t._getHeightForPrint(index); if (defaultHeight) { return defaultHeight; } @@ -2197,17 +2197,17 @@ } if (Asc.c_oAscPageOrientation.PageLandscape === pageOrientation) { - var tmp = pageWidth; + let tmp = pageWidth; pageWidth = pageHeight; pageHeight = tmp; } - var pageWidthWithFields = pageWidth - pageLeftField - pageRightField; - var pageHeightWithFields = pageHeight - pageTopField - pageBottomField; - var leftFieldInPx = pageLeftField / vector_koef + 1; - var topFieldInPx = pageTopField / vector_koef + 1; + let pageWidthWithFields = pageWidth - pageLeftField - pageRightField; + let pageHeightWithFields = pageHeight - pageTopField - pageBottomField; + let leftFieldInPx = pageLeftField / vector_koef + 1; + let topFieldInPx = pageTopField / vector_koef + 1; - var startPrintPreview = this.workbook.printPreviewState && this.workbook.printPreviewState.isStart(); + let startPrintPreview = this.workbook.printPreviewState && this.workbook.printPreviewState.isStart(); let _retinaPixelRatio = this.getRetinaPixelRatio(); if (pageHeadings) { @@ -2217,15 +2217,15 @@ } //TODO при сравнении резальтатов рассчета страниц в зависимости от scale - LO выдаёт похожие результаты, MS - другие. Необходимо пересмотреть! - var pageWidthWithFieldsHeadings = ((pageWidth - pageRightField) / vector_koef - leftFieldInPx); - var pageHeightWithFieldsHeadings = ((pageHeight - pageBottomField) / vector_koef - topFieldInPx); + let pageWidthWithFieldsHeadings = ((pageWidth - pageRightField) / vector_koef - leftFieldInPx); + let pageHeightWithFieldsHeadings = ((pageHeight - pageBottomField) / vector_koef - topFieldInPx); //PRINT TITLES - var tCol1, tCol2, tRow1, tRow2; + let tCol1, tCol2, tRow1, tRow2; //первостепенно ориентируемся что в этих настройках - var printTitlesHeight = pageOptions.printTitlesHeight; - var printTitlesWidth = pageOptions.printTitlesWidth; - var _titleRange; + let printTitlesHeight = pageOptions.printTitlesHeight; + let printTitlesWidth = pageOptions.printTitlesWidth; + let _titleRange; if (null !== printTitlesHeight) { AscCommonExcel.executeInR1C1Mode(AscCommonExcel.g_R1C1Mode, function () { _titleRange = AscCommonExcel.g_oRangeCache.getAscRange(printTitlesHeight); @@ -2251,17 +2251,17 @@ } } - //var titleWidth = 0, titleHeight = 0; + //let titleWidth = 0, titleHeight = 0; if (!printTitlesHeight || !printTitlesWidth) { - var printTitles = this.model.workbook.getDefinesNames("Print_Titles", this.model.getId()); + let printTitles = this.model.workbook.getDefinesNames("Print_Titles", this.model.getId()); if(printTitles) { - var printTitleRefs; + let printTitleRefs; AscCommonExcel.executeInR1C1Mode(false, function () { printTitleRefs = AscCommonExcel.getRangeByRef(printTitles.ref, t.model, true, true) }); if(printTitleRefs && printTitleRefs.length) { - for(var i = 0; i < printTitleRefs.length; i++) { - var bbox = printTitleRefs[i].bbox; + for(let i = 0; i < printTitleRefs.length; i++) { + let bbox = printTitleRefs[i].bbox; if(bbox) { if(c_oAscSelectionType.RangeCol === bbox.getType() && null == printTitlesWidth) { tCol1 = bbox.c1; @@ -2276,32 +2276,32 @@ } } - var currentColIndex = range.c1; - var currentWidth = 0; - var currentRowIndex = range.r1; - var currentHeight = 0; - var isCalcColumnsWidth = true; + let currentColIndex = range.c1; + let currentWidth = 0; + let currentRowIndex = range.r1; + let currentHeight = 0; + let isCalcColumnsWidth = true; - var currentHeightReal = 0; - var currentWidthReal = 0; + let currentHeightReal = 0; + let currentWidthReal = 0; - var bIsAddOffset = false; - var nCountOffset = 0; - var nCountPages = 0; + let bIsAddOffset = false; + let nCountOffset = 0; + let nCountPages = 0; - var curTitleWidth = 0, curTitleHeight = 0; - var addedTitleHeight = 0, addedTitleWidth = 0; + let curTitleWidth = 0, curTitleHeight = 0; + let addedTitleHeight = 0, addedTitleWidth = 0; - var startTitleArrRow = []; + let startTitleArrRow = []; - var j; - var baseTitleHeight = 0; + let j; + let baseTitleHeight = 0; if (tRow1 < currentRowIndex) { for (j = tRow1; j < Math.min(currentRowIndex, tRow2 + 1); j++) { baseTitleHeight += _getRowHeight(j) * scale; } } - var baseTitleWidth = 0; + let baseTitleWidth = 0; if (tCol1 < currentColIndex) { for (j = tCol1; j < Math.min(currentColIndex, tCol2 + 1); j++) { baseTitleWidth += _getColumnWidth(j) * scale; @@ -2313,9 +2313,10 @@ break; } - var newPagePrint = new asc_CPagePrint(); + let newPagePrint = new asc_CPagePrint(); - var colIndex = currentColIndex, rowIndex = currentRowIndex, pageRange; + let colIndex = currentColIndex, rowIndex = currentRowIndex, pageRange; + let rowBreak = false, colBreak = false; newPagePrint.indexWorksheet = indexWorksheet; @@ -2347,12 +2348,13 @@ newPagePrint.titleHeight = curTitleHeight; for (rowIndex = currentRowIndex; rowIndex <= range.r2; ++rowIndex) { - var currentRowHeight = _getRowHeight(rowIndex) * scale; - var currentRowHeightReal = (t._getRowHeight(rowIndex)/this.getRetinaPixelRatio()) *scale; - if (currentHeight + currentRowHeight + curTitleHeight > pageHeightWithFieldsHeadings && rowIndex !== currentRowIndex) { + let currentRowHeight = _getRowHeight(rowIndex) * scale; + let currentRowHeightReal = (t._getRowHeight(rowIndex)/this.getRetinaPixelRatio()) *scale; + rowBreak = t.model.rowBreaks && t.model.rowBreaks.isBreak(rowIndex); + if ((currentHeight + currentRowHeight + curTitleHeight > pageHeightWithFieldsHeadings + && rowIndex !== currentRowIndex) || rowBreak) { // Закончили рисовать страницу curTitleHeight = addedTitleHeight; - rowIndex = rowIndex; break; } if (isCalcColumnsWidth) { @@ -2369,17 +2371,18 @@ newPagePrint.titleWidth = curTitleWidth; for (colIndex = currentColIndex; colIndex <= range.c2; ++colIndex) { - var currentColWidth = _getColumnWidth(colIndex) * scale; - var currentRowWidthReal = (t._getColumnWidth(colIndex)/this.getRetinaPixelRatio()) *scale; + let currentColWidth = _getColumnWidth(colIndex) * scale; + let currentRowWidthReal = (t._getColumnWidth(colIndex)/this.getRetinaPixelRatio()) *scale; if (bIsAddOffset) { newPagePrint.startOffset = ++nCountOffset; newPagePrint.startOffsetPx = (pageWidthWithFieldsHeadings * newPagePrint.startOffset); currentColWidth -= newPagePrint.startOffsetPx; } - if (currentWidth + currentColWidth + curTitleWidth > pageWidthWithFieldsHeadings && colIndex !== currentColIndex) { + colBreak = t.model.colBreaks && t.model.colBreaks.isBreak(rowIndex); + if ((currentWidth + currentColWidth + curTitleWidth > pageWidthWithFieldsHeadings + && colIndex !== currentColIndex) || colBreak) { curTitleWidth = addedTitleWidth; - colIndex = colIndex; break; } @@ -2472,7 +2475,7 @@ nCountOffset = 0; } - if (colIndex <= range.c2) { + if (colIndex <= range.c2 && !rowBreak) { // Мы еще не все колонки отрисовали currentColIndex = colIndex; currentHeight = 0; From a04f851931b6dfcc9b5f0954424c73c7f2ccf53e Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 4 Jul 2023 09:57:19 +0500 Subject: [PATCH 05/42] [se] Fix --- cell/model/WorkbookElems.js | 5 +++++ cell/view/WorksheetView.js | 19 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 765016e75b..483cd1cff0 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15561,6 +15561,11 @@ QueryTableField.prototype.clone = function() { } return false; }; + CRowColBreaks.prototype.forEach = function (callback) { + for (var i = 0, l = this.breaks.length; i < l; ++i) { + callback(this.breaks[i], i); + } + }; function CBreak(/*ws*/) { diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 34b30337f3..4c492cf849 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -2350,7 +2350,7 @@ for (rowIndex = currentRowIndex; rowIndex <= range.r2; ++rowIndex) { let currentRowHeight = _getRowHeight(rowIndex) * scale; let currentRowHeightReal = (t._getRowHeight(rowIndex)/this.getRetinaPixelRatio()) *scale; - rowBreak = t.model.rowBreaks && t.model.rowBreaks.isBreak(rowIndex); + rowBreak = !bFitToHeight && rowIndex !== currentRowIndex && t.model.rowBreaks && t.model.rowBreaks.isBreak(rowIndex); if ((currentHeight + currentRowHeight + curTitleHeight > pageHeightWithFieldsHeadings && rowIndex !== currentRowIndex) || rowBreak) { // Закончили рисовать страницу @@ -2379,7 +2379,7 @@ currentColWidth -= newPagePrint.startOffsetPx; } - colBreak = t.model.colBreaks && t.model.colBreaks.isBreak(rowIndex); + colBreak = !bFitToWidth && colIndex !== currentColIndex && t.model.colBreaks && t.model.colBreaks.isBreak(colIndex); if ((currentWidth + currentColWidth + curTitleWidth > pageWidthWithFieldsHeadings && colIndex !== currentColIndex) || colBreak) { curTitleWidth = addedTitleWidth; @@ -2475,7 +2475,7 @@ nCountOffset = 0; } - if (colIndex <= range.c2 && !rowBreak) { + if (colIndex <= range.c2) { // Мы еще не все колонки отрисовали currentColIndex = colIndex; currentHeight = 0; @@ -4827,6 +4827,7 @@ return; } + let t = this; let oPrintPages = this.pagesModeData; let allPagesRange; //рисуем страницы @@ -4846,6 +4847,18 @@ } this._drawElements(this._drawSelectionElement, allPagesRange, lineType, color, true); } + + //draw pages break + if (this.model.colBreaks) { + this.model.colBreaks.forEach(function (colBreak) { + t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color); + }); + } + if (this.model.rowBreaks) { + this.model.rowBreaks.forEach(function (rowBreak) { + t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color); + }); + } } }; From aaee687be4d3906b82cb7542a177314a861fedb8 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 4 Jul 2023 12:50:13 +0500 Subject: [PATCH 06/42] [se] Fix --- cell/view/WorksheetView.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 4c492cf849..378342f759 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -4849,14 +4849,15 @@ } //draw pages break + let widthLine = 3; if (this.model.colBreaks) { this.model.colBreaks.forEach(function (colBreak) { - t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color); + t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color, allPagesRange, widthLine); }); } if (this.model.rowBreaks) { this.model.rowBreaks.forEach(function (rowBreak) { - t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color); + t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color, allPagesRange, widthLine); }); } } @@ -6309,14 +6310,22 @@ let col = args[0]; let row = args[1]; let strokeColor = args[2]; + let range = args[3]; + let widthLine = args[4] != null ? args[4] : 2; let ctx = this.overlayCtx; + if (range) { + visibleRange = range.intersection(visibleRange); + } + if (!visibleRange) { + return; + } + let fHorLine, fVerLine; fHorLine = ctx.lineHorPrevPx; fVerLine = ctx.lineVerPrevPx; - let widthLine = 2; if (AscBrowser.retinaPixelRatio === 2) { widthLine = AscCommon.AscBrowser.convertToRetinaValue(widthLine, true); @@ -9230,6 +9239,16 @@ } } + if (this.model.colBreaks) { + cFrozen = this.topLeftFrozenCell.getCol0(); + rFrozen = this.topLeftFrozenCell.getRow0(); + widthDiff = this._getColLeft(cFrozen) - this._getColLeft(0); + heightDiff = this._getRowTop(rFrozen) - this._getRowTop(0); + + offsetX = (x < this.cellsLeft + widthDiff) ? 0 : offsetX - widthDiff; + offsetY = (y < this.cellsTop + heightDiff) ? 0 : offsetY - heightDiff; + } + if (x > this.cellsLeft && y > this.cellsTop) { c = this._findColUnderCursor(x, true); r = this._findRowUnderCursor(y, true); @@ -9319,7 +9338,7 @@ } if (canEdit && readyMode) { - var _range = new asc_Range(c.col, r.row, c.col, r.row) + var _range = new asc_Range(c.col, r.row, c.col, r.row); var pivotButtons = !this.model.inTopAutoFilter(_range) && this.model.getPivotTableButtons(_range); var pivotButton = pivotButtons && pivotButtons.find(function (element) { return element.row === r.row && element.col === c.col; From f3b5f8e2793336ffd0c60bae21cebe099835ecce Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Wed, 5 Jul 2023 00:39:54 +0500 Subject: [PATCH 07/42] [se] Fix --- cell/view/WorksheetView.js | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 378342f759..85d96dbc3a 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -4849,13 +4849,18 @@ } //draw pages break + let pageOptions = this.model.PagePrintOptions; + let pageSetup = pageOptions && pageOptions.asc_getPageSetup(); + let bFitToWidth = pageSetup && pageSetup.asc_getFitToWidth(); + let bFitToHeight = pageSetup && pageSetup.asc_getFitToHeight(); + let widthLine = 3; - if (this.model.colBreaks) { + if (this.model.colBreaks && !bFitToWidth) { this.model.colBreaks.forEach(function (colBreak) { t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color, allPagesRange, widthLine); }); } - if (this.model.rowBreaks) { + if (this.model.rowBreaks && !bFitToHeight) { this.model.rowBreaks.forEach(function (rowBreak) { t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color, allPagesRange, widthLine); }); @@ -8743,13 +8748,13 @@ let res = null; let _range = null; if (oPrintPages) { - let printRanges = this._getPageBreakPreviewRanges(oPrintPages); + let printRanges = this.pagesModeData.printPages; if (printRanges) { for (let i = 0; i < printRanges.length; i++) { - res = this._hitInRange(printRanges[i].range, + res = this._hitInRange(printRanges[i].page.pageRange, AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY, true); if (res) { - _range = printRanges[i].range.clone(); + _range = printRanges[i].page.pageRange.clone(); break; } } @@ -9239,16 +9244,6 @@ } } - if (this.model.colBreaks) { - cFrozen = this.topLeftFrozenCell.getCol0(); - rFrozen = this.topLeftFrozenCell.getRow0(); - widthDiff = this._getColLeft(cFrozen) - this._getColLeft(0); - heightDiff = this._getRowTop(rFrozen) - this._getRowTop(0); - - offsetX = (x < this.cellsLeft + widthDiff) ? 0 : offsetX - widthDiff; - offsetY = (y < this.cellsTop + heightDiff) ? 0 : offsetY - heightDiff; - } - if (x > this.cellsLeft && y > this.cellsTop) { c = this._findColUnderCursor(x, true); r = this._findRowUnderCursor(y, true); From a1c3a960bc38f841abf8841d7f2f47eb037f8c24 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Wed, 5 Jul 2023 17:07:27 +0500 Subject: [PATCH 08/42] [se] Fix --- cell/view/WorksheetView.js | 82 ++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 12 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 85d96dbc3a..8b23fe0bcd 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -8748,13 +8748,55 @@ let res = null; let _range = null; if (oPrintPages) { - let printRanges = this.pagesModeData.printPages; + let printRanges = this._getPageBreakPreviewRanges(oPrintPages); + //hit in all pages area if (printRanges) { for (let i = 0; i < printRanges.length; i++) { - res = this._hitInRange(printRanges[i].page.pageRange, + res = this._hitInRange(printRanges[i].range, AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY, true); if (res) { - _range = printRanges[i].page.pageRange.clone(); + _range = printRanges[i].range.clone(); + break; + } + } + } + //hit inside pages lines + if (!res) { + let printPages = this.pagesModeData.printPages; + if (printPages) { + for (let i = 0; i < printPages.length; i++) { + res = this._hitInRange(printPages[i].page.pageRange, + AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY, true); + if (res) { + //_range = printRanges[i].page.pageRange.clone(); + break; + } + } + } + } + } + return res ? { + cursor: res.cursor, + target: c_oTargetType.MoveResizeRange, + col: res.col, + row: res.row, + range: _range, + isPageBreakPreview: true + } : null; + }; + + WorksheetView.prototype._hitCursorPageBreakPreviewLines = function (vr, x, y, offsetX, offsetY) { + let oPrintPages = this.isPageBreakPreview(true) && this.pagesModeData; + let res = null; + let _range = null; + if (oPrintPages) { + let printRanges = this._getPageBreakPreviewRanges(oPrintPages); + if (printRanges) { + for (let i = 0; i < printRanges.length; i++) { + res = this._hitInRange(printRanges[i].range, + AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY, true); + if (res) { + _range = printRanges[i].range.clone(); break; } } @@ -9230,6 +9272,11 @@ this._drawElements(function (_vr, _offsetX, _offsetY) { return (null === (res = this._hitCursorPageBreakPreviewRange(_vr, x, y, _offsetX, _offsetY))); }); + if (!res) { + this._drawElements(function (_vr, _offsetX, _offsetY) { + return (null === (res = this._hitCursorPageBreakPreviewLines(_vr, x, y, _offsetX, _offsetY))); + }); + } if (res) { return res; } @@ -12296,6 +12343,7 @@ this.startCellMoveResizeRange = ar.clone(true); } else { this.startCellMoveResizeRange = ar.clone(true); + if (colByX < ar.c1) { colByX = ar.c1; } else if (colByX > ar.c2) { @@ -12307,6 +12355,16 @@ rowByY = ar.r2; } } + + if (this.startCellMoveRange.colRowMoveProps && !this.targetInfo.range) { + this.startCellMoveResizeRange.colRowMoveProps = {}; + if (this.targetInfo.col !== -1) { + this.startCellMoveResizeRange.colRowMoveProps.colByX = this.targetInfo.col; + } else if (this.targetInfo.row !== -1) { + this.startCellMoveResizeRange.colRowMoveProps.rowByY = rowByY; + } + } + return null; }; @@ -12390,17 +12448,17 @@ }; WorksheetView.prototype.changeSelectionMoveResizeRangeHandle = function (x, y, targetInfo, editor) { - // Возвращаемый результат - if (!targetInfo) { - return null; - } + // Возвращаемый результат + if (!targetInfo) { + return null; + } - if (this.getFormulaEditMode()) { - editor.cleanSelectRange(); - } + if (this.getFormulaEditMode()) { + editor.cleanSelectRange(); + } - var index = targetInfo.indexFormulaRange; - var initialRange = this.oOtherRanges.ranges[index]; + var index = targetInfo.indexFormulaRange; + var initialRange = this.oOtherRanges.ranges[index]; if (null === this.startCellMoveResizeRange) { return this._startMoveResizeRangeHandle(x, y, targetInfo, initialRange); From 6021a556524e512811cd7644646de3756125fbea Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 6 Jul 2023 01:52:19 +0500 Subject: [PATCH 09/42] [se] By move break lines --- cell/view/EventsController.js | 2 +- cell/view/WorkbookView.js | 2 +- cell/view/WorksheetView.js | 90 ++++++----------------------------- 3 files changed, 16 insertions(+), 78 deletions(-) diff --git a/cell/view/EventsController.js b/cell/view/EventsController.js index 72c48799f2..9d8e2dd9c9 100644 --- a/cell/view/EventsController.js +++ b/cell/view/EventsController.js @@ -1839,7 +1839,7 @@ if (this.isMoveResizeRange) { this.isMoveResizeRange = false; - this._moveResizeRangeHandleDone(this.targetInfo && this.targetInfo.isPageBreakPreview); + this._moveResizeRangeHandleDone(this.targetInfo && this.targetInfo.pageBreakSelectionType); return true; } // Режим установки закреплённых областей diff --git a/cell/view/WorkbookView.js b/cell/view/WorkbookView.js index c55956d2a8..f9f65e25d7 100644 --- a/cell/view/WorkbookView.js +++ b/cell/view/WorkbookView.js @@ -1743,7 +1743,7 @@ if (this.Api.isEditVisibleAreaOleEditor && target.isOleRange) { d = ws.changeSelectionMoveResizeVisibleAreaHandle(x, y, target); - } else if (target.isPageBreakPreview) { + } else if (target.pageBreakSelectionType) { d = ws.changePageBreakPreviewAreaHandle(x, y, target); } else { d = ws.changeSelectionMoveResizeRangeHandle(x, y, target, this.cellEditor); diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 8b23fe0bcd..1db98a8a0f 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -8747,6 +8747,7 @@ let oPrintPages = this.isPageBreakPreview(true) && this.pagesModeData; let res = null; let _range = null; + let pageBreakSelectionType = null;//1 - outer range, 2 - inner if (oPrintPages) { let printRanges = this._getPageBreakPreviewRanges(oPrintPages); //hit in all pages area @@ -8756,6 +8757,7 @@ AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY, true); if (res) { _range = printRanges[i].range.clone(); + pageBreakSelectionType = 1; break; } } @@ -8768,7 +8770,13 @@ res = this._hitInRange(printPages[i].page.pageRange, AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY, true); if (res) { - //_range = printRanges[i].page.pageRange.clone(); + for (let j = 0; j < printRanges.length; j++) { + if (printPages[i].page.pageRange.intersection(printRanges[j].range)) { + _range = printRanges[j].range.clone(); + pageBreakSelectionType = 2; + break; + } + } break; } } @@ -8781,34 +8789,7 @@ col: res.col, row: res.row, range: _range, - isPageBreakPreview: true - } : null; - }; - - WorksheetView.prototype._hitCursorPageBreakPreviewLines = function (vr, x, y, offsetX, offsetY) { - let oPrintPages = this.isPageBreakPreview(true) && this.pagesModeData; - let res = null; - let _range = null; - if (oPrintPages) { - let printRanges = this._getPageBreakPreviewRanges(oPrintPages); - if (printRanges) { - for (let i = 0; i < printRanges.length; i++) { - res = this._hitInRange(printRanges[i].range, - AscCommonExcel.selectionLineType.Resize, vr, x, y, offsetX, offsetY, true); - if (res) { - _range = printRanges[i].range.clone(); - break; - } - } - } - } - return res ? { - cursor: res.cursor, - target: c_oTargetType.MoveResizeRange, - col: res.col, - row: res.row, - range: _range, - isPageBreakPreview: true + pageBreakSelectionType: pageBreakSelectionType } : null; }; @@ -9272,11 +9253,6 @@ this._drawElements(function (_vr, _offsetX, _offsetY) { return (null === (res = this._hitCursorPageBreakPreviewRange(_vr, x, y, _offsetX, _offsetY))); }); - if (!res) { - this._drawElements(function (_vr, _offsetX, _offsetY) { - return (null === (res = this._hitCursorPageBreakPreviewLines(_vr, x, y, _offsetX, _offsetY))); - }); - } if (res) { return res; } @@ -12320,63 +12296,25 @@ }; WorksheetView.prototype.changePageBreakPreviewAreaHandle = function (x, y, targetInfo) { - if (!targetInfo || !targetInfo.range) { + if (!targetInfo) { return; } var _range = targetInfo.range; this.pageBreakPreviewSelectionRange = _range; if (null === this.startCellMoveResizeRange) { - return this._startResizePageBreakPreviewRangeHandle(x, y, targetInfo, _range); + this.startCellMoveResizeRange = _range.clone(true); + return; } return this._endResizePageBreakPreviewRangeHandle(x, y, targetInfo, _range).delta; }; - - WorksheetView.prototype._startResizePageBreakPreviewRangeHandle = function (x, y, targetInfo, range) { - var ar = range.clone(); - - // Колонка по X и строка по Y - var colByX = this._findColUnderCursor(x, /*canReturnNull*/false, false).col; - var rowByY = this._findRowUnderCursor(y, /*canReturnNull*/false, false).row; - - if ((targetInfo.cursor === kCurNEResize || targetInfo.cursor === kCurSEResize)) { - this.startCellMoveResizeRange = ar.clone(true); - } else { - this.startCellMoveResizeRange = ar.clone(true); - - if (colByX < ar.c1) { - colByX = ar.c1; - } else if (colByX > ar.c2) { - colByX = ar.c2; - } - if (rowByY < ar.r1) { - rowByY = ar.r1; - } else if (rowByY > ar.r2) { - rowByY = ar.r2; - } - } - - if (this.startCellMoveRange.colRowMoveProps && !this.targetInfo.range) { - this.startCellMoveResizeRange.colRowMoveProps = {}; - if (this.targetInfo.col !== -1) { - this.startCellMoveResizeRange.colRowMoveProps.colByX = this.targetInfo.col; - } else if (this.targetInfo.row !== -1) { - this.startCellMoveResizeRange.colRowMoveProps.rowByY = rowByY; - } - } - - return null; - }; - WorksheetView.prototype._endResizePageBreakPreviewRangeHandle = function (x, y, targetInfo, range) { var d = new AscCommon.CellBase(0, 0); var colByX = this._findColUnderCursor(x, /*canReturnNull*/false, false).col; var rowByY = this._findRowUnderCursor(y, /*canReturnNull*/false, false).row; - var type = this.startCellMoveResizeRange.getType(); var ar = range.clone(); - this.overlayCtx.clear(); if (targetInfo.cursor === kCurEWResize) { @@ -12432,7 +12370,7 @@ d.col = 1; } - type = this.startCellMoveResizeRange.getType(); + let type = this.startCellMoveResizeRange.getType(); if (type === c_oAscSelectionType.RangeRow) { d.col = 0; } else if (type === c_oAscSelectionType.RangeCol) { From 063d4d1e9541a6fb704970b7611c73bbe52d9f3d Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 6 Jul 2023 02:31:16 +0500 Subject: [PATCH 10/42] [se] Fix --- cell/view/WorksheetView.js | 98 ++++++++++++++++++++++---------------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 1db98a8a0f..e6742775fa 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -10760,8 +10760,12 @@ WorksheetView.prototype._drawPageBreakPreviewSelectionRange = function () { var range = this.pageBreakPreviewSelectionRange; - this._drawElements(this._drawSelectionElement, range, AscCommonExcel.selectionLineType.ResizeRange, - this.settings.activeCellBorderColor); + if (this.pageBreakPreviewSelectionRange.pageBreakSelectionType === 2) { + this._drawElements(this._drawLineBetweenRowCol, range.colByX, range.rowByY, this.settings.activeCellBorderColor, range, 2); + } else { + this._drawElements(this._drawSelectionElement, range, AscCommonExcel.selectionLineType.ResizeRange, + this.settings.activeCellBorderColor); + } }; WorksheetView.prototype.changeVisibleAreaStartPoint = function (x, y, isCtrl, isRelative) { @@ -12301,6 +12305,7 @@ } var _range = targetInfo.range; this.pageBreakPreviewSelectionRange = _range; + this.pageBreakPreviewSelectionRange.pageBreakSelectionType = targetInfo.pageBreakSelectionType; if (null === this.startCellMoveResizeRange) { this.startCellMoveResizeRange = _range.clone(true); return; @@ -12317,45 +12322,56 @@ this.overlayCtx.clear(); - if (targetInfo.cursor === kCurEWResize) { - if (this.startCellMoveResizeRange.c1 === targetInfo.col) { - //left border - ar.c1 = Math.min(colByX, this.startCellMoveResizeRange.c2); - } else if (this.startCellMoveResizeRange.c2 === targetInfo.col) { - //right border - ar.c2 = Math.max(colByX, this.startCellMoveResizeRange.c1); - } - } else if (targetInfo.cursor === kCurNSResize) { - if (this.startCellMoveResizeRange.r1 === targetInfo.row) { - //top border - ar.r1 = Math.min(rowByY, this.startCellMoveResizeRange.r2); - } else if (this.startCellMoveResizeRange.r2 === targetInfo.row) { - //bottom border - ar.r2 = Math.max(rowByY, this.startCellMoveResizeRange.r1); - } - } else if (targetInfo.cursor === kCurSEResize) { - //left up / right down - if (this.startCellMoveResizeRange.r1 === targetInfo.row) { - //right down - ar.c2 = Math.max(colByX, this.startCellMoveResizeRange.c1); - ar.r2 = Math.max(rowByY, this.startCellMoveResizeRange.r1); - } else if (this.startCellMoveResizeRange.r2 === targetInfo.row) { - //left up - ar.r1 = Math.min(rowByY, this.startCellMoveResizeRange.r2); - ar.c1 = Math.min(colByX, this.startCellMoveResizeRange.c2); - } - } else if (targetInfo.cursor === kCurNEResize) { - //right up / left down - if (this.startCellMoveResizeRange.r1 === targetInfo.row) { - //left down - ar.r2 = Math.max(rowByY, this.startCellMoveResizeRange.r1); - ar.c1 = Math.min(colByX, this.startCellMoveResizeRange.c2); - - } else if (this.startCellMoveResizeRange.r2 === targetInfo.row) { - //right up - ar.r1 = Math.min(rowByY, this.startCellMoveResizeRange.r2); - ar.c2 = Math.max(colByX, this.startCellMoveResizeRange.c1); + if (targetInfo.pageBreakSelectionType === 2) { + if (targetInfo.cursor === kCurEWResize) { + range.colByX = colByX; + ar.colByX = colByX; + } else { + range.rowByY = rowByY; + ar.rowByY = rowByY; + } + } else { + if (targetInfo.cursor === kCurEWResize) { + if (this.startCellMoveResizeRange.c1 === targetInfo.col) { + //left border + ar.c1 = Math.min(colByX, this.startCellMoveResizeRange.c2); + } else if (this.startCellMoveResizeRange.c2 === targetInfo.col) { + //right border + ar.c2 = Math.max(colByX, this.startCellMoveResizeRange.c1); + } + } else if (targetInfo.cursor === kCurNSResize) { + if (this.startCellMoveResizeRange.r1 === targetInfo.row) { + //top border + ar.r1 = Math.min(rowByY, this.startCellMoveResizeRange.r2); + } else if (this.startCellMoveResizeRange.r2 === targetInfo.row) { + //bottom border + ar.r2 = Math.max(rowByY, this.startCellMoveResizeRange.r1); + } + } else if (targetInfo.cursor === kCurSEResize) { + //left up / right down + if (this.startCellMoveResizeRange.r1 === targetInfo.row) { + //right down + ar.c2 = Math.max(colByX, this.startCellMoveResizeRange.c1); + ar.r2 = Math.max(rowByY, this.startCellMoveResizeRange.r1); + } else if (this.startCellMoveResizeRange.r2 === targetInfo.row) { + //left up + ar.r1 = Math.min(rowByY, this.startCellMoveResizeRange.r2); + ar.c1 = Math.min(colByX, this.startCellMoveResizeRange.c2); + } + } else if (targetInfo.cursor === kCurNEResize) { + //right up / left down + if (this.startCellMoveResizeRange.r1 === targetInfo.row) { + //left down + ar.r2 = Math.max(rowByY, this.startCellMoveResizeRange.r1); + ar.c1 = Math.min(colByX, this.startCellMoveResizeRange.c2); + + } else if (this.startCellMoveResizeRange.r2 === targetInfo.row) { + //right up + ar.r1 = Math.min(rowByY, this.startCellMoveResizeRange.r2); + ar.c2 = Math.max(colByX, this.startCellMoveResizeRange.c1); + } } + ar = range.assign2(ar.clone(true)); } if (y <= this.cellsTop + 2) { @@ -12379,7 +12395,7 @@ d.col = 0; d.row = 0; } - ar = range.assign2(ar.clone(true)); + this._drawSelection(); return {range: ar, delta: d}; From a394564865c82709388f58d8f336b6507f7d146e Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 6 Jul 2023 11:33:30 +0500 Subject: [PATCH 11/42] [se] By change row/col breaks --- cell/view/WorksheetView.js | 61 ++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index e6742775fa..d035311d88 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -12308,6 +12308,15 @@ this.pageBreakPreviewSelectionRange.pageBreakSelectionType = targetInfo.pageBreakSelectionType; if (null === this.startCellMoveResizeRange) { this.startCellMoveResizeRange = _range.clone(true); + + if (targetInfo.pageBreakSelectionType === 2) { + if (targetInfo.cursor === kCurEWResize) { + this.startCellMoveResizeRange.colByX = targetInfo.col + 1; + } else { + this.startCellMoveResizeRange.rowByY = targetInfo.row + 1; + } + } + return; } return this._endResizePageBreakPreviewRangeHandle(x, y, targetInfo, _range).delta; @@ -12600,12 +12609,26 @@ WorksheetView.prototype.applyResizePageBreakPreviewRangeHandle = function () { let fromRange = this.startCellMoveResizeRange; let toRange = this.pageBreakPreviewSelectionRange; - if (!this.getFormulaEditMode() && !fromRange.isEqual(toRange)) { - var printArea = this.model.workbook.getDefinesNames("Print_Area", this.model.getId()); - if(printArea && printArea.sheetId === this.model.getId()) { - this.changePrintArea(Asc.c_oAscChangePrintAreaType.change, [toRange], [fromRange]) - } else { - this.changePrintArea(Asc.c_oAscChangePrintAreaType.set, [toRange]); + if (!this.getFormulaEditMode()) { + if (this.pageBreakPreviewSelectionRange.pageBreakSelectionType === 2) { + //change page breaks + if (toRange.colByX) { + if (toRange.colByX !== fromRange.colByX) { + this.changeRowColBreaks(fromRange.colByX, toRange.colByX, fromRange, true) + } + } else { + if (toRange.rowByY !== fromRange.rowByY) { + this.changeRowColBreaks(fromRange.rowByY, toRange.rowByY, fromRange) + } + } + } else if (!fromRange.isEqual(toRange)) { + //change all area + var printArea = this.model.workbook.getDefinesNames("Print_Area", this.model.getId()); + if(printArea && printArea.sheetId === this.model.getId()) { + this.changePrintArea(Asc.c_oAscChangePrintAreaType.change, [toRange], [fromRange]) + } else { + this.changePrintArea(Asc.c_oAscChangePrintAreaType.set, [toRange]); + } } } @@ -21366,6 +21389,32 @@ return res; }; + WorksheetView.prototype.changeRowColBreaks = function (form, to, byCol, range) { + var t = this; + + var onChangePrintTitles = function (isSuccess) { + if (false === isSuccess) { + return; + } + + History.Create_NewPoint(); + History.StartTransaction(); + + //t._changePrintTitles(cols, rows); + //t.changeViewPrintLines(true); + + if(t.viewPrintLines) { + t.updateSelection(); + } + window["Asc"]["editor"]._onUpdateLayoutMenu(t.model.Id); + + History.EndTransaction(); + }; + + //лочу по аналогии со всеми опциями из print settings + this._isLockedLayoutOptions(onChangePrintTitles); + }; + WorksheetView.prototype.changePrintTitles = function (cols, rows) { var t = this; From 2955692763b383eaa9768d7530faa61184d800b2 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 6 Jul 2023 13:10:32 +0500 Subject: [PATCH 12/42] [se] Add change breaks functions --- cell/model/Workbook.js | 22 ++++++++- cell/model/WorkbookElems.js | 90 ++++++++++++++++++++++++++++++++++--- cell/view/WorksheetView.js | 16 ++++--- 3 files changed, 116 insertions(+), 12 deletions(-) diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 15c4a6f45b..49bafb5cc2 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11812,7 +11812,27 @@ return printProps.getJson(this); }; - + Worksheet.prototype.changeRowColBreaks = function (from, to, range, byCol, addToHistory) { + let rowColBreaks, notContains; + if (byCol) { + if (!this.rowBreaks) { + this.rowBreaks = new AscCommonExcel.CRowColBreaks(); + notContains = true; + } + rowColBreaks = this.rowBreaks; + } else { + if (!this.colBreaks) { + this.colBreaks = new AscCommonExcel.CRowColBreaks(); + notContains = true; + } + rowColBreaks = this.colBreaks; + } + if (!notContains && rowColBreaks.containsBreak(from)) { + rowColBreaks.changeBreak(from, to); + } else { + rowColBreaks.addBreak(from, to) + } + }; Worksheet.prototype.addCellWatch = function (ref, addToHistory) { for (var i = 0; i < this.aCellWatches.length; i++) { diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 483cd1cff0..1ccb0068db 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15563,16 +15563,70 @@ QueryTableField.prototype.clone = function() { }; CRowColBreaks.prototype.forEach = function (callback) { for (var i = 0, l = this.breaks.length; i < l; ++i) { - callback(this.breaks[i], i); + if (callback(this.breaks[i], i)) { + break; + } + } + }; + CRowColBreaks.prototype.containsBreak = function (id) { + let res = false; + this.forEach(function (breaksElem) { + if (breaksElem.id === id) { + res = true; + return true; + } + }); + return res; + }; + CRowColBreaks.prototype.getBreak = function (id) { + let res = null; + this.forEach(function (breaksElem) { + if (breaksElem.id === id) { + res = breaksElem; + return true; + } + }); + return res; + }; + CRowColBreaks.prototype.changeBreak = function (idFrom, idTo, min, max, man, pt, addToHistory) { + let breakElem = this.getBreak(idFrom); + if (breakElem) { + let isChanged = breakElem.set(idTo, min, max, man, pt); + if (isChanged && addToHistory) { + + } + } + }; + CRowColBreaks.prototype.addBreak = function (id, min, max, man, pt, addToHistory) { + let newBreak = new CBreak(); + newBreak.set(id, min, max, man, pt); + + this._addBreak(newBreak); + + if (addToHistory) { + + } + }; + + CRowColBreaks.prototype.addBreak = function (newBreak) { + newBreak.push(newBreak); + if (this.manualBreakCount === null) { + this.manualBreakCount = 0; + } + if (this.count === null) { + this.count = 0; } + this.manualBreakCount++; + this.count++; }; function CBreak(/*ws*/) { this.id = null; - this.man = null; - this.max = null; this.min = null; + this.max = null; + + this.man = null; this.pt = null; return this; @@ -15580,9 +15634,11 @@ QueryTableField.prototype.clone = function() { CBreak.prototype.clone = function () { var res = new CBreak(); res.id = this.id; - res.man = this.man; - res.max = this.max; + res.min = this.min; + res.max = this.max; + + res.man = this.man; res.pt = this.pt; return res; @@ -15620,6 +15676,30 @@ QueryTableField.prototype.clone = function() { CBreak.prototype.isBreak = function (index) { return this.id === index; }; + CBreak.prototype.set = function (id, min, max, man, pt) { + let isChanged = false; + if (id !== this.getId()) { + this.setId(id); + isChanged = true; + } + if (min !== this.getMin()) { + this.setMin(min); + isChanged = true; + } + if (max !== this.getMax()) { + this.setMax(max); + isChanged = true; + } + if (man !== this.getMan()) { + this.setMan(man); + isChanged = true; + } + if (pt !== this.getPt()) { + this.setPt(pt); + isChanged = true; + } + return isChanged; + }; diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index d035311d88..f4ca1bc926 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -21389,10 +21389,14 @@ return res; }; - WorksheetView.prototype.changeRowColBreaks = function (form, to, byCol, range) { + WorksheetView.prototype.changeRowColBreaks = function (from, to, range, byCol) { var t = this; - var onChangePrintTitles = function (isSuccess) { + if (from === -1 || to === -1) { + return; + } + + var onChangeCallback = function (isSuccess) { if (false === isSuccess) { return; } @@ -21400,8 +21404,8 @@ History.Create_NewPoint(); History.StartTransaction(); - //t._changePrintTitles(cols, rows); - //t.changeViewPrintLines(true); + t.model.changeRowColBreaks(from, to, range, byCol, true) + t.changeViewPrintLines(true); if(t.viewPrintLines) { t.updateSelection(); @@ -21411,8 +21415,8 @@ History.EndTransaction(); }; - //лочу по аналогии со всеми опциями из print settings - this._isLockedLayoutOptions(onChangePrintTitles); + //do lock print settings + this._isLockedLayoutOptions(onChangeCallback); }; WorksheetView.prototype.changePrintTitles = function (cols, rows) { From e7024587ea2854a09ea467d24bd59e5550f603cb Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 6 Jul 2023 13:38:50 +0500 Subject: [PATCH 13/42] [se] Fix --- cell/model/Workbook.js | 26 +++++++++++++++++++++++--- cell/model/WorkbookElems.js | 4 ++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 49bafb5cc2..238d7d4bfc 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11813,8 +11813,26 @@ }; Worksheet.prototype.changeRowColBreaks = function (from, to, range, byCol, addToHistory) { + let min = null; + let max = byCol ? gc_nMaxCol0 : gc_nMaxRow0; + + let printArea = this.workbook.getDefinesNames("Print_Area", this.getId()); + if (printArea) { + if (byCol) { + min = range.r1; + max = range.r2; + } else { + min = range.c1; + max = range.c2; + } + } + + this._changeRowColBreaks(from, to, min, max, byCol, addToHistory); + }; + + Worksheet.prototype._changeRowColBreaks = function (from, to, min, max, byCol, addToHistory) { let rowColBreaks, notContains; - if (byCol) { + if (!byCol) { if (!this.rowBreaks) { this.rowBreaks = new AscCommonExcel.CRowColBreaks(); notContains = true; @@ -11828,10 +11846,12 @@ rowColBreaks = this.colBreaks; } if (!notContains && rowColBreaks.containsBreak(from)) { - rowColBreaks.changeBreak(from, to); + rowColBreaks.changeBreak(from, to, min, max, true, null, addToHistory); } else { - rowColBreaks.addBreak(from, to) + rowColBreaks.addBreak(to, min, max, true, null, addToHistory) } + + this.workbook.handlers.trigger("onChangePageSetupProps", this.getId()); }; Worksheet.prototype.addCellWatch = function (ref, addToHistory) { diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 1ccb0068db..645382f1ea 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15608,8 +15608,8 @@ QueryTableField.prototype.clone = function() { } }; - CRowColBreaks.prototype.addBreak = function (newBreak) { - newBreak.push(newBreak); + CRowColBreaks.prototype._addBreak = function (newBreak) { + this.breaks.push(newBreak); if (this.manualBreakCount === null) { this.manualBreakCount = 0; } From 5a058df71fdae512b3591fbefac100e0ba2da104 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 6 Jul 2023 16:53:06 +0500 Subject: [PATCH 14/42] [se] Fix --- cell/view/WorksheetView.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index f4ca1bc926..a4e5c08052 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -4857,12 +4857,34 @@ let widthLine = 3; if (this.model.colBreaks && !bFitToWidth) { this.model.colBreaks.forEach(function (colBreak) { - t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color, allPagesRange, widthLine); + if (printRanges.length > 1) { + let _colBreakRange = new Asc.Range(colBreak.id, colBreak.min != null ? colBreak.min : 0, colBreak.id, colBreak.max != null ? colBreak.max : gc_nMaxCol0); + for (let i = 0; i < printRanges.length; i++) { + //if intersection with range between min/max -> draw line + if (printRanges[i].range.intersection(_colBreakRange)) { + t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color, printRanges[i].range, widthLine); + break; + } + } + } else { + t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color, allPagesRange, widthLine); + } }); } if (this.model.rowBreaks && !bFitToHeight) { this.model.rowBreaks.forEach(function (rowBreak) { - t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color, allPagesRange, widthLine); + if (printRanges.length > 1) { + let _rowBreakRange = new Asc.Range(rowBreak.min != null ? rowBreak.min : 0, rowBreak.id, rowBreak.max != null ? rowBreak.max : gc_nMaxRow0, rowBreak.id); + for (let i = 0; i < printRanges.length; i++) { + //if intersection with range between min/max -> draw line + if (printRanges[i].range.intersection(_rowBreakRange)) { + t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color, printRanges[i].range, widthLine); + break; + } + } + } else { + t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color, allPagesRange, widthLine); + } }); } } From 8d0520c5e77b1dd2702e04cd65df16f293ae4ff6 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 6 Jul 2023 17:48:58 +0500 Subject: [PATCH 15/42] [se] Fix --- cell/view/WorksheetView.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index a4e5c08052..1eb5918a15 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -4827,16 +4827,19 @@ return; } - let t = this; + const t = this; + + const color = new CColor(0, 0, 208); + const printRanges = this._getPageBreakPreviewRanges(oPrintPages); + const lineType = AscCommonExcel.selectionLineType.ResizeRange; + const dashLineType = AscCommonExcel.selectionLineType.Dash | lineType; + const widthLine = 3; + let oPrintPages = this.pagesModeData; let allPagesRange; //рисуем страницы let printPages = oPrintPages && oPrintPages.printPages; if(printPages && printPages.length) { - let color = new CColor(0, 0, 208); - let printRanges = this._getPageBreakPreviewRanges(oPrintPages); - let lineType = AscCommonExcel.selectionLineType.ResizeRange; - let dashLineType = AscCommonExcel.selectionLineType.Dash | lineType; for (let i = 0; i < printRanges.length; i++) { let oPrintRange = printRanges[i]; allPagesRange = oPrintRange.range; @@ -4854,7 +4857,6 @@ let bFitToWidth = pageSetup && pageSetup.asc_getFitToWidth(); let bFitToHeight = pageSetup && pageSetup.asc_getFitToHeight(); - let widthLine = 3; if (this.model.colBreaks && !bFitToWidth) { this.model.colBreaks.forEach(function (colBreak) { if (printRanges.length > 1) { From 281a70fab0f09a0cbe20ea87f22be48562420315 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 7 Jul 2023 13:00:02 +0500 Subject: [PATCH 16/42] [se] Fix --- cell/model/WorkbookElems.js | 20 +++++++++--- cell/view/WorksheetView.js | 63 +++++++++++++++++++------------------ 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 645382f1ea..b8fdcbb260 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15551,10 +15551,10 @@ QueryTableField.prototype.clone = function() { CRowColBreaks.prototype.getBreaks = function () { return this.breaks; }; - CRowColBreaks.prototype.isBreak = function (index) { + CRowColBreaks.prototype.isBreak = function (index, opt_min, opt_max) { if (this.count > 0) { for (let i = 0; i < this.breaks.length; i++) { - if (this.breaks[i].isBreak(index)) { + if (this.breaks[i].isBreak(index, opt_min, opt_max)) { return true; } } @@ -15673,8 +15673,20 @@ QueryTableField.prototype.clone = function() { CBreak.prototype.getPt = function () { return this.pt; }; - CBreak.prototype.isBreak = function (index) { - return this.id === index; + CBreak.prototype.isBreak = function (index, opt_min, opt_max) { + let res = this.id === index; + if (res) { + if (opt_min != null && opt_max != null) { + if (this.min == null && this.max == null) { + res = false; + } else { + if (this.min > opt_max || this.max < opt_min) { + res = false; + } + } + } + } + return res; }; CBreak.prototype.set = function (id, min, max, man, pt) { let isChanged = false; diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 1eb5918a15..f2b4e36378 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -2101,7 +2101,7 @@ }; // ----- Drawing for print ----- - WorksheetView.prototype._calcPagesPrint = function(range, pageOptions, indexWorksheet, arrPages, printScale, adjustPrint) { + WorksheetView.prototype._calcPagesPrint = function(range, pageOptions, indexWorksheet, arrPages, printScale, adjustPrint, bPrintArea) { if (0 > range.r2 || 0 > range.c2) { // Ничего нет return; @@ -2350,7 +2350,7 @@ for (rowIndex = currentRowIndex; rowIndex <= range.r2; ++rowIndex) { let currentRowHeight = _getRowHeight(rowIndex) * scale; let currentRowHeightReal = (t._getRowHeight(rowIndex)/this.getRetinaPixelRatio()) *scale; - rowBreak = !bFitToHeight && rowIndex !== currentRowIndex && t.model.rowBreaks && t.model.rowBreaks.isBreak(rowIndex); + rowBreak = !bFitToHeight && rowIndex !== currentRowIndex && t.model.rowBreaks && t.model.rowBreaks.isBreak(rowIndex, bPrintArea && range.c1, bPrintArea && range.c2); if ((currentHeight + currentRowHeight + curTitleHeight > pageHeightWithFieldsHeadings && rowIndex !== currentRowIndex) || rowBreak) { // Закончили рисовать страницу @@ -2379,7 +2379,7 @@ currentColWidth -= newPagePrint.startOffsetPx; } - colBreak = !bFitToWidth && colIndex !== currentColIndex && t.model.colBreaks && t.model.colBreaks.isBreak(colIndex); + colBreak = !bFitToWidth && colIndex !== currentColIndex && t.model.colBreaks && t.model.colBreaks.isBreak(colIndex, bPrintArea && range.r1, bPrintArea && range.r2); if ((currentWidth + currentColWidth + curTitleWidth > pageWidthWithFieldsHeadings && colIndex !== currentColIndex) || colBreak) { curTitleWidth = addedTitleWidth; @@ -2650,7 +2650,7 @@ } let _startPages = arrPages.length; - this._calcPagesPrint(range, pageOptions, indexWorksheet, arrPages, tempPrintScale, adjustPrint); + this._calcPagesPrint(range, pageOptions, indexWorksheet, arrPages, tempPrintScale, adjustPrint, true); if(arrRanges) { arrRanges.push({range: range, start: _startPages, end: arrPages.length}); @@ -4829,16 +4829,17 @@ const t = this; + const printArea = this.model.workbook.getDefinesNames("Print_Area", this.model.getId()); + const oPrintPages = this.pagesModeData; + const printPages = oPrintPages && oPrintPages.printPages; const color = new CColor(0, 0, 208); const printRanges = this._getPageBreakPreviewRanges(oPrintPages); const lineType = AscCommonExcel.selectionLineType.ResizeRange; const dashLineType = AscCommonExcel.selectionLineType.Dash | lineType; const widthLine = 3; - let oPrintPages = this.pagesModeData; let allPagesRange; //рисуем страницы - let printPages = oPrintPages && oPrintPages.printPages; if(printPages && printPages.length) { for (let i = 0; i < printRanges.length; i++) { let oPrintRange = printRanges[i]; @@ -4857,36 +4858,38 @@ let bFitToWidth = pageSetup && pageSetup.asc_getFitToWidth(); let bFitToHeight = pageSetup && pageSetup.asc_getFitToHeight(); + let doDrawBreaks = function (_break, _byCol) { + if (!printArea) { + t._drawElements(t._drawLineBetweenRowCol, _byCol && _break.id, !_byCol && _break.id, color, allPagesRange, widthLine); + return; + } + if (_break.min === null && _break.max === null) { + return; + } + + let _range; + if (_byCol) { + _range = new Asc.Range(_break.id, _break.min != null ? _break.min : 0, _break.id, _break.max != null ? _break.max : gc_nMaxCol0); + } else { + _range = new Asc.Range(_break.min != null ? _break.min : 0, _break.id, _break.max != null ? _break.max : gc_nMaxRow0, _break.id); + } + + for (let i = 0; i < printRanges.length; i++) { + //if intersection with range between min/max -> draw line + if (printRanges[i].range.intersection(_range)) { + t._drawElements(t._drawLineBetweenRowCol, _byCol && _break.id, !_byCol && _break.id, color, printRanges[i].range, widthLine); + } + } + }; + if (this.model.colBreaks && !bFitToWidth) { this.model.colBreaks.forEach(function (colBreak) { - if (printRanges.length > 1) { - let _colBreakRange = new Asc.Range(colBreak.id, colBreak.min != null ? colBreak.min : 0, colBreak.id, colBreak.max != null ? colBreak.max : gc_nMaxCol0); - for (let i = 0; i < printRanges.length; i++) { - //if intersection with range between min/max -> draw line - if (printRanges[i].range.intersection(_colBreakRange)) { - t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color, printRanges[i].range, widthLine); - break; - } - } - } else { - t._drawElements(t._drawLineBetweenRowCol, colBreak.id, null, color, allPagesRange, widthLine); - } + doDrawBreaks(colBreak, true); }); } if (this.model.rowBreaks && !bFitToHeight) { this.model.rowBreaks.forEach(function (rowBreak) { - if (printRanges.length > 1) { - let _rowBreakRange = new Asc.Range(rowBreak.min != null ? rowBreak.min : 0, rowBreak.id, rowBreak.max != null ? rowBreak.max : gc_nMaxRow0, rowBreak.id); - for (let i = 0; i < printRanges.length; i++) { - //if intersection with range between min/max -> draw line - if (printRanges[i].range.intersection(_rowBreakRange)) { - t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color, printRanges[i].range, widthLine); - break; - } - } - } else { - t._drawElements(t._drawLineBetweenRowCol, null, rowBreak.id, color, allPagesRange, widthLine); - } + doDrawBreaks(rowBreak); }); } } From 79994acd6459a661fbc48c7002980688127eaa3a Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 7 Jul 2023 13:23:11 +0500 Subject: [PATCH 17/42] [se] Fix --- cell/view/WorksheetView.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index f2b4e36378..14bf17fb88 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -4867,17 +4867,11 @@ return; } - let _range; - if (_byCol) { - _range = new Asc.Range(_break.id, _break.min != null ? _break.min : 0, _break.id, _break.max != null ? _break.max : gc_nMaxCol0); - } else { - _range = new Asc.Range(_break.min != null ? _break.min : 0, _break.id, _break.max != null ? _break.max : gc_nMaxRow0, _break.id); - } - for (let i = 0; i < printRanges.length; i++) { //if intersection with range between min/max -> draw line - if (printRanges[i].range.intersection(_range)) { - t._drawElements(t._drawLineBetweenRowCol, _byCol && _break.id, !_byCol && _break.id, color, printRanges[i].range, widthLine); + let printRange = printRanges[i].range; + if (_break.isBreak(_break.id, _byCol ? printRange.r1 : printRange.c1, _byCol ? printRange.r2 : printRange.c2)) { + t._drawElements(t._drawLineBetweenRowCol, _byCol && _break.id, !_byCol && _break.id, color, printRange, widthLine); } } }; From 0514fe1ca93e16629c29dc728c79746b54d61437 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 7 Jul 2023 16:33:32 +0500 Subject: [PATCH 18/42] [se] Insert page break --- cell/api.js | 31 +++++++++++++++++ cell/model/Workbook.js | 23 ++++++++++++- cell/view/WorksheetView.js | 68 +++++++++++++++++++++++++++++++++++++- 3 files changed, 120 insertions(+), 2 deletions(-) diff --git a/cell/api.js b/cell/api.js index 5151838cec..5922e9fc6b 100644 --- a/cell/api.js +++ b/cell/api.js @@ -5882,6 +5882,9 @@ var editor; }; spreadsheet_api.prototype.asc_setCellBold = function(isBold) { + this.asc_InsertPageBreak(); + return; + var ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellBold) { ws.objectRender.controller.setCellBold(isBold); @@ -8763,6 +8766,34 @@ var editor; return res == null ? AscCommonExcel.ESheetViewType.normal : res; }; + spreadsheet_api.prototype.asc_InsertPageBreak = function() { + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + let wb = this.wb; + if (!wb) { + return; + } + var ws = this.wb.getWorksheet(); + return ws && ws.insertPageBreak(); + }; + + spreadsheet_api.prototype.asc_RemovePageBreak = function() { + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + let wb = this.wb; + if (!wb) { + return; + } + var ws = this.wb.getWorksheet(); + return ws.removePageBreak(); + }; + + spreadsheet_api.prototype.asc_ResetAllPageBreaks = function() { + + }; + /* * Export * ----------------------------------------------------------------------------- diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 238d7d4bfc..3175de68ae 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11817,7 +11817,7 @@ let max = byCol ? gc_nMaxCol0 : gc_nMaxRow0; let printArea = this.workbook.getDefinesNames("Print_Area", this.getId()); - if (printArea) { + if (printArea && range) { if (byCol) { min = range.r1; max = range.r2; @@ -11854,6 +11854,27 @@ this.workbook.handlers.trigger("onChangePageSetupProps", this.getId()); }; + Worksheet.prototype.getPrintAreaRangeByRowCol = function (row, col) { + let printArea = this.workbook.getDefinesNames("Print_Area", this.getId()); + let t = this; + + if (printArea) { + let ranges; + AscCommonExcel.executeInR1C1Mode(false, function () { + ranges = AscCommonExcel.getRangeByRef(printArea.ref, t, true, true) + }); + if (ranges) { + for (let i = 0; i < ranges.length; i++) { + if (ranges[i].bbox.contains(col, row)) { + return ranges[i].bbox; + } + } + } + } + + return null; + }; + Worksheet.prototype.addCellWatch = function (ref, addToHistory) { for (var i = 0; i < this.aCellWatches.length; i++) { if (ref.isEqual(this.aCellWatches[i].r)) { diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 14bf17fb88..21478bc49e 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -21425,7 +21425,73 @@ History.Create_NewPoint(); History.StartTransaction(); - t.model.changeRowColBreaks(from, to, range, byCol, true) + t.model.changeRowColBreaks(from, to, range, byCol, true); + t.changeViewPrintLines(true); + + if(t.viewPrintLines) { + t.updateSelection(); + } + window["Asc"]["editor"]._onUpdateLayoutMenu(t.model.Id); + + History.EndTransaction(); + }; + + //do lock print settings + this._isLockedLayoutOptions(onChangeCallback); + }; + + WorksheetView.prototype.insertPageBreak = function () { + let t = this; + + //TODO check need change?(if added already by col and row) + + let onChangeCallback = function (isSuccess) { + if (false === isSuccess) { + return; + } + + History.Create_NewPoint(); + History.StartTransaction(); + + let activeCell = t.model.getSelection().activeCell; + let range = t.model.getPrintAreaRangeByRowCol(activeCell.row, activeCell.col); + + t.model.changeRowColBreaks(null, activeCell.row, range, null, true); + t.model.changeRowColBreaks(null, activeCell.col, range, true, true); + + t.changeViewPrintLines(true); + + if(t.viewPrintLines) { + t.updateSelection(); + } + window["Asc"]["editor"]._onUpdateLayoutMenu(t.model.Id); + + History.EndTransaction(); + }; + + //do lock print settings + this._isLockedLayoutOptions(onChangeCallback); + }; + + WorksheetView.prototype.removePageBreak = function () { + let t = this; + + + + let onChangeCallback = function (isSuccess) { + if (false === isSuccess) { + return; + } + + History.Create_NewPoint(); + History.StartTransaction(); + + let activeCell = t.model.getSelection().activeCell; + let range = t.model.getPrintAreaRangeByRowCol(activeCell.row, activeCell.col); + + t.model.changeRowColBreaks(null, activeCell.row, range, null, true); + t.model.changeRowColBreaks(null, activeCell.col, range, true, true); + t.changeViewPrintLines(true); if(t.viewPrintLines) { From e904bd0e83ff7b7f32c1247ee7352f8dba87cde6 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 7 Jul 2023 17:42:53 +0500 Subject: [PATCH 19/42] [se] Remove page break --- cell/api.js | 3 +++ cell/model/Workbook.js | 42 ++++++++++++++++++++++++------------- cell/model/WorkbookElems.js | 15 ++++++++++++- cell/view/WorksheetView.js | 6 +++--- 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/cell/api.js b/cell/api.js index 5922e9fc6b..05d833a39d 100644 --- a/cell/api.js +++ b/cell/api.js @@ -5895,6 +5895,9 @@ var editor; }; spreadsheet_api.prototype.asc_setCellItalic = function(isItalic) { + this.asc_RemovePageBreak() + return; + var ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellItalic) { ws.objectRender.controller.setCellItalic(isItalic); diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 3175de68ae..ffd5b5ba2e 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11831,23 +11831,35 @@ }; Worksheet.prototype._changeRowColBreaks = function (from, to, min, max, byCol, addToHistory) { - let rowColBreaks, notContains; - if (!byCol) { - if (!this.rowBreaks) { - this.rowBreaks = new AscCommonExcel.CRowColBreaks(); - notContains = true; + let t = this; + let rowColBreaks = !byCol ? t.rowBreaks : t.colBreaks; + + let checkInit = function () { + if (!byCol) { + if (!t.rowBreaks) { + t.rowBreaks = new AscCommonExcel.CRowColBreaks(); + rowColBreaks = t.rowBreaks; + } + } else { + if (!t.colBreaks) { + t.colBreaks = new AscCommonExcel.CRowColBreaks(); + rowColBreaks = t.colBreaks; + } } - rowColBreaks = this.rowBreaks; - } else { - if (!this.colBreaks) { - this.colBreaks = new AscCommonExcel.CRowColBreaks(); - notContains = true; + }; + + + if (rowColBreaks.containsBreak(from, min, max)) { + if (to) { + //change + checkInit(); + rowColBreaks.changeBreak(from, to, min, max, true, null, addToHistory); + } else { + //delete + rowColBreaks && rowColBreaks.removeBreak(from, min, max, addToHistory); } - rowColBreaks = this.colBreaks; - } - if (!notContains && rowColBreaks.containsBreak(from)) { - rowColBreaks.changeBreak(from, to, min, max, true, null, addToHistory); - } else { + } else if (to) { + //add rowColBreaks.addBreak(to, min, max, true, null, addToHistory) } diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index b8fdcbb260..c248d64189 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15568,7 +15568,7 @@ QueryTableField.prototype.clone = function() { } } }; - CRowColBreaks.prototype.containsBreak = function (id) { + CRowColBreaks.prototype.containsBreak = function (id, min, max) { let res = false; this.forEach(function (breaksElem) { if (breaksElem.id === id) { @@ -15620,6 +15620,19 @@ QueryTableField.prototype.clone = function() { this.count++; }; + CRowColBreaks.prototype.removeBreak = function (id, min, max, addToHistory) { + for (let i = 0; i < this.breaks.length; i++) { + if (this.breaks[i].isBreak(id, min, max)) { + this.breaks.splice(i, 1); + + if (addToHistory) { + + } + break; + } + } + }; + function CBreak(/*ws*/) { this.id = null; diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 21478bc49e..fb1c0bf507 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -21476,7 +21476,7 @@ WorksheetView.prototype.removePageBreak = function () { let t = this; - + let onChangeCallback = function (isSuccess) { if (false === isSuccess) { @@ -21489,8 +21489,8 @@ let activeCell = t.model.getSelection().activeCell; let range = t.model.getPrintAreaRangeByRowCol(activeCell.row, activeCell.col); - t.model.changeRowColBreaks(null, activeCell.row, range, null, true); - t.model.changeRowColBreaks(null, activeCell.col, range, true, true); + t.model.changeRowColBreaks(activeCell.row, null, range, null, true); + t.model.changeRowColBreaks(activeCell.col, null, range, true, true); t.changeViewPrintLines(true); From 9c24fe20c0eed407abd757d792f467f9bbd30e53 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 7 Jul 2023 18:58:38 +0500 Subject: [PATCH 20/42] [se] Remove all --- cell/api.js | 15 +++++++++++++-- cell/model/Workbook.js | 25 ++++++++++++++++++++++++- cell/model/WorkbookElems.js | 3 +++ cell/view/WorksheetView.js | 29 +++++++++++++++++++++++++++-- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/cell/api.js b/cell/api.js index 05d833a39d..581bb92b50 100644 --- a/cell/api.js +++ b/cell/api.js @@ -5908,7 +5908,10 @@ var editor; }; spreadsheet_api.prototype.asc_setCellUnderline = function(isUnderline) { - var ws = this.wb.getWorksheet(); + this.asc_ResetAllPageBreaks() + return; + + var ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellUnderline) { ws.objectRender.controller.setCellUnderline(isUnderline); } else { @@ -8794,7 +8797,15 @@ var editor; }; spreadsheet_api.prototype.asc_ResetAllPageBreaks = function() { - + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + let wb = this.wb; + if (!wb) { + return; + } + var ws = this.wb.getWorksheet(); + return ws.resetAllPageBreaks(); }; /* diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index ffd5b5ba2e..06fc7e2726 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11848,7 +11848,6 @@ } }; - if (rowColBreaks.containsBreak(from, min, max)) { if (to) { //change @@ -11866,6 +11865,30 @@ this.workbook.handlers.trigger("onChangePageSetupProps", this.getId()); }; + Worksheet.prototype.resetAllPageBreaks = function () { + let t = this; + + let doRemoveBreaks = function(_breaks) { + if (!_breaks) { + return; + } + let aBreaks = _breaks.getBreaks(); + for (let i = 0; i < aBreaks.length; i++) { + if (_breaks.removeBreak(aBreaks[i].id)) { + i--; + } + } + }; + + if (this.rowBreaks) { + doRemoveBreaks(this.rowBreaks); + } + if (this.colBreaks) { + doRemoveBreaks(this.colBreaks); + } + this.workbook.handlers.trigger("onChangePageSetupProps", this.getId()); + }; + Worksheet.prototype.getPrintAreaRangeByRowCol = function (row, col) { let printArea = this.workbook.getDefinesNames("Print_Area", this.getId()); let t = this; diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index c248d64189..ace6a91fb3 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15621,9 +15621,11 @@ QueryTableField.prototype.clone = function() { }; CRowColBreaks.prototype.removeBreak = function (id, min, max, addToHistory) { + let isDeleted = false; for (let i = 0; i < this.breaks.length; i++) { if (this.breaks[i].isBreak(id, min, max)) { this.breaks.splice(i, 1); + isDeleted = true; if (addToHistory) { @@ -15631,6 +15633,7 @@ QueryTableField.prototype.clone = function() { break; } } + return isDeleted; }; diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index fb1c0bf507..5a66c73169 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -21476,8 +21476,6 @@ WorksheetView.prototype.removePageBreak = function () { let t = this; - - let onChangeCallback = function (isSuccess) { if (false === isSuccess) { return; @@ -21506,6 +21504,33 @@ this._isLockedLayoutOptions(onChangeCallback); }; + WorksheetView.prototype.resetAllPageBreaks = function () { + let t = this; + + let onChangeCallback = function (isSuccess) { + if (false === isSuccess) { + return; + } + + History.Create_NewPoint(); + History.StartTransaction(); + + t.model.resetAllPageBreaks(); + + t.changeViewPrintLines(true); + + if(t.viewPrintLines) { + t.updateSelection(); + } + window["Asc"]["editor"]._onUpdateLayoutMenu(t.model.Id); + + History.EndTransaction(); + }; + + //do lock print settings + this._isLockedLayoutOptions(onChangeCallback); + }; + WorksheetView.prototype.changePrintTitles = function (cols, rows) { var t = this; From 5da5cc8dbdb5d5fdec109695281323acffb5d188 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 7 Jul 2023 19:00:52 +0500 Subject: [PATCH 21/42] [se] Export --- cell/api.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cell/api.js b/cell/api.js index 581bb92b50..934cd1781e 100644 --- a/cell/api.js +++ b/cell/api.js @@ -9373,6 +9373,9 @@ var editor; prot["asc_ChangeTextCase"] = prot.asc_ChangeTextCase; + prot["asc_InsertPageBreak"] = prot.asc_InsertPageBreak; + prot["asc_RemovePageBreak"] = prot.asc_RemovePageBreak; + prot["asc_ResetAllPageBreaks"] = prot.asc_ResetAllPageBreaks; From f82b09548d54a4befdf74ebb4382e429937037bd Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Mon, 10 Jul 2023 11:49:12 +0500 Subject: [PATCH 22/42] [se] By tests --- cell/model/Workbook.js | 3 +- .../spreadsheet-calculation/PrintTests.js | 72 ++++++++++++++++++- 2 files changed, 73 insertions(+), 2 deletions(-) diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 06fc7e2726..09fe424f14 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11848,7 +11848,7 @@ } }; - if (rowColBreaks.containsBreak(from, min, max)) { + if (rowColBreaks && rowColBreaks.containsBreak(from, min, max)) { if (to) { //change checkInit(); @@ -11859,6 +11859,7 @@ } } else if (to) { //add + checkInit(); rowColBreaks.addBreak(to, min, max, true, null, addToHistory) } diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index cee5b88afc..55ab6a76b0 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -45,7 +45,33 @@ $(function() { AscCommon.baseEditorsApi.prototype._onEndLoadSdk.call(this); }; Asc.spreadsheet_api.prototype.initGlobalObjects = function(wbModel) { + AscCommonExcel.g_oUndoRedoCell = new AscCommonExcel.UndoRedoCell(wbModel); + AscCommonExcel.g_oUndoRedoWorksheet = new AscCommonExcel.UndoRedoWoorksheet(wbModel); + AscCommonExcel.g_oUndoRedoWorkbook = new AscCommonExcel.UndoRedoWorkbook(wbModel); + AscCommonExcel.g_oUndoRedoCol = new AscCommonExcel.UndoRedoRowCol(wbModel, false); + AscCommonExcel.g_oUndoRedoRow = new AscCommonExcel.UndoRedoRowCol(wbModel, true); + AscCommonExcel.g_oUndoRedoComment = new AscCommonExcel.UndoRedoComment(wbModel); + AscCommonExcel.g_oUndoRedoAutoFilters = new AscCommonExcel.UndoRedoAutoFilters(wbModel); + AscCommonExcel.g_oUndoRedoSparklines = new AscCommonExcel.UndoRedoSparklines(wbModel); AscCommonExcel.g_DefNameWorksheet = new AscCommonExcel.Worksheet(wbModel, -1); + AscCommonExcel.g_oUndoRedoSharedFormula = new AscCommonExcel.UndoRedoSharedFormula(wbModel); + AscCommonExcel.g_oUndoRedoLayout = new AscCommonExcel.UndoRedoRedoLayout(wbModel); + AscCommonExcel.g_oUndoRedoHeaderFooter = new AscCommonExcel.UndoRedoHeaderFooter(wbModel); + AscCommonExcel.g_oUndoRedoArrayFormula = new AscCommonExcel.UndoRedoArrayFormula(wbModel); + AscCommonExcel.g_oUndoRedoSortState = new AscCommonExcel.UndoRedoSortState(wbModel); + AscCommonExcel.g_oUndoRedoSlicer = new AscCommonExcel.UndoRedoSlicer(wbModel); + AscCommonExcel.g_oUndoRedoPivotTables = new AscCommonExcel.UndoRedoPivotTables(wbModel); + AscCommonExcel.g_oUndoRedoPivotFields = new AscCommonExcel.UndoRedoPivotFields(wbModel); + AscCommonExcel.g_oUndoRedoCF = new AscCommonExcel.UndoRedoCF(wbModel); + AscCommonExcel.g_oUndoRedoProtectedRange = new AscCommonExcel.UndoRedoProtectedRange(wbModel); + AscCommonExcel.g_oUndoRedoProtectedSheet = new AscCommonExcel.UndoRedoProtectedSheet(wbModel); + AscCommonExcel.g_oUndoRedoProtectedWorkbook = new AscCommonExcel.UndoRedoProtectedWorkbook(wbModel); + AscCommonExcel.g_oUndoRedoNamedSheetViews = new AscCommonExcel.UndoRedoNamedSheetViews(wbModel); + AscCommonExcel.g_oUndoRedoUserProtectedRange = new AscCommonExcel.UndoRedoUserProtectedRange(wbModel); + + History.init(wbModel); + }; + Asc.spreadsheet_api.prototype._onUpdateDocumentCanSave = function() { }; AscCommonExcel.WorkbookView.prototype._onWSSelectionChanged = function() { }; @@ -93,7 +119,7 @@ $(function() { startTests(); }; - AscCommon.CHistory.prototype.Create_NewPoint = function() { + AscCommon.CHistory.prototype.UndoRedoEnd = function () { }; var api = new Asc.spreadsheet_api({ @@ -134,6 +160,12 @@ $(function() { wsView.changeWorksheet("update", {reinitRanges: true}); } + function undoAll() { + for (let i = 0, length = History.Points.length; i < length; i++) { + AscCommon.History.Undo(); + } + } + let wb, ws, wsView; function testPrintFileSettings() { QUnit.test("Test: open print settings ", function(assert ) { @@ -350,6 +382,43 @@ $(function() { }; comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page4: "); + + undoAll(); + updateView(); + + printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 1"); + page = printPagesData.arrPages[0]; + referenceObj = { + indexWorksheet: 0, + leftFieldInPx: 38.79527559055118, + pageClipRectHeight: 700.7800000000003, + pageClipRectLeft: 37.79527559055118, + pageClipRectTop: 37.79527559055118, + pageClipRectWidth: 796.2399999999999, + pageGridLines: false, + pageHeadings: false, + pageHeight: 210, + pageWidth: 297, + scale: 0.74, + startOffset: 0, + startOffsetPx: 0, + titleColRange: null, + titleHeight: 0, + titleRowRange: null, + titleWidth: 0, + topFieldInPx: 38.79527559055118, + pageRange: { + c1: 0, + c2: 18, + r1: 0, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings 1:"); }); } @@ -358,6 +427,7 @@ $(function() { function startTests() { QUnit.start(); testPrintFileSettings(); + //testPageBreaks(); } From 839485af3ed2aa50ac9856139f90f69173be4d6e Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Mon, 10 Jul 2023 13:26:39 +0500 Subject: [PATCH 23/42] [se] Add tests --- .../spreadsheet-calculation/PrintTests.js | 189 +++++++++++++++++- 1 file changed, 185 insertions(+), 4 deletions(-) diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index 55ab6a76b0..65d5ad7f9e 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -86,8 +86,6 @@ $(function() { }; AscCommonExcel.WorksheetView.prototype._autoFitColumnsWidth = function() { }; - AscCommonExcel.WorksheetView.prototype.setSelection = function() { - }; AscCommonExcel.WorksheetView.prototype.draw = function() { }; AscCommonExcel.WorksheetView.prototype._prepareDrawingObjects = function() { @@ -168,7 +166,7 @@ $(function() { let wb, ws, wsView; function testPrintFileSettings() { - QUnit.test("Test: open print settings ", function(assert ) { + QUnit.test("Test: open print settings ", function (assert) { let printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 1"); let page = printPagesData.arrPages[0]; @@ -422,12 +420,195 @@ $(function() { }); } + function testPageBreaks() { + QUnit.test("Test: page break settings ", function (assert) { + //change active cell and add page break + //C5 + wsView.setSelection(new Asc.Range(2, 4, 2, 4)); + api.asc_InsertPageBreak(); + + let printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 1"); + let page = printPagesData.arrPages[0]; + let referenceObj = { + indexWorksheet: 0, + leftFieldInPx: 38.79527559055118, + pageClipRectHeight: 700.7800000000003, + pageClipRectLeft: 37.79527559055118, + pageClipRectTop: 37.79527559055118, + pageClipRectWidth: 796.2399999999999, + pageGridLines: false, + pageHeadings: false, + pageHeight: 210, + pageWidth: 297, + scale: 0.74, + startOffset: 0, + startOffsetPx: 0, + titleColRange: null, + titleHeight: 0, + titleRowRange: null, + titleWidth: 0, + topFieldInPx: 38.79527559055118, + pageRange: { + c1: 0, + c2: 18, + r1: 0, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings 1:"); + wsView._changeFitToPage(0, 0); + updateView(); + + + printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + assert.strictEqual(printPagesData.arrPages.length, 4, "Compare pages length 2"); + + page = printPagesData.arrPages[0]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:43.66, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:67.34, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:0.74, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 0, + c2: 1, + r1: 0, + r2: 3, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes with scale page1: "); + + page = printPagesData.arrPages[1]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:43.66, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:728.9, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:0.74, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 2, + c2: 18, + r1: 0, + r2: 3, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes with scale page2: "); + + + page = printPagesData.arrPages[2]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:657.1200000000002, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:67.34, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:0.74, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 0, + c2: 1, + r1: 4, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes with scale page3: "); + + page = printPagesData.arrPages[3]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:657.1200000000002, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:728.9, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:0.74, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 2, + c2: 18, + r1: 4, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes with scale page4: "); + + }); + } + QUnit.module("Print"); function startTests() { QUnit.start(); testPrintFileSettings(); - //testPageBreaks(); + testPageBreaks(); } From 1e79a89a98716789e9b0ef0fa74e082d0bdc4f4d Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Mon, 10 Jul 2023 14:11:17 +0500 Subject: [PATCH 24/42] [se] Add tests --- .../spreadsheet-calculation/PrintTests.js | 205 ++++++++++++++++++ 1 file changed, 205 insertions(+) diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index 65d5ad7f9e..cdce2d2d98 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -600,6 +600,211 @@ $(function() { comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes with scale page4: "); + api.asc_SetPrintScale(null, null, 100); + + updateView(); + + printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + assert.strictEqual(printPagesData.arrPages.length, 6, "Compare pages length 2"); + + page = printPagesData.arrPages[0]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:59, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:91, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:1, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 0, + c2: 1, + r1: 0, + r2: 3, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page1: "); + + page = printPagesData.arrPages[1]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:59, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:985, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:1, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 2, + c2: 18, + r1: 0, + r2: 3, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page2: "); + + page = printPagesData.arrPages[2]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:705, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:91, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:1, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 0, + c2: 1, + r1: 4, + r2: 48, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page3: "); + + page = printPagesData.arrPages[3]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:705, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:985, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:1, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 2, + c2: 18, + r1: 4, + r2: 48, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page4: "); + + page = printPagesData.arrPages[4]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:183, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:91, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:1, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 0, + c2: 1, + r1: 49, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page5: "); + + page = printPagesData.arrPages[5]; + + referenceObj = { + indexWorksheet:0, + leftFieldInPx:38.79527559055118, + pageClipRectHeight:183, + pageClipRectLeft:37.79527559055118, + pageClipRectTop:37.79527559055118, + pageClipRectWidth:985, + pageGridLines:false, + pageHeadings:false, + pageHeight:210, + pageWidth:297, + scale:1, + startOffset:0, + startOffsetPx:0, + titleColRange:null, + titleHeight:0, + titleRowRange:null, + titleWidth:0, + topFieldInPx:38.79527559055118, + pageRange: { + c1: 2, + c2: 18, + r1: 49, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page6: "); + }); } From 5d8f19082f4108bb0cc3cb57c2f508341b43db43 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 11 Jul 2023 14:48:34 +0500 Subject: [PATCH 25/42] [se] By history --- cell/model/History.js | 2 + cell/model/UndoRedo.js | 131 +++++++++--------- cell/model/Workbook.js | 14 +- cell/model/WorkbookElems.js | 27 ++-- .../spreadsheet-calculation/PrintTests.js | 36 +++++ 5 files changed, 126 insertions(+), 84 deletions(-) diff --git a/cell/model/History.js b/cell/model/History.js index b134081dc9..3a1dfc1a04 100644 --- a/cell/model/History.js +++ b/cell/model/History.js @@ -116,6 +116,8 @@ function (window, undefined) { window['AscCH'].historyitem_Worksheet_SetShowFormulas = 62; + window['AscCH'].historyitem_Worksheet_ChangeRowColBreaks = 63; + window['AscCH'].historyitem_RowCol_Fontname = 1; window['AscCH'].historyitem_RowCol_Fontsize = 2; window['AscCH'].historyitem_RowCol_Fontcolor = 3; diff --git a/cell/model/UndoRedo.js b/cell/model/UndoRedo.js index f575787bf7..fa4c7e1120 100644 --- a/cell/model/UndoRedo.js +++ b/cell/model/UndoRedo.js @@ -454,6 +454,8 @@ function (window, undefined) { this.externalReference = 170; + this.RowColBreaks = 175; + this.Create = function (nType) { switch (nType) { case this.ValueMultiTextElem: @@ -837,16 +839,12 @@ function (window, undefined) { switch (nType) { case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; case this.Properties.copyRange: return this.copyRange; - break; case this.Properties.sheetIdTo: return this.sheetIdTo; - break; } return null; }; @@ -886,13 +884,10 @@ function (window, undefined) { switch (nType) { case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; case this.Properties.hyperlink: return this.hyperlink; - break; } return null; }; @@ -930,10 +925,8 @@ function (window, undefined) { switch (nType) { case this.Properties.index: return this.index; - break; case this.Properties.oNewVal: return this.oNewVal; - break; } return null; }; @@ -995,22 +988,16 @@ function (window, undefined) { switch (nType) { case this.Properties.width: return this.width; - break; case this.Properties.hd: return this.hd; - break; case this.Properties.CustomWidth: return this.CustomWidth; - break; case this.Properties.BestFit: return this.BestFit; - break; case this.Properties.OutlineLevel: return this.OutlineLevel; - break; case this.Properties.Collapsed: return this.Collapsed; - break; } return null; }; @@ -1074,19 +1061,14 @@ function (window, undefined) { switch (nType) { case this.Properties.h: return this.h; - break; case this.Properties.hd: return this.hd; - break; case this.Properties.CustomHeight: return this.CustomHeight; - break; case this.Properties.OutlineLevel: return this.OutlineLevel; - break; case this.Properties.Collapsed: return this.Collapsed; - break; } return null; }; @@ -1137,16 +1119,12 @@ function (window, undefined) { switch (nType) { case this.Properties.c1: return this.c1; - break; case this.Properties.r1: return this.r1; - break; case this.Properties.c2: return this.c2; - break; case this.Properties.r2: return this.r2; - break; } return null; }; @@ -1229,13 +1207,10 @@ function (window, undefined) { switch (nType) { case this.Properties.bbox: return this.bbox; - break; case this.Properties.places: return this.places; - break; case this.Properties.sortByRow: return this.sortByRow; - break; } return null; }; @@ -1288,13 +1263,10 @@ function (window, undefined) { switch (nType) { case this.Properties.pivot: return this.pivot; - break; case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; } return null; }; @@ -1340,16 +1312,12 @@ function (window, undefined) { switch (nType) { case this.Properties.pivot: return this.pivot; - break; case this.Properties.index: return this.index; - break; case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; } return null; }; @@ -1452,10 +1420,8 @@ function (window, undefined) { switch (nType) { case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; } return null; }; @@ -1557,10 +1523,8 @@ function (window, undefined) { switch (nType) { case this.Properties.sheetId: return this.sheetId; - break; case this.Properties.sheet: return this.sheet; - break; } return null; }; @@ -1596,19 +1560,14 @@ function (window, undefined) { switch (nType) { case this.Properties.name: return this.name; - break; case this.Properties.ref: return this.ref; - break; case this.Properties.sheetId: return this.sheetId; - break; case this.Properties.type: return this.type; - break; case this.Properties.isXLNM: return this.isXLNM; - break; } return null; }; @@ -1857,7 +1816,7 @@ function (window, undefined) { tableCustomFunc: [] }; - var table = new AscCommonExcel.TablePart(); + table = new AscCommonExcel.TablePart(); var res = oBinaryTableReader.bcr.Read1(dstLen, function (t, l) { return oBinaryTableReader.ReadTable(t, l, table); }); @@ -1928,10 +1887,8 @@ function (window, undefined) { switch (nType) { case this.Properties.range: return new UndoRedoData_BBox(this.range); - break; case this.Properties.formula: return this.formula; - break; } return null; @@ -1966,7 +1923,6 @@ function (window, undefined) { switch (nType) { case this.Properties.elem: return this.elem; - break; } return null; }; @@ -1998,16 +1954,12 @@ function (window, undefined) { switch (nType) { case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; case this.Properties.bFilter: return this.bFilter; - break; case this.Properties.tableName: return this.tableName; - break; } return null; }; @@ -2047,13 +1999,10 @@ function (window, undefined) { switch (nType) { case this.Properties.name: return this.name; - break; case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; } return null; }; @@ -2090,13 +2039,10 @@ function (window, undefined) { switch (nType) { case this.Properties.id: return this.id; - break; case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; } return null; }; @@ -2144,13 +2090,10 @@ function (window, undefined) { switch (nType) { case this.Properties.id: return this.id; - break; case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; } return null; }; @@ -2187,13 +2130,10 @@ function (window, undefined) { switch (nType) { case this.Properties.id: return this.id; - break; case this.Properties.from: return this.from; - break; case this.Properties.to: return this.to; - break; } return null; }; @@ -2301,6 +2241,64 @@ function (window, undefined) { } }; + function UndoRedoData_RowColBreaks(from, to, min, max, man, pt) { + this.from = from; + this.to = to; + this.min = min; + this.max = max; + this.man = man; + this.pt = pt; + } + + UndoRedoData_RowColBreaks.prototype.Properties = { + from: 0, to: 1, min: 2, max: 3, man: 4, pt: 5 + }; + UndoRedoData_RowColBreaks.prototype.getType = function () { + return UndoRedoDataTypes.RowColBreaks; + }; + UndoRedoData_RowColBreaks.prototype.getProperties = function () { + return this.Properties; + }; + UndoRedoData_RowColBreaks.prototype.getProperty = function (nType) { + switch (nType) { + case this.Properties.from: + return this.from; + case this.Properties.to: + return this.to; + case this.Properties.min: + return this.min; + case this.Properties.max: + return this.max; + case this.Properties.man: + return this.man; + case this.Properties.pt: + return this.pt; + } + return null; + }; + UndoRedoData_RowColBreaks.prototype.setProperty = function (nType, value) { + switch (nType) { + case this.Properties.from: + this.from = value; + break; + case this.Properties.to: + this.to = value; + break; + case this.Properties.min: + this.min = value; + break; + case this.Properties.max: + this.min = value; + break; + case this.Properties.man: + this.min = value; + break; + case this.Properties.pt: + this.pt = value; + break; + } + }; + //для применения изменений var UndoRedoClassTypes = new function () { this.aTypes = []; @@ -3376,6 +3374,12 @@ function (window, undefined) { if (window["NATIVE_EDITOR_ENJINE"] || !wb.oApi.isDocumentLoadComplete || !wb.bCollaborativeChanges) { ws.setSheetViewType(bUndo ? Data.from : Data.to); } + } else if (historyitem_Worksheet_ChangeRowColBreaks === Type) { + if (bUndo) { + ws._changeRowColBreaks(Data.to, Data.from); + } else { + ws._changeRowColBreaks(Data.to, Data.from); + } } }; UndoRedoWoorksheet.prototype.forwardTransformationIsAffect = function (Type) { @@ -4947,6 +4951,7 @@ function (window, undefined) { window['AscCommonExcel'].UndoRedoData_CF = UndoRedoData_CF; window['AscCommonExcel'].UndoRedoData_ProtectedRange = UndoRedoData_ProtectedRange; window['AscCommonExcel'].UndoRedoData_UserProtectedRange = UndoRedoData_UserProtectedRange; + window['AscCommonExcel'].UndoRedoData_RowColBreaks = UndoRedoData_RowColBreaks; window['AscCommonExcel'].UndoRedoWorkbook = UndoRedoWorkbook; window['AscCommonExcel'].UndoRedoCell = UndoRedoCell; window['AscCommonExcel'].UndoRedoWoorksheet = UndoRedoWoorksheet; diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 09fe424f14..2aa49dbc5c 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11848,19 +11848,27 @@ } }; + let isChanged = false; if (rowColBreaks && rowColBreaks.containsBreak(from, min, max)) { if (to) { //change checkInit(); - rowColBreaks.changeBreak(from, to, min, max, true, null, addToHistory); + isChanged = rowColBreaks.changeBreak(from, to, min, max, true); } else { //delete - rowColBreaks && rowColBreaks.removeBreak(from, min, max, addToHistory); + isChanged = rowColBreaks && rowColBreaks.removeBreak(from, min, max); } } else if (to) { //add checkInit(); - rowColBreaks.addBreak(to, min, max, true, null, addToHistory) + isChanged = rowColBreaks.addBreak(to, min, max, true, null) + } + + if (isChanged && addToHistory) { + let fromData = new AscCommonExcel.UndoRedoData_RowColBreaks(from, to, min, max, man, pt); + let toData = new AscCommonExcel.UndoRedoData_RowColBreaks(from, to, min, max, man, pt); + History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_ChangeRowColBreaks, this.getId(), + null, new AscCommonExcel.UndoRedoData_FromTo(fromData, toData)); } this.workbook.handlers.trigger("onChangePageSetupProps", this.getId()); diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index ace6a91fb3..0933d74ec2 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15588,24 +15588,18 @@ QueryTableField.prototype.clone = function() { }); return res; }; - CRowColBreaks.prototype.changeBreak = function (idFrom, idTo, min, max, man, pt, addToHistory) { + + CRowColBreaks.prototype.changeBreak = function (idFrom, idTo, min, max, man, pt) { let breakElem = this.getBreak(idFrom); if (breakElem) { - let isChanged = breakElem.set(idTo, min, max, man, pt); - if (isChanged && addToHistory) { - - } + return breakElem.set(idTo, min, max, man, pt); } }; - CRowColBreaks.prototype.addBreak = function (id, min, max, man, pt, addToHistory) { + + CRowColBreaks.prototype.addBreak = function (id, min, max, man, pt) { let newBreak = new CBreak(); newBreak.set(id, min, max, man, pt); - - this._addBreak(newBreak); - - if (addToHistory) { - - } + return this._addBreak(newBreak); }; CRowColBreaks.prototype._addBreak = function (newBreak) { @@ -15618,18 +15612,15 @@ QueryTableField.prototype.clone = function() { } this.manualBreakCount++; this.count++; + return true; }; - CRowColBreaks.prototype.removeBreak = function (id, min, max, addToHistory) { + CRowColBreaks.prototype.removeBreak = function (id, min, max) { let isDeleted = false; for (let i = 0; i < this.breaks.length; i++) { if (this.breaks[i].isBreak(id, min, max)) { this.breaks.splice(i, 1); isDeleted = true; - - if (addToHistory) { - - } break; } } @@ -15726,7 +15717,7 @@ QueryTableField.prototype.clone = function() { this.setPt(pt); isChanged = true; } - return isChanged; + return isChanged ? this : null; }; diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index cdce2d2d98..977f9f33df 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -805,6 +805,42 @@ $(function() { comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings changes without scale page6: "); + undoAll(); + updateView(); + + printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 1"); + page = printPagesData.arrPages[0]; + referenceObj = { + indexWorksheet: 0, + leftFieldInPx: 38.79527559055118, + pageClipRectHeight: 700.7800000000003, + pageClipRectLeft: 37.79527559055118, + pageClipRectTop: 37.79527559055118, + pageClipRectWidth: 796.2399999999999, + pageGridLines: false, + pageHeadings: false, + pageHeight: 210, + pageWidth: 297, + scale: 0.74, + startOffset: 0, + startOffsetPx: 0, + titleColRange: null, + titleHeight: 0, + titleRowRange: null, + titleWidth: 0, + topFieldInPx: 38.79527559055118, + pageRange: { + c1: 0, + c2: 18, + r1: 0, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:"); }); } From 564831b3feaf0afb9de20a771e6a2a2437345877 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 11 Jul 2023 16:54:45 +0500 Subject: [PATCH 26/42] [se] By history --- cell/model/UndoRedo.js | 48 +++++++++++++++++++++++++++--------------- cell/model/Workbook.js | 13 +++++++----- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/cell/model/UndoRedo.js b/cell/model/UndoRedo.js index fa4c7e1120..55c45a416b 100644 --- a/cell/model/UndoRedo.js +++ b/cell/model/UndoRedo.js @@ -2241,17 +2241,17 @@ function (window, undefined) { } }; - function UndoRedoData_RowColBreaks(from, to, min, max, man, pt) { - this.from = from; - this.to = to; + function UndoRedoData_RowColBreaks(id, min, max, man, pt, byCol) { + this.id = id; this.min = min; this.max = max; this.man = man; this.pt = pt; + this.byCol = byCol; } UndoRedoData_RowColBreaks.prototype.Properties = { - from: 0, to: 1, min: 2, max: 3, man: 4, pt: 5 + id: 0, min: 1, max: 2, man: 3, pt: 4, byCol: 5 }; UndoRedoData_RowColBreaks.prototype.getType = function () { return UndoRedoDataTypes.RowColBreaks; @@ -2261,10 +2261,8 @@ function (window, undefined) { }; UndoRedoData_RowColBreaks.prototype.getProperty = function (nType) { switch (nType) { - case this.Properties.from: - return this.from; - case this.Properties.to: - return this.to; + case this.Properties.id: + return this.id; case this.Properties.min: return this.min; case this.Properties.max: @@ -2273,16 +2271,15 @@ function (window, undefined) { return this.man; case this.Properties.pt: return this.pt; + case this.Properties.byCol: + return this.byCol; } return null; }; UndoRedoData_RowColBreaks.prototype.setProperty = function (nType, value) { switch (nType) { - case this.Properties.from: - this.from = value; - break; - case this.Properties.to: - this.to = value; + case this.Properties.id: + this.id = value; break; case this.Properties.min: this.min = value; @@ -2296,6 +2293,9 @@ function (window, undefined) { case this.Properties.pt: this.pt = value; break; + case this.Properties.byCol: + this.byCol = value; + break; } }; @@ -3374,12 +3374,26 @@ function (window, undefined) { if (window["NATIVE_EDITOR_ENJINE"] || !wb.oApi.isDocumentLoadComplete || !wb.bCollaborativeChanges) { ws.setSheetViewType(bUndo ? Data.from : Data.to); } - } else if (historyitem_Worksheet_ChangeRowColBreaks === Type) { + } else if (AscCH.historyitem_Worksheet_ChangeRowColBreaks === Type) { + let from, to, min, max, man, pt, byCol; if (bUndo) { - ws._changeRowColBreaks(Data.to, Data.from); + from = Data.to && Data.to.id; + to = Data.from && Data.from.id; + min = Data.from && Data.from.min; + max = Data.from && Data.from.max; + man = Data.from && Data.from.man; + pt = Data.from && Data.from.pt; + byCol = Data.from && Data.from.byCol; } else { - ws._changeRowColBreaks(Data.to, Data.from); - } + from = Data.from && Data.from.id; + to = Data.to && Data.to.id; + min = Data.to && Data.to.min; + max = Data.to && Data.to.max; + man = Data.to && Data.to.man; + pt = Data.to && Data.to.pt; + byCol = Data.to && Data.to.byCol; + } + ws._changeRowColBreaks(from, to, min, max, man, pt, byCol); } }; UndoRedoWoorksheet.prototype.forwardTransformationIsAffect = function (Type) { diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 2aa49dbc5c..d448ae56f4 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11815,6 +11815,7 @@ Worksheet.prototype.changeRowColBreaks = function (from, to, range, byCol, addToHistory) { let min = null; let max = byCol ? gc_nMaxCol0 : gc_nMaxRow0; + let man = true, pt = null; let printArea = this.workbook.getDefinesNames("Print_Area", this.getId()); if (printArea && range) { @@ -11827,10 +11828,10 @@ } } - this._changeRowColBreaks(from, to, min, max, byCol, addToHistory); + this._changeRowColBreaks(from, to, min, max, man, pt, byCol, addToHistory); }; - Worksheet.prototype._changeRowColBreaks = function (from, to, min, max, byCol, addToHistory) { + Worksheet.prototype._changeRowColBreaks = function (from, to, min, max, man, pt, byCol, addToHistory) { let t = this; let rowColBreaks = !byCol ? t.rowBreaks : t.colBreaks; @@ -11849,7 +11850,8 @@ }; let isChanged = false; - if (rowColBreaks && rowColBreaks.containsBreak(from, min, max)) { + let oFromBreak = rowColBreaks && rowColBreaks.containsBreak(from, min, max); + if (oFromBreak) { if (to) { //change checkInit(); @@ -11865,8 +11867,9 @@ } if (isChanged && addToHistory) { - let fromData = new AscCommonExcel.UndoRedoData_RowColBreaks(from, to, min, max, man, pt); - let toData = new AscCommonExcel.UndoRedoData_RowColBreaks(from, to, min, max, man, pt); + let fromData = oFromBreak && new AscCommonExcel.UndoRedoData_RowColBreaks(from, oFromBreak.min, oFromBreak.max, oFromBreak.man, oFromBreak.pt, byCol); + let toData = new AscCommonExcel.UndoRedoData_RowColBreaks(to, min, max, man, pt, byCol); + History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_ChangeRowColBreaks, this.getId(), null, new AscCommonExcel.UndoRedoData_FromTo(fromData, toData)); } From cf4fac7f283b593e67a6b40755adaac26a4a8fee Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 11 Jul 2023 17:19:07 +0500 Subject: [PATCH 27/42] [se] Fix --- cell/model/UndoRedo.js | 4 ++-- cell/model/WorkbookElems.js | 2 ++ tests/cell/spreadsheet-calculation/PrintTests.js | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cell/model/UndoRedo.js b/cell/model/UndoRedo.js index 55c45a416b..ad3dd6f8d6 100644 --- a/cell/model/UndoRedo.js +++ b/cell/model/UndoRedo.js @@ -3383,7 +3383,7 @@ function (window, undefined) { max = Data.from && Data.from.max; man = Data.from && Data.from.man; pt = Data.from && Data.from.pt; - byCol = Data.from && Data.from.byCol; + byCol = (Data.from && Data.from.byCol) || (Data.to && Data.to.byCol); } else { from = Data.from && Data.from.id; to = Data.to && Data.to.id; @@ -3391,7 +3391,7 @@ function (window, undefined) { max = Data.to && Data.to.max; man = Data.to && Data.to.man; pt = Data.to && Data.to.pt; - byCol = Data.to && Data.to.byCol; + byCol = (Data.from && Data.from.byCol) || (Data.to && Data.to.byCol); } ws._changeRowColBreaks(from, to, min, max, man, pt, byCol); } diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index 0933d74ec2..b9a90ad856 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15621,6 +15621,8 @@ QueryTableField.prototype.clone = function() { if (this.breaks[i].isBreak(id, min, max)) { this.breaks.splice(i, 1); isDeleted = true; + this.manualBreakCount--; + this.count--; break; } } diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index 977f9f33df..e9b1cc1bf9 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -159,7 +159,7 @@ $(function() { } function undoAll() { - for (let i = 0, length = History.Points.length; i < length; i++) { + while(AscCommon.History.Index !== -1) { AscCommon.History.Undo(); } } @@ -810,7 +810,7 @@ $(function() { printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 1"); - page = printPagesData.arrPages[0]; + /*page = printPagesData.arrPages[0]; referenceObj = { indexWorksheet: 0, leftFieldInPx: 38.79527559055118, @@ -840,7 +840,7 @@ $(function() { } }; - comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:"); + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:");*/ }); } From a39e5c0b5e171921b8a5bd6fb3ba5e7d11a62c06 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 11 Jul 2023 17:55:45 +0500 Subject: [PATCH 28/42] [se] Fix tests --- tests/cell/spreadsheet-calculation/PrintTests.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index e9b1cc1bf9..550bb59a12 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -417,6 +417,7 @@ $(function() { }; comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings 1:"); + AscCommon.History.Clear(); }); } @@ -810,7 +811,7 @@ $(function() { printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 1"); - /*page = printPagesData.arrPages[0]; + page = printPagesData.arrPages[0]; referenceObj = { indexWorksheet: 0, leftFieldInPx: 38.79527559055118, @@ -840,7 +841,7 @@ $(function() { } }; - comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:");*/ + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:"); }); } From 7b385b639729f4d6123ca55dc7b2d651a5697f10 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 13 Jul 2023 17:49:28 +0500 Subject: [PATCH 29/42] [se] Tests --- .../spreadsheet-calculation/PrintTests.js | 194 +++++++++++++++++- 1 file changed, 192 insertions(+), 2 deletions(-) diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index 550bb59a12..f3d1de02cf 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -140,7 +140,7 @@ $(function() { function comparePrintPageSettings (assert, obj1, obj2, desc) { for (let i in obj1) { if (obj1.hasOwnProperty(i)) { - if (i === "pageRange") { + if (typeof(obj1[i]) === "object" && (i === "pageRange" || i === "titleRowRange" || i === "titleColRange")) { for (let j in obj1[i]) { if (obj1[i].hasOwnProperty(j)) { assert.strictEqual(obj1[i][j], obj2[i][j], desc + j); @@ -810,7 +810,7 @@ $(function() { updateView(); printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); - assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 1"); + assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 6 after undo"); page = printPagesData.arrPages[0]; referenceObj = { indexWorksheet: 0, @@ -842,6 +842,196 @@ $(function() { }; comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:"); + + api.asc_SetPrintScale(null, null, 100); + api.asc_changePrintTitles("$A:$D", "$1:$5", 0); + wsView.setSelection(new Asc.Range(1, 3, 1, 3)); + api.asc_InsertPageBreak(); + + printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + assert.strictEqual(printPagesData.arrPages.length, 9, "Compare pages length with print titles"); + + page = printPagesData.arrPages[0]; + + referenceObj = { + "pageWidth": 297, + "pageHeight": 210, + "pageClipRectLeft": 37.79527559055118, + "pageClipRectTop": 37.79527559055118, + "pageClipRectWidth": 21, + "pageClipRectHeight": 45, + "pageRange": {"c1": 0, "r1": 0, "c2": 0, "r2": 2, "refType1": 3, "refType2": 3}, + "leftFieldInPx": 38.79527559055118, + "topFieldInPx": 38.79527559055118, + "pageGridLines": false, + "pageHeadings": false, + "indexWorksheet": 0, + "startOffset": 0, + "startOffsetPx": 0, + "scale": 1, + "titleRowRange": null, + "titleColRange": null, + "titleWidth": 0, + "titleHeight": 0 + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 1:"); + + page = printPagesData.arrPages[1]; + + referenceObj = { + "pageWidth": 297, + "pageHeight": 210, + "pageClipRectLeft": 37.79527559055118, + "pageClipRectTop": 37.79527559055118, + "pageClipRectWidth": 966, + "pageClipRectHeight": 45, + "pageRange": {"c1": 1, "r1": 0, "c2": 16, "r2": 2, "refType1": 3, "refType2": 3}, + "leftFieldInPx": 38.79527559055118, + "topFieldInPx": 38.79527559055118, + "pageGridLines": false, + "pageHeadings": false, + "indexWorksheet": 0, + "startOffset": 0, + "startOffsetPx": 0, + "scale": 1, + "titleRowRange": null, + "titleColRange": {"c1": 0, "r1": 0, "c2": 0, "r2": 2, "refType1": 3, "refType2": 3}, + "titleWidth": 21, + "titleHeight": 0 + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 2:"); + + page = printPagesData.arrPages[2]; + + referenceObj = { + "pageWidth": 297, + "pageHeight": 210, + "pageClipRectLeft": 37.79527559055118, + "pageClipRectTop": 37.79527559055118, + "pageClipRectWidth": 89, + "pageClipRectHeight": 45, + "pageRange": {"c1": 17, "r1": 0, "c2": 18, "r2": 2, "refType1": 3, "refType2": 3}, + "leftFieldInPx": 38.79527559055118, + "topFieldInPx": 38.79527559055118, + "pageGridLines": false, + "pageHeadings": false, + "indexWorksheet": 0, + "startOffset": 0, + "startOffsetPx": 0, + "scale": 1, + "titleRowRange": null, + "titleColRange": {"c1": 0, "r1": 0, "c2": 3, "r2": 2, "refType1": 3, "refType2": 3}, + "titleWidth": 177, + "titleHeight": 0 + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 3:"); + + page = printPagesData.arrPages[3]; + + referenceObj = { + "pageWidth": 297, + "pageHeight": 210, + "pageClipRectLeft": 37.79527559055118, + "pageClipRectTop": 37.79527559055118, + "pageClipRectWidth": 21, + "pageClipRectHeight": 662, + "pageRange": {"c1": 0, "r1": 3, "c2": 0, "r2": 45, "refType1": 3, "refType2": 3}, + "leftFieldInPx": 38.79527559055118, + "topFieldInPx": 38.79527559055118, + "pageGridLines": false, + "pageHeadings": false, + "indexWorksheet": 0, + "startOffset": 0, + "startOffsetPx": 0, + "scale": 1, + "titleRowRange": {"c1": 0, "r1": 0, "c2": 0, "r2": 2, "refType1": 3, "refType2": 3}, + "titleColRange": null, + "titleWidth": 0, + "titleHeight": 45 + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 4:"); + + page = printPagesData.arrPages[4]; + + referenceObj = { + "pageWidth": 297, + "pageHeight": 210, + "pageClipRectLeft": 37.79527559055118, + "pageClipRectTop": 37.79527559055118, + "pageClipRectWidth": 966, + "pageClipRectHeight": 662, + "pageRange": {"c1": 1, "r1": 3, "c2": 16, "r2": 45, "refType1": 3, "refType2": 3}, + "leftFieldInPx": 38.79527559055118, + "topFieldInPx": 38.79527559055118, + "pageGridLines": false, + "pageHeadings": false, + "indexWorksheet": 0, + "startOffset": 0, + "startOffsetPx": 0, + "scale": 1, + "titleRowRange": {"c1": 1, "r1": 0, "c2": 16, "r2": 2, "refType1": 3, "refType2": 3}, + "titleColRange": {"c1": 0, "r1": 3, "c2": 0, "r2": 45, "refType1": 3, "refType2": 3}, + "titleWidth": 21, + "titleHeight": 45 + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 5:"); + + page = printPagesData.arrPages[5]; + + referenceObj = { + "pageWidth": 297, + "pageHeight": 210, + "pageClipRectLeft": 37.79527559055118, + "pageClipRectTop": 37.79527559055118, + "pageClipRectWidth": 89, + "pageClipRectHeight": 662, + "pageRange": {"c1": 17, "r1": 3, "c2": 18, "r2": 45, "refType1": 3, "refType2": 3}, + "leftFieldInPx": 38.79527559055118, + "topFieldInPx": 38.79527559055118, + "pageGridLines": false, + "pageHeadings": false, + "indexWorksheet": 0, + "startOffset": 0, + "startOffsetPx": 0, + "scale": 1, + "titleRowRange": {"c1": 17, "r1": 0, "c2": 18, "r2": 2, "refType1": 3, "refType2": 3}, + "titleColRange": {"c1": 0, "r1": 3, "c2": 3, "r2": 45, "refType1": 3, "refType2": 3}, + "titleWidth": 177, + "titleHeight": 45 + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 6:"); + + page = printPagesData.arrPages[7]; + + referenceObj = { + "pageWidth": 297, + "pageHeight": 210, + "pageClipRectLeft": 37.79527559055118, + "pageClipRectTop": 37.79527559055118, + "pageClipRectWidth": 966, + "pageClipRectHeight": 240, + "pageRange": {"c1": 1, "r1": 46, "c2": 16, "r2": 57, "refType1": 3, "refType2": 3}, + "leftFieldInPx": 38.79527559055118, + "topFieldInPx": 38.79527559055118, + "pageGridLines": false, + "pageHeadings": false, + "indexWorksheet": 0, + "startOffset": 0, + "startOffsetPx": 0, + "scale": 1, + "titleRowRange": {"c1": 1, "r1": 0, "c2": 16, "r2": 4, "refType1": 3, "refType2": 3}, + "titleColRange": {"c1": 0, "r1": 46, "c2": 0, "r2": 57, "refType1": 3, "refType2": 3}, + "titleWidth": 21, + "titleHeight": 73 + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 8:"); }); } From 14f00fabdb9f8a4d2e476fbe60116bb90d2d6675 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Thu, 13 Jul 2023 19:14:11 +0500 Subject: [PATCH 30/42] [se] Tests --- .../spreadsheet-calculation/PrintTests.js | 79 +++++++++++++++++-- 1 file changed, 74 insertions(+), 5 deletions(-) diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index f3d1de02cf..fc3efd667c 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -421,7 +421,7 @@ $(function() { }); } - function testPageBreaks() { + function testPageBreaksSimple() { QUnit.test("Test: page break settings ", function (assert) { //change active cell and add page break //C5 @@ -842,18 +842,23 @@ $(function() { }; comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:"); + AscCommon.History.Clear(); + }); + } + function testPageBreaksAndTitles() { + QUnit.test("Test: page break and titles settings ", function (assert) { api.asc_SetPrintScale(null, null, 100); api.asc_changePrintTitles("$A:$D", "$1:$5", 0); wsView.setSelection(new Asc.Range(1, 3, 1, 3)); api.asc_InsertPageBreak(); - printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + let printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); assert.strictEqual(printPagesData.arrPages.length, 9, "Compare pages length with print titles"); - page = printPagesData.arrPages[0]; + let page = printPagesData.arrPages[0]; - referenceObj = { + let referenceObj = { "pageWidth": 297, "pageHeight": 210, "pageClipRectLeft": 37.79527559055118, @@ -1032,6 +1037,68 @@ $(function() { }; comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings with titles 8:"); + + undoAll(); + updateView(); + + printPagesData = api.wb.calcPagesPrint(new Asc.asc_CAdjustPrint()); + assert.strictEqual(printPagesData.arrPages.length, 1, "Compare pages length 6 after undo"); + page = printPagesData.arrPages[0]; + referenceObj = { + indexWorksheet: 0, + leftFieldInPx: 38.79527559055118, + pageClipRectHeight: 700.7800000000003, + pageClipRectLeft: 37.79527559055118, + pageClipRectTop: 37.79527559055118, + pageClipRectWidth: 796.2399999999999, + pageGridLines: false, + pageHeadings: false, + pageHeight: 210, + pageWidth: 297, + scale: 0.74, + startOffset: 0, + startOffsetPx: 0, + titleColRange: null, + titleHeight: 0, + titleRowRange: null, + titleWidth: 0, + topFieldInPx: 38.79527559055118, + pageRange: { + c1: 0, + c2: 18, + r1: 0, + r2: 57, + refType1: 3, + refType2: 3 + } + }; + + comparePrintPageSettings(assert, page, referenceObj, "Compare pages settings after undo:"); + AscCommon.History.Clear(); + }); + } + + function testPageBreaksManipulation() { + QUnit.test("Test: page break manipulation ", function (assert) { + //add breaks + ws = api.wbModel.aWorksheets[0]; + + assert.strictEqual((ws.colBreaks == null || ws.colBreaks.getCount() === 0) ? null : 1, null, "colbreaks count before 1"); + assert.strictEqual((ws.rowBreaks == null || ws.rowBreaks.getCount() === 0) ? null : 1, null, "rowBreaks count before 1"); + + let insertColBreakId = 1; + let insertRowBreakId = 3; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + assert.strictEqual(ws.colBreaks.getCount(), 1, "colbreaks count after 1"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, "rowBreaks count after 1"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, "colBreaks is null before add colbreaks"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, "rowBreaks is null before add rowBreaks"); + + AscCommon.History.Undo(); + }); } @@ -1040,7 +1107,9 @@ $(function() { function startTests() { QUnit.start(); testPrintFileSettings(); - testPageBreaks(); + testPageBreaksSimple(); + testPageBreaksAndTitles(); + testPageBreaksManipulation(); } From 6c61ac739a343d9ba02c83201a76b0460993b2bc Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 14 Jul 2023 12:40:39 +0500 Subject: [PATCH 31/42] [se] Fix + tests --- cell/model/WorkbookElems.js | 3 + .../spreadsheet-calculation/PrintTests.js | 158 +++++++++++++++++- 2 files changed, 154 insertions(+), 7 deletions(-) diff --git a/cell/model/WorkbookElems.js b/cell/model/WorkbookElems.js index b9a90ad856..e3e6a6af09 100644 --- a/cell/model/WorkbookElems.js +++ b/cell/model/WorkbookElems.js @@ -15597,6 +15597,9 @@ QueryTableField.prototype.clone = function() { }; CRowColBreaks.prototype.addBreak = function (id, min, max, man, pt) { + if (!id) { + return false; + } let newBreak = new CBreak(); newBreak.set(id, min, max, man, pt); return this._addBreak(newBreak); diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index fc3efd667c..8da7c51258 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -118,6 +118,7 @@ $(function() { }; AscCommon.CHistory.prototype.UndoRedoEnd = function () { + this.TurnOn(); }; var api = new Asc.spreadsheet_api({ @@ -1078,27 +1079,170 @@ $(function() { }); } + function checkUndoRedo(fBefore, fAfter, desc, skipLastUndo) { + fAfter("after_" + desc); + AscCommon.History.Undo(); + fBefore("undo_" + desc); + AscCommon.History.Redo(); + fAfter("redo_" + desc); + if (!skipLastUndo) { + AscCommon.History.Undo(); + } + } + function testPageBreaksManipulation() { QUnit.test("Test: page break manipulation ", function (assert) { //add breaks ws = api.wbModel.aWorksheets[0]; - assert.strictEqual((ws.colBreaks == null || ws.colBreaks.getCount() === 0) ? null : 1, null, "colbreaks count before 1"); - assert.strictEqual((ws.rowBreaks == null || ws.rowBreaks.getCount() === 0) ? null : 1, null, "rowBreaks count before 1"); + let beforeFunc = function(desc) { + assert.strictEqual((ws.colBreaks == null || ws.colBreaks.getCount() === 0) ? null : 1, null, desc); + assert.strictEqual((ws.rowBreaks == null || ws.rowBreaks.getCount() === 0) ? null : 1, null, desc); + }; let insertColBreakId = 1; let insertRowBreakId = 3; wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); api.asc_InsertPageBreak(); - assert.strictEqual(ws.colBreaks.getCount(), 1, "colbreaks count after 1"); - assert.strictEqual(ws.rowBreaks.getCount(), 1, "rowBreaks count after 1"); + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); - assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, "colBreaks is null before add colbreaks"); - assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, "rowBreaks is null before add rowBreaks"); + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, "insert page break_col1row3"); - AscCommon.History.Undo(); + insertColBreakId = 5; + insertRowBreakId = 5; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, "insert page break_col5row5"); + + + + insertColBreakId = 1; + insertRowBreakId = 1; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, "insert page break_col1row1"); + + insertColBreakId = 0; + insertRowBreakId = 0; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 0, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 0, desc + " check row count"); + }, "insert page break_col0row0"); + + insertColBreakId = 0; + insertRowBreakId = 1; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 0, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); + + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, "insert page break_col0row1"); + + insertColBreakId = 1; + insertRowBreakId = 0; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 0, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + }, "insert page break_col1row0"); + + insertColBreakId = 3; + insertRowBreakId = 3; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, "insert page break_col3row3", true); + + //remove + insertColBreakId = 4; + insertRowBreakId = 4; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_RemovePageBreak(); + + assert.strictEqual(ws.colBreaks.getCount(), 1, " check col count + remove1"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, " check row count + remove1"); + + assert.strictEqual(ws.colBreaks.containsBreak(3), true, " check col contains + remove1"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, " check row contains + remove1"); + + + insertColBreakId = 3; + insertRowBreakId = 3; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_RemovePageBreak(); + + checkUndoRedo(function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, beforeFunc, "remove page break_col3row3"); + + assert.strictEqual(ws.colBreaks.getCount(), 1, " check col count + remove2"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, " check row count + remove2"); + + assert.strictEqual(ws.colBreaks.containsBreak(3), true, " check col contains + remove2"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, " check row contains + remove2"); + + insertColBreakId = 5; + insertRowBreakId = 5; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 1, desc); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc); + }, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 2, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 2, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, "insert page break_col5row5", true); + + //reset all + api.asc_ResetAllPageBreaks(); + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 2, desc); + assert.strictEqual(ws.rowBreaks.getCount(), 2, desc); + }, beforeFunc, "insert page break_col5row5", true); }); } From 4983a97875f4d5ed26edfba9bb2daf668c9085c4 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 14 Jul 2023 13:28:34 +0500 Subject: [PATCH 32/42] [se] Add remove all to history --- cell/model/Workbook.js | 7 +++++-- tests/cell/spreadsheet-calculation/PrintTests.js | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index d448ae56f4..26f0aab27d 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11880,13 +11880,16 @@ Worksheet.prototype.resetAllPageBreaks = function () { let t = this; - let doRemoveBreaks = function(_breaks) { + let doRemoveBreaks = function(_breaks, byCol) { if (!_breaks) { return; } let aBreaks = _breaks.getBreaks(); for (let i = 0; i < aBreaks.length; i++) { + let fromData = new AscCommonExcel.UndoRedoData_RowColBreaks(aBreaks[i].id, aBreaks[i].min, aBreaks[i].max, aBreaks[i].man, aBreaks[i].pt, byCol); if (_breaks.removeBreak(aBreaks[i].id)) { + History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_ChangeRowColBreaks, t.getId(), + null, new AscCommonExcel.UndoRedoData_FromTo(fromData, null)); i--; } } @@ -11896,7 +11899,7 @@ doRemoveBreaks(this.rowBreaks); } if (this.colBreaks) { - doRemoveBreaks(this.colBreaks); + doRemoveBreaks(this.colBreaks, true); } this.workbook.handlers.trigger("onChangePageSetupProps", this.getId()); }; diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index 8da7c51258..aa862bb0a1 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -1242,7 +1242,13 @@ $(function() { checkUndoRedo(function (desc) { assert.strictEqual(ws.colBreaks.getCount(), 2, desc); assert.strictEqual(ws.rowBreaks.getCount(), 2, desc); - }, beforeFunc, "insert page break_col5row5", true); + + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains"); + + }, beforeFunc, "remove all page breaks", true); }); } From 0ec107133b278c15845d98e3d8d26611e4de28a0 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Fri, 14 Jul 2023 16:28:26 +0500 Subject: [PATCH 33/42] [se] Fix --- cell/view/WorksheetView.js | 11 +++++--- .../spreadsheet-calculation/PrintTests.js | 27 +++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 5a66c73169..6010213b61 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -12635,11 +12635,11 @@ //change page breaks if (toRange.colByX) { if (toRange.colByX !== fromRange.colByX) { - this.changeRowColBreaks(fromRange.colByX, toRange.colByX, fromRange, true) + this.changeRowColBreaks(fromRange.colByX, toRange.colByX, fromRange, true, true) } } else { if (toRange.rowByY !== fromRange.rowByY) { - this.changeRowColBreaks(fromRange.rowByY, toRange.rowByY, fromRange) + this.changeRowColBreaks(fromRange.rowByY, toRange.rowByY, fromRange, null, true) } } } else if (!fromRange.isEqual(toRange)) { @@ -21410,7 +21410,7 @@ return res; }; - WorksheetView.prototype.changeRowColBreaks = function (from, to, range, byCol) { + WorksheetView.prototype.changeRowColBreaks = function (from, to, range, byCol, opt_handle_move) { var t = this; if (from === -1 || to === -1) { @@ -21425,6 +21425,11 @@ History.Create_NewPoint(); History.StartTransaction(); + //remove all breaks on path(from->to) + if (opt_handle_move) { + + } + t.model.changeRowColBreaks(from, to, range, byCol, true); t.changeViewPrintLines(true); diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index aa862bb0a1..b1d9c12016 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -1252,6 +1252,32 @@ $(function() { }); } + function testPageBreakMove() { + QUnit.test("Test: page break move ", function (assert) { + //add breaks + ws = api.wbModel.aWorksheets[0]; + + let beforeFunc = function(desc) { + assert.strictEqual((ws.colBreaks == null || ws.colBreaks.getCount() === 0) ? null : 1, null, desc); + assert.strictEqual((ws.rowBreaks == null || ws.rowBreaks.getCount() === 0) ? null : 1, null, desc); + }; + + let insertColBreakId = 1; + let insertRowBreakId = 3; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(beforeFunc, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); + assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); + }, "insert page break_col1row3"); + + }); + } + QUnit.module("Print"); function startTests() { @@ -1260,6 +1286,7 @@ $(function() { testPageBreaksSimple(); testPageBreaksAndTitles(); testPageBreaksManipulation(); + //testPageBreakMove(); } From d579b05943b6a11d860e0c6b6acd9887130712a5 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Mon, 17 Jul 2023 12:19:34 +0500 Subject: [PATCH 34/42] [se] Fixes + test --- cell/model/Workbook.js | 2 +- cell/view/WorksheetView.js | 10 +++ .../spreadsheet-calculation/PrintTests.js | 67 ++++++++++++++++++- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/cell/model/Workbook.js b/cell/model/Workbook.js index 26f0aab27d..f5b402117f 100644 --- a/cell/model/Workbook.js +++ b/cell/model/Workbook.js @@ -11850,7 +11850,7 @@ }; let isChanged = false; - let oFromBreak = rowColBreaks && rowColBreaks.containsBreak(from, min, max); + let oFromBreak = rowColBreaks && rowColBreaks.getBreak(from, min, max); if (oFromBreak) { if (to) { //change diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 6010213b61..19361ba079 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -21427,7 +21427,17 @@ //remove all breaks on path(from->to) if (opt_handle_move) { + let reverse = from > to; + let firstIndex = !reverse ? from : to; + let lastIndex = !reverse ? to : from; + for (let i = firstIndex; i <= lastIndex; i++) { + if (i === from) { + continue; + } + + t.model.changeRowColBreaks(i, null, range, byCol, true); + } } t.model.changeRowColBreaks(from, to, range, byCol, true); diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index b1d9c12016..63217fa872 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -1248,7 +1248,71 @@ $(function() { assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains"); assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains"); - }, beforeFunc, "remove all page breaks", true); + }, beforeFunc, "remove all page breaks"); + + //move + insertColBreakId = 8; + insertRowBreakId = 8; + wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); + api.asc_InsertPageBreak(); + + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 2, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 2, desc + " check row count"); + }, function (desc){ + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + }, "insert page break_col8row8", true); + + wsView.changeRowColBreaks(3, 4, new Asc.Range(0, 0, 16, 57), true, true); + + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains 3"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 3"); + }, function (desc){ + + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(4), true, desc + " check col contains 4"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 4"); + + }, "change page col break_from3to4"); + + wsView.changeRowColBreaks(3, 12, new Asc.Range(0, 0, 16, 57), true, true); + + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains 3"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 3"); + }, function (desc){ + + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(12), true, desc + " check col contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 4"); + + }, "change page col break_from3to4"); }); } @@ -1275,6 +1339,7 @@ $(function() { assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); }, "insert page break_col1row3"); + }); } From a73f81920fd2f26e2026858ecc22b382d170f8e3 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Mon, 17 Jul 2023 12:44:37 +0500 Subject: [PATCH 35/42] [se] Fix --- .../spreadsheet-calculation/PrintTests.js | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index 63217fa872..3716d4d504 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -1307,38 +1307,36 @@ $(function() { assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); - assert.strictEqual(ws.colBreaks.containsBreak(12), true, desc + " check col contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(12), true, desc + " check col contains 12"); assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 4"); - }, "change page col break_from3to4"); - }); - } + }, "change page col break_from3to12"); - function testPageBreakMove() { - QUnit.test("Test: page break move ", function (assert) { - //add breaks - ws = api.wbModel.aWorksheets[0]; + wsView.changeRowColBreaks(3, 12, new Asc.Range(0, 0, 16, 57), null, true); - let beforeFunc = function(desc) { - assert.strictEqual((ws.colBreaks == null || ws.colBreaks.getCount() === 0) ? null : 1, null, desc); - assert.strictEqual((ws.rowBreaks == null || ws.rowBreaks.getCount() === 0) ? null : 1, null, desc); - }; + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); - let insertColBreakId = 1; - let insertRowBreakId = 3; - wsView.setSelection(new Asc.Range(insertColBreakId, insertRowBreakId, insertColBreakId, insertRowBreakId)); - api.asc_InsertPageBreak(); + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains 3"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 3"); + }, function (desc){ - checkUndoRedo(beforeFunc, function (desc){ - assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); - assert.strictEqual(ws.colBreaks.containsBreak(insertColBreakId), true, desc + " check col contains"); - assert.strictEqual(ws.rowBreaks.containsBreak(insertRowBreakId), true, desc + " check row contains"); - }, "insert page break_col1row3"); + assert.strictEqual(ws.rowBreaks.containsBreak(12), true, desc + " check row contains 12"); + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains 4"); + }, "change page row break_from3to12"); }); } @@ -1351,7 +1349,6 @@ $(function() { testPageBreaksSimple(); testPageBreaksAndTitles(); testPageBreaksManipulation(); - //testPageBreakMove(); } From c3955bdf6a3da44e767742f9376ee8631e03860d Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Mon, 17 Jul 2023 13:11:39 +0500 Subject: [PATCH 36/42] [se] By tests --- .../spreadsheet-calculation/PrintTests.js | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/cell/spreadsheet-calculation/PrintTests.js b/tests/cell/spreadsheet-calculation/PrintTests.js index 3716d4d504..12a4ccbb1f 100644 --- a/tests/cell/spreadsheet-calculation/PrintTests.js +++ b/tests/cell/spreadsheet-calculation/PrintTests.js @@ -1338,6 +1338,54 @@ $(function() { }, "change page row break_from3to12"); + + wsView.changeRowColBreaks(8, 2, new Asc.Range(0, 0, 16, 57), true, true); + + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains 3"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 3"); + }, function (desc){ + + assert.strictEqual(ws.colBreaks.getCount(), 1, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(2), true, desc + " check col contains 12"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 4"); + + }, "change page col break_from8to2"); + + wsView.changeRowColBreaks(8, 2, new Asc.Range(0, 0, 16, 57), null, true); + + checkUndoRedo(function (desc) { + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 3, desc + " check row count"); + + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.rowBreaks.containsBreak(8), true, desc + " check row contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.rowBreaks.containsBreak(5), true, desc + " check row contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains 3"); + assert.strictEqual(ws.rowBreaks.containsBreak(3), true, desc + " check row contains 3"); + }, function (desc){ + + assert.strictEqual(ws.colBreaks.getCount(), 3, desc + " check col count"); + assert.strictEqual(ws.rowBreaks.getCount(), 1, desc + " check row count"); + + assert.strictEqual(ws.rowBreaks.containsBreak(2), true, desc + " check row contains 12"); + assert.strictEqual(ws.colBreaks.containsBreak(8), true, desc + " check col contains 8"); + assert.strictEqual(ws.colBreaks.containsBreak(5), true, desc + " check col contains 5"); + assert.strictEqual(ws.colBreaks.containsBreak(3), true, desc + " check col contains 4"); + + }, "change page row break_from8to2"); }); } From ae3992ee9eba50e42047a9a8b1ce2cf7a69f875a Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 18 Jul 2023 16:14:02 +0500 Subject: [PATCH 37/42] [se] Add asc_isContainsPageBreaks --- cell/api.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cell/api.js b/cell/api.js index 5a497510e4..c90425f979 100644 --- a/cell/api.js +++ b/cell/api.js @@ -8820,6 +8820,16 @@ var editor; return ws.resetAllPageBreaks(); }; + spreadsheet_api.prototype.asc_isContainsPageBreaks = function (index) { + if (!this.wbModel) { + return; + } + let sheetIndex = (undefined !== index && null !== index) ? index : this.wbModel.getActive(); + let ws = this.wbModel.getWorksheet(sheetIndex); + + return ws && ((ws.colBreaks && ws.colBreaks.getCount()) || (ws.rowBreaks && ws.rowBreaks.getCount())); + }; + /* * Export * ----------------------------------------------------------------------------- @@ -9388,6 +9398,8 @@ var editor; prot["asc_InsertPageBreak"] = prot.asc_InsertPageBreak; prot["asc_RemovePageBreak"] = prot.asc_RemovePageBreak; prot["asc_ResetAllPageBreaks"] = prot.asc_ResetAllPageBreaks; + prot["asc_isContainsPageBreaks"] = prot.asc_isContainsPageBreaks; + From 00bf82ff27bad9f656a3981a8fd395a00db4cf99 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 18 Jul 2023 16:57:19 +0500 Subject: [PATCH 38/42] [se] Add asc_GetPageBreaksDisableType --- cell/api.js | 45 ++++++++++++++++++++++++++++++++++++++------- cell/apiDefines.js | 17 ++++++++++++++++- 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/cell/api.js b/cell/api.js index c90425f979..056c023f69 100644 --- a/cell/api.js +++ b/cell/api.js @@ -5813,9 +5813,22 @@ var editor; return oWorksheet.getActiveCellCoord(useUpRightMerge); } } - }; + // Получить координаты активной ячейки + spreadsheet_api.prototype.asc_getActiveCell = function() { + var oWorksheet = this.wb.getWorksheet(); + if(oWorksheet){ + if(oWorksheet.isSelectOnShape){ + return null; + } + else{ + return oWorksheet.getActiveCell(); + } + } + + }; + // Получить координаты для каких-либо действий (для общей схемы) spreadsheet_api.prototype.asc_getAnchorPosition = function() { return this.asc_getActiveCellCoord(); @@ -8820,16 +8833,34 @@ var editor; return ws.resetAllPageBreaks(); }; - spreadsheet_api.prototype.asc_isContainsPageBreaks = function (index) { + spreadsheet_api.prototype.asc_GetPageBreaksDisableType = function (index) { if (!this.wbModel) { return; } let sheetIndex = (undefined !== index && null !== index) ? index : this.wbModel.getActive(); let ws = this.wbModel.getWorksheet(sheetIndex); + let res = Asc.c_oAscPageBreaksDisableType.none; + if (ws) { + let isPageBreaks = ws && ((ws.colBreaks && ws.colBreaks.getCount()) || (ws.rowBreaks && ws.rowBreaks.getCount())); + let activeCell = ws.selectionRange && ws.selectionRange.activeCell; + let isFirstActiveCell = activeCell && activeCell.col === 0 && activeCell.row === 0; + + if (isFirstActiveCell && !isPageBreaks) { + //disable all + res = Asc.c_oAscPageBreaksDisableType.all; + } else if (isFirstActiveCell && isPageBreaks) { + //disable insert/remove + res = Asc.c_oAscPageBreaksDisableType.insertRemove; + } else if (!isFirstActiveCell && !isPageBreaks) { + //disable reset + res = Asc.c_oAscPageBreaksDisableType.reset; + } + } - return ws && ((ws.colBreaks && ws.colBreaks.getCount()) || (ws.rowBreaks && ws.rowBreaks.getCount())); + return res; }; + /* * Export * ----------------------------------------------------------------------------- @@ -9395,10 +9426,10 @@ var editor; prot["asc_ChangeTextCase"] = prot.asc_ChangeTextCase; - prot["asc_InsertPageBreak"] = prot.asc_InsertPageBreak; - prot["asc_RemovePageBreak"] = prot.asc_RemovePageBreak; - prot["asc_ResetAllPageBreaks"] = prot.asc_ResetAllPageBreaks; - prot["asc_isContainsPageBreaks"] = prot.asc_isContainsPageBreaks; + prot["asc_InsertPageBreak"] = prot.asc_InsertPageBreak; + prot["asc_RemovePageBreak"] = prot.asc_RemovePageBreak; + prot["asc_ResetAllPageBreaks"] = prot.asc_ResetAllPageBreaks; + prot["asc_GetPageBreaksDisableType"]= prot.asc_GetPageBreaksDisableType; diff --git a/cell/apiDefines.js b/cell/apiDefines.js index e03a5aa286..7e717d0101 100644 --- a/cell/apiDefines.js +++ b/cell/apiDefines.js @@ -571,7 +571,15 @@ var c_oAscPopUpSelectorType = { path: 2 }; - //----------------------------------------------------------export---------------------------------------------------- + var c_oAscPageBreaksDisableType = { + none: 0, + all: 1, + insertRemove: 3, + reset: 3 + }; + + + //----------------------------------------------------------export---------------------------------------------------- window['AscCommonExcel'] = window['AscCommonExcel'] || {}; window['AscCommonExcel'].c_oAscDrawDepOptions = c_oAscDrawDepOptions; window['AscCommonExcel'].c_oAscScrollType = c_oAscScrollType; @@ -965,5 +973,12 @@ var c_oAscPopUpSelectorType = { prot['link'] = prot.link; prot['path'] = prot.path; + window['Asc']['c_oAscPageBreaksDisableType'] = window['Asc'].c_oAscPageBreaksDisableType = c_oAscPageBreaksDisableType; + prot = c_oAscPageBreaksDisableType; + prot['none'] = prot.none; + prot['all'] = prot.all; + prot['insertRemove'] = prot.insertRemove; + prot['reset'] = prot.reset; + })(window); From 3b63aa3be7cd352be5c2f470db45bf955e059f24 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 18 Jul 2023 16:58:56 +0500 Subject: [PATCH 39/42] [se] Fix style code --- cell/apiDefines.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cell/apiDefines.js b/cell/apiDefines.js index 7e717d0101..c71c937268 100644 --- a/cell/apiDefines.js +++ b/cell/apiDefines.js @@ -973,12 +973,12 @@ var c_oAscPopUpSelectorType = { prot['link'] = prot.link; prot['path'] = prot.path; - window['Asc']['c_oAscPageBreaksDisableType'] = window['Asc'].c_oAscPageBreaksDisableType = c_oAscPageBreaksDisableType; - prot = c_oAscPageBreaksDisableType; - prot['none'] = prot.none; - prot['all'] = prot.all; - prot['insertRemove'] = prot.insertRemove; - prot['reset'] = prot.reset; + window['Asc']['c_oAscPageBreaksDisableType'] = window['Asc'].c_oAscPageBreaksDisableType = c_oAscPageBreaksDisableType; + prot = c_oAscPageBreaksDisableType; + prot['none'] = prot.none; + prot['all'] = prot.all; + prot['insertRemove'] = prot.insertRemove; + prot['reset'] = prot.reset; })(window); From 6626567730400b66a97fd40803852b6c811ac094 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 18 Jul 2023 17:25:10 +0500 Subject: [PATCH 40/42] [se] Fix --- cell/apiDefines.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cell/apiDefines.js b/cell/apiDefines.js index c71c937268..dbb574f2a7 100644 --- a/cell/apiDefines.js +++ b/cell/apiDefines.js @@ -574,7 +574,7 @@ var c_oAscPopUpSelectorType = { var c_oAscPageBreaksDisableType = { none: 0, all: 1, - insertRemove: 3, + insertRemove: 2, reset: 3 }; From 5fd1547742563f095494151ac2210f3e19e00710 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 18 Jul 2023 17:53:49 +0500 Subject: [PATCH 41/42] [se] Fix --- cell/api.js | 51 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/cell/api.js b/cell/api.js index 056c023f69..a526c165ad 100644 --- a/cell/api.js +++ b/cell/api.js @@ -5899,10 +5899,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellBold = function(isBold) { - this.asc_InsertPageBreak(); - return; + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } - var ws = this.wb.getWorksheet(); + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellBold) { ws.objectRender.controller.setCellBold(isBold); } else { @@ -5912,10 +5913,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellItalic = function(isItalic) { - this.asc_RemovePageBreak() - return; + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } - var ws = this.wb.getWorksheet(); + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellItalic) { ws.objectRender.controller.setCellItalic(isItalic); } else { @@ -5925,10 +5927,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellUnderline = function(isUnderline) { - this.asc_ResetAllPageBreaks() - return; + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } - var ws = this.wb.getWorksheet(); + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellUnderline) { ws.objectRender.controller.setCellUnderline(isUnderline); } else { @@ -5938,7 +5941,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellStrikeout = function(isStrikeout) { - var ws = this.wb.getWorksheet(); + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellStrikeout) { ws.objectRender.controller.setCellStrikeout(isStrikeout); } else { @@ -5948,7 +5955,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellSubscript = function(isSubscript) { - var ws = this.wb.getWorksheet(); + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellSubscript) { ws.objectRender.controller.setCellSubscript(isSubscript); } else { @@ -5958,7 +5969,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellSuperscript = function(isSuperscript) { - var ws = this.wb.getWorksheet(); + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellSuperscript) { ws.objectRender.controller.setCellSuperscript(isSuperscript); } else { @@ -5968,7 +5983,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellAlign = function(align) { - var ws = this.wb.getWorksheet(); + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellAlign) { ws.objectRender.controller.setCellAlign(align); } else { @@ -5978,7 +5997,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellVertAlign = function(align) { - var ws = this.wb.getWorksheet(); + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + return; + } + + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellVertAlign) { ws.objectRender.controller.setCellVertAlign(align); } else { From 893141bb426ff9005798e728ff00057d375c61d7 Mon Sep 17 00:00:00 2001 From: Igor Zotov Date: Tue, 18 Jul 2023 18:49:17 +0500 Subject: [PATCH 42/42] [se] Fix style code --- cell/api.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cell/api.js b/cell/api.js index a526c165ad..1a09fe10ad 100644 --- a/cell/api.js +++ b/cell/api.js @@ -5913,11 +5913,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellItalic = function(isItalic) { - if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { return; - } + } - let ws = this.wb.getWorksheet(); + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellItalic) { ws.objectRender.controller.setCellItalic(isItalic); } else { @@ -5931,7 +5931,7 @@ var editor; return; } - let ws = this.wb.getWorksheet(); + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellUnderline) { ws.objectRender.controller.setCellUnderline(isUnderline); } else { @@ -5970,7 +5970,7 @@ var editor; spreadsheet_api.prototype.asc_setCellSuperscript = function(isSuperscript) { if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { - return; + return; } let ws = this.wb.getWorksheet(); @@ -5983,11 +5983,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellAlign = function(align) { - if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { return; - } + } - let ws = this.wb.getWorksheet(); + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellAlign) { ws.objectRender.controller.setCellAlign(align); } else { @@ -5997,11 +5997,11 @@ var editor; }; spreadsheet_api.prototype.asc_setCellVertAlign = function(align) { - if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { + if (this.collaborativeEditing.getGlobalLock() || !this.canEdit()) { return; - } + } - let ws = this.wb.getWorksheet(); + let ws = this.wb.getWorksheet(); if (ws.objectRender.selectedGraphicObjectsExists() && ws.objectRender.controller.setCellVertAlign) { ws.objectRender.controller.setCellVertAlign(align); } else {