From c2593774a779956876002dc86d40efa9e544ea6f Mon Sep 17 00:00:00 2001 From: GoshaZotov Date: Tue, 4 Feb 2025 12:24:10 +0000 Subject: [PATCH 01/18] fix/bug-59814 (#634) [se] Fix bug 59814 Co-authored-by: GoshaZotov Co-committed-by: GoshaZotov --- .../FormulaObjects/mathematicFunctions.js | 18 +- .../spreadsheet-calculation/FormulaTests.js | 392 ++++++++++++++++++ 2 files changed, 403 insertions(+), 7 deletions(-) diff --git a/cell/model/FormulaObjects/mathematicFunctions.js b/cell/model/FormulaObjects/mathematicFunctions.js index 902fdfbc31..b07ba52a6a 100644 --- a/cell/model/FormulaObjects/mathematicFunctions.js +++ b/cell/model/FormulaObjects/mathematicFunctions.js @@ -4069,7 +4069,7 @@ function (window, undefined) { return truncate(quotient + nolpiat) * significance; } - function roundHelper(number, num_digits) { + function roundHelper(number, decimals) { if (num_digits > AscCommonExcel.cExcelMaxExponent) { if (Math.abs(number) < 1 || num_digits < 1e10) // The values are obtained experimentally { @@ -4084,16 +4084,20 @@ function (window, undefined) { return new cNumber(0); } - var significance = SignZeroPositive(number) * Math.pow(10, -truncate(num_digits)); + const EPSILON = 1e-14; - number += significance / 2; + // ->integer + decimals = decimals >> 0; - if (number / significance == Infinity) { - return new cNumber(number); - } + const multiplier = Math.pow(10, decimals); + const shifted = Math.abs(number) * multiplier; - return new cNumber(Floor(number, significance)); + // Add epsilon to handle floating point precision issues (1.005 case) + const compensated = shifted + EPSILON; + const rounded = Math.floor(compensated + 0.5); + let result = (Math.sign(number) * rounded) / multiplier; + return new cNumber(result); } var arg0 = arg[0], arg1 = arg[1]; diff --git a/tests/cell/spreadsheet-calculation/FormulaTests.js b/tests/cell/spreadsheet-calculation/FormulaTests.js index b1a4da6283..10b49a1dfe 100644 --- a/tests/cell/spreadsheet-calculation/FormulaTests.js +++ b/tests/cell/spreadsheet-calculation/FormulaTests.js @@ -5939,6 +5939,398 @@ $(function () { assert.ok(oParser.parse()); assert.strictEqual(oParser.calculate().getValue(), -51); + oParser = new parserFormula("ROUND(183.64, 2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 183.64); + + ws.getRange2("A100").setValue("3.14159"); + ws.getRange2("A101").setValue("2.71828"); + ws.getRange2("A102").setValue("1.005"); + ws.getRange2("A103").setValue("-1.56789"); + ws.getRange2("A104").setValue("123.456"); + ws.getRange2("A105").setValue("0.4999"); + ws.getRange2("A106").setValue("-0.4999"); + ws.getRange2("A107").setValue("1000.567"); + ws.getRange2("A108").setValue("999.999"); + ws.getRange2("A109").setValue("5.55555"); + ws.getRange2("A110").setValue("1.123123"); + ws.getRange2("A111").setValue("1.123123"); + + ws.getRange2("B100").setValue("2"); + ws.getRange2("B101").setValue("3"); + ws.getRange2("B102").setValue("2"); + ws.getRange2("B103").setValue("1"); + ws.getRange2("B104").setValue("0"); + ws.getRange2("B105").setValue("2"); + ws.getRange2("B106").setValue("2"); + ws.getRange2("B107").setValue("-1"); + ws.getRange2("B108").setValue("2"); + ws.getRange2("B109").setValue("4"); + ws.getRange2("B110").setValue("6"); + ws.getRange2("B111").setValue("5"); + + + oParser = new parserFormula("ROUND(A100, B100)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3.14, "Round ROUND(A100, B100)"); + + oParser = new parserFormula("ROUND(A101, B101)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 2.718, "Round ROUND(A101, B101)"); + + oParser = new parserFormula("ROUND(A102, B102)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.01, "Round ROUND(A102, B102)"); + + oParser = new parserFormula("ROUND(A103, B103)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -1.6, "Round ROUND(A103, B103)"); + + oParser = new parserFormula("ROUND(A104, B104)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 123, "Round ROUND(A104, B104)"); + + oParser = new parserFormula("ROUND(A105, B105)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.5, "Round ROUND(A105, B105)"); + + oParser = new parserFormula("ROUND(A106, B106)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -0.5, "Round ROUND(A106, B106)"); + + oParser = new parserFormula("ROUND(A107, B107)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1000, "Round ROUND(A107, B107)"); + + oParser = new parserFormula("ROUND(A108, B108)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1000, "Round ROUND(A108, B108)"); + + oParser = new parserFormula("ROUND(A109, B109)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 5.5556, "Round ROUND(A109, B109)"); + + oParser = new parserFormula("ROUND(A110, B110)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.123123, "Round ROUND(A110, B110)"); + + oParser = new parserFormula("ROUND(A111, B111)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.12312, "Round ROUND(A111, B111)"); + + + oParser = new parserFormula("ROUND(1.123,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.12, "ROUND(1.123,2)"); + + oParser = new parserFormula("ROUND(1.125,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.13, "ROUND(1.125,2)"); + + oParser = new parserFormula("ROUND(1.005,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.01, "ROUND(1.005,2)"); + + oParser = new parserFormula("ROUND(1.995,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 2.00, "ROUND(1.995,2)"); + + + oParser = new parserFormula("ROUND(3.14159,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3, "ROUND(3.14159,0)"); + + oParser = new parserFormula("ROUND(3.14159,1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3.1, "ROUND(3.14159,1)"); + + oParser = new parserFormula("ROUND(3.14159,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3.14, "ROUND(3.14159,2)"); + + oParser = new parserFormula("ROUND(3.14159,3)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3.142, "ROUND(3.14159,3)"); + + oParser = new parserFormula("ROUND(3.14159,4)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3.1416, "ROUND(3.14159,4)"); + + + oParser = new parserFormula("ROUND(-1.123,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -1.12, "ROUND(-1.123,2)"); + + oParser = new parserFormula("ROUND(-1.125,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -1.13, "ROUND(-1.125,2)"); + + oParser = new parserFormula("ROUND(-1.005,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -1.01, "ROUND(-1.005,2)"); + + oParser = new parserFormula("ROUND(-1.995,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -2.00, "ROUND(-1.995,2)"); + + oParser = new parserFormula("ROUND(1.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 2, "ROUND(1.5,0)"); + + oParser = new parserFormula("ROUND(2.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3, "ROUND(2.5,0)"); + + oParser = new parserFormula("ROUND(3.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 4, "ROUND(3.5,0)"); + + oParser = new parserFormula("ROUND(-1.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -2, "ROUND(-1.5,0)"); + + oParser = new parserFormula("ROUND(-2.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -3, "ROUND(-2.5,0)"); + + // Negative decimal places tests + oParser = new parserFormula("ROUND(123.456,-1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 120, "ROUND(123.456,-1)"); + + oParser = new parserFormula("ROUND(123.456,-2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 100, "ROUND(123.456,-2)"); + + oParser = new parserFormula("ROUND(555.555,-1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 560, "ROUND(555.555,-1)"); + + oParser = new parserFormula("ROUND(555.555,-2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 600, "ROUND(555.555,-2)"); + + oParser = new parserFormula("ROUND(555.555,-3)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1000, "ROUND(555.555,-3)"); + + oParser = new parserFormula("ROUND(0.123456,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.12, "ROUND(0.123456,2)"); + + oParser = new parserFormula("ROUND(0.123456,3)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.123, "ROUND(0.123456,3)"); + + oParser = new parserFormula("ROUND(0.123456,4)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.1235, "ROUND(0.123456,4)"); + + oParser = new parserFormula("ROUND(0.999999,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.00, "ROUND(0.999999,2)"); + + oParser = new parserFormula("ROUND(123456.789,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 123456.79, "ROUND(123456.789,2)"); + + oParser = new parserFormula("ROUND(999999.999,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1000000.00, "ROUND(999999.999,2)"); + + oParser = new parserFormula("ROUND(1000000.001,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1000000.00, "ROUND(1000000.001,2)"); + + oParser = new parserFormula("ROUND(0.0000123456,5)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.00001, "ROUND(0.0000123456,5)"); + + oParser = new parserFormula("ROUND(0.0000123456,6)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.000012, "ROUND(0.0000123456,6)"); + + oParser = new parserFormula("ROUND(0.0000123456,7)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.0000123, "ROUND(0.0000123456,7)"); + + oParser = new parserFormula("ROUND(2.005,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 2.01, "ROUND(2.005,2)"); + + oParser = new parserFormula("ROUND(3.005,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3.01, "ROUND(3.005,2)"); + + oParser = new parserFormula("ROUND(4.005,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 4.01, "ROUND(4.005,2)"); + + oParser = new parserFormula("ROUND(5.005,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 5.01, "ROUND(5.005,2)"); + + oParser = new parserFormula("ROUND(0.333333,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.33, "ROUND(0.333333,2)"); + + oParser = new parserFormula("ROUND(0.666666,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.67, "ROUND(0.666666,2)"); + + oParser = new parserFormula("ROUND(0.166666,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.17, "ROUND(0.166666,2)"); + + oParser = new parserFormula("ROUND(0.142857,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.14, "ROUND(0.142857,2)"); + + oParser = new parserFormula("ROUND(3.141592653589793,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3.14, "ROUND(3.141592653589793,2)"); + + oParser = new parserFormula("ROUND(2.718281828459045,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 2.72, "ROUND(2.718281828459045,2)"); + + oParser = new parserFormula("ROUND(1.414213562373095,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.41, "ROUND(1.414213562373095,2)"); + + oParser = new parserFormula("ROUND(0.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1, "ROUND(0.5,0)"); + + oParser = new parserFormula("ROUND(1.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 2, "ROUND(1.5,0)"); + + oParser = new parserFormula("ROUND(2.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 3, "ROUND(2.5,0)"); + + oParser = new parserFormula("ROUND(-0.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -1, "ROUND(-0.5,0)"); + + oParser = new parserFormula("ROUND(-1.5,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -2, "ROUND(-1.5,0)"); + + oParser = new parserFormula("ROUND(1.23456789,1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.2, "ROUND(1.23456789,1)"); + + oParser = new parserFormula("ROUND(1.23456789,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.23, "ROUND(1.23456789,2)"); + + oParser = new parserFormula("ROUND(1.23456789,3)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.235, "ROUND(1.23456789,3)"); + + oParser = new parserFormula("ROUND(1.23456789,4)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.2346, "ROUND(1.23456789,4)"); + + oParser = new parserFormula("ROUND(1.23456789,5)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.23457, "ROUND(1.23456789,5)"); + + oParser = new parserFormula("ROUND(0,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0, "ROUND(0,2)"); + + oParser = new parserFormula("ROUND(0,0)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0, "ROUND(0,0)"); + + oParser = new parserFormula("ROUND(0,-2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0, "ROUND(0,-2)"); + + oParser = new parserFormula("ROUND(1.15,1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.2, "ROUND(1.15,1)"); + + oParser = new parserFormula("ROUND(1.25,1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.3, "ROUND(1.25,1)"); + + oParser = new parserFormula("ROUND(1.35,1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.4, "ROUND(1.35,1)"); + + oParser = new parserFormula("ROUND(1.45,1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.5, "ROUND(1.45,1)"); + + oParser = new parserFormula("ROUND(1.55,1)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 1.6, "ROUND(1.55,1)"); + + oParser = new parserFormula("ROUND(0.01,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.01, "ROUND(0.01,2)"); + + oParser = new parserFormula("ROUND(0.02,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.02, "ROUND(0.02,2)"); + + oParser = new parserFormula("ROUND(0.03,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.03, "ROUND(0.03,2)"); + + oParser = new parserFormula("ROUND(0.04,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.04, "ROUND(0.04,2)"); + + oParser = new parserFormula("ROUND(0.05,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 0.05, "ROUND(0.05,2)"); + + oParser = new parserFormula("ROUND(-0.01,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -0.01, "ROUND(-0.01,2)"); + + oParser = new parserFormula("ROUND(-0.02,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -0.02, "ROUND(-0.02,2)"); + + oParser = new parserFormula("ROUND(-0.03,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -0.03, "ROUND(-0.03,2)"); + + oParser = new parserFormula("ROUND(-0.04,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -0.04, "ROUND(-0.04,2)"); + + oParser = new parserFormula("ROUND(-0.05,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), -0.05, "ROUND(-0.05,2)"); + + + oParser = new parserFormula("ROUND(19.99,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 19.99, "ROUND(19.99,2)"); + + oParser = new parserFormula("ROUND(19.90,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 19.90, "ROUND(19.90,2)"); + + oParser = new parserFormula("ROUND(19.00,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 19.00, "ROUND(19.00,2)"); + + oParser = new parserFormula("ROUND(19.999,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 20.00, "ROUND(19.999,2)"); + + oParser = new parserFormula("ROUND(19.001,2)", "A1", ws); + assert.ok(oParser.parse()); + assert.strictEqual(oParser.calculate().getValue(), 19.00, "ROUND(19.001,2)"); + testArrayFormula2(assert, "ROUND", 2, 2); }); From a48acdc244f9c8c6e7997d79289945fc52a8b1df Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Wed, 5 Feb 2025 15:51:57 +0700 Subject: [PATCH 02/18] Fix bug #73082 --- word/apiBuilder.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/word/apiBuilder.js b/word/apiBuilder.js index 6420262f0e..247e294335 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -14879,6 +14879,28 @@ this.TablePr.TableBorders.InsideV = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); }; + /** + * Specifies the border which will be displayed on all table cell borders. + * @memberof ApiTablePr + * @typeofeditors ["CDE"] + * @param {BorderType} sType - The vertical table cell border style. + * @param {pt_8} nSize - The width of the current border measured in eighths of a point. + * @param {pt} nSpace - The spacing offset in the vertical table cells of the table measured in points used to place this border. + * @param {byte} r - Red color component value. + * @param {byte} g - Green color component value. + * @param {byte} b - Blue color component value. + * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderAll.js + */ + ApiTablePr.prototype.SetTableBorderAll = function(sType, nSize, nSpace, r, g, b) + { + this.TablePr.TableBorders.Top = private_GetTableBorder(sType, nSize, nSpace, r, g, b); + this.TablePr.TableBorders.Bottom = private_GetTableBorder(sType, nSize, nSpace, r, g, b); + this.TablePr.TableBorders.Left = private_GetTableBorder(sType, nSize, nSpace, r, g, b); + this.TablePr.TableBorders.Right = private_GetTableBorder(sType, nSize, nSpace, r, g, b); + this.TablePr.TableBorders.InsideH = private_GetTableBorder(sType, nSize, nSpace, r, g, b); + this.TablePr.TableBorders.InsideV = private_GetTableBorder(sType, nSize, nSpace, r, g, b); + this.private_OnChange(); + }; /** * Specifies an amount of space which will be left between the bottom extent of the cell contents and the border @@ -22548,6 +22570,7 @@ ApiTablePr.prototype["SetTableBorderRight"] = ApiTablePr.prototype.SetTableBorderRight; ApiTablePr.prototype["SetTableBorderInsideH"] = ApiTablePr.prototype.SetTableBorderInsideH; ApiTablePr.prototype["SetTableBorderInsideV"] = ApiTablePr.prototype.SetTableBorderInsideV; + ApiTablePr.prototype["SetTableBorderAll"] = ApiTablePr.prototype.SetTableBorderAll; ApiTablePr.prototype["SetTableCellMarginBottom"] = ApiTablePr.prototype.SetTableCellMarginBottom; ApiTablePr.prototype["SetTableCellMarginLeft"] = ApiTablePr.prototype.SetTableCellMarginLeft; ApiTablePr.prototype["SetTableCellMarginRight"] = ApiTablePr.prototype.SetTableCellMarginRight; From 75145f2ac3d669560e34aaa0d3cf3e16380511f4 Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Wed, 5 Feb 2025 16:39:54 +0700 Subject: [PATCH 03/18] [bu][de] Added new method --- word/apiBuilder.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/word/apiBuilder.js b/word/apiBuilder.js index 247e294335..82c9453302 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -5774,6 +5774,19 @@ return this.Document.GetText(oInnerProps); }; + + /** + * Returns the current paragraph where the cursor is located. + * @memberof ApiDocumentContent + * @typeofeditors ["CDE"] + * @return {ApiParagraph} + * @since 8.4.0 + * @see office-js-api/Examples/{Editor}/ApiDocumentContent/Methods/GetCurrentParagraph.js + */ + ApiDocumentContent.prototype.GetCurrentParagraph = function() + { + return new ApiParagraph(this.Document.GetCurrentParagraph()); + }; //------------------------------------------------------------------------------------------------------------------ // // ApiDocument @@ -22095,6 +22108,7 @@ ApiDocumentContent.prototype["GetAllParagraphs"] = ApiDocumentContent.prototype.GetAllParagraphs; ApiDocumentContent.prototype["GetAllTables"] = ApiDocumentContent.prototype.GetAllTables; ApiDocumentContent.prototype["GetText"] = ApiDocumentContent.prototype.GetText; + ApiDocumentContent.prototype["GetCurrentParagraph"] = ApiDocumentContent.prototype.GetCurrentParagraph; ApiRange.prototype["GetClassType"] = ApiRange.prototype.GetClassType; ApiRange.prototype["GetParagraph"] = ApiRange.prototype.GetParagraph; From f6c032cee9dc469cba4c05747b9e6d6731b2dca8 Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Wed, 5 Feb 2025 16:56:21 +0700 Subject: [PATCH 04/18] [bu][de] Fix method --- word/apiBuilder.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/word/apiBuilder.js b/word/apiBuilder.js index 82c9453302..a6d85998cb 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -5779,13 +5779,18 @@ * Returns the current paragraph where the cursor is located. * @memberof ApiDocumentContent * @typeofeditors ["CDE"] - * @return {ApiParagraph} + * @return {?ApiParagraph} * @since 8.4.0 * @see office-js-api/Examples/{Editor}/ApiDocumentContent/Methods/GetCurrentParagraph.js */ ApiDocumentContent.prototype.GetCurrentParagraph = function() { - return new ApiParagraph(this.Document.GetCurrentParagraph()); + let oPara = this.Document.GetCurrentParagraph(); + if (!oPara) { + return null; + } + + return new ApiParagraph(oPara); }; //------------------------------------------------------------------------------------------------------------------ // From 7f14f3b3163163e7e41861a164d5119010a50f0a Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Wed, 5 Feb 2025 18:21:13 +0700 Subject: [PATCH 05/18] Fix bug #46804 --- common/apiBase.js | 6 +- word/apiBuilder.js | 489 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 458 insertions(+), 37 deletions(-) diff --git a/common/apiBase.js b/common/apiBase.js index cb3cb2befa..df1d38252a 100644 --- a/common/apiBase.js +++ b/common/apiBase.js @@ -4859,17 +4859,21 @@ if (!this.internalEvents.hasOwnProperty(name)) this.internalEvents[name] = {}; this.internalEvents[name]["" + ((undefined === listenerId) ? 0 : listenerId)] = callback; + + return true; }; baseEditorsApi.prototype.detachEvent = function(name, listenerId) { if (!this.internalEvents.hasOwnProperty(name)) - return; + return false; var obj = this.internalEvents[name]; var prop = "" + ((undefined === listenerId) ? 0 : listenerId); if (obj[prop]) delete obj[prop]; if (0 === Object.getOwnPropertyNames(obj).length) delete this.internalEvents[name]; + + return true; }; baseEditorsApi.prototype.sendInternalEvent = function() { diff --git a/word/apiBuilder.js b/word/apiBuilder.js index a6d85998cb..68f00c32c5 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -1714,6 +1714,7 @@ * Sets the selection to the specified range. * @memberof ApiRange * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRange/Methods/Select.js */ ApiRange.prototype.Select = function(bUpdate) @@ -1755,6 +1756,8 @@ Document.SetDocPosType(controllerType); Document.UpdateSelection(); } + + return true; }; /** @@ -4907,11 +4910,13 @@ * Saves changes to the specified document. * @typeofeditors ["CDE"] * @memberof Api + * @returns {boolean} * @see office-js-api/Examples/{Editor}/Api/Methods/Save.js */ Api.prototype.Save = function() { this.SaveAfterMacros = true; + return true; }; /** @@ -5037,6 +5042,7 @@ * @memberof Api * @typeofeditors ["CDE"] * @param {ApiDocumentContent} documentContent - The document content which the main document content will be replaced with. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/Api/Methods/ReplaceDocumentContent.js */ Api.prototype.ReplaceDocumentContent = function(documentContent) @@ -5049,6 +5055,8 @@ oDocument.Add_ToContent(oDocument.Content.length, mailMergeContent[nElement].Copy(oDocument, oDocument.DrawingDocument), false); oDocument.Remove_FromContent(0, 1); + + return true; }; /** @@ -5082,6 +5090,7 @@ * @memberof Api * @param {JSON} message - The JSON object to convert. * @typeofeditors ["CDE"] + * @returns {object} - readed api class element * @see office-js-api/Examples/{Editor}/Api/Methods/FromJSON.js */ Api.prototype.FromJSON = function(message) @@ -5434,6 +5443,7 @@ * @typeofeditors ["CDE"] * @param {string} eventName - The event name. * @param {function} callback - Function to be called when the event fires. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/Api/Methods/attachEvent.js */ Api.prototype["attachEvent"] = Api.prototype.attachEvent; @@ -5444,6 +5454,7 @@ * @memberof Api * @typeofeditors ["CDE"] * @param {string} eventName - The event name. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/Api/Methods/detachEvent.js */ Api.prototype["detachEvent"] = Api.prototype.detachEvent; @@ -5505,6 +5516,7 @@ * @typeofeditors ["CDE", "CSE", "CPE"] * @param {number} nPos - The position where the current element will be added. * @param {DocumentElement} oElement - The document element which will be added at the current position. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocumentContent/Methods/AddElement.js */ ApiDocumentContent.prototype.AddElement = function(nPos, oElement) @@ -5515,7 +5527,11 @@ if (oElm.IsUseInDocument()) return false; this.Document.Internal_Content_Add(nPos, oElm); + + return true; } + + return false; }; /** * Pushes a paragraph or a table to actually add it to the document. @@ -5545,25 +5561,29 @@ * content to this paragraph, use the {@link ApiDocumentContent#GetElement} method. * @memberof ApiDocumentContent * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocumentContent/Methods/RemoveAllElements.js */ ApiDocumentContent.prototype.RemoveAllElements = function() { this.Document.Internal_Content_Remove(0, this.Document.Content.length, true); + return true; }; /** * Removes an element using the position specified. * @memberof ApiDocumentContent * @typeofeditors ["CDE", "CSE", "CPE"] * @param {number} nPos - The element number (position) in the document or inside other element. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocumentContent/Methods/RemoveElement.js */ ApiDocumentContent.prototype.RemoveElement = function(nPos) { if (nPos < 0 || nPos >= this.GetElementsCount()) - return; + return false; this.Document.Internal_Content_Remove(nPos, 1, true); + return true; }; /** * Returns a Range object that represents the part of the document contained in the document content. @@ -5813,11 +5833,13 @@ * Creates a new history point. * @typeofeditors ["CDE"] * @memberof ApiDocument + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/CreateNewHistoryPoint.js */ ApiDocument.prototype.CreateNewHistoryPoint = function() { this.Document.Create_NewHistoryPoint(AscDFH.historydescription_Document_ApiBuilder); + return true; }; /** * Returns a style by its name. @@ -5972,11 +5994,13 @@ * @memberof ApiDocument * @typeofeditors ["CDE"] * @param {boolean} isEvenAndOdd - If true the header/footer will be different for odd and even pages, if false they will be the same. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/SetEvenAndOddHdrFtr.js */ ApiDocument.prototype.SetEvenAndOddHdrFtr = function(isEvenAndOdd) { this.Document.Set_DocumentEvenAndOddHeaders(isEvenAndOdd); + return true; }; /** * Creates an abstract multilevel numbering with a specified type. @@ -6288,7 +6312,7 @@ * @param {string} oProperties.searchString - Search string. * @param {string} oProperties.replaceString - Replacement string. * @param {string} [oProperties.matchCase=true] - Case sensitive or not. - * + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/SearchAndReplace.js */ ApiDocument.prototype.SearchAndReplace = function(oProperties) @@ -6299,7 +6323,7 @@ var oSearchEngine = this.Document.Search(oProps); if (!oSearchEngine) - return; + return false; var sReplace = oProperties["replaceString"]; @@ -6314,6 +6338,7 @@ //sReplace = sReplace.replaceAll('\x1f', ""); this.Document.ReplaceSearchElement(sReplace, true, null, false); + return true; }; /** * Returns a list of all the content controls from the document. @@ -6478,6 +6503,7 @@ * @memberof ApiDocument * @typeofeditors ["CDE"] * @param {Array.} arrData - An array of form data to set to the specified forms. + * @returns {boolean} * @since 8.0.0 * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/SetFormsData.js */ @@ -6485,9 +6511,10 @@ { return executeNoFormLockCheck(function() { if (!arrData || !Array.isArray(arrData)) - return; + return false; this.Document.GetFormsManager().SetAllFormsData(arrData); + return true; }, this); }; /** @@ -6495,11 +6522,13 @@ * @memberof ApiDocument * @typeofeditors ["CDE"] * @param isTrack {boolean} - Specifies if the change tracking mode is set or not. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/SetTrackRevisions.js */ ApiDocument.prototype.SetTrackRevisions = function(isTrack) { this.Document.SetGlobalTrackRevisions(isTrack); + return true; }; /** * Checks if change tracking mode is enabled or not. @@ -6700,11 +6729,13 @@ * Removes the current selection. * @memberof ApiDocument * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/RemoveSelection.js */ ApiDocument.prototype.RemoveSelection = function() { this.Document.RemoveSelection(); + return true; }; /** * Searches for a scope of a document object. The search results are a collection of ApiRange objects. @@ -6881,6 +6912,7 @@ * Removes a watermark from the current document. * @memberof ApiDocument * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/RemoveWatermark.js */ ApiDocument.prototype.RemoveWatermark = function() @@ -6888,6 +6920,7 @@ let Settings = new Asc.CAscWatermarkProperties(); Settings.put_Type(Asc.c_oAscWatermarkType.None); this.Document.SetWatermarkPropsAction(Settings); + return true; }; /** @@ -6895,6 +6928,7 @@ * @memberof ApiDocument * @typeofeditors ["CDE"] * @param {boolean} [bOnlyPageNumbers=false] - Specifies that only page numbers will be updated. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/UpdateAllTOC.js */ ApiDocument.prototype.UpdateAllTOC = function(bOnlyPageNumbers) @@ -6913,14 +6947,14 @@ { oTOC = oDocument.GetTableOfContents(); if (!oTOC) - return; + return false; } if (oTOC instanceof AscCommonWord.CBlockLevelSdt) oTOC = oTOC.GetInnerTableOfContents(); if (!oTOC) - return; + return false; var oState = oDocument.SaveDocumentState(); @@ -6947,12 +6981,15 @@ oDocument.LoadDocumentState(oState); } } + + return true; }; /** * Updates all tables of figures in the current document. * @memberof ApiDocument * @typeofeditors ["CDE"] * @param {boolean} [bOnlyPageNumbers=false] - Specifies that only page numbers will be updated. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/UpdateAllTOF.js */ ApiDocument.prototype.UpdateAllTOF = function(bOnlyPageNumbers) @@ -6970,14 +7007,14 @@ { oTOC = oDocument.GetTableOfContents(); if (!oTOC) - return; + return false; } if (oTOC instanceof AscCommonWord.CBlockLevelSdt) oTOC = oTOC.GetInnerTableOfContents(); if (!oTOC) - return; + return false; var oState = oDocument.SaveDocumentState(); @@ -7004,18 +7041,22 @@ oDocument.LoadDocumentState(oState); } } + + return true; }; /** * Updates all fields in the document. * @memberof ApiDocument * @typeofeditors ["CDE"] * @param {boolean} [bBySelection=false] - Specifies whether all fields will be updated within the selection. + * @returns {boolean} * @since 8.2.0 * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/UpdateAllFields.js */ ApiDocument.prototype.UpdateAllFields = function(bBySelection) { this.Document.UpdateFields(bBySelection); + return true; }; /** * Converts the ApiDocument object into the JSON object. @@ -7073,11 +7114,13 @@ * Clears all forms in the document. * @memberof ApiDocument * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/ClearAllFields.js */ ApiDocument.prototype.ClearAllFields = function() { this.Document.ClearAllSpecialForms(false); + return true; }; /** @@ -7088,6 +7131,7 @@ * @param {byte} b - Blue color component value. * @param {boolean} [bNone=false] - Defines that highlight will not be set. * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/SetFormsHighlight.js */ ApiDocument.prototype.SetFormsHighlight = function(r, g, b, bNone) @@ -7096,6 +7140,8 @@ this.Document.SetSpecialFormsHighlight(null, null, null); else this.Document.SetSpecialFormsHighlight(r, g, b); + + return true; }; /** @@ -7228,22 +7274,26 @@ * Accepts all changes made in review mode. * @memberof ApiDocument * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/AcceptAllRevisionChanges.js */ ApiDocument.prototype.AcceptAllRevisionChanges = function() { this.Document.AcceptAllRevisionChanges(); + return true; }; /** * Rejects all changes made in review mode. * @memberof ApiDocument * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/RejectAllRevisionChanges.js */ ApiDocument.prototype.RejectAllRevisionChanges = function() { this.Document.RejectAllRevisionChanges(); + return true; }; /** @@ -7334,6 +7384,7 @@ * @param {string} sImageUrl - The image source where the image to be inserted should be taken from (currently, only internet URL or Base64 encoded images are supported). * @param {EMU} Width - The image width in English measure units. * @param {EMU} Height - The image height in English measure units. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/ReplaceCurrentImage.js */ ApiDocument.prototype.ReplaceCurrentImage = function(sImageUrl, Width, Height) @@ -7343,6 +7394,7 @@ let dK = 1 / 36000 / AscCommon.g_dKoef_pix_to_mm; oDrawingObjects.putImageToSelection(sImageUrl, Width * dK, Height * dK ); + return true; }; /** @@ -7433,6 +7485,7 @@ * @param {byte} b - Blue color component value. * @param {boolean} [bNone=false] - Defines that highlight will not be set. * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/SetControlsHighlight.js */ ApiDocument.prototype.SetControlsHighlight = function(r, g, b, bNone) @@ -7444,6 +7497,7 @@ this.Document.SetSdtGlobalShowHighlight(true); this.Document.SetSdtGlobalColor(r, g, b); } + return true; }; /** @@ -7452,6 +7506,7 @@ * @memberof ApiDocument * @typeofeditors ["CDE"] * @param {TocPr} [oTocPr={}] - Table of contents properties. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/AddTableOfContents.js */ ApiDocument.prototype.AddTableOfContents = function(oTocPr) @@ -7523,7 +7578,7 @@ var oInnerTOC = oTOC.GetInnerTableOfContents(); oTOC = oInnerTOC; if (!oTOC) - return; + return false; var oStyles = this.Document.GetStyles(); var nStylesType = oTargetPr.get_StylesType(); @@ -7535,10 +7590,11 @@ oTOC.SetPr(oTargetPr); oTOC.Update(); - return; + return true; } this.Document.AddTableOfContents(null, oTargetPr, undefined); + return true; }; /** @@ -7978,6 +8034,7 @@ * @param {"unicode" | "latex"} [sFormat="unicode"] - The format of the specified linear representation. * @memberof ApiDocument * @typeofeditors ["CDE"] + * @returns {boolean} * @since 8.2.0 * @see office-js-api/Examples/{Editor}/ApiDocument/Methods/AddMathEquation.js */ @@ -7998,9 +8055,10 @@ let info = logicDocument.GetSelectedElementsInfo(); let paraMath = info.GetMath(); if (!paraMath) - return; + return false; paraMath.ConvertView(false, "latex" === format ? Asc.c_oAscMathInputType.LaTeX : Asc.c_oAscMathInputType.Unicode); + return true; }; /** @@ -8195,14 +8253,16 @@ * @typeofeditors ["CDE"] * @see Same as {@link ApiParagraph#SetNumPr} * @param {ApiNumberingLevel} oNumberingLevel - The numbering level which will be used for assigning the numbers to the paragraph. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParagraph/Methods/SetNumbering.js */ ApiParagraph.prototype.SetNumbering = function(oNumberingLevel) { if (!(oNumberingLevel instanceof ApiNumberingLevel)) - return; + return false; this.SetNumPr(oNumberingLevel.GetNumbering(), oNumberingLevel.GetLevelIndex()); + return true; }; /** * Returns a number of elements in the current paragraph. @@ -8240,15 +8300,17 @@ * @memberof ApiParagraph * @typeofeditors ["CDE", "CSE", "CPE"] * @param {number} nPos - The element position which we want to remove from the paragraph. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParagraph/Methods/RemoveElement.js */ ApiParagraph.prototype.RemoveElement = function(nPos) { if (nPos < 0 || nPos >= this.Paragraph.Content.length - 1) - return; + return false; this.Paragraph.RemoveFromContent(nPos, 1); this.Paragraph.CorrectContent(); + return true; }; /** * Removes all the elements from the current paragraph. @@ -8256,6 +8318,7 @@ * content to this run, use the {@link ApiParagraph#GetElement} method. * @memberof ApiParagraph * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParagraph/Methods/RemoveAllElements.js */ ApiParagraph.prototype.RemoveAllElements = function() @@ -8265,6 +8328,8 @@ this.Paragraph.RemoveFromContent(0, this.Paragraph.Content.length - 1); this.Paragraph.CorrectContent(); } + + return true; }; /** * Deletes the current paragraph. @@ -9316,6 +9381,7 @@ * Wraps the paragraph content in a mail merge field. * @memberof ApiParagraph * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParagraph/Methods/WrapInMailMergeField.js */ ApiParagraph.prototype.WrapInMailMergeField = function() @@ -9342,6 +9408,7 @@ this.RemoveAllElements(); oDocument.Register_Field(oField); this.Paragraph.AddToParagraph(oField); + return true; }; /** @@ -9946,26 +10013,31 @@ * Clears the content from the current run. * @memberof ApiRun * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/ClearContent.js */ ApiRun.prototype.ClearContent = function() { this.Run.Remove_FromContent(0, this.Run.Content.length); + return true; }; /** * Removes all the elements from the current run. * @memberof ApiRun * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/RemoveAllElements.js */ ApiRun.prototype.RemoveAllElements = function() { this.Run.Remove_FromContent(0, this.Run.Content.length); + return true; }; /** * Deletes the current run. * @memberof ApiRun * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/Delete.js */ ApiRun.prototype.Delete = function() @@ -9980,60 +10052,72 @@ } else return false; + + return true; }; /** * Adds some text to the current run. * @memberof ApiRun * @typeofeditors ["CDE", "CSE", "CPE"] * @param {string} sText - The text which will be added to the current run. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/AddText.js */ ApiRun.prototype.AddText = function(sText) { if (!sText || !sText.length) - return; + return false; this.Run.AddText(sText); + return true; }; /** * Adds a page break and starts the next element from a new page. * @memberof ApiRun * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/AddPageBreak.js */ ApiRun.prototype.AddPageBreak = function() { this.Run.Add_ToContent(this.Run.Content.length, new AscWord.CRunBreak(AscWord.break_Page)); + return true; }; /** * Adds a line break to the current run position and starts the next element from a new line. * @memberof ApiRun * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/AddLineBreak.js */ ApiRun.prototype.AddLineBreak = function() { this.Run.Add_ToContent(this.Run.Content.length, new AscWord.CRunBreak(AscWord.break_Line)); + return true; }; /** * Adds a column break to the current run position and starts the next element from a new column. * @memberof ApiRun * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/AddColumnBreak.js */ ApiRun.prototype.AddColumnBreak = function() { this.Run.Add_ToContent(this.Run.Content.length, new AscWord.CRunBreak(AscWord.break_Column)); + return true; }; /** * Adds a tab stop to the current run. * @memberof ApiRun * @typeofeditors ["CDE", "CSE", "CPE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/AddTabStop.js */ ApiRun.prototype.AddTabStop = function() { this.Run.Add_ToContent(this.Run.Content.length, new AscWord.CRunTab()); + return true; }; /** * Adds a drawing object (image, shape or chart) to the current text run. @@ -10581,6 +10665,7 @@ * Wraps a run in a mail merge field. * @memberof ApiRun * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiRun/Methods/WrapInMailMergeField.js */ ApiRun.prototype.WrapInMailMergeField = function() @@ -10608,6 +10693,7 @@ } oDocument.Register_Field(oField); + return true; }; /** * Converts the ApiRun object into the JSON object. @@ -10760,20 +10846,35 @@ * @memberof ApiSection * @typeofeditors ["CDE"] * @param {SectionBreakType} sType - The section break type. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetType.js */ ApiSection.prototype.SetType = function(sType) { - if ("oddPage" === sType) - this.Section.Set_Type(c_oAscSectionBreakType.OddPage); - else if ("evenPage" === sType) - this.Section.Set_Type(c_oAscSectionBreakType.EvenPage); - else if ("continuous" === sType) - this.Section.Set_Type(c_oAscSectionBreakType.Continuous); - else if ("nextColumn" === sType) - this.Section.Set_Type(c_oAscSectionBreakType.Column); - else if ("nextPage" === sType) - this.Section.Set_Type(c_oAscSectionBreakType.NextPage); + switch (sType) { + case "oddPage": { + this.Section.Set_Type(c_oAscSectionBreakType.OddPage); + return true; + } + case "evenPage": { + this.Section.Set_Type(c_oAscSectionBreakType.EvenPage); + return true; + } + case "continuous": { + this.Section.Set_Type(c_oAscSectionBreakType.Continuous); + return true; + } + case "nextColumn": { + this.Section.Set_Type(c_oAscSectionBreakType.Column); + return true; + } + case "nextPage": { + this.Section.Set_Type(c_oAscSectionBreakType.NextPage); + return true; + } + default: + return false; + } }; /** @@ -10806,6 +10907,7 @@ * @typeofeditors ["CDE"] * @param {number} nCount - Number of columns. * @param {twips} nSpace - Distance between columns measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetEqualColumns.js */ ApiSection.prototype.SetEqualColumns = function(nCount, nSpace) @@ -10813,6 +10915,7 @@ this.Section.Set_Columns_EqualWidth(true); this.Section.Set_Columns_Num(nCount); this.Section.Set_Columns_Space(private_Twips2MM(nSpace)); + return true; }; /** * Specifies that all the columns in the current section have the different widths. Number of columns is equal @@ -10821,12 +10924,13 @@ * @typeofeditors ["CDE"] * @param {twips[]} aWidths - An array of column width values measured in twentieths of a point (1/1440 of an inch). * @param {twips[]} aSpaces - An array of distance values between the columns measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetNotEqualColumns.js */ ApiSection.prototype.SetNotEqualColumns = function(aWidths, aSpaces) { if (!aWidths || !aWidths.length || aWidths.length <= 1 || aSpaces.length !== aWidths.length - 1) - return; + return false; this.Section.Set_Columns_EqualWidth(false); var aCols = []; @@ -10840,6 +10944,7 @@ this.Section.Set_Columns_Cols(aCols); this.Section.Set_Columns_Num(aCols.length); + return true; }; /** * Specifies the properties (size and orientation) for all the pages in the current section. @@ -10848,12 +10953,14 @@ * @param {twips} nWidth - The page width measured in twentieths of a point (1/1440 of an inch). * @param {twips} nHeight - The page height measured in twentieths of a point (1/1440 of an inch). * @param {boolean} [isPortrait=false] - Specifies the orientation of all the pages in this section (if set to true, then the portrait orientation is chosen). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetPageSize.js */ ApiSection.prototype.SetPageSize = function(nWidth, nHeight, isPortrait) { this.Section.SetPageSize(private_Twips2MM(nWidth), private_Twips2MM(nHeight)); this.Section.SetOrientation(false === isPortrait ? Asc.c_oAscPageOrientation.PageLandscape : Asc.c_oAscPageOrientation.PagePortrait, false); + return true; }; /** * Gets page height for current section. @@ -10886,22 +10993,26 @@ * @param {twips} nTop - The top margin height measured in twentieths of a point (1/1440 of an inch). * @param {twips} nRight - The right margin width measured in twentieths of a point (1/1440 of an inch). * @param {twips} nBottom - The bottom margin height measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetPageMargins.js */ ApiSection.prototype.SetPageMargins = function(nLeft, nTop, nRight, nBottom) { this.Section.SetPageMargins(private_Twips2MM(nLeft), private_Twips2MM(nTop), private_Twips2MM(nRight), private_Twips2MM(nBottom)); + return true; }; /** * Specifies the distance from the top edge of the page to the top edge of the header. * @memberof ApiSection * @typeofeditors ["CDE"] * @param {twips} nDistance - The distance from the top edge of the page to the top edge of the header measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetHeaderDistance.js */ ApiSection.prototype.SetHeaderDistance = function(nDistance) { this.Section.SetPageMarginHeader(private_Twips2MM(nDistance)); + return true; }; /** * Specifies the distance from the bottom edge of the page to the bottom edge of the footer. @@ -10909,11 +11020,13 @@ * @typeofeditors ["CDE"] * @param {twips} nDistance - The distance from the bottom edge of the page to the bottom edge of the footer measured * in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetFooterDistance.js */ ApiSection.prototype.SetFooterDistance = function(nDistance) { this.Section.SetPageMarginFooter(private_Twips2MM(nDistance)); + return true; }; /** * Returns the content for the specified header type. @@ -10960,6 +11073,7 @@ * @memberof ApiSection * @typeofeditors ["CDE"] * @param {HdrFtrType} sType - Header type to be removed. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/RemoveHeader.js */ ApiSection.prototype.RemoveHeader = function(sType) @@ -10970,6 +11084,10 @@ this.Section.Set_Header_Even(null); else if ("default" === sType) this.Section.Set_Header_Default(null); + else + return false; + + return true; }; /** * Returns the content for the specified footer type. @@ -11017,6 +11135,7 @@ * @memberof ApiSection * @typeofeditors ["CDE"] * @param {HdrFtrType} sType - Footer type to be removed. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/RemoveFooter.js */ ApiSection.prototype.RemoveFooter = function(sType) @@ -11027,17 +11146,23 @@ this.Section.Set_Footer_Even(null); else if ("default" === sType) this.Section.Set_Footer_Default(null); + else + return false; + + return true; }; /** * Specifies whether the current section in this document has the different header and footer for the section first page. * @memberof ApiSection * @typeofeditors ["CDE"] * @param {boolean} isTitlePage - If true, the first page of the section will have header and footer that will differ from the other pages of the same section. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiSection/Methods/SetTitlePage.js */ ApiSection.prototype.SetTitlePage = function(isTitlePage) { this.Section.Set_TitlePage(private_GetBoolean(isTitlePage)); + return true; }; /** * Returns the next section if exists. @@ -11303,6 +11428,7 @@ * @param {boolean} isLastRow - Specifies that the last row conditional formatting will be applied to the table. * @param {boolean} isHorBand - Specifies that the horizontal band conditional formatting will not be applied to the table. * @param {boolean} isVerBand - Specifies that the vertical band conditional formatting will not be applied to the table. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTable/Methods/SetTableLook.js */ ApiTable.prototype.SetTableLook = function(isFirstColumn, isFirstRow, isLastColumn, isLastRow, isHorBand, isVerBand) @@ -11314,6 +11440,7 @@ private_GetBoolean(isHorBand), private_GetBoolean(isVerBand)); this.Table.Set_TableLook(oTableLook); + return true; }; /** * Splits the cell into a given number of rows and columns. @@ -11418,6 +11545,7 @@ * @param {ApiTableCell} [oCell] - The cell after which a new column will be added. If not specified, a new column will be added at the end of the table. * @param {boolean} [isBefore=false] - Adds a new column before (false) or after (true) the specified cell. If no cell is specified, * then this parameter will be ignored. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTable/Methods/AddColumn.js */ ApiTable.prototype.AddColumn = function(oCell, isBefore) @@ -11441,6 +11569,7 @@ this.Table.AddTableColumn(_isBefore); private_EndSilentMode(); + return true; }; /** * Adds the new columns to the current table. @@ -11450,6 +11579,7 @@ * @param {Number} nCount - Count of columns to be added. * @param {boolean} [isBefore=false] - Adds the new columns before (false) or after (true) the specified cell. If no cell is specified, * then this parameter will be ignored. + * @returns {ApiTable} * @see office-js-api/Examples/{Editor}/ApiTable/Methods/AddColumns.js */ ApiTable.prototype.AddColumns = function(oCell, nCount, isBefore) @@ -11468,6 +11598,7 @@ * @param {ApiTableCell} oCell - The cell where the specified element will be added. * @param {number} nPos - The position in the cell where the specified element will be added. * @param {DocumentElement} oElement - The document element which will be added at the current position. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTable/Methods/AddElement.js */ ApiTable.prototype.AddElement = function(oCell, nPos, oElement) @@ -12877,11 +13008,13 @@ * @memberof ApiStyle * @typeofeditors ["CDE"] * @param {string} sStyleName - The name which will be used for the current style. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiStyle/Methods/SetName.js */ ApiStyle.prototype.SetName = function(sStyleName) { this.Style.Set_Name(sStyleName); + return true; }; /** * Returns a type of the current style. @@ -12976,14 +13109,16 @@ * @memberof ApiStyle * @typeofeditors ["CDE"] * @param {ApiStyle} oStyle - The parent style which the style inherits properties from. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiStyle/Methods/SetBasedOn.js */ ApiStyle.prototype.SetBasedOn = function(oStyle) { if (!(oStyle instanceof ApiStyle) || this.Style.Get_Type() !== oStyle.Style.Get_Type()) - return; + return false; this.Style.Set_BasedOn(oStyle.Style.Get_Id()); + return true; }; /** * Returns a set of formatting properties which will be conditionally applied to the parts of a table that match the @@ -13788,15 +13923,17 @@ * @memberof ApiParaPr * @typeofeditors ["CDE"] * @param {ApiStyle} oStyle - The style of the paragraph to be set. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetStyle.js */ ApiParaPr.prototype.SetStyle = function(oStyle) { if (!oStyle || !(oStyle instanceof ApiStyle)) - return; + return false; this.ParaPr.PStyle = oStyle.Style.Get_Id(); this.private_OnChange(); + return true; }; /** * Returns the paragraph style method. @@ -13833,24 +13970,28 @@ * @memberof ApiParaPr * @typeofeditors ["CDE"] * @param {boolean} isContextualSpacing - The true value will enable the paragraph contextual spacing. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetContextualSpacing.js */ ApiParaPr.prototype.SetContextualSpacing = function(isContextualSpacing) { this.ParaPr.ContextualSpacing = private_GetBoolean(isContextualSpacing); this.private_OnChange(); + return true; }; /** * Sets the paragraph left side indentation. * @memberof ApiParaPr * @typeofeditors ["CDE", "CSE", "CPE"] * @param {twips} nValue - The paragraph left side indentation value measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetIndLeft.js */ ApiParaPr.prototype.SetIndLeft = function(nValue) { this.ParaPr.Ind.Left = private_Twips2MM(nValue); this.private_OnChange(); + return true; }; /** * Returns the paragraph left side indentation. @@ -13874,12 +14015,14 @@ * @memberof ApiParaPr * @typeofeditors ["CDE", "CSE", "CPE"] * @param {twips} nValue - The paragraph right side indentation value measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetIndRight.js */ ApiParaPr.prototype.SetIndRight = function(nValue) { this.ParaPr.Ind.Right = private_Twips2MM(nValue); this.private_OnChange(); + return true; }; /** * Returns the paragraph right side indentation. @@ -13904,12 +14047,14 @@ * @memberof ApiParaPr * @typeofeditors ["CDE", "CSE", "CPE"] * @param {twips} nValue - The paragraph first line indentation value measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetIndFirstLine.js */ ApiParaPr.prototype.SetIndFirstLine = function(nValue) { this.ParaPr.Ind.FirstLine = private_Twips2MM(nValue); this.private_OnChange(); + return true; }; /** * Returns the paragraph first line indentation. @@ -13936,12 +14081,14 @@ * @typeofeditors ["CDE", "CSE", "CPE"] * @param {("left" | "right" | "both" | "center")} sJc - The justification type that * will be applied to the paragraph contents. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetJc.js */ ApiParaPr.prototype.SetJc = function(sJc) { this.ParaPr.Jc = private_GetParaAlign(sJc); this.private_OnChange(); + return true; }; /** * Returns the paragraph contents justification. @@ -13984,12 +14131,14 @@ * @memberof ApiParaPr * @typeofeditors ["CDE"] * @param {boolean} isKeepLines - The true value enables the option to keep lines of the paragraph on a single page. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetKeepLines.js */ ApiParaPr.prototype.SetKeepLines = function(isKeepLines) { this.ParaPr.KeepLines = isKeepLines; this.private_OnChange(); + return true; }; /** * Specifies that when rendering the document using a paginated view, the contents of the current paragraph are at least @@ -13998,12 +14147,14 @@ * @typeofeditors ["CDE"] * @param {boolean} isKeepNext - The true value enables the option to keep lines of the paragraph on the same * page as the following paragraph. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetKeepNext.js */ ApiParaPr.prototype.SetKeepNext = function(isKeepNext) { this.ParaPr.KeepNext = isKeepNext; this.private_OnChange(); + return true; }; /** * Specifies that when rendering the document using a paginated view, the contents of the current paragraph are rendered at @@ -14012,12 +14163,14 @@ * @typeofeditors ["CDE"] * @param {boolean} isPageBreakBefore - The true value enables the option to render the contents of the paragraph * at the beginning of a new page in the document. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetPageBreakBefore.js */ ApiParaPr.prototype.SetPageBreakBefore = function(isPageBreakBefore) { this.ParaPr.PageBreakBefore = isPageBreakBefore; this.private_OnChange(); + return true; }; /** * Sets the paragraph line spacing. If the value of the sLineRule parameter is either @@ -14028,6 +14181,7 @@ * @typeofeditors ["CDE", "CSE", "CPE"] * @param {(twips | line240)} nLine - The line spacing value measured either in twentieths of a point (1/1440 of an inch) or in 240ths of a line. * @param {("auto" | "atLeast" | "exact")} sLineRule - The rule that determines the measuring units of the line spacing. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetSpacingLine.js */ ApiParaPr.prototype.SetSpacingLine = function(nLine, sLineRule) @@ -14053,6 +14207,7 @@ } this.private_OnChange(); + return true; }; /** * Returns the paragraph line spacing value. @@ -14130,6 +14285,7 @@ * @typeofeditors ["CDE", "CSE", "CPE"] * @param {twips} nBefore - The value of the spacing before the current paragraph measured in twentieths of a point (1/1440 of an inch). * @param {boolean} [isBeforeAuto=false] - The true value disables the spacing before the current paragraph. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetSpacingBefore.js */ ApiParaPr.prototype.SetSpacingBefore = function(nBefore, isBeforeAuto) @@ -14141,6 +14297,7 @@ this.ParaPr.Spacing.BeforeAutoSpacing = isBeforeAuto; this.private_OnChange(); + return true; }; /** * Returns the spacing before value of the current paragraph. @@ -14169,6 +14326,7 @@ * @typeofeditors ["CDE", "CSE", "CPE"] * @param {twips} nAfter - The value of the spacing after the current paragraph measured in twentieths of a point (1/1440 of an inch). * @param {boolean} [isAfterAuto=false] - The true value disables the spacing after the current paragraph. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetSpacingAfter.js */ ApiParaPr.prototype.SetSpacingAfter = function(nAfter, isAfterAuto) @@ -14180,6 +14338,7 @@ this.ParaPr.Spacing.AfterAutoSpacing = isAfterAuto; this.private_OnChange(); + return true; }; /** * Returns the spacing after value of the current paragraph. @@ -14209,12 +14368,14 @@ * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. * @param {boolean} [isAuto=false] - The true value disables paragraph contents shading. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetShd.js */ ApiParaPr.prototype.SetShd = function(sType, r, g, b, isAuto) { this.ParaPr.Shd = private_GetShd(sType, r, g, b, isAuto); this.private_OnChange(); + return true; }; /** * Returns the shading applied to the contents of the paragraph. @@ -14262,12 +14423,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetBottomBorder.js */ ApiParaPr.prototype.SetBottomBorder = function(sType, nSize, nSpace, r, g, b) { this.ParaPr.Brd.Bottom = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies the border which will be displayed at the left side of the page around the specified paragraph. @@ -14279,12 +14442,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetLeftBorder.js */ ApiParaPr.prototype.SetLeftBorder = function(sType, nSize, nSpace, r, g, b) { this.ParaPr.Brd.Left = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies the border which will be displayed at the right side of the page around the specified paragraph. @@ -14296,12 +14461,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetRightBorder.js */ ApiParaPr.prototype.SetRightBorder = function(sType, nSize, nSpace, r, g, b) { this.ParaPr.Brd.Right = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies the border which will be displayed above a set of paragraphs which have the same set of paragraph border settings. @@ -14314,12 +14481,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetTopBorder.js */ ApiParaPr.prototype.SetTopBorder = function(sType, nSize, nSpace, r, g, b) { this.ParaPr.Brd.Top = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies the border which will be displayed between each paragraph in a set of paragraphs which have the same set of paragraph border settings. @@ -14331,24 +14500,28 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetBetweenBorder.js */ ApiParaPr.prototype.SetBetweenBorder = function(sType, nSize, nSpace, r, g, b) { this.ParaPr.Brd.Between = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies whether a single line of the current paragraph will be displayed on a separate page from the remaining content at display time by moving the line onto the following page. * @memberof ApiParaPr * @typeofeditors ["CDE"] * @param {boolean} isWidowControl - The true value means that a single line of the current paragraph will be displayed on a separate page from the remaining content at display time by moving the line onto the following page. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetWidowControl.js */ ApiParaPr.prototype.SetWidowControl = function(isWidowControl) { this.ParaPr.WidowControl = isWidowControl; this.private_OnChange(); + return true; }; /** * Specifies a sequence of custom tab stops which will be used for any tab characters in the current paragraph. @@ -14359,12 +14532,13 @@ * measured in twentieths of a point (1/1440 of an inch). * @param {TabJc[]} aVal - An array of the styles of custom tab stops, which determines the behavior of the tab * stop and the alignment which will be applied to text entered at the current custom tab stop. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetTabs.js */ ApiParaPr.prototype.SetTabs = function(aPos, aVal) { if (!(aPos instanceof Array) || !(aVal instanceof Array) || aPos.length !== aVal.length) - return; + return false; var oTabs = new CParaTabs(); for (var nIndex = 0, nCount = aPos.length; nIndex < nCount; ++nIndex) @@ -14373,6 +14547,7 @@ } this.ParaPr.Tabs = oTabs; this.private_OnChange(); + return true; }; /** * Specifies that the current paragraph references a numbering definition instance in the current document. @@ -14382,12 +14557,13 @@ * @param {number} [nLvl=0] - Specifies a numbering level reference. If the current instance of the ApiParaPr class is direct * formatting of a paragraph, then this parameter MUST BE specified. Otherwise, if the current instance of the ApiParaPr class * is the part of ApiStyle properties, this parameter will be ignored. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiParaPr/Methods/SetNumPr.js */ ApiParaPr.prototype.SetNumPr = function(oNumPr, nLvl) { if (!(oNumPr instanceof ApiNumbering)) - return; + return false; let numId = oNumPr.Num.GetId(); let numLvl = undefined; @@ -14397,6 +14573,7 @@ this.ParaPr.NumPr = new AscWord.NumPr(numId, numLvl); this.private_OnChange(); + return true; }; /** * Sets the bullet or numbering to the current paragraph. @@ -14584,6 +14761,7 @@ * @typeofeditors ["CDE"] * @param {("none" | "bullet" | "1)" | "1." | "I." | "A." | "a)" | "a." | "i." )} sType - The predefined numbering template. * @param {string} [sSymbol=""] - The symbol used for the list numbering. This parameter has the meaning only if the predefined numbering template is "bullet". + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiNumberingLevel/Methods/SetTemplateType.js */ ApiNumberingLevel.prototype.SetTemplateType = function(sType, sSymbol) @@ -14617,7 +14795,11 @@ case "i." : this.Num.SetLvlByType(this.Lvl, c_oAscNumberingLevel.LowerRomanDot_Right); break; + default: + return false; } + + return true; }; /** * Sets your own customized numbering type. @@ -14627,6 +14809,7 @@ * "decimalZero")} sType - The custom numbering type used for the current numbering definition. * @param {string} sTextFormatString - Any text in this parameter will be taken as literal text to be repeated in each instance of this numbering level, except for any use of the percent symbol (%) followed by a number, which will be used to indicate the one-based index of the number to be used at this level. Any number of a level higher than this level will be ignored. * @param {("left" | "right" | "center")} sAlign - Type of justification applied to the text run in the current numbering level. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiNumberingLevel/Methods/SetCustomType.js */ ApiNumberingLevel.prototype.SetCustomType = function(sType, sTextFormatString, sAlign) @@ -14648,6 +14831,8 @@ nType = Asc.c_oAscNumberingFormat.UpperLetter; else if ("decimalZero" === sType) nType = Asc.c_oAscNumberingFormat.DecimalZero; + else + return false; var nAlign = align_Left; if ("left" === sAlign) @@ -14656,36 +14841,44 @@ nAlign = align_Right; else if ("center" === sAlign) nAlign = align_Center; + else + return false; this.Num.SetLvlByFormat(this.Lvl, nType, sTextFormatString, nAlign); + return true; }; /** * Specifies a one-based index which determines when a numbering level should restart to its starting value. A numbering level restarts when an instance of the specified numbering level which is higher (earlier than this level) is used in the given document contents. By default this value is true. * @memberof ApiNumberingLevel * @typeofeditors ["CDE"] * @param {boolean} isRestart - The true value means that a numbering level will be restarted to its starting value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiNumberingLevel/Methods/SetRestart.js */ ApiNumberingLevel.prototype.SetRestart = function(isRestart) { this.Num.SetLvlRestart(this.Lvl, private_GetBoolean(isRestart, true)); + return true; }; /** * Specifies the starting value for the numbering used by the parent numbering level within a given numbering level definition. By default this value is 1. * @memberof ApiNumberingLevel * @typeofeditors ["CDE"] * @param {number} nStart - The starting value for the numbering used by the parent numbering level. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiNumberingLevel/Methods/SetStart.js */ ApiNumberingLevel.prototype.SetStart = function(nStart) { this.Num.SetLvlStart(this.Lvl, private_GetInt(nStart)); + return true; }; /** * Specifies the content which will be added between the given numbering level text and the text of every numbered paragraph which references that numbering level. By default this value is "tab". * @memberof ApiNumberingLevel * @typeofeditors ["CDE"] * @param {("space" | "tab" | "none")} sType - The content added between the numbering level text and the text in the numbered paragraph. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiNumberingLevel/Methods/SetSuff.js */ ApiNumberingLevel.prototype.SetSuff = function(sType) @@ -14696,6 +14889,10 @@ this.Num.SetLvlSuff(this.Lvl, Asc.c_oAscNumberingSuff.Tab); else if ("none" === sType) this.Num.SetLvlSuff(this.Lvl, Asc.c_oAscNumberingSuff.None); + else + return false; + + return true; }; /** @@ -14703,20 +14900,22 @@ * @memberof ApiNumberingLevel * @typeofeditors ["CDE"] * @param {ApiStyle} oStyle - The paragraph style. + * @returns {boolean} * @since 8.3.0 * @see office-js-api/Examples/{Editor}/ApiNumberingLevel/Methods/LinkWithStyle.js */ ApiNumberingLevel.prototype.LinkWithStyle = function(oStyle) { if (!oStyle || !(oStyle instanceof ApiStyle)) - return; + return false; let logicDocument = private_GetLogicDocument(); if (!logicDocument) - return; + return false; let styles = logicDocument.GetStyleManager(); this.Num.LinkWithStyle(this.Lvl, oStyle.Style.Get_Id(), styles); + return true; }; //------------------------------------------------------------------------------------------------------------------ @@ -14741,30 +14940,35 @@ * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {number} nCount - The number of columns measured in positive integers. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetStyleColBandSize.js */ ApiTablePr.prototype.SetStyleColBandSize = function(nCount) { this.TablePr.TableStyleColBandSize = private_GetInt(nCount, 1, null); this.private_OnChange(); + return true; }; /** * Specifies a number of rows which will comprise each table row band for this table style. * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {number} nCount - The number of rows measured in positive integers. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetStyleRowBandSize.js */ ApiTablePr.prototype.SetStyleRowBandSize = function(nCount) { this.TablePr.TableStyleRowBandSize = private_GetInt(nCount, 1, null); this.private_OnChange(); + return true; }; /** * Specifies the alignment of the current table with respect to the text margins in the current section. * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {("left" | "right" | "center")} sJcType - The alignment type used for the current table placement. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetJc.js */ ApiTablePr.prototype.SetJc = function(sJcType) @@ -14776,6 +14980,7 @@ else if ("center" === sJcType) this.TablePr.Jc = align_Center; this.private_OnChange(); + return true; }; /** * Specifies the shading which is applied to the extents of the current table. @@ -14786,12 +14991,14 @@ * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. * @param {boolean} [isAuto=false] - The true value disables the SetShd method use. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetShd.js */ ApiTablePr.prototype.SetShd = function(sType, r, g, b, isAuto) { this.TablePr.Shd = private_GetShd(sType, r, g, b, isAuto); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed at the top of the current table. @@ -14803,12 +15010,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderTop.js */ ApiTablePr.prototype.SetTableBorderTop = function(sType, nSize, nSpace, r, g, b) { this.TablePr.TableBorders.Top = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed at the bottom of the current table. @@ -14820,12 +15029,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderBottom.js */ ApiTablePr.prototype.SetTableBorderBottom = function(sType, nSize, nSpace, r, g, b) { this.TablePr.TableBorders.Bottom = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed on the left of the current table. @@ -14837,12 +15048,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderLeft.js */ ApiTablePr.prototype.SetTableBorderLeft = function(sType, nSize, nSpace, r, g, b) { this.TablePr.TableBorders.Left = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed on the right of the current table. @@ -14854,12 +15067,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderRight.js */ ApiTablePr.prototype.SetTableBorderRight = function(sType, nSize, nSpace, r, g, b) { this.TablePr.TableBorders.Right = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies the border which will be displayed on all horizontal table cell borders which are not on the outmost edge @@ -14872,12 +15087,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderInsideH.js */ ApiTablePr.prototype.SetTableBorderInsideH = function(sType, nSize, nSpace, r, g, b) { this.TablePr.TableBorders.InsideH = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies the border which will be displayed on all vertical table cell borders which are not on the outmost edge @@ -14890,12 +15107,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderInsideV.js */ ApiTablePr.prototype.SetTableBorderInsideV = function(sType, nSize, nSpace, r, g, b) { this.TablePr.TableBorders.InsideV = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Specifies the border which will be displayed on all table cell borders. @@ -14907,6 +15126,7 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderAll.js */ ApiTablePr.prototype.SetTableBorderAll = function(sType, nSize, nSpace, r, g, b) @@ -14918,6 +15138,7 @@ this.TablePr.TableBorders.InsideH = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.TablePr.TableBorders.InsideV = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** @@ -14927,12 +15148,14 @@ * @typeofeditors ["CDE"] * @param {twips} nValue - The value for the amount of space below the bottom extent of the cell measured in * twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableCellMarginBottom.js */ ApiTablePr.prototype.SetTableCellMarginBottom = function(nValue) { this.TablePr.TableCellMar.Bottom = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Specifies an amount of space which will be left between the left extent of the cell contents and the left @@ -14940,12 +15163,14 @@ * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {twips} nValue - The value for the amount of space to the left extent of the cell measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableCellMarginLeft.js */ ApiTablePr.prototype.SetTableCellMarginLeft = function(nValue) { this.TablePr.TableCellMar.Left = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Specifies an amount of space which will be left between the right extent of the cell contents and the right @@ -14953,12 +15178,14 @@ * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {twips} nValue - The value for the amount of space to the right extent of the cell measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableCellMarginRight.js */ ApiTablePr.prototype.SetTableCellMarginRight = function(nValue) { this.TablePr.TableCellMar.Right = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Specifies an amount of space which will be left between the top extent of the cell contents and the top border @@ -14966,18 +15193,21 @@ * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {twips} nValue - The value for the amount of space above the top extent of the cell measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableCellMarginTop.js */ ApiTablePr.prototype.SetTableCellMarginTop = function(nValue) { this.TablePr.TableCellMar.Top = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Specifies the default table cell spacing (the spacing between adjacent cells and the edges of the table). * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {?twips} nValue - Spacing value measured in twentieths of a point (1/1440 of an inch). "Null" means that no spacing will be applied. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetCellSpacing.js */ ApiTablePr.prototype.SetCellSpacing = function(nValue) @@ -14987,6 +15217,7 @@ else this.TablePr.TableCellSpacing = private_Twips2MM(nValue); this.private_OnChange(); + return true; }; /** * Specifies the indentation which will be added before the leading edge of the current table in the document @@ -14994,12 +15225,14 @@ * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {twips} nValue - The indentation value measured in twentieths of a point (1/1440 of an inch). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableInd.js */ ApiTablePr.prototype.SetTableInd = function(nValue) { this.TablePr.TableInd = private_Twips2MM(nValue); this.private_OnChange(); + return true; }; /** * Sets the preferred width to the current table. @@ -15008,18 +15241,21 @@ * @typeofeditors ["CDE"] * @param {TableWidth} sType - Type of the width value from one of the available width values types. * @param {number} [nValue] - The table width value measured in positive integers. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetWidth.js */ ApiTablePr.prototype.SetWidth = function(sType, nValue) { this.TablePr.TableW = private_GetTableMeasure(sType, nValue); this.private_OnChange(); + return true; }; /** * Specifies the algorithm which will be used to lay out the contents of the current table within the document. * @memberof ApiTablePr * @typeofeditors ["CDE"] * @param {("autofit" | "fixed")} sType - The type of the table layout in the document. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableLayout.js */ ApiTablePr.prototype.SetTableLayout = function(sType) @@ -15030,6 +15266,7 @@ this.TablePr.TableLayout = tbllayout_Fixed; this.private_OnChange(); + return true; }; /** * Sets the table title (caption). @@ -15129,6 +15366,7 @@ * @typeofeditors ["CDE"] * @param {("auto" | "atLeast")} sHRule - The rule to apply the height value to the current table row or ignore it. Use the "atLeast" value to enable the SetHeight method use. * @param {twips} [nValue] - The height for the current table row measured in twentieths of a point (1/1440 of an inch). This value will be ignored if sHRule="auto". + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableRowPr/Methods/SetHeight.js */ ApiTableRowPr.prototype.SetHeight = function(sHRule, nValue) @@ -15137,8 +15375,11 @@ this.RowPr.Height = new CTableRowHeight(0, Asc.linerule_Auto); else if ("atLeast" === sHRule) this.RowPr.Height = new CTableRowHeight(private_Twips2MM(nValue), Asc.linerule_AtLeast); + else + return false; this.private_OnChange(); + return true; }; /** * Specifies that the current table row will be repeated at the top of each new page @@ -15148,12 +15389,14 @@ * @memberof ApiTableRowPr * @typeofeditors ["CDE"] * @param {boolean} isHeader - The true value means that the current table row will be repeated at the top of each new page. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableRowPr/Methods/SetTableHeader.js */ ApiTableRowPr.prototype.SetTableHeader = function(isHeader) { this.RowPr.TableHeader = private_GetBoolean(isHeader); this.private_OnChange(); + return true; }; /** * Converts the ApiTableRowPr object into the JSON object. @@ -15194,12 +15437,14 @@ * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. * @param {boolean} [isAuto=false] - The true value disables the table cell contents shading. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetShd.js */ ApiTableCellPr.prototype.SetShd = function(sType, r, g, b, isAuto) { this.CellPr.Shd = private_GetShd(sType, r, g, b, isAuto); this.private_OnChange(); + return true; }; /** * Specifies an amount of space which will be left between the bottom extent of the cell contents and the border @@ -15209,6 +15454,7 @@ * @param {?twips} nValue - The value for the amount of space below the bottom extent of the cell measured in twentieths * of a point (1/1440 of an inch). If this value is null, then default table cell bottom margin will be used, otherwise * the table cell bottom margin will be overridden with the specified value for the current cell. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellMarginBottom.js */ ApiTableCellPr.prototype.SetCellMarginBottom = function(nValue) @@ -15229,6 +15475,7 @@ else this.CellPr.TableCellMar.Bottom = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Specifies an amount of space which will be left between the left extent of the cell contents and @@ -15238,6 +15485,7 @@ * @param {?twips} nValue - The value for the amount of space to the left extent of the cell measured in twentieths * of a point (1/1440 of an inch). If this value is null, then default table cell left margin will be used, otherwise * the table cell left margin will be overridden with the specified value for the current cell. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellMarginLeft.js */ ApiTableCellPr.prototype.SetCellMarginLeft = function(nValue) @@ -15258,6 +15506,7 @@ else this.CellPr.TableCellMar.Left = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Specifies an amount of space which will be left between the right extent of the cell contents and the border of a specific table cell within a table. @@ -15266,6 +15515,7 @@ * @param {?twips} nValue - The value for the amount of space to the right extent of the cell measured in twentieths * of a point (1/1440 of an inch). If this value is null, then default table cell right margin will be used, otherwise * the table cell right margin will be overridden with the specified value for the current cell. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellMarginRight.js */ ApiTableCellPr.prototype.SetCellMarginRight = function(nValue) @@ -15286,6 +15536,7 @@ else this.CellPr.TableCellMar.Right = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Specifies an amount of space which will be left between the upper extent of the cell contents @@ -15295,6 +15546,7 @@ * @param {?twips} nValue - The value for the amount of space above the upper extent of the cell measured in twentieths * of a point (1/1440 of an inch). If this value is null, then default table cell top margin will be used, otherwise * the table cell top margin will be overridden with the specified value for the current cell. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellMarginTop.js */ ApiTableCellPr.prototype.SetCellMarginTop = function(nValue) @@ -15315,6 +15567,7 @@ else this.CellPr.TableCellMar.Top = private_GetTableMeasure("twips", nValue); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed at the bottom of the current table cell. @@ -15326,12 +15579,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellBorderBottom.js */ ApiTableCellPr.prototype.SetCellBorderBottom = function(sType, nSize, nSpace, r, g, b) { this.CellPr.TableCellBorders.Bottom = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed to the left of the current table cell. @@ -15343,12 +15598,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellBorderLeft.js */ ApiTableCellPr.prototype.SetCellBorderLeft = function(sType, nSize, nSpace, r, g, b) { this.CellPr.TableCellBorders.Left = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed to the right of the current table cell. @@ -15360,12 +15617,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellBorderRight.js */ ApiTableCellPr.prototype.SetCellBorderRight = function(sType, nSize, nSpace, r, g, b) { this.CellPr.TableCellBorders.Right = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Sets the border which will be displayed at the top of the current table cell. @@ -15377,12 +15636,14 @@ * @param {byte} r - Red color component value. * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetCellBorderTop.js */ ApiTableCellPr.prototype.SetCellBorderTop = function(sType, nSize, nSpace, r, g, b) { this.CellPr.TableCellBorders.Top = private_GetTableBorder(sType, nSize, nSpace, r, g, b); this.private_OnChange(); + return true; }; /** * Sets the preferred width to the current table cell. @@ -15390,18 +15651,21 @@ * @typeofeditors ["CDE"] * @param {TableWidth} sType - Type of the width value from one of the available width values types. * @param {number} [nValue] - The table cell width value measured in positive integers. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetWidth.js */ ApiTableCellPr.prototype.SetWidth = function(sType, nValue) { this.CellPr.TableCellW = private_GetTableMeasure(sType, nValue); this.private_OnChange(); + return true; }; /** * Specifies the vertical alignment for the text contents within the current table cell. * @memberof ApiTableCellPr * @typeofeditors ["CDE"] * @param {("top" | "center" | "bottom")} sType - The available types of the vertical alignment for the text contents of the current table cell. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetVerticalAlign.js */ ApiTableCellPr.prototype.SetVerticalAlign = function(sType) @@ -15412,8 +15676,11 @@ this.CellPr.VAlign = vertalignjc_Bottom; else if ("center" === sType) this.CellPr.VAlign = vertalignjc_Center; + else + return false; this.private_OnChange(); + return true; }; /** * Specifies the direction of the text flow for this table cell. @@ -15422,6 +15689,7 @@ * @param {("lrtb" | "tbrl" | "btlr")} sType - The available types of the text direction in the table cell: "lrtb" * - text direction left-to-right moving from top to bottom, "tbrl" - text direction top-to-bottom moving from right * to left, "btlr" - text direction bottom-to-top moving from left to right. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetTextDirection.js */ ApiTableCellPr.prototype.SetTextDirection = function(sType) @@ -15432,8 +15700,11 @@ this.CellPr.TextDirection = textdirection_TBRL; else if ("btlr" === sType) this.CellPr.TextDirection = textdirection_BTLR; + else + return false; this.private_OnChange(); + return true; }; /** * Specifies how the current table cell is laid out when the parent table is displayed in a document. This setting @@ -15441,12 +15712,14 @@ * @memberof ApiTableCellPr * @typeofeditors ["CDE"] * @param {boolean} isNoWrap - The true value means that the current table cell will not be wrapped in the parent table. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiTableCellPr/Methods/SetNoWrap.js */ ApiTableCellPr.prototype.SetNoWrap = function(isNoWrap) { this.CellPr.NoWrap = private_GetBoolean(isNoWrap); this.private_OnChange(); + return true; }; /** * Converts the ApiTableCellPr object into the JSON object. @@ -15597,6 +15870,7 @@ * @typeofeditors ["CDE"] * @param {EMU} nWidth - The object width measured in English measure units. * @param {EMU} nHeight - The object height measured in English measure units. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetSize.js */ ApiDrawing.prototype.SetSize = function(nWidth, nHeight) @@ -15609,6 +15883,7 @@ this.Drawing.spPr.xfrm.setExtX(fWidth); this.Drawing.spPr.xfrm.setExtY(fHeight); } + return true; }; /** * Sets the wrapping type of the current object (image, shape, chart). One of the following wrapping style types can be set: @@ -15623,6 +15898,7 @@ * @memberof ApiDrawing * @typeofeditors ["CDE"] * @param {"inline" | "square" | "tight" | "through" | "topAndBottom" | "behind" | "inFront"} sType - The wrapping style type available for the object. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetWrappingStyle.js */ ApiDrawing.prototype.SetWrappingStyle = function(sType) @@ -15672,12 +15948,19 @@ oParaDrawing.Set_WrappingType(WRAPPING_TYPE_NONE); oParaDrawing.Set_BehindDoc(false); } + else + return false; + oParaDrawing.Check_WrapPolygon(); if(this.Drawing.setRecalculateInfo) { this.Drawing.setRecalculateInfo(); } } + else + return false; + + return true; }; /** * Specifies how the floating object will be horizontally aligned. @@ -15685,6 +15968,7 @@ * @typeofeditors ["CDE"] * @param {RelFromH} [sRelativeFrom="page"] - The document element which will be taken as a countdown point for the object horizontal alignment. * @param {("left" | "right" | "center")} [sAlign="left"] - The alignment type which will be used for the object horizontal alignment. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetHorAlign.js */ ApiDrawing.prototype.SetHorAlign = function(sRelativeFrom, sAlign) @@ -15692,6 +15976,7 @@ let nAlign = private_GetAlignH(sAlign); let nRelativeFrom = private_GetRelativeFromH(sRelativeFrom); this.getParaDrawing().Set_PositionH(nRelativeFrom, true, nAlign, false); + return true; }; /** * Specifies how the floating object will be vertically aligned. @@ -15699,6 +15984,7 @@ * @typeofeditors ["CDE"] * @param {RelFromV} [sRelativeFrom="page"] - The document element which will be taken as a countdown point for the object vertical alignment. * @param {("top" | "bottom" | "center")} [sAlign="top"] - The alingment type which will be used for the object vertical alignment. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetVerAlign.js */ ApiDrawing.prototype.SetVerAlign = function(sRelativeFrom, sAlign) @@ -15706,6 +15992,7 @@ let nAlign = private_GetAlignV(sAlign); let nRelativeFrom = private_GetRelativeFromV(sRelativeFrom); this.getParaDrawing().Set_PositionV(nRelativeFrom, true, nAlign, false); + return true; }; /** * Sets the absolute measurement for the horizontal positioning of the floating object. @@ -15713,6 +16000,7 @@ * @typeofeditors ["CDE"] * @param {RelFromH} sRelativeFrom - The document element which will be taken as a countdown point for the object horizontal alignment. * @param {EMU} nDistance - The distance from the right side of the document element to the floating object measured in English measure units. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetHorPosition.js */ ApiDrawing.prototype.SetHorPosition = function(sRelativeFrom, nDistance) @@ -15720,6 +16008,7 @@ let nValue = private_EMU2MM(nDistance); let nRelativeFrom = private_GetRelativeFromH(sRelativeFrom); this.getParaDrawing().Set_PositionH(nRelativeFrom, false, nValue, false); + return true; }; /** * Sets the absolute measurement for the vertical positioning of the floating object. @@ -15727,6 +16016,7 @@ * @typeofeditors ["CDE"] * @param {RelFromV} sRelativeFrom - The document element which will be taken as a countdown point for the object vertical alignment. * @param {EMU} nDistance - The distance from the bottom part of the document element to the floating object measured in English measure units. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetVerPosition.js */ ApiDrawing.prototype.SetVerPosition = function(sRelativeFrom, nDistance) @@ -15734,6 +16024,7 @@ let nValue = private_EMU2MM(nDistance); let nRelativeFrom = private_GetRelativeFromV(sRelativeFrom); this.getParaDrawing().Set_PositionV(nRelativeFrom, false, nValue, false); + return true; }; /** * Specifies the minimum distance which will be maintained between the edges of the current drawing object and any @@ -15744,11 +16035,13 @@ * @param {EMU} nTop - The distance from the top side of the current object and the preceding text run measured in English measure units. * @param {EMU} nRight - The distance from the right side of the current object and the subsequent text run measured in English measure units. * @param {EMU} nBottom - The distance from the bottom side of the current object and the subsequent text run measured in English measure units. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetDistances.js */ ApiDrawing.prototype.SetDistances = function(nLeft, nTop, nRight, nBottom) { this.getParaDrawing().Set_Distance(private_EMU2MM(nLeft), private_EMU2MM(nTop), private_EMU2MM(nRight), private_EMU2MM(nBottom)); + return true; }; /** * Returns a parent paragraph that contains the graphic object. @@ -15918,14 +16211,17 @@ * Selects the current graphic object. * @memberof ApiDrawing * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/Select.js */ ApiDrawing.prototype.Select = function() { let oParaDrawing = this.getParaDrawing(); - if(!oParaDrawing) return; + if(!oParaDrawing) return false; let oLogicDocument = private_GetLogicDocument(); oLogicDocument.Select_DrawingObject(oParaDrawing.Id); + + return true; }; /** * Inserts a break at the specified location in the main document. @@ -15966,12 +16262,18 @@ * @memberof ApiDrawing * @typeofeditors ["CDE"] * @param {boolean} bFlip - Specifies if the figure will be flipped horizontally or not. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiDrawing/Methods/SetHorFlip.js */ ApiDrawing.prototype.SetHorFlip = function(bFlip) { if (this.Drawing.spPr && this.Drawing.spPr.xfrm) + { this.Drawing.spPr.xfrm.setFlipH(bFlip); + return true; + } + + return false; }; /** * Flips the current drawing vertically. @@ -16424,6 +16726,7 @@ * @memberof ApiShape * @typeofeditors ["CDE", "CSE"] * @param {VerticalTextAlign} VerticalAlign - The type of the vertical alignment for the shape inner contents. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetVerticalTextAlign.js */ ApiShape.prototype.SetVerticalTextAlign = function(VerticalAlign) @@ -16447,8 +16750,14 @@ this.Shape.setVerticalAlign(0); break; } + default: + return false; } + + return true; } + + return false; }; /** * Sets the text paddings to the current shape. @@ -16458,6 +16767,7 @@ * @param {?EMU} nTop - Top padding. * @param {?EMU} nRight - Right padding. * @param {?EMU} nBottom - Bottom padding. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiShape/Methods/SetPaddings.js */ ApiShape.prototype.SetPaddings = function(nLeft, nTop, nRight, nBottom) @@ -16470,7 +16780,11 @@ Right: AscFormat.isRealNumber(nRight) ? private_EMU2MM(nRight) : null, Bottom: AscFormat.isRealNumber(nBottom) ? private_EMU2MM(nBottom) : null }); + + return true; } + + return false; }; /** * Returns the next inline shape if exists. @@ -16568,11 +16882,13 @@ * @param {string} sTitle - The title which will be displayed for the current chart. * @param {pt} nFontSize - The text size value measured in points. * @param {?bool} bIsBold - Specifies if the chart title is written in bold font or not. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetTitle.js */ ApiChart.prototype.SetTitle = function (sTitle, nFontSize, bIsBold) { AscFormat.builder_SetChartTitle(this.Chart, sTitle, nFontSize, bIsBold); + return true; }; /** @@ -16582,11 +16898,13 @@ * @param {string} sTitle - The title which will be displayed for the horizontal axis of the current chart. * @param {pt} nFontSize - The text size value measured in points. * @param {?bool} bIsBold - Specifies if the horizontal axis title is written in bold font or not. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetHorAxisTitle.js */ ApiChart.prototype.SetHorAxisTitle = function (sTitle, nFontSize, bIsBold) { AscFormat.builder_SetChartHorAxisTitle(this.Chart, sTitle, nFontSize, bIsBold); + return true; }; /** @@ -16596,11 +16914,13 @@ * @param {string} sTitle - The title which will be displayed for the vertical axis of the current chart. * @param {pt} nFontSize - The text size value measured in points. * @param {?bool} bIsBold - Specifies if the vertical axis title is written in bold font or not. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetVerAxisTitle.js */ ApiChart.prototype.SetVerAxisTitle = function (sTitle, nFontSize, bIsBold) { AscFormat.builder_SetChartVertAxisTitle(this.Chart, sTitle, nFontSize, bIsBold); + return true; }; /** @@ -16608,10 +16928,12 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {boolean} bIsMinMax - The true value will set the normal data direction for the vertical axis (from minimum to maximum). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetVerAxisOrientation.js */ ApiChart.prototype.SetVerAxisOrientation = function(bIsMinMax){ AscFormat.builder_SetChartVertAxisOrientation(this.Chart, bIsMinMax); + return true; }; /** @@ -16619,10 +16941,12 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {boolean} bIsMinMax - The true value will set the normal data direction for the horizontal axis (from minimum to maximum). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetHorAxisOrientation.js */ ApiChart.prototype.SetHorAxisOrientation = function(bIsMinMax){ AscFormat.builder_SetChartHorAxisOrientation(this.Chart, bIsMinMax); + return true; }; /** @@ -16630,6 +16954,7 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {"left" | "top" | "right" | "bottom" | "none"} sLegendPos - The position of the chart legend inside the chart window. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetLegendPos.js */ ApiChart.prototype.SetLegendPos = function(sLegendPos) @@ -16668,6 +16993,8 @@ nLegendPos = Asc.c_oAscChartLegendShowSettings.bottom; break; } + default: + return false; } if(null !== nLegendPos) { @@ -16683,7 +17010,11 @@ } } } + + return true; } + + return false; }; /** @@ -16691,11 +17022,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {pt} nFontSize - The text size value measured in points. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetLegendFontSize.js */ ApiChart.prototype.SetLegendFontSize = function(nFontSize) { AscFormat.builder_SetLegendFontSize(this.Chart, nFontSize); + return true; }; /** @@ -16706,11 +17039,13 @@ * @param {boolean} bShowCatName - Whether to show or hide the source table row names used for the data which the chart will be build from. * @param {boolean} bShowVal - Whether to show or hide the chart data values. * @param {boolean} bShowPercent - Whether to show or hide the percent for the data values (works with stacked chart types). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetShowDataLabels.js */ ApiChart.prototype.SetShowDataLabels = function(bShowSerName, bShowCatName, bShowVal, bShowPercent) { AscFormat.builder_SetShowDataLabels(this.Chart, bShowSerName, bShowCatName, bShowVal, bShowPercent); + return true; }; @@ -16724,11 +17059,13 @@ * @param {boolean} bShowCatName - Whether to show or hide the source table row names used for the data which the chart will be build from. * @param {boolean} bShowVal - Whether to show or hide the chart data values. * @param {boolean} bShowPercent - Whether to show or hide the percent for the data values (works with stacked chart types). + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetShowPointDataLabel.js */ ApiChart.prototype.SetShowPointDataLabel = function(nSeriesIndex, nPointIndex, bShowSerName, bShowCatName, bShowVal, bShowPercent) { AscFormat.builder_SetShowPointDataLabel(this.Chart, nSeriesIndex, nPointIndex, bShowSerName, bShowCatName, bShowVal, bShowPercent); + return true; }; /** @@ -16736,11 +17073,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {TickLabelPosition} sTickLabelPosition - The type for the position of chart vertical tick labels. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetVertAxisTickLabelPosition.js */ ApiChart.prototype.SetVertAxisTickLabelPosition = function(sTickLabelPosition) { AscFormat.builder_SetChartVertAxisTickLablePosition(this.Chart, sTickLabelPosition); + return true; }; /** @@ -16748,11 +17087,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {TickLabelPosition} sTickLabelPosition - The type for the position of chart horizontal tick labels. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetHorAxisTickLabelPosition.js */ ApiChart.prototype.SetHorAxisTickLabelPosition = function(sTickLabelPosition) { AscFormat.builder_SetChartHorAxisTickLablePosition(this.Chart, sTickLabelPosition); + return true; }; /** @@ -16760,10 +17101,12 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {TickMark} sTickMark - The type of tick mark appearance. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetHorAxisMajorTickMark.js */ ApiChart.prototype.SetHorAxisMajorTickMark = function(sTickMark){ AscFormat.builder_SetChartHorAxisMajorTickMark(this.Chart, sTickMark); + return true; }; /** @@ -16771,10 +17114,12 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {TickMark} sTickMark - The type of tick mark appearance. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetHorAxisMinorTickMark.js */ ApiChart.prototype.SetHorAxisMinorTickMark = function(sTickMark){ AscFormat.builder_SetChartHorAxisMinorTickMark(this.Chart, sTickMark); + return true; }; /** @@ -16782,11 +17127,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {TickMark} sTickMark - The type of tick mark appearance. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetVertAxisMajorTickMark.js */ ApiChart.prototype.SetVertAxisMajorTickMark = function(sTickMark){ AscFormat.builder_SetChartVerAxisMajorTickMark(this.Chart, sTickMark); + return true; }; /** @@ -16794,10 +17141,12 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {TickMark} sTickMark - The type of tick mark appearance. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetVertAxisMinorTickMark.js */ ApiChart.prototype.SetVertAxisMinorTickMark = function(sTickMark){ AscFormat.builder_SetChartVerAxisMinorTickMark(this.Chart, sTickMark); + return true; }; /** @@ -16805,11 +17154,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {?ApiStroke} oStroke - The stroke used to create the element shadow. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetMajorVerticalGridlines.js */ ApiChart.prototype.SetMajorVerticalGridlines = function(oStroke) { AscFormat.builder_SetVerAxisMajorGridlines(this.Chart, oStroke ? oStroke.Ln : null); + return true; }; /** @@ -16817,11 +17168,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {?ApiStroke} oStroke - The stroke used to create the element shadow. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetMinorVerticalGridlines.js */ ApiChart.prototype.SetMinorVerticalGridlines = function(oStroke) { AscFormat.builder_SetVerAxisMinorGridlines(this.Chart, oStroke ? oStroke.Ln : null); + return true; }; @@ -16830,11 +17183,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {?ApiStroke} oStroke - The stroke used to create the element shadow. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetMajorHorizontalGridlines.js */ ApiChart.prototype.SetMajorHorizontalGridlines = function(oStroke) { AscFormat.builder_SetHorAxisMajorGridlines(this.Chart, oStroke ? oStroke.Ln : null); + return true; }; /** @@ -16842,11 +17197,13 @@ * @memberof ApiChart * @typeofeditors ["CDE", "CSE", "CPE"] * @param {?ApiStroke} oStroke - The stroke used to create the element shadow. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetMinorHorizontalGridlines.js */ ApiChart.prototype.SetMinorHorizontalGridlines = function(oStroke) { AscFormat.builder_SetHorAxisMinorGridlines(this.Chart, oStroke ? oStroke.Ln : null); + return true; }; @@ -16855,10 +17212,12 @@ * @memberof ApiChart * @typeofeditors ["CDE"] * @param {pt} nFontSize - The text size value measured in points. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetHorAxisLablesFontSize.js */ ApiChart.prototype.SetHorAxisLablesFontSize = function(nFontSize){ AscFormat.builder_SetHorAxisFontSize(this.Chart, nFontSize); + return true; }; /** @@ -16866,10 +17225,12 @@ * @memberof ApiChart * @typeofeditors ["CDE"] * @param {pt} nFontSize - The text size value measured in points. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiChart/Methods/SetVertAxisLablesFontSize.js */ ApiChart.prototype.SetVertAxisLablesFontSize = function(nFontSize){ AscFormat.builder_SetVerAxisFontSize(this.Chart, nFontSize); + return true; }; /** @@ -17706,6 +18067,7 @@ * @memberof ApiInlineLvlSdt * @typeofeditors ["CDE"] * @param {"contentLocked" | "sdtContentLocked" | "sdtLocked"} sLockType - The lock type applied to the inline text content control. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiInlineLvlSdt/Methods/SetLock.js */ ApiInlineLvlSdt.prototype.SetLock = function(sLockType) @@ -17717,8 +18079,11 @@ nLock = c_oAscSdtLockType.SdtContentLocked; else if ("sdtLocked" === sLockType) nLock = c_oAscSdtLockType.SdtLocked; + else + return false; this.Sdt.SetContentControlLock(nLock); + return true; }; /** @@ -17749,11 +18114,13 @@ * @memberof ApiInlineLvlSdt * @typeofeditors ["CDE"] * @param {string} sTag - The tag which will be added to the current inline text content control. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiInlineLvlSdt/Methods/SetTag.js */ ApiInlineLvlSdt.prototype.SetTag = function(sTag) { this.Sdt.SetTag(sTag); + return true; }; /** @@ -17773,11 +18140,13 @@ * @memberof ApiInlineLvlSdt * @typeofeditors ["CDE"] * @param {string} sLabel - The label which will be added to the current inline text content control. Can be a positive or negative integer from -2147483647 to 2147483647. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiInlineLvlSdt/Methods/SetLabel.js */ ApiInlineLvlSdt.prototype.SetLabel = function(sLabel) { this.Sdt.SetLabel(sLabel); + return true; }; /** @@ -17797,11 +18166,13 @@ * @memberof ApiInlineLvlSdt * @typeofeditors ["CDE"] * @param {string} sAlias - The alias which will be added to the current inline text content control. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiInlineLvlSdt/Methods/SetAlias.js */ ApiInlineLvlSdt.prototype.SetAlias = function(sAlias) { this.Sdt.SetAlias(sAlias); + return true; }; /** @@ -18256,12 +18627,14 @@ * @param {boolean?} [isAfter=true] - Specifies whether a cursor will be placed before (false) or after (true) the current content control. * @memberof ApiInlineLvlSdt * @typeofeditors ["CDE"] + * @returns {boolean} * @since 8.1.0 * @see office-js-api/Examples/{Editor}/ApiInlineLvlSdt/Methods/MoveCursorOutside.js */ ApiInlineLvlSdt.prototype.MoveCursorOutside = function(isAfter) { this.Sdt.MoveCursorOutsideForm(false === isAfter); + return true; }; /** @@ -18376,6 +18749,7 @@ * Clears a list of values of the combo box / dropdown list content control. * @memberof ApiContentControlList * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiContentControlList/Methods/Clear.js */ ApiContentControlList.prototype.Clear = function() @@ -18384,6 +18758,7 @@ listPr.Clear(); this.SetListPr(listPr) this.Sdt.SelectListItem(""); + return true; }; /** @@ -18664,6 +19039,7 @@ * @memberof ApiBlockLvlSdt * @typeofeditors ["CDE"] * @param {"contentLocked" | "sdtContentLocked" | "sdtLocked"} lockType - The type of the lock applied to the block text content control. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiBlockLvlSdt/Methods/SetLock.js */ ApiBlockLvlSdt.prototype.SetLock = function(lockType) @@ -18675,8 +19051,11 @@ nLock = c_oAscSdtLockType.SdtContentLocked; else if ("sdtLocked" === lockType) nLock = c_oAscSdtLockType.SdtLocked; + else + return false; this.Sdt.SetContentControlLock(nLock); + return true; }; /** @@ -18707,11 +19086,13 @@ * @memberof ApiBlockLvlSdt * @typeofeditors ["CDE"] * @param {string} tag - The tag which will be added to the current container. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiBlockLvlSdt/Methods/SetTag.js */ ApiBlockLvlSdt.prototype.SetTag = function(tag) { this.Sdt.SetTag(tag); + return true; }; /** @@ -18731,11 +19112,13 @@ * @memberof ApiBlockLvlSdt * @typeofeditors ["CDE"] * @param {string} sLabel - The label which will be added to the current container. Can be a positive or negative integer from -2147483647 to 2147483647. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiBlockLvlSdt/Methods/SetLabel.js */ ApiBlockLvlSdt.prototype.SetLabel = function(label) { this.Sdt.SetLabel(label); + return true; }; /** @@ -18755,11 +19138,13 @@ * @memberof ApiBlockLvlSdt * @typeofeditors ["CDE"] * @param {string} alias - The alias which will be added to the current container. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiBlockLvlSdt/Methods/SetAlias.js */ ApiBlockLvlSdt.prototype.SetAlias = function(alias) { this.Sdt.SetAlias(alias); + return true; }; /** @@ -18903,6 +19288,7 @@ * @memberof ApiBlockLvlSdt * @typeofeditors ["CDE"] * @param {ApiTextPr} textPr - The properties that will be set to the content of the content control. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiBlockLvlSdt/Methods/SetTextPr.js */ ApiBlockLvlSdt.prototype.SetTextPr = function(textPr) @@ -18911,6 +19297,7 @@ this.Sdt.Content.SetApplyToAll(true); this.Sdt.Add(ParaTextPr); this.Sdt.Content.SetApplyToAll(false); + return true; }; /** @@ -19149,6 +19536,7 @@ * Selects the current content control. * @memberof ApiBlockLvlSdt * @typeofeditors ["CDE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiBlockLvlSdt/Methods/Select.js */ ApiBlockLvlSdt.prototype.Select = function() @@ -19157,6 +19545,7 @@ this.Sdt.SelectContentControl(); Document.UpdateSelection(); + return true; }; /** @@ -19385,12 +19774,14 @@ * @param {boolean?} [isAfter=true] - Specifies whether a cursor will be placed before (false) or after (true) the current content control. * @memberof ApiBlockLvlSdt * @typeofeditors ["CDE"] + * @returns {boolean} * @since 8.1.0 * @see office-js-api/Examples/{Editor}/ApiBlockLvlSdt/Methods/MoveCursorOutside.js */ ApiBlockLvlSdt.prototype.MoveCursorOutside = function(isAfter) { this.Sdt.MoveCursorOutsideForm(false === isAfter); + return true; }; /** @@ -19719,12 +20110,14 @@ * Clears the current form. * @memberof ApiFormBase * @typeofeditors ["CDE", "CFE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiFormBase/Methods/Clear.js */ ApiFormBase.prototype.Clear = function() { return executeNoFormLockCheck(function() { this.Sdt.ClearContentControlExt(); + return true; }, this); }; /** @@ -19801,12 +20194,14 @@ * @param {boolean?} [isAfter=true] - Specifies whether a cursor will be placed before (false) or after (true) the current form. * @memberof ApiFormBase * @typeofeditors ["CDE", "CFE"] + * @returns {boolean} * @since 8.1.0 * @see office-js-api/Examples/{Editor}/ApiFormBase/Methods/MoveCursorOutside.js */ ApiFormBase.prototype.MoveCursorOutside = function(isAfter) { this.Sdt.MoveCursorOutsideForm(false === isAfter); + return true; }; /** * Copies the current form (copies with the shape if it exists). @@ -20522,6 +20917,7 @@ * @memberof ApiCheckBoxForm * @param {string} sKey - Radio group key. * @typeofeditors ["CDE", "CFE"] + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiCheckBoxForm/Methods/SetRadioGroup.js */ ApiCheckBoxForm.prototype.SetRadioGroup = function(sKey) @@ -20529,11 +20925,12 @@ return executeNoFormLockCheck(function(){ let oPr = this.Sdt.GetCheckBoxPr(); if (!oPr) - return; + return false; oPr = oPr.Copy(); oPr.SetGroupKey(sKey); this.Sdt.SetCheckBoxPr(oPr); + return true; }, this); }; @@ -20689,6 +21086,7 @@ * @param {Array} textStrings - An array of replacement strings. * @param {string} [tab="\t"] - A character which is used to specify the tab in the source text. * @param {string} [newLine="\r\n"] - A character which is used to specify the line break character in the source text. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/Api/Methods/ReplaceTextSmart.js */ Api.prototype.ReplaceTextSmart = function(textStrings, tab, newLine) @@ -21016,7 +21414,7 @@ if (arrSelectedParas[0] && arrSelectedParas[0].Parent) arrSelectedParas[0].Parent.RemoveSelection(); Asc.editor.wb.recalculateDrawingObjects(); - return; + return true; } if (oWorksheet.worksheet.getSheetProtection()) { @@ -21074,7 +21472,7 @@ arrSelectedParas = oDocument.Document.GetSelectedParagraphs(); if(arrSelectedParas.length <= 0 ) { - return; + return false; } ReplaceInParas(arrSelectedParas); @@ -21088,7 +21486,7 @@ var nIndexToPaste = arrSelectedParas[arrSelectedParas.length - 1].Index + 1; var isPres = !arrSelectedParas[0].bFromDocument; if (!oParaParent) - return; + return true; for (var nPara = arrSelectedParas.length; nPara < textStrings.length; nPara++) { @@ -21101,6 +21499,8 @@ nIndexToPaste++; } } + + return true; }; Api.prototype.CoAuthoringChatSendMessage = function(message) { @@ -21610,6 +22010,7 @@ * @memberof ApiWatermarkSettings * @typeofeditors ["CDE"] * @param {WatermarkType} sType - The watermark type. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiWatermarkSettings/Methods/SetType.js */ ApiWatermarkSettings.prototype.SetType = function (sType) @@ -21628,6 +22029,7 @@ nType = Asc.c_oAscWatermarkType.None; } this.Settings.put_Type(nType); + return true; }; /** @@ -21656,11 +22058,13 @@ * @memberof ApiWatermarkSettings * @typeofeditors ["CDE"] * @param {string} sText - The watermark text. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiWatermarkSettings/Methods/SetText.js */ ApiWatermarkSettings.prototype.SetText = function (sText) { this.Settings.put_Text(sText); + return true; }; /** @@ -21680,11 +22084,13 @@ * @memberof ApiWatermarkSettings * @typeofeditors ["CDE"] * @param {ApiTextPr} oTextPr - The watermark text properties. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiWatermarkSettings/Methods/SetTextPr.js */ ApiWatermarkSettings.prototype.SetTextPr = function (oTextPr) { this.Settings.put_TextPr(new Asc.CTextProp(oTextPr.TextPr)); + return true; }; /** @@ -21714,12 +22120,14 @@ * @memberof ApiWatermarkSettings * @typeofeditors ["CDE"] * @param {number} nOpacity - The watermark opacity. This value must be from 0 to 255. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiWatermarkSettings/Methods/SetOpacity.js */ ApiWatermarkSettings.prototype.SetOpacity = function (nOpacity) { let nOpacityVal = Math.min(255, Math.max(0, nOpacity)); this.Settings.put_Opacity(nOpacityVal); + return true; }; /** @@ -21741,6 +22149,7 @@ * @memberof ApiWatermarkSettings * @typeofeditors ["CDE"] * @param {WatermarkDirection} sDirection - The watermark direction. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiWatermarkSettings/Methods/SetDirection.js */ ApiWatermarkSettings.prototype.SetDirection = function (sDirection) @@ -21762,7 +22171,11 @@ this.Settings.put_Angle(-45); break; } + default: + return false; } + + return true; }; /** * Returns the direction of the watermark in the document. @@ -21794,11 +22207,13 @@ * @memberof ApiWatermarkSettings * @typeofeditors ["CDE"] * @param {string} sURL - The watermark image URL. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiWatermarkSettings/Methods/SetImageURL.js */ ApiWatermarkSettings.prototype.SetImageURL = function (sURL) { this.Settings.put_ImageUrl2(sURL); + return true; }; /** @@ -21843,11 +22258,13 @@ * @typeofeditors ["CDE"] * @param {EMU} nWidth - The watermark image width. * @param {EMU} nHeight - The watermark image height. + * @returns {boolean} * @see office-js-api/Examples/{Editor}/ApiWatermarkSettings/Methods/SetImageSize.js */ ApiWatermarkSettings.prototype.SetImageSize = function (nWidth, nHeight) { this.Settings.put_ImageSize(nWidth, nHeight); + return true; }; /** From 6928df01ef3b073296de5192f1320b3b2a70b28b Mon Sep 17 00:00:00 2001 From: Nikita Khromov Date: Wed, 5 Feb 2025 18:23:51 +0700 Subject: [PATCH 06/18] [bu][de] Fix description --- word/apiBuilder.js | 1 + 1 file changed, 1 insertion(+) diff --git a/word/apiBuilder.js b/word/apiBuilder.js index 68f00c32c5..456012efdc 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -15127,6 +15127,7 @@ * @param {byte} g - Green color component value. * @param {byte} b - Blue color component value. * @returns {boolean} + * @since 8.4.0 * @see office-js-api/Examples/{Editor}/ApiTablePr/Methods/SetTableBorderAll.js */ ApiTablePr.prototype.SetTableBorderAll = function(sType, nSize, nSpace, r, g, b) From baa74640ae439c1da9acfb50885a29f0e01a0bc1 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Thu, 6 Feb 2025 19:09:43 +0300 Subject: [PATCH 07/18] [build] Revert deployment of "diagram" sdk --- build/Gruntfile.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/build/Gruntfile.js b/build/Gruntfile.js index 0a4455ffa0..aa5c9288ae 100644 --- a/build/Gruntfile.js +++ b/build/Gruntfile.js @@ -365,22 +365,22 @@ module.exports = function(grunt) { } ] }, - // visio: { - // files: [ - // { - // expand: true, - // cwd: visio, - // src: [ - // 'sdk-all-min.js.map', - // 'sdk-all.js.map', - // ], - // dest: 'maps', - // rename: function (dest, src) { - // return path.join(dest , src.replace('sdk', 'visio')); - // } - // } - // ] - // } + visio: { + files: [ + { + expand: true, + cwd: visio, + src: [ + 'sdk-all-min.js.map', + 'sdk-all.js.map', + ], + dest: 'maps', + rename: function (dest, src) { + return path.join(dest , src.replace('sdk', 'visio')); + } + } + ] + } }, clean: { deploy: { @@ -394,15 +394,15 @@ module.exports = function(grunt) { path.join(cell, 'sdk-all.js.map'), path.join(slide, 'sdk-all-min.js.map'), path.join(slide, 'sdk-all.js.map'), - // path.join(visio, 'sdk-all-min.js.map'), - // path.join(visio, 'sdk-all.js.map'), + path.join(visio, 'sdk-all-min.js.map'), + path.join(visio, 'sdk-all.js.map'), ] } } }); grunt.task.run('copy', 'clean'); }); - grunt.registerTask('compile-sdk', ['compile-word', 'compile-cell', 'compile-slide'/* , 'compile-visio' */]); + grunt.registerTask('compile-sdk', ['compile-word', 'compile-cell', 'compile-slide', 'compile-visio']); grunt.registerTask('clean-deploy', 'Clean deploy folder before deploying', function () { grunt.initConfig({ clean: { @@ -521,7 +521,7 @@ module.exports = function(grunt) { writeScripts(configs.word['sdk'], 'word'); writeScripts(configs.cell['sdk'], 'cell'); writeScripts(configs.slide['sdk'], 'slide'); - // writeScripts(configs.visio['sdk'], 'visio'); + writeScripts(configs.visio['sdk'], 'visio'); }); const defaultTasks = ['clean-deploy', 'compile-sdk', 'copy-other']; if (grunt.option('map')) { From 082029b5bf45b785d77cff5f9e94dbcb68df735d Mon Sep 17 00:00:00 2001 From: GoshaZotov Date: Fri, 7 Feb 2025 11:52:15 +0300 Subject: [PATCH 08/18] [se] Fix bug 71890 --- common/AdvancedOptions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/AdvancedOptions.js b/common/AdvancedOptions.js index 42b2ec1d14..d87bcfd6ae 100644 --- a/common/AdvancedOptions.js +++ b/common/AdvancedOptions.js @@ -92,7 +92,7 @@ this.delimiter = delimiter; this.delimiterChar = delimiterChar; - this.textQualifier = null; + this.textQualifier = '"'; this.numberDecimalSeparator = null; this.numberGroupSeparator = null; From fa1d1fd26527737a26b1463d72cd907c0fc5a41d Mon Sep 17 00:00:00 2001 From: GoshaZotov Date: Mon, 10 Feb 2025 12:55:05 +0300 Subject: [PATCH 09/18] [se] By bug 49860: fix move cursor on left click mouse --- cell/view/CellEditorView.js | 14 +++++++++----- cell/view/CellTextRender.js | 7 +++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cell/view/CellEditorView.js b/cell/view/CellEditorView.js index eff5235086..e47ab4ce04 100644 --- a/cell/view/CellEditorView.js +++ b/cell/view/CellEditorView.js @@ -1679,11 +1679,11 @@ function (window, undefined) { this.cursorStyle.display = "none"; }; - CellEditor.prototype._updateCursorPosition = function (redrawText, isExpand) { + CellEditor.prototype._updateCursorPosition = function (redrawText, isExpand, lineIndex) { // ToDo стоит переправить данную функцию let h = this.canvas.height; let y = -this.textRender.calcLineOffset(this.topLineIndex); - let cur = this.textRender.calcCharOffset(this.cursorPos); + let cur = this.textRender.calcCharOffset(this.cursorPos, lineIndex); let charsCount = this.textRender.getCharsCount(); let textAlign = this.textFlags && this.textFlags.textAlign; let curLeft = asc_round( @@ -1759,7 +1759,7 @@ function (window, undefined) { this._updateSelectionInfo(); }; - CellEditor.prototype._moveCursor = function (kind, pos) { + CellEditor.prototype._moveCursor = function (kind, pos, lineIndex) { this.newTextFormat = null; var t = this; this.sAutoComplete = null; @@ -1807,7 +1807,7 @@ function (window, undefined) { t.selectionBegin = t.selectionEnd = -1; t._cleanSelection(); } - t._updateCursorPosition(); + t._updateCursorPosition(null, null, lineIndex); t._updateCursor(); }; @@ -1815,6 +1815,10 @@ function (window, undefined) { return this.textRender.getCharPosByXY(coord.x, coord.y, this.topLineIndex, this.getZoom()); }; + CellEditor.prototype._findLineIndex = function (coord) { + return this.textRender.getLineByY(coord.y, this.topLineIndex, this.getZoom()); + }; + CellEditor.prototype._updateTopLineCurPos = function () { if (this.loadFonts) { return; @@ -3012,7 +3016,7 @@ function (window, undefined) { this._updateCursor(); pos = this._findCursorPosition(coord); if (pos !== undefined) { - pos >= 0 ? this._moveCursor(kPosition, pos) : this._moveCursor(pos); + pos >= 0 ? this._moveCursor(kPosition, pos, this._findLineIndex(coord)) : this._moveCursor(pos, null, this._findLineIndex(coord)); } } else { this._changeSelection(coord); diff --git a/cell/view/CellTextRender.js b/cell/view/CellTextRender.js index 307299c57d..e418f3a8f2 100644 --- a/cell/view/CellTextRender.js +++ b/cell/view/CellTextRender.js @@ -233,7 +233,7 @@ h * zoom), Asc.round(li.th * zoom), lineIndex); }; - CellTextRender.prototype.calcCharOffset = function (pos) { + CellTextRender.prototype.calcCharOffset = function (pos, lineIndex) { var t = this, l = t.lines, i, h, co; if (l.length < 1) { @@ -249,7 +249,10 @@ for (i = 0, h = 0; i < l.length; ++i) { if (pos >= l[i].beg && pos <= l[i].end) { - return this.charOffset(pos, i, h); + //end of line and start of line can have same index + if (!(lineIndex != null && (pos === l[i].end/* || pos === l[i].beg*/) && lineIndex !== i)) { + return this.charOffset(pos, i, h); + } } if (i !== l.length - 1) { h += l[i].th; From 28d4f8546a161a9325860ef267d1f6d954f282ca Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Fri, 31 Jan 2025 20:38:08 +0300 Subject: [PATCH 10/18] [ve] Fix image scale and offset (srcRect); For bug 72746 --- visio/model/ooxmlApi/convertFunctions.js | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/visio/model/ooxmlApi/convertFunctions.js b/visio/model/ooxmlApi/convertFunctions.js index e57882051d..cc7f8c98a1 100644 --- a/visio/model/ooxmlApi/convertFunctions.js +++ b/visio/model/ooxmlApi/convertFunctions.js @@ -1826,6 +1826,40 @@ this.cImageShape.setBDeleted(false); this.cImageShape.setSpPr(cShape.spPr.createDuplicate()); this.cImageShape.spPr.setParent(this.cImageShape); + + let imgWidth_inch = this.getCellNumberValueWithScale("ImgWidth", drawingPageScale); + let imgHeight_inch = this.getCellNumberValueWithScale("ImgHeight", drawingPageScale); + let imgOffsetX_inch = this.getCellNumberValueWithScale("ImgOffsetX", drawingPageScale); + let imgOffsetY_inch = this.getCellNumberValueWithScale("ImgOffsetY", drawingPageScale); + + let imgWidth_mm = imgWidth_inch * g_dKoef_in_to_mm; + let imgHeight_mm = imgHeight_inch * g_dKoef_in_to_mm; + + this.cImageShape.blipFill.srcRect = new AscFormat.CSrcRect(); + let rect = this.cImageShape.blipFill.srcRect; + + if (imgWidth_inch !== undefined && imgHeight_inch !== undefined) { + let widthScale = imgWidth_mm / shapeWidth_mm; + let heightScale = imgHeight_mm / shapeHeight_mm; + // coords in our class CSrcRect is srcRect relative i.e. relative to original image size + // isInvertCoords check? + // add scale + rect.setLTRB(0, 100 - 1/heightScale * 100, 1/widthScale * 100, 100); + } + if (imgOffsetX_inch !== undefined) { + let imgOffsetX_mm = imgOffsetX_inch * g_dKoef_in_to_mm; + let offsetX = imgOffsetX_mm / imgWidth_mm; + // add horizontal shift + rect.setLTRB(rect.l - offsetX * 100, rect.t, rect.r - offsetX * 100, rect.b); + } + if (imgOffsetY_inch !== undefined) { + let imgOffsetY_mm = imgOffsetY_inch * g_dKoef_in_to_mm; + let offsetY = imgOffsetY_mm / imgHeight_mm; + // add vertical shift + rect.setLTRB(rect.l, rect.t + offsetY * 100, rect.r, rect.b + offsetY * 100); + } + + this.cImageShape.rot = cShape.rot; // this.cImageShape.brush = cShape.brush; this.cImageShape.bounds = cShape.bounds; @@ -1837,6 +1871,8 @@ this.cImageShape.setParent2(visioDocument); this.cImageShape.recalculate(); + this.cImageShape.recalculateTransformText && this.cImageShape.recalculateTransformText(); + this.cImageShape.recalculateContent && this.cImageShape.recalculateContent(); cShape = this.cImageShape; } else { From df6356039ae1a638c5a95fcda8298edc751d93b3 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Fri, 31 Jan 2025 22:02:18 +0300 Subject: [PATCH 11/18] [ve] Don't add empty colors to gradients; Fix bug 72702 --- visio/model/ooxmlApi/convertFunctions.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/visio/model/ooxmlApi/convertFunctions.js b/visio/model/ooxmlApi/convertFunctions.js index cc7f8c98a1..564a26e440 100644 --- a/visio/model/ooxmlApi/convertFunctions.js +++ b/visio/model/ooxmlApi/convertFunctions.js @@ -1579,6 +1579,10 @@ colorStop.setPos(pos); fillGradientStops.push({Gs : colorStop}); + + if (pos === 100000 || (invertGradient && pos === 0)) { + break; + } } if (fillGradientDir === 3) { From a1faab3e7ce619f13a37d6f9e39e9c2eeb5f5c27 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Sat, 1 Feb 2025 15:58:08 +0300 Subject: [PATCH 12/18] [ve] Change invert gradient handle --- visio/model/ooxmlApi/convertFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/visio/model/ooxmlApi/convertFunctions.js b/visio/model/ooxmlApi/convertFunctions.js index 564a26e440..e5ba305e47 100644 --- a/visio/model/ooxmlApi/convertFunctions.js +++ b/visio/model/ooxmlApi/convertFunctions.js @@ -1580,7 +1580,7 @@ fillGradientStops.push({Gs : colorStop}); - if (pos === 100000 || (invertGradient && pos === 0)) { + if ((pos === 100000 && !invertGradient) || (invertGradient && pos === 0)) { break; } } From f2bad45ae2a87047f9ae02323248bf70d6b2f637 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Sun, 2 Feb 2025 22:43:32 +0300 Subject: [PATCH 13/18] [ve] Don't duplicate background; Fix bug 72711 --- visio/model/VisioDocument.js | 1 + 1 file changed, 1 insertion(+) diff --git a/visio/model/VisioDocument.js b/visio/model/VisioDocument.js index 7dc6272a44..285f596a21 100644 --- a/visio/model/VisioDocument.js +++ b/visio/model/VisioDocument.js @@ -727,6 +727,7 @@ let pageContent = this.pageContents[pageIndex]; if (!this.backgroundAppliedFor.includes(pageIndex)) { + this.backgroundAppliedFor.push(pageIndex); let backgroundPageId = pageInfo.backPage; if (backgroundPageId !== null && backgroundPageId !== undefined) { // find background page From 7455fa7c1025a564d81d98000266c654ac7ca55a Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Tue, 4 Feb 2025 13:16:15 +0300 Subject: [PATCH 14/18] [ve] Handle m units; For bug 72725 --- visio/model/overrides.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/visio/model/overrides.js b/visio/model/overrides.js index 2aa38ad789..4b1b998770 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -692,6 +692,8 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() valueInProperUnits = Number(valueV) * g_dKoef_in_to_mm / 10; } else if (valueUnits === "MM") { valueInProperUnits = Number(valueV) * g_dKoef_in_to_mm; + } else if (valueUnits === "M") { + valueInProperUnits = Number(valueV) * g_dKoef_in_to_mm / 1000; } else { valueInProperUnits = valueV; } @@ -764,7 +766,7 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() else if("WIDTH" === sFieldType) { //todo display units - val = this.vsdxFieldValue.getValueInMM(); + //leave value } else if ((this.vsdxFieldValue.u === "STR" || !this.vsdxFieldValue.u) && (sFieldType === "INH" || !sFieldType)) { // handle simple values. consider is function is INH value is calculated correctly already From 6f1f96cbef5b8d41e0ef8f14b5f58459e9c8a0dd Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Wed, 5 Feb 2025 03:07:19 +0300 Subject: [PATCH 15/18] [ve] Less try to calculate fields; For bug 72725 --- visio/model/ooxmlApi/ooxmlApiIndex.js | 3 +-- visio/model/overrides.js | 32 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/visio/model/ooxmlApi/ooxmlApiIndex.js b/visio/model/ooxmlApi/ooxmlApiIndex.js index 48572e3661..b889cbbd87 100644 --- a/visio/model/ooxmlApi/ooxmlApiIndex.js +++ b/visio/model/ooxmlApi/ooxmlApiIndex.js @@ -51,8 +51,7 @@ */ function Text_Type() { /** - * if text is inherited so we consider that text fields in it have wrong values, - * and we recalculate values them + * if text is inherited (for calculate presentation field) */ this.isInherited = false; diff --git a/visio/model/overrides.js b/visio/model/overrides.js index 4b1b998770..7f3be1099c 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -402,7 +402,7 @@ AscCommon.CShapeDrawer.prototype.ds = function() function parseFieldPictureFormat(vsdxFieldValue, vsdxFieldFormat) { let res = "@"; - if (vsdxFieldFormat.f) { + if (vsdxFieldFormat.f && vsdxFieldFormat.f !== "Inh") { let formatFunction = vsdxFieldFormat.f.toUpperCase(); let vFieldPicture = parseInt(formatFunction.substring('FIELDPICTURE('.length)); @@ -670,6 +670,9 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() { //todo add num formats with units in editor + // now it works like if field function is not CREATOR or PAGECOUNT or it's now simple override value + // take values from text tag despite it is inherited or not + // return; returns direct tag value // if (!this.isTextInherited) { // return; @@ -737,11 +740,12 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() val = logicDocument.getCountPages(); } } - else if("PAGENUMBER()" === sFieldType) { - if (logicDocument) { - val = logicDocument.getCurrentPage(); - } - } + // else if("PAGENUMBER()" === sFieldType) { + // todo add recalculate on page load + // if (logicDocument) { + // val = logicDocument.getCurrentPage(); + // } + // } // else if("NOW()" === sFieldType) // { // let oDateTime = new Asc.cDate(); @@ -763,13 +767,17 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() val = logicDocument.core.creator; } } - else if("WIDTH" === sFieldType) - { - //todo display units - //leave value - } - else if ((this.vsdxFieldValue.u === "STR" || !this.vsdxFieldValue.u) && (sFieldType === "INH" || !sFieldType)) { + // else if("WIDTH" === sFieldType) + // { + // //todo display units + // //leave value + // } + else if ((this.vsdxFieldValue.u === "STR" || !this.vsdxFieldValue.u) && (sFieldType === "INH" || !sFieldType) + && !this.vsdxFieldFormat) { + // else if (this.vsdxFieldValue.u === "STR" && (sFieldType === "INH" || !sFieldType)) { // handle simple values. consider is function is INH value is calculated correctly already + // like + // val = this.vsdxFieldValue.v; } else From e84555722399c5b0b50b2feaee674b50c553cf54 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Thu, 6 Feb 2025 14:37:26 +0300 Subject: [PATCH 16/18] [ve] Add themeval font cell calculation (set Calibri for default theme); Fix bug 72727 --- visio/model/ooxmlApi/convertFunctions.js | 33 ++++++++++++------------ visio/model/ooxmlApi/ooxmlApiIndex.js | 2 +- visio/model/visioFunctionsApi.js | 15 +++++++++++ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/visio/model/ooxmlApi/convertFunctions.js b/visio/model/ooxmlApi/convertFunctions.js index e5ba305e47..013827f19b 100644 --- a/visio/model/ooxmlApi/convertFunctions.js +++ b/visio/model/ooxmlApi/convertFunctions.js @@ -168,10 +168,11 @@ * @param {number} maxHeightScaledIn * @param {number} currentPageIndex * @param {number} pagesCount + * @param {Page_Type} pageInfo * @return {CShape} textCShape */ function getTextCShape(theme, shape, cShape, lineUniFill, - fillUniFill, drawingPageScale, maxHeightScaledIn, currentPageIndex, pagesCount ) { + fillUniFill, drawingPageScale, maxHeightScaledIn, currentPageIndex, pagesCount, pageInfo) { // see 2.2.8 Text [MS-VSDX]-220215 /** * handle QuickStyleVariation cell which can change color (but only if color is a result of ThemeVal) @@ -241,7 +242,7 @@ Math.abs(backgroundColorHSL.L - fillColorHSL.L) > Math.abs(backgroundColorHSL.L - lineColorHSL.L) && Math.abs(backgroundColorHSL.L - fillColorHSL.L) > - Math.abs(backgroundColorHSL.L - textColorHSL.L); + Math.abs(backgroundColorHSL.L - textColorHSL.L); if (fillDifferenceIsTheLargest) { textColorRGBA.R = fillColorRGBA.R; textColorRGBA.G = fillColorRGBA.G; @@ -417,9 +418,10 @@ * @param theme * @param shape * @param visioDocument + * @param {Page_Type} pageInfo */ function setRunProps(characterRowNum, characterPropsCommon, oRun, lineUniFill, - fillUniFill, theme, shape, visioDocument) { + fillUniFill, theme, shape, visioDocument, pageInfo) { let characterPropsFinal = characterRowNum !== null && characterPropsCommon.getRow(characterRowNum); /** @@ -532,16 +534,12 @@ let fontCell = characterPropsFinal && characterPropsFinal.getCell("Font"); let cRFonts = new CRFonts(); if (fontCell && fontCell.kind === AscVisio.c_oVsdxSheetStorageKind.Cell_Type) { - // let fontColor = calculateCellValue(theme, shape, characterColorCell); - // all document fonts all loaded already in CVisioDocument.prototype.loadFonts - let fontName = fontCell.v; - if (fontName !== "Themed") { - cRFonts = getRFonts(fontName, visioDocument); - } else { - let themeFontName = theme.getFontScheme().majorFont.latin; - cRFonts = getRFonts(themeFontName, visioDocument); - } + + let fontName = fontCell.calculateValue(shape, pageInfo, + visioDocument.themes, themeValWasUsedFor, true); + + cRFonts = getRFonts(fontName, visioDocument); } else { AscCommon.consoleLog("fontCell was not found so default is set (Calibri). Check mb AsianFont or ScriptFont"); } @@ -586,6 +584,7 @@ const valueCell = fieldRow.getCell("Value"); oFld.SetFieldType(valueCell.f); oFld.vsdxFieldValue = valueCell; + // inits new class variable oFld.isTextInherited = isTextInherited; // then format it according to Format cell @@ -852,7 +851,7 @@ setRunProps(characterRowNum, characterPropsCommon, oRun, lineUniFill, fillUniFill, theme, shape, - visioDocument); + visioDocument, pageInfo); paragraph.Add_ToContent(paragraph.Content.length - 1, oRun); } else if (textElementPart.kind === AscVisio.c_oVsdxTextKind.FLD) { // text field @@ -879,7 +878,7 @@ setRunProps(characterRowNum, characterPropsCommon, oFld, lineUniFill, fillUniFill, theme, shape, - visioDocument); + visioDocument, pageInfo); paragraph.AddToContent(paragraph.Content.length - 1, new ParaRun(paragraph, false)); paragraph.AddToContent(paragraph.Content.length - 1, oFld); @@ -1117,7 +1116,7 @@ oXfrm.setExtY(Math.abs(shapeHeight) * g_dKoef_in_to_mm); oXfrm.setRot(0); } - oSpPr.setXfrm(oXfrm); + oSpPr.setXfrm(oXfrm); oXfrm.setParent(oSpPr); oSpPr.setFill(AscFormat.CreateNoFillUniFill()); oSpPr.setLn(AscFormat.CreateNoFillLine()); @@ -1515,7 +1514,7 @@ let gradientEnabled; if (gradientEnabledCell !== undefined) { gradientEnabled = gradientEnabledCell.calculateValue(this, pageInfo, - visioDocument.themes, themeValWasUsedFor, true); + visioDocument.themes, themeValWasUsedFor, true); } else { gradientEnabled = false; } @@ -1808,7 +1807,7 @@ // not scaling fontSize let textCShape = getTextCShape(visioDocument.themes[0], this, cShape, lineUniFill, uniFillForegnd, drawingPageScale, maxHeightScaledIn, - visioDocument.pageIndex, visioDocument.pages.page.length); + visioDocument.pageIndex, visioDocument.pages.page.length, pageInfo); if (textCShape !== null) { if (isShapeDeleted) { diff --git a/visio/model/ooxmlApi/ooxmlApiIndex.js b/visio/model/ooxmlApi/ooxmlApiIndex.js index b889cbbd87..01b21b634a 100644 --- a/visio/model/ooxmlApi/ooxmlApiIndex.js +++ b/visio/model/ooxmlApi/ooxmlApiIndex.js @@ -760,7 +760,7 @@ let fillColorResultCells = ["Color", "GradientStopColor"]; let numberResultCells = ["LinePattern", "LineWeight", "GradientStopColorTrans", "GradientStopPosition", "FillGradientAngle", "EndArrowSize", "BeginArrowSize", "FillPattern", "LineCap"]; - let stringResultCells = ["EndArrow", "BeginArrow"]; + let stringResultCells = ["EndArrow", "BeginArrow", "Font"]; let booleanResultCells = ["FillGradientEnabled"]; // TODO handle 2.2.7.5 Fixed Theme diff --git a/visio/model/visioFunctionsApi.js b/visio/model/visioFunctionsApi.js index a0ac36175c..ebae1cdae5 100644 --- a/visio/model/visioFunctionsApi.js +++ b/visio/model/visioFunctionsApi.js @@ -185,6 +185,14 @@ isFillIdx = true; initialDefaultValue = 1; // number is return type in calculateValue. Solid fill. + } else if (cellName === "Font") { + // // uses other mechanism + // quickStyleCellName = null; + // quickStyleModifiersCellName = "QuickStyleFillMatrix"; + // getModifiersMethod = themes[0].getFillProp; + // isFillIdx = true; + + initialDefaultValue = "Calibri"; } else { AscCommon.consoleLog("themeval argument error. cell name: " + cellName + " is unknown. return undefined."); return undefined; @@ -474,6 +482,13 @@ } } + if (isNaN(quickStyleColor) && isNaN(quickStyleMatrix)) { + // other mechanism for theme value calculate is used + if (cellName === "Font") { + result = theme.getFontScheme().majorFont.latin; + } + } + /** * calculate exact color on theme. for quickStyleVariation to consider real color * @param {CUniColor | CUniFill} color From 6a318af1d9e127327d530d0e6cb2ad012d5c1d2e Mon Sep 17 00:00:00 2001 From: Dmitriy Orlov Date: Mon, 10 Feb 2025 12:30:50 +0000 Subject: [PATCH 17/18] [se] Fix bug 46130 (#640) [se] Fix bug 46130 Co-authored-by: Dmitriy Orlov Co-committed-by: Dmitriy Orlov --- cell/view/WorksheetView.js | 30 ++- .../SheetStructureTests.js | 176 ++++++++++++++++++ 2 files changed, 201 insertions(+), 5 deletions(-) diff --git a/cell/view/WorksheetView.js b/cell/view/WorksheetView.js index 13e17f1c16..141a577185 100644 --- a/cell/view/WorksheetView.js +++ b/cell/view/WorksheetView.js @@ -2240,6 +2240,9 @@ for (i = 0; i < hasNumber.arrCols.length; ++i) { c = hasNumber.arrCols[i]; cell = t._getVisibleCell(c, arCopy.r2); + if (cell.hasMerged()) { + continue; + } text = (new asc_Range(c, arCopy.r1, c, arCopy.r2 - 1)).getName(); val = t.generateAutoCompleteFormula(functionName, text); // ToDo - при вводе формулы в заголовок автофильтра надо писать "0" @@ -2249,15 +2252,20 @@ for (i = 0; i < hasNumber.arrRows.length; ++i) { r = hasNumber.arrRows[i]; cell = t._getVisibleCell(arCopy.c2, r); + if (cell.hasMerged()) { + continue; + } text = (new asc_Range(arCopy.c1, r, arCopy.c2 - 1, r)).getName(); val = t.generateAutoCompleteFormula(functionName, text); cell.setValue(val); } // Значение в правой нижней ячейке cell = t._getVisibleCell(arCopy.c2, arCopy.r2); - text = (new asc_Range(arCopy.c1, arCopy.r2, arCopy.c2 - 1, arCopy.r2)).getName(); - val = t.generateAutoCompleteFormula(functionName, text); - cell.setValue(val); + if (!cell.hasMerged()) { + text = (new asc_Range(arCopy.c1, arCopy.r2, arCopy.c2 - 1, arCopy.r2)).getName(); + val = t.generateAutoCompleteFormula(functionName, text); + cell.setValue(val); + } }; } else if (true === hasNumberInLastRow && false === hasNumberInLastColumn) { // Есть значения только в последней строке (значит нужно заполнить только последнюю колонку) @@ -2269,6 +2277,9 @@ for (i = 0; i < hasNumber.arrRows.length; ++i) { r = hasNumber.arrRows[i]; cell = t._getVisibleCell(arCopy.c2, r); + if (cell.hasMerged()) { + continue; + } text = (new asc_Range(arCopy.c1, r, arCopy.c2 - 1, r)).getName(); val = t.generateAutoCompleteFormula(functionName, text); cell.setValue(val); @@ -2284,6 +2295,9 @@ for (i = 0; i < hasNumber.arrCols.length; ++i) { c = hasNumber.arrCols[i]; cell = t._getVisibleCell(c, arCopy.r2); + if (cell.hasMerged()) { + continue; + } text = (new asc_Range(c, arCopy.r1, c, arCopy.r2 - 1)).getName(); val = t.generateAutoCompleteFormula(functionName, text); cell.setValue(val); @@ -2356,9 +2370,15 @@ return result; } } else { - // change selection to the last cell if the values ​​in the range are not valid in the autocomplete formula if (!result.text && !result.notEditCell) { - selection.setActiveCell(ar.r2, ar.c2); + let supposedCell = this.model.getCell3(activeCell.row, activeCell.col); + let merged = supposedCell && supposedCell.hasMerged(); + if (merged) { + selection.setActiveCell(merged.r1, merged.c1); + } else if (firstCell && (firstCell.cellType === CellValueType.String) && lastCell && (lastCell.cellType === CellValueType.String)) { + // change selection to the last cell if the values ​​in the range are not valid in the autocomplete formula + selection.setActiveCell(ar.r2, ar.c2); + } } } diff --git a/tests/cell/spreadsheet-calculation/SheetStructureTests.js b/tests/cell/spreadsheet-calculation/SheetStructureTests.js index 4a66ee5825..d2a314ea1d 100644 --- a/tests/cell/spreadsheet-calculation/SheetStructureTests.js +++ b/tests/cell/spreadsheet-calculation/SheetStructureTests.js @@ -3896,6 +3896,182 @@ $(function () { supposedActiveCell = ws.getCell2("B22"); assert.strictEqual(activeCell.col === supposedActiveCell.bbox.c1 && activeCell.row === supposedActiveCell.bbox.r1, true, "Active cell test. B20:B22(only text in range) autosum"); + /* autocomplete to merge cells */ + ws.getRange2("A30:B31").setValue("111"); + // C30:D31 merge & center + ws.getRange2("C30:D31").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("C30:D31").hasMerged(), 'Range C30:D31 is merged'); + + fillRange = ws.getRange2("A30:D31"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + resCell = ws.getRange2("C30"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A30:D31 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A30:D31 autosum"); + resCell = ws.getRange2("C31"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A30:D31 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A30:D31 autosum"); + resCell = ws.getRange2("D30"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A30:D31 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A30:D31 autosum"); + resCell = ws.getRange2("D31"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A30:D31 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A30:D31 autosum"); + + assert.strictEqual(wsView.model.selectionRange.getLast().getName(), "A30:D31", "Selection after A30:D31 autosum"); + + + ws.getRange2("A40:B41").setValue("111"); + ws.getRange2("C40:C41").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("C40:C41").hasMerged(), 'Range C40:C41 is merged'); + + ws.getRange2("D40:D41").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("D40:C41").hasMerged(), 'Range D40:C41 is merged'); + + fillRange = ws.getRange2("A40:D41"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + resCell = ws.getRange2("C40"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A40:D41 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A40:D41 autosum"); + resCell = ws.getRange2("C41"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A40:D41 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A40:D41 autosum"); + resCell = ws.getRange2("D40"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A40:D41 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A40:D41 autosum"); + resCell = ws.getRange2("D41"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A40:D41 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A40:D41 autosum"); + + assert.strictEqual(wsView.model.selectionRange.getLast().getName(), "A40:D41", "Selection after A40:D41 autosum"); + + + ws.getRange2("A50:A51").setValue("111"); + ws.getRange2("A52:A53").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("A52:A53").hasMerged(), 'Range A52:A53 is merged'); + + fillRange = ws.getRange2("A50:A53"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + resCell = ws.getRange2("A52"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A50:A53 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A50:A53 autosum"); + resCell = ws.getRange2("A52"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A50:A53 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A50:A53 autosum"); + + assert.strictEqual(wsView.model.selectionRange.getLast().getName(), "A50:A53", "Selection after A50:A53 autosum"); + + + ws.getRange2("A60:B61").setValue("111"); + ws.getRange2("C60:D60").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("C60:D60").hasMerged(), 'Range C60:D60 is merged'); + + ws.getRange2("C62:D62").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("C62:D62").hasMerged(), 'Range C62:D62 is merged'); + + fillRange = ws.getRange2("A60:D62"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + resCell = ws.getRange2("A62"); + assert.strictEqual(resCell.getValueWithFormat(), "222", "Value in merged cell after A60:D62 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "=SUM(A60:A61)", "Formula in merged cell after A60:D62 autosum"); + resCell = ws.getRange2("B62"); + assert.strictEqual(resCell.getValueWithFormat(), "222", "Value in merged cell after A60:D62 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "=SUM(B60:B61)", "Formula in merged cell after A60:D62 autosum"); + resCell = ws.getRange2("C62"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A60:D62 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A60:D62 autosum"); + resCell = ws.getRange2("D62"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A60:D62 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A60:D62 autosum"); + resCell = ws.getRange2("D60"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A60:D62 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A60:D62 autosum"); + resCell = ws.getRange2("D61"); + assert.strictEqual(resCell.getValueWithFormat(), "222", "Value in merged cell after A60:D62 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "=SUM(A61:C61)", "Formula in merged cell after A60:D62 autosum"); + + assert.strictEqual(wsView.model.selectionRange.getLast().getName(), "A60:D62", "Selection after A60:D62 autosum"); + + ws.getRange2("A1:D70").cleanAll(); + // autosum from merged cell + ws.getRange2("A70:B70").setValue("111"); + ws.getRange2("C70:D70").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("C70:D70").hasMerged(), 'Range C70:D70 is merged'); + + fillRange = ws.getRange2("D70"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + assert.strictEqual(autoCompleteRes && autoCompleteRes.text, "A70:B70", "Formula after autosum from merged cell. C70:D70 autosum from right"); + resCell = ws.getRange2("C70"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after C70:D70 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after C70:D70 autosum"); + + + ws.getRange2("A80:B82").setValue("111"); + ws.getRange2("C80:H88").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("C80:H88").hasMerged(), 'Range C80:H88" is merged'); + + fillRange = ws.getRange2("D82"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + assert.strictEqual(autoCompleteRes && autoCompleteRes.text, "A80:B80", "Formula after autosum from merged cell. C80:H88 autosum from right"); + resCell = ws.getRange2("C80"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after C80:H88 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after C80:H88 autosum"); + + + ws.getRange2("A90:B91").setValue("111"); + ws.getRange2("A92:D94").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("A92:D94").hasMerged(), 'Range A92:D94 is merged'); + + fillRange = ws.getRange2("D94"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + assert.strictEqual(autoCompleteRes && autoCompleteRes.text, "A90:A91", "Formula after autosum from merged cell. A92:D94 autosum from bottom"); + resCell = ws.getRange2("A92"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A92:D94 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A92:D94 autosum"); + + + ws.getRange2("A110:C111").setValue("111"); + ws.getRange2("C112").setValue("111"); + ws.getRange2("A113:C115").merge(Asc.c_oAscMergeOptions.MergeCenter); + assert.ok(ws.getRange2("A113:C115").hasMerged(), 'Range A113:C115 is merged'); + + fillRange = ws.getRange2("C113"); + wsView.setSelection(fillRange.bbox); + wsView._initRowsCount(); + wsView._initColsCount(); + autoCompleteRes = wsView.autoCompleteFormula("SUM"); + + assert.strictEqual(autoCompleteRes && autoCompleteRes.text, "A110:A112", "Formula after autosum from merged cell. A113:C115 autosum from bottom"); + resCell = ws.getRange2("A92"); + assert.strictEqual(resCell.getValueWithFormat(), "", "Value in merged cell after A113:C115 autosum"); + assert.strictEqual(resCell.getValueForEdit(), "", "Formula in merged cell after A113:C115 autosum"); ws.getRange2("A1:Z100").cleanAll(); }); From 5c3ecc4053b2bdc95d2372c96ea3470b32a57e49 Mon Sep 17 00:00:00 2001 From: Dmitriy Orlov Date: Mon, 10 Feb 2025 13:09:34 +0000 Subject: [PATCH 18/18] [se] Fix bug 61855 (#590) [se] Fix bug 61855 Co-authored-by: Dmitriy Orlov Co-committed-by: Dmitriy Orlov --- cell/view/WorkbookView.js | 11 ++++++----- .../spreadsheet-calculation/SheetStructureTests.js | 11 +++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/cell/view/WorkbookView.js b/cell/view/WorkbookView.js index 45ded79f66..e15fad4b76 100644 --- a/cell/view/WorkbookView.js +++ b/cell/view/WorkbookView.js @@ -3244,16 +3244,17 @@ this.cellEditor.changeCellText(sArguments); if (name) { - - var res = new AscCommonExcel.CFunctionInfo(name); + let res = new AscCommonExcel.CFunctionInfo(name); if (needChange) { res.asc_setArguments(args); } res.argumentsResult = []; - var argCalc = ws.calculateWizardFormula(args[argNum], argType); + let argCalc = ws.calculateWizardFormula(args[argNum], argType); res.argumentsResult[argNum] = argCalc.str; - if (argCalc.obj && argCalc.obj.type !== AscCommonExcel.cElementType.error) { - var funcCalc = ws.calculateWizardFormula(name + '(' + sArguments + ')'); + //second condition: if we haven't received the formulaResult, calculate with those arguments that exist in the array + if ((argCalc.obj && argCalc.obj.type !== AscCommonExcel.cElementType.error) || + (argCalc.obj === null && res && !res.functionResult && args && sArguments)) { + let funcCalc = ws.calculateWizardFormula(name + '(' + sArguments + ')'); res.functionResult = funcCalc.str; if (funcCalc.obj && funcCalc.obj.type !== AscCommonExcel.cElementType.error) { res.formulaResult = ws.calculateWizardFormula(this.cellEditor.getText().substring(1)).str; diff --git a/tests/cell/spreadsheet-calculation/SheetStructureTests.js b/tests/cell/spreadsheet-calculation/SheetStructureTests.js index d2a314ea1d..0aec36d8a1 100644 --- a/tests/cell/spreadsheet-calculation/SheetStructureTests.js +++ b/tests/cell/spreadsheet-calculation/SheetStructureTests.js @@ -3337,6 +3337,17 @@ $(function () { wb.dependencyFormulas._foreachDefName(function(defName) { wb.dependencyFormulas.removeDefName(undefined, defName.name); }); + + // for bug 61855 + let insertArgsRes = api.wb.insertArgumentsInFormula(["1"], 0, 0, "SUM", true/*bEndInsertArg*/); + assert.strictEqual(insertArgsRes && insertArgsRes.functionResult, "1", "Calculation result for SUM function when insert first argument in formula"); + + insertArgsRes = api.wb.insertArgumentsInFormula(["1,2"], 1, 0, "SUM", true); + assert.strictEqual(insertArgsRes && insertArgsRes.functionResult, "3", "Calculation result for SUM function when insert second argument in formula"); + + insertArgsRes = api.wb.insertArgumentsInFormula(["1"], 1, 0, "SUM", true); + assert.strictEqual(insertArgsRes && insertArgsRes.functionResult, "1", "Calculation result for SUM function when delete second argument in formula"); + }); QUnit.test('autoCompleteFormula', function (assert) {