diff --git a/tests/word/js-api/api-section.js b/tests/word/js-api/api-section.js new file mode 100644 index 0000000000..7aa5e6ad58 --- /dev/null +++ b/tests/word/js-api/api-section.js @@ -0,0 +1,60 @@ +/* + * (c) Copyright Ascensio System SIA 2010-2025 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +$(function () { + QUnit.module('Test the ApiSection methods'); + + QUnit.test('GetColumnsCount, GetColumnsSpaces, GetColumnsWidths', function(assert) + { + let document = AscTest.JsApi.GetDocument(); + + section = document.GetFinalSection(); + + let widths = [1440, 2880, 4320]; + let spaces = [720, 480]; + + section.SetNotEqualColumns(widths, spaces); + + let checkWidths = section.GetColumnsWidths(); + let checkSpaces = section.GetColumnsSpaces(); + + assert.strictEqual(section.GetColumnsCount(), 3, 'Columns count should be 3'); + + widths.forEach((width, idx) => { + assert.strictEqual(width, checkWidths[idx], `The set width with idx = ${idx} differs from the received one`); + }); + + spaces.forEach((space, idx) => { + assert.strictEqual(space, checkSpaces[idx], `The set space with idx = ${idx} differs from the received one`); + }); + }); +}); diff --git a/tests/word/js-api/js-api.html b/tests/word/js-api/js-api.html index 9b84b721db..5bc3a8b1d6 100644 --- a/tests/word/js-api/js-api.html +++ b/tests/word/js-api/js-api.html @@ -32,6 +32,7 @@ +

Test document js-api

diff --git a/word/apiBuilder.js b/word/apiBuilder.js index 02797b572d..0358f32163 100644 --- a/word/apiBuilder.js +++ b/word/apiBuilder.js @@ -12952,6 +12952,63 @@ this.Section.Set_Columns_Num(aCols.length); return true; }; + /** + * Returns number of columns in this section. + * @memberof ApiSection + * @typeofeditors ["CDE"] + * @returns {number} + * @see office-js-api/Examples/{Editor}/ApiSection/Methods/GetColumnsCount.js + */ + ApiSection.prototype.GetColumnsCount = function() + { + return this.Section.GetColumnCount(); + }; + /** + * Returns an array of column width values measured in twentieths of a point (1/1440 of an inch). + * @memberof ApiSection + * @typeofeditors ["CDE"] + * @returns {twips[]} + * @see office-js-api/Examples/{Editor}/ApiSection/Methods/GetColumnsWidths.js + */ + ApiSection.prototype.GetColumnsWidths = function() + { + if (this.Section.IsEqualColumnWidth()) { + return [private_MM2Twips(this.Section.GetColumnWidth())]; + } + else + { + let nCols = this.GetColumnsCount(); + let aRes = []; + + for (let i = 0; i < nCols; i++) + aRes.push(private_MM2Twips(this.Section.GetColumnWidth(i))); + + return aRes; + } + }; + /** + * Returns an array of distance values between the columns measured in twentieths of a point (1/1440 of an inch). + * @memberof ApiSection + * @typeofeditors ["CDE"] + * @returns {twips[]} + * @see office-js-api/Examples/{Editor}/ApiSection/Methods/GetColumnsSpaces.js + */ + ApiSection.prototype.GetColumnsSpaces = function() + { + if (this.Section.IsEqualColumnWidth()) { + return [private_MM2Twips(this.Section.GetColumnSpace())]; + } + else + { + let nCols = this.GetColumnsCount(); + let aRes = []; + + for (let i = 0; i < nCols - 1; i++) + aRes.push(private_MM2Twips(this.Section.GetColumnSpace(i))); + + return aRes; + } + }; /** * Specifies the properties (size and orientation) for all the pages in the current section. * @memberof ApiSection @@ -17060,7 +17117,7 @@ * Sets the outline level for the specified properties. * @memberof ApiParaPr * @typeofeditors ["CDE", "CSE", "CPE"] - * @param {Number?} [nLvl=undefined] - The outline level. Possible values: 0-8. The 0 value means the basic outline level. + * @param {Number?} [nLvl=undefined] - The outline level. Possible values: 1-9. The 1The desired functionality is as follows: When inserting document A into document B using the merge document API during editing, the source of document A should be visible within document B. By clicking or hovering over the inserted content of document A in document B, information about the insertion of document A should be displayed in a pop-up/floating window, preserving the boundaries of document A. Document A should be able to be inserted between any two characters in document B. * To set no outline level, use this method without a parameter. * @returns {boolean} * @since 8.2.0 @@ -17070,7 +17127,7 @@ { if (typeof(nLvl) === "number") { nLvl = Math.ceil(nLvl); - if (nLvl < 0 || nLvl > 8) { + if (nLvl < 1 || nLvl > 9) { return false; } } @@ -17078,7 +17135,7 @@ return false; } - this.ParaPr.OutlineLvl = nLvl; + this.ParaPr.OutlineLvl = typeof(nLvl) === "number" ? nLvl - 1 : nLvl; this.private_OnChange(); }; @@ -17092,7 +17149,7 @@ */ ApiParaPr.prototype.GetOutlineLvl = function() { - return this.ParaPr.OutlineLvl; + return typeof(this.ParaPr.OutlineLvl) == "number" ? this.ParaPr.OutlineLvl + 1 : this.ParaPr.OutlineLvl; }; /** diff --git a/word/fromToJSON.js b/word/fromToJSON.js index 349325679d..7f3f80dcb8 100644 --- a/word/fromToJSON.js +++ b/word/fromToJSON.js @@ -7968,7 +7968,7 @@ var oTempElm = null; var arrContent = []; - if (oMathContent instanceof AscCommonWord.CDenominator || oMathContent instanceof AscCommonWord.CNumerator) + if (oMathContent instanceof CDenominator || oMathContent instanceof CNumerator) arrContent.push(SerFracArg.call(this, oMathContent)); else { @@ -8052,9 +8052,9 @@ return oFractionArg; var sArgType = ""; - if (oFractionArg instanceof AscCommonWord.CDenominator) + if (oFractionArg instanceof CDenominator) sArgType = "den"; - else if (oFractionArg instanceof AscCommonWord.CNumerator) + else if (oFractionArg instanceof CNumerator) sArgType = "num"; return {