diff --git a/api.js b/api.js index ae792fa..9fad3c6 100644 --- a/api.js +++ b/api.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) @@ -61,6 +61,7 @@ window["AscOForm"] = window.AscOForm = AscOForm; oPr.UncheckedFont = "Segoe UI Symbol"; } + var nCheckedSymbol = oPr && oPr.CheckedSymbol ? oPr.CheckedSymbol : Asc.c_oAscSdtCheckBoxDefaults.CheckedSymbol; var nUncheckedSymbol = oPr && oPr.UncheckedSymbol ? oPr.UncheckedSymbol : Asc.c_oAscSdtCheckBoxDefaults.UncheckedSymbol; var sCheckedFont = oPr && oPr.CheckedFont ? oPr.CheckedFont : Asc.c_oAscSdtCheckBoxDefaults.CheckedFont; @@ -87,7 +88,11 @@ window["AscOForm"] = window.AscOForm = AscOForm; if (oFormPr) { private_ApplyFormPr(oCC, oFormPr, oLogicDocument); - private_CheckFormKey(oCC, oLogicDocument); + + if (oPr && oPr.GroupKey) + private_CheckRadioButtonChoice(oCC, oLogicDocument, oPr.GroupKey); + else + private_CheckFormKey(oCC, oLogicDocument); } if (oCommonPr) @@ -166,7 +171,7 @@ window["AscOForm"] = window.AscOForm = AscOForm; private_PerformAddCheckBox(); } }; - window['Asc']['asc_docs_api'].prototype['asc_AddContentControlPicture'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlPicture = function(oFormPr, oCommonPr) + window['Asc']['asc_docs_api'].prototype['asc_AddContentControlPicture'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlPicture = function(oFormPr, oCommonPr, isSignature) { var oLogicDocument = this.private_GetLogicDocument(); if (!oLogicDocument) @@ -179,16 +184,31 @@ window["AscOForm"] = window.AscOForm = AscOForm; { oLogicDocument.StartAction(AscDFH.historydescription_Document_AddContentControlPicture); - var oCC = oLogicDocument.AddContentControlPicture(); + // 150x32pt for Signature + let w = isSignature ? 150 / 72 * 25.4 : undefined; + let h = isSignature ? 32 / 72 * 25.4 : undefined; + + var oCC = oLogicDocument.AddContentControlPicture(w, h); let oFormParaDrawing = null; if (oCC && oFormPr) { oCC.SetFormPr(oFormPr); oCC.UpdatePlaceHolderTextPrForForm(); + let pictPr = new AscCommon.CSdtPictureFormPr(); + if (isSignature) + { + pictPr.SetSignature(true); + let glossary = oLogicDocument.GetGlossaryDocument(); + if (glossary) + oCC.SetPlaceholder(glossary.GetDefaultPlaceholderSignatureOformDocPartId()); + } + + oCC.SetPictureFormPr(pictPr); + private_CheckFormKey(oCC, oLogicDocument); oLogicDocument.Recalculate(true); oFormParaDrawing = oCC.ConvertFormToFixed(); - oCC.SetPictureFormPr(new AscCommon.CSdtPictureFormPr()); + var aDrawings = oCC.GetAllDrawingObjects(); for(var nDrawing = 0; nDrawing < aDrawings.length; ++nDrawing) { @@ -263,6 +283,10 @@ window["AscOForm"] = window.AscOForm = AscOForm; oLogicDocument.FinalizeAction(); } }; + window['Asc']['asc_docs_api'].prototype['asc_AddContentControlSignature'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlSignature = function(oFormPr, oCommonPr) + { + return this.asc_AddContentControlPicture(oFormPr, oCommonPr, true); + }; window['Asc']['asc_docs_api'].prototype['asc_AddContentControlList'] = window['Asc']['asc_docs_api'].prototype.asc_AddContentControlList = function(isComboBox, oPr, oFormPr, oCommonPr) { var oLogicDocument = this.private_GetLogicDocument(); @@ -622,6 +646,26 @@ window["AscOForm"] = window.AscOForm = AscOForm; formPr.SetKey(key); form.SetFormPr(formPr); } + function private_CheckRadioButtonChoice(form, logicDocument, groupKey) + { + if (!form || !form.IsForm() || !logicDocument) + return; + + let choice = form.GetFormKey(); + if (choice && "" !== choice.trim()) + return; + + let formManager = logicDocument.GetFormsManager(); + let keyGenerator = formManager.GetKeyGenerator(); + + let formPr = form.GetFormPr().Copy(); + if (!formPr) + return; + + choice = keyGenerator.GetNewChoiceByGroupKey(groupKey); + formPr.SetKey(choice); + form.SetFormPr(formPr); + } function private_ApplyFormPr(form, formPr, logicDocument) { if (!form || !formPr) diff --git a/apiBuilder.js b/apiBuilder.js index 844dddf..99074f1 100644 --- a/apiBuilder.js +++ b/apiBuilder.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) @@ -60,8 +60,10 @@ * @typedef {Object} FormPrBase * @property {string} key - Form key. * @property {string} tip - Form tip text. + * @property {string} tag - Form tag. * @property {boolean} required - Specifies if the form is required or not. * @property {string} placeholder - Form placeholder text. + * @see office-js-api/Examples/Enumerations/FormPrBase.js */ /** @@ -72,11 +74,13 @@ * @property {number} cellWidth - The cell width for each character measured in millimeters. If this parameter is not specified or equal to 0 or less, then the width will be set automatically. * @property {boolean} multiLine - Specifies if the current fixed size text field is multiline or not. * @property {boolean} autoFit - Specifies if the text field content should be autofit, i.e. whether the font size adjusts to the size of the fixed size form. + * @see office-js-api/Examples/Enumerations/TextFormPrBase.js */ /** * Text field properties. * @typedef {FormPrBase | TextFormPrBase} TextFormPr + * @see office-js-api/Examples/Enumerations/TextFormPr.js */ /** @@ -84,11 +88,13 @@ * @typedef {Object} FormInsertPr * @property {boolean} [placeholderFromSelection=false] - Specifies if the currently selected text should be saved as a placeholder of the inserted form. * @property {boolean} [keepSelectedTextInForm=true] - Specifies if the currently selected text should be saved as the content of the inserted form. + * @see office-js-api/Examples/Enumerations/FormInsertPr.js */ /** * Properties for inserting a text field. * @typedef {FormPrBase | TextFormPrBase | FormInsertPr} TextFormInsertPr + * @see office-js-api/Examples/Enumerations/TextFormInsertPr.js */ @@ -96,11 +102,13 @@ * Specific checkbox / radio button properties. * @typedef {Object} CheckBoxFormPrBase * @property {boolean} radio - Specifies if the current checkbox is a radio button. In this case, the key parameter is considered as an identifier for the group of radio buttons. + * @see office-js-api/Examples/Enumerations/CheckBoxFormPrBase.js */ /** * Checkbox / radio button properties. * @typedef {FormPrBase | CheckBoxFormPrBase} CheckBoxFormPr + * @see office-js-api/Examples/Enumerations/CheckBoxFormPr.js */ /** @@ -113,21 +121,25 @@      * If the array consists of single strings, then the displayed value and its meaning are the same.      * Example: ["First", ["Second", "2"], ["Third", "3"], "Fourth"]. + * @see office-js-api/Examples/Enumerations/ComboBoxFormPrBase.js */ /** * Combo box / dropdown list properties. * @typedef {FormPrBase | ComboBoxFormPrBase} ComboBoxFormPr + * @see office-js-api/Examples/Enumerations/ComboBoxFormPr.js */ /** * The condition to scale an image in the picture form. * @typedef {"always" | "never" | "tooBig" | "tooSmall"} ScaleFlag + * @see office-js-api/Examples/Enumerations/ScaleFlag.js */ /** * Value from 0 to 100. * @typedef {number} percentage + * @see office-js-api/Examples/Enumerations/percentage.js */ /** @@ -137,18 +149,20 @@ * @property {boolean} lockAspectRatio - Specifies if the aspect ratio of the picture form is locked or not. * @property {boolean} respectBorders - Specifies if the form border width is respected or not when scaling the image. * @property {percentage} shiftX - Horizontal picture position inside the picture form measured in percent: - * * 0 - the picture is placed on the left; - * * 50 - the picture is placed in the center; - * * 100 - the picture is placed on the right. + * 0 - the picture is placed on the left; + * 50 - the picture is placed in the center; + * 100 - the picture is placed on the right. * @property {percentage} shiftY - Vertical picture position inside the picture form measured in percent: - * * 0 - the picture is placed on top; - * * 50 - the picture is placed in the center; - * * 100 - the picture is placed on the bottom. + * 0 - the picture is placed on top; + * 50 - the picture is placed in the center; + * 100 - the picture is placed on the bottom. + * @see office-js-api/Examples/Enumerations/PictureFormPrBase.js */ /** * Picture form properties. * @typedef {FormPrBase | PictureFormPrBase} PictureFormPr + * @see office-js-api/Examples/Enumerations/PictureFormPr.js */ /** @@ -157,18 +171,22 @@ * @property {string} format - The date format, ex: mm.dd.yyyy * @property {string} lang - The date language. Possible value for this parameter is a language identifier as defined by * RFC 4646/BCP 47. Example: "en-CA". + * @see office-js-api/Examples/Enumerations/DateFormPrBase.js */ /** * Date form properties. * @typedef {FormPrBase | DateFormPrBase} DateFormPr + * @see office-js-api/Examples/Enumerations/DateFormPr.js */ /** * Creates a text field with the specified text field properties. * @memberof Api + * @typeofeditors ["CDE", "CFE"] * @param {TextFormPr} oFormPr - Text field properties. * @returns {ApiTextForm} + * @see office-js-api/Examples/Forms/Api/Methods/CreateTextForm.js */ Api.prototype.CreateTextForm = function(oFormPr) { @@ -186,8 +204,10 @@ /** * Creates a checkbox / radio button with the specified checkbox / radio button properties. * @memberof Api + * @typeofeditors ["CDE", "CFE"] * @param {CheckBoxFormPr} oFormPr - Checkbox / radio button properties. * @returns {ApiCheckBoxForm} + * @see office-js-api/Examples/Forms/Api/Methods/CreateCheckBoxForm.js */ Api.prototype.CreateCheckBoxForm = function(oFormPr) { @@ -259,8 +279,10 @@ /** * Creates a combo box / dropdown list with the specified combo box / dropdown list properties. * @memberof Api + * @typeofeditors ["CDE", "CFE"] * @param {ComboBoxFormPr} oFormPr - Combo box / dropdown list properties. * @returns {ApiComboBoxForm} + * @see office-js-api/Examples/Forms/Api/Methods/CreateComboBoxForm.js */ Api.prototype.CreateComboBoxForm = function(oFormPr) { @@ -327,8 +349,10 @@ /** * Creates a picture form with the specified picture form properties. * @memberof Api + * @typeofeditors ["CDE", "CFE"] * @param {PictureFormPr} oFormPr - Picture form properties. * @returns {ApiPictureForm} + * @see office-js-api/Examples/Forms/Api/Methods/CreatePictureForm.js */ Api.prototype.CreatePictureForm = function(oFormPr) { @@ -377,8 +401,10 @@ /** * Creates a date form with the specified date form properties. * @memberof Api + * @typeofeditors ["CDE", "CFE"] * @param {DateFormPr} oFormPr - Date form properties. * @returns {ApiDateForm} + * @see office-js-api/Examples/Forms/Api/Methods/CreateDateForm.js */ Api.prototype.CreateDateForm = function(oFormPr) { @@ -396,8 +422,10 @@ /** * Inserts a text box with the specified text box properties over the selected text. * @memberof ApiDocument + * @typeofeditors ["CDE", "CFE"] * @param {TextFormInsertPr} oFormPr - Properties for inserting a text field. * @returns {ApiTextForm} + * @see office-js-api/Examples/Forms/ApiDocument/Methods/InsertTextForm.js */ ApiDocument.prototype.InsertTextForm = function(oFormPr) { @@ -437,6 +465,10 @@ let placeholder = oFormPr ? GetStringParameter(oFormPr["placeholder"], undefined) : undefined; SetFormPlaceholder(contentControl, placeholder); + let tag = oFormPr ? GetStringParameter(oFormPr["tag"], undefined) : undefined; + if (tag) + contentControl.SetTag(tag); + contentControl.ReplaceContentWithPlaceHolder(false); contentControl.UpdatePlaceHolderTextPrForForm(); return contentControl; @@ -515,3 +547,4 @@ ApiDocument.prototype["InsertTextForm"] = ApiDocument.prototype.InsertTextForm; }(window, null)); + diff --git a/apiPlugins.js b/apiPlugins.js index fddce0c..d63ebf0 100644 --- a/apiPlugins.js +++ b/apiPlugins.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) @@ -41,16 +41,18 @@ * @property {string} Id - A unique identifier of the content control. It can be used to search for a certain content control and make reference to it in the code. * @property {ContentControlLock} Lock - A value that defines if it is possible to delete and/or edit the content control or not: 0 - only deleting, 1 - no deleting or editing, 2 - only editing, 3 - full access. * @property {string} InternalId - A unique internal identifier of the content control. It is used for all operations with content controls. - */ + * @see office-js-api/Examples/Plugins/Forms/Enumeration/ContentControl.js + */ /** * @typedef {(0 | 1 | 2 | 3)} ContentControlLock * A value that defines if it is possible to delete and/or edit the content control or not: - * * **0** - only deleting - * * **1** - disable deleting or editing - * * **2** - only editing - * * **3** - full access - */ + * **0** - only deleting + * **1** - disable deleting or editing + * **2** - only editing + * **3** - full access + * @see office-js-api/Examples/Plugins/Forms/Enumeration/ContentControlLock.js + */ /** * Returns information about all the forms that have been added to the document. @@ -58,8 +60,7 @@ * @typeofeditors ["CDE"] * @alias GetAllForms * @returns {ContentControl[]} - An array with all the forms from the document. - * @example - * window.Asc.plugin.executeMethod("GetAllForms"); + * @see office-js-api/Examples/Plugins/Forms/Api/Methods/GetAllForms.js */ window["asc_docs_api"].prototype["pluginMethod_GetAllForms"] = function() { @@ -82,8 +83,7 @@ * @alias GetFormsByTag * @param {string} tag - The form tag. * @returns {ContentControl[]} - An array with all the forms from the document with the specified tag. - * @example - * window.Asc.plugin.executeMethod("GetFormsByTag"); + * @see office-js-api/Examples/Plugins/Forms/Api/Methods/GetFormsByTag.js */ window["asc_docs_api"].prototype["pluginMethod_GetFormsByTag"] = function(tag) { @@ -109,8 +109,7 @@ * @alias SetFormValue * @param {string} internalId - A unique internal identifier of the form. * @param {string | boolean} value - Form value to be set. Its type depends on the form type. - * @example - * window.Asc.plugin.executeMethod("SetFormValue"); + * @see office-js-api/Examples/Plugins/Forms/Api/Methods/SetFormValue.js */ window["asc_docs_api"].prototype["pluginMethod_SetFormValue"] = function(internalId, value) { @@ -123,9 +122,7 @@ * @alias GetFormValue * @param {string} internalId - A unique internal identifier of the form. * @returns {null | string | boolean} The form value in the string or boolean format depending on the form type. The null value means that the form is filled with a placeholder. - * @example - * window.Asc.plugin.executeMethod("GetFormValue"); - * + * @see office-js-api/Examples/Plugins/Forms/Api/Methods/GetFormValue.js */ window["asc_docs_api"].prototype["pluginMethod_GetFormValue"] = function(internalId) { @@ -171,3 +168,4 @@ }; })(window); + diff --git a/oform/OForm.js b/oform/OForm.js index 19b2fa3..b3147b3 100644 --- a/oform/OForm.js +++ b/oform/OForm.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/Role.js b/oform/Role.js index 03fb962..1ee7f6f 100644 --- a/oform/Role.js +++ b/oform/Role.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/BaseFormatObject.js b/oform/format/BaseFormatObject.js index 406bb20..19d153f 100644 --- a/oform/format/BaseFormatObject.js +++ b/oform/format/BaseFormatObject.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/Document.js b/oform/format/Document.js index e99cd9e..c3c99da 100644 --- a/oform/format/Document.js +++ b/oform/format/Document.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/FieldGroup.js b/oform/format/FieldGroup.js index 3053e92..0e7d5a8 100644 --- a/oform/format/FieldGroup.js +++ b/oform/format/FieldGroup.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/FieldMaster.js b/oform/format/FieldMaster.js index 65aa41c..34cca2e 100644 --- a/oform/format/FieldMaster.js +++ b/oform/format/FieldMaster.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/User.js b/oform/format/User.js index e2250b3..069af01 100644 --- a/oform/format/User.js +++ b/oform/format/User.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/UserMaster.js b/oform/format/UserMaster.js index b2b7e7f..969333b 100644 --- a/oform/format/UserMaster.js +++ b/oform/format/UserMaster.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/changes/DictionaryBase.js b/oform/format/changes/DictionaryBase.js index 1e7b2a0..b160838 100644 --- a/oform/format/changes/DictionaryBase.js +++ b/oform/format/changes/DictionaryBase.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/changes/DocumentChanges.js b/oform/format/changes/DocumentChanges.js index 0e95689..72dc976 100644 --- a/oform/format/changes/DocumentChanges.js +++ b/oform/format/changes/DocumentChanges.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/changes/FieldGroupChanges.js b/oform/format/changes/FieldGroupChanges.js index 82e915d..f83adce 100644 --- a/oform/format/changes/FieldGroupChanges.js +++ b/oform/format/changes/FieldGroupChanges.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/changes/FieldMasterChanges.js b/oform/format/changes/FieldMasterChanges.js index ddbde6c..a24725e 100644 --- a/oform/format/changes/FieldMasterChanges.js +++ b/oform/format/changes/FieldMasterChanges.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/changes/UserChanges.js b/oform/format/changes/UserChanges.js index af9b050..e833589 100644 --- a/oform/format/changes/UserChanges.js +++ b/oform/format/changes/UserChanges.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/format/changes/UserMasterChanges.js b/oform/format/changes/UserMasterChanges.js index a2dfad3..180e98e 100644 --- a/oform/format/changes/UserMasterChanges.js +++ b/oform/format/changes/UserMasterChanges.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/xml/XmlContext.js b/oform/xml/XmlContext.js index c3bf8f8..a1ce77c 100644 --- a/oform/xml/XmlContext.js +++ b/oform/xml/XmlContext.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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) diff --git a/oform/xml/XmlPackage.js b/oform/xml/XmlPackage.js index 4ce89fb..78c5bb2 100644 --- a/oform/xml/XmlPackage.js +++ b/oform/xml/XmlPackage.js @@ -1,5 +1,5 @@ /* - * (c) Copyright Ascensio System SIA 2010-2023 + * (c) Copyright Ascensio System SIA 2010-2024 * * 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)