Compare commits

..

10 Commits

3 changed files with 52 additions and 30 deletions

25
api.js
View File

@ -171,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)
@ -184,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)
{
@ -268,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();

View File

@ -60,6 +60,7 @@
* @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
@ -148,13 +149,13 @@
* @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:
* * <b>0</b> - the picture is placed on the left;
* * <b>50</b> - the picture is placed in the center;
* * <b>100</b> - the picture is placed on the right.
* <b>0</b> - the picture is placed on the left;
* <b>50</b> - the picture is placed in the center;
* <b>100</b> - the picture is placed on the right.
* @property {percentage} shiftY - Vertical picture position inside the picture form measured in percent:
* * <b>0</b> - the picture is placed on top;
* * <b>50</b> - the picture is placed in the center;
* * <b>100</b> - the picture is placed on the bottom.
* <b>0</b> - the picture is placed on top;
* <b>50</b> - the picture is placed in the center;
* <b>100</b> - the picture is placed on the bottom.
* @see office-js-api/Examples/Enumerations/PictureFormPrBase.js
*/
@ -185,7 +186,7 @@
* @typeofeditors ["CDE", "CFE"]
* @param {TextFormPr} oFormPr - Text field properties.
* @returns {ApiTextForm}
* @see office-js-api/Examples/../Sdkjs-Forms/Api/Methods/CreateTextForm.js
* @see office-js-api/Examples/Forms/Api/Methods/CreateTextForm.js
*/
Api.prototype.CreateTextForm = function(oFormPr)
{
@ -206,7 +207,7 @@
* @typeofeditors ["CDE", "CFE"]
* @param {CheckBoxFormPr} oFormPr - Checkbox / radio button properties.
* @returns {ApiCheckBoxForm}
* @see office-js-api/Examples/../Sdkjs-Forms/Api/Methods/CreateCheckBoxForm.js
* @see office-js-api/Examples/Forms/Api/Methods/CreateCheckBoxForm.js
*/
Api.prototype.CreateCheckBoxForm = function(oFormPr)
{
@ -281,7 +282,7 @@
* @typeofeditors ["CDE", "CFE"]
* @param {ComboBoxFormPr} oFormPr - Combo box / dropdown list properties.
* @returns {ApiComboBoxForm}
* @see office-js-api/Examples/../Sdkjs-Forms/Api/Methods/CreateComboBoxForm.js
* @see office-js-api/Examples/Forms/Api/Methods/CreateComboBoxForm.js
*/
Api.prototype.CreateComboBoxForm = function(oFormPr)
{
@ -351,7 +352,7 @@
* @typeofeditors ["CDE", "CFE"]
* @param {PictureFormPr} oFormPr - Picture form properties.
* @returns {ApiPictureForm}
* @see office-js-api/Examples/../Sdkjs-Forms/Api/Methods/CreatePictureForm.js
* @see office-js-api/Examples/Forms/Api/Methods/CreatePictureForm.js
*/
Api.prototype.CreatePictureForm = function(oFormPr)
{
@ -403,7 +404,7 @@
* @typeofeditors ["CDE", "CFE"]
* @param {DateFormPr} oFormPr - Date form properties.
* @returns {ApiDateForm}
* @see office-js-api/Examples/../Sdkjs-Forms/Api/Methods/CreateDateForm.js
* @see office-js-api/Examples/Forms/Api/Methods/CreateDateForm.js
*/
Api.prototype.CreateDateForm = function(oFormPr)
{
@ -424,7 +425,7 @@
* @typeofeditors ["CDE", "CFE"]
* @param {TextFormInsertPr} oFormPr - Properties for inserting a text field.
* @returns {ApiTextForm}
* @see office-js-api/Examples/../Sdkjs-Forms/ApiDocument/Methods/InsertTextForm.js
* @see office-js-api/Examples/Forms/ApiDocument/Methods/InsertTextForm.js
*/
ApiDocument.prototype.InsertTextForm = function(oFormPr)
{
@ -464,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;

View File

@ -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);