Defines the auxiliary window.Asc.plugin.info object which is available when the plugin works. It stores all the information about the editor that uses the plugin (the used editorType - text documents, spreadsheets, presentations) and additional settings for OLE objects (their width, height, millimeter to pixel ratio for the OLE objects vector drawing and some other OLE object parameters).
This object is used to change the object data and to send additional parameters when executing the window.Asc.plugin.callcommand method. For example, if the document content is changed and recalculation is needed, the parameter recalculate must be set to true. This action is necessary because the recalculation process is asynchronous. Moreover, some other data might need to be uploaded (e.g. a font or something else).
See the available window.Asc.plugin.info object parameters below to find out more about them.
Name | Description | Type | Example |
data | The OLE object data which need to be sent to the window.Asc.plugin.info object and used by the plugin. | string | "{data}" |
editorType | The editor type where the plugin is currently running. | string | "word" |
guid | The OLE object GUID in the current document. | string | "asc.{UUID}" |
height | The OLE object height measured in millimeters. | number | 70 |
imgSrc | The link to the image (its visual representation) stored in the OLE object and used by the plugin. | string | "./resources/image.png" |
mmToPx | Millimeter to pixel conversion ratio for the OLE object vector draw. | number | 3 |
objectId | The OLE object identifier in the current document. | string | 1 |
recalculate | Forces the document to recalculate its content data. | boolean | true |
resize | Checks if the OLE object size has been changed. | boolean | true |
width | The OLE object width measured in millimeters. | number | 70 |
window.Asc.plugin.button = function (id) { var _info = window.Asc.plugin.info; var _method = (_info.objectId === undefined) ? "asc_addOleObject" : "asc_editOleObject"; _info.width = _info.width ? _info.width : 70; _info.height = _info.height ? _info.height : 70; _info.widthPix = (_info.mmToPx * _info.width) >> 0; _info.heightPix = (_info.mmToPx * _info.height) >> 0; _info.imgSrc = window.g_board.getResult(_info.widthPix, _info.heightPix).image; _info.data = window.g_board.getData(); var _code = "Api." + _method + "(" + JSON.stringify(_info) + ");"; this.callCommand("close", _code); };
function createScriptFromArray (aSelected) { var sScript = ''; if (aSelected.length > 0) { switch (window.Asc.plugin.info.editorType) { case 'word': { sScript += 'var oDocument = Api.GetDocument();'; sScript += '\noDocument.CreateNewHistoryPoint();'; sScript += '\nvar oParagraph, oRun, arrInsertResult = [], oImage;'; sScript += '\noDocument.InsertContent(arrInsertResult);'; break; } } } return sScript; }
window.Asc.plugin.init = function () { var plugin_uuid = window.Asc.plugin.info.guid; };
window.Asc.plugin.init = function () { var sScript = 'var oDocument = Api.GetDocument();'; sScript += 'oDocument.CreateNewHistoryPoint();'; sScript += 'oParagraph = Api.CreateParagraph();'; sScript += 'oParagraph.AddText(\'Hello word!\');'; sScript += 'oDocument.InsertContent([oParagraph]);'; window.Asc.plugin.info.recalculate = true; this.callCommand("close", sScript); };
if (window.Asc.plugin.info.resize === true) { return window.Asc.plugin.button(0); }