@microsoft/office-js
Version:
Office JavaScript APIs
946 lines (871 loc) • 955 kB
JavaScript
/* Version: 16.0.8828.1000 */
/*
Copyright (c) Microsoft Corporation. All rights reserved.
*/
/*
Your use of this file is governed by the Microsoft Services Agreement http://go.microsoft.com/fwlink/?LinkId=266419.
*/
if (!Office) {
var Office = new function () {
this._appContext = 127; // All hosts; see _officeintellisense.js in VS, with binary 1111111
this._showAll = true;
this._setContext = {};
}
}
Office._ExcelMask = 0x1;
Office._WordMask = 0x2;
Office._ProjectMask = 0x4;
Office._OutlookMask = 0x8;
Office._PowerPointMask = 0x10;
Office._OutlookComposeMask = 0x20;
Office._AccessWebAppMask = 0x40;
{
Office._extractedCallback = function (originalArgs, totalArgsCount, optionalArgsCount) {
var optionalArgs = Array.prototype.slice.call(originalArgs, totalArgsCount - optionalArgsCount);
var callback = function(){};
for (var i = Math.min(optionalArgs.length, optionalArgsCount) - 1; i >= 0; i--) {
if (typeof optionalArgs[i] == "function") {
callback = optionalArgs[i];
break;
}
}
return callback;
}
Office._BindingDataChangedEvents = function (eventType) {
this.binding = new Office._Binding(bindingType);
this.type = eventType;
this.startColumn = {};
this.startRow = {};
}
Office._DocumentEventArgs = function (eventType) {
Office._processContents(this, {
type: {
annotate: {
/// <field type="Office.EventType"></field>
type: undefined
},
value: eventType
}
});
if (eventType == "activeViewChanged") {
Office._processItem(
this,
{
annotate: {
/// <field type="Office.ActiveView"></field>
activeView: undefined
}
},
"activeView"
);
}
}
Office._DialogEventArgs = function (eventType) {
Office._processContents(this, {
type: {
annotate: {
/// <field type="Office.EventType"></field>
type: undefined
},
value: eventType
}
});
if (eventType == "dialogMessageReceived") {
Office._processItem(
this,
{
annotate: {
/// <field type="string"></field>
message: undefined
}
},
"message"
);
} else if (eventType == "dialogEventReceived") {
Office._processItem(
this,
{
annotate: {
/// <field type="Integer"></field>
error: undefined
}
},
"error"
);
}
}
Office._CustomXmlNodeEvents = function (eventType) {
this.type = eventType;
this.inUndoRedo = {};
if (eventType == 'nodeDeleted') {
this.oldNode = new Office._CustomXmlNode();
this.oldNextSibling = new Office._CustomXmlNode();
}
if (eventType == 'nodeInserted') {
this.newNode = new Office._CustomXmlNode();
}
if (eventType == 'nodeReplaced') {
this.oldNode = new Office._CustomXmlNode();
this.newNode = new Office._CustomXmlNode();
}
}
Office._Error = function () {
this.id = {};
this.message = {};
this.name = {};
}
Office._CustomXmlNode = function () {
this.baseName = {};
this.namespaceUri = {};
this.nodeType = {};
this.getNodesAsync = function (xPath, callback) {
///<summary> Gets the nodes associated with the xPath expression. </summary>
///<param name="xPath" type="string">The xPath expression</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getNodesAsync");
callback(result);
};
this.getNodeValueAsync = function (callback) {
///<summary> Gets the node value. </summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getNodeValueAsync");
callback(result);
};
this.getXmlAsync = function (callback) {
///<summary> Gets the node's XML. </summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getXmlAsync");
callback(result);
};
this.setNodeValueAsync = function (value, callback) {
///<summary> Sets the node value. </summary>
///<param name="value" type="string">The value to be set on the node</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("setNodeValueAsync");
callback(result);
};
this.setXmlAsync = function (xml, callback) {
///<summary> Sets the node XML. </summary>
///<param name="xml" type="string">The XML to be set on the node</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("setXmlAsync");
callback(result);
};
}
Office._context_document_customXmlParts_customXmlPrefixMappings = function () {
this.addNamespaceAsync = function (prefix, nsUri, callback) {
///<summary>Adds a namespace. </summary>
//////<param name="prefix" type="string">The namespace prefix</param>
//////<param name="nsUri" type="string">The namespace URI</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("addNamespaceAsync");
callback(result);
};
this.getNamespaceAsync = function (prefix, callback) {
///<summary> Gets a namespace with the specified prefix </summary>
///<param name="prefix" type="string">The namespace prefix</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getNamespaceAsync");
callback(result);
};
this.getPrefixAsync = function (nsUri, callback) {
///<summary> Gets a prefix for the specified URI </summary>
///<param name="nsUri" type="string">The namespace URI</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getPrefixAsync");
callback(result);
};
}
Office._CustomXmlPart = function () {
this.builtIn = {};
this.id = {};
this.namespaceManager = new Office._context_document_customXmlParts_customXmlPrefixMappings();
this.deleteAsync = function (callback) {
///<summary> Deletes the Custom XML Part. </summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("deleteAsync");
callback(result);
};
this.getNodesAsync = function (xPath, callback) {
///<summary> Gets the nodes associated with the xPath expression. </summary>
///<param name="xPath" type="string">The xPath expression</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getNodesAsync");
callback(result);
};
this.getXmlAsync = function (callback) {
///<summary> Gets the XML for the Custom XML Part. </summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getXmlAsync");
callback(result);
};
this.addHandlerAsync = function (eventType, handler, callback) {
///<summary> Adds an event handler to the object using the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' </param>
///<param name="handler" type="function">The name of the handler </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var events = new Office._CustomXmlNodeEvents(eventType);
handler(events);
var result = new Office._AsyncResult("addHandlerAsync");
callback(result);
};
this.removeHandlerAsync = function (eventType, options, callback) {
///<summary> Removes an event handler from the object using the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For CustomXmlPartNode it can be 'nodeDeleted', 'nodeInserted' or 'nodeReplaced' </param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {handler:eventHandler}
/// handler: Indicates a specific handler to be removed, if not specified all handlers are removed
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
///
Office._extractedCallback(arguments, 3, 2)(new Office._AsyncResult("removeHandlerAsync"));
}
}
Office._Binding = function (bindingType) {
///<field type="String" name="id">Id of the Binding</field>};
this.id = {};
this.type = {};
this.document = {};
this.setDataAsync = function (data, options, callback) {
///<summary> Writes the specified data into the current selection.</summary>
///<param name="data" type="Object">The data to be set. Either a string or value, 2d array or TableData object</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'}
/// coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type.
/// startRow: Used in partial set for table/matrix. Indicates the start row.
/// startColumn: Used in partial set for table/matrix. Indicates the start column.
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
Office._extractedCallback(arguments, 3, 2)(new Office._AsyncResult("setDataAsync"));
};
this.getDataAsync = function (options, callback) {
///<summary> Returns the current selection.</summary>
///<param name="options" type="Object" optional="true">
/// Syntax example: {coercionType: 'matrix,'valueFormat: 'formatted', filterType:'all'}
/// coercionType: The expected shape of the selection. If not specified returns the bindingType shape. Use Office.CoercionType or text value.
/// valueFormat: Get data with or without format. Use Office.ValueFormat or text value.
/// startRow: Used in partial get for table/matrix. Indicates the start row.
/// startColumn: Used in partial get for table/matrix. Indicates the start column.
/// rowCount: Used in partial get for table/matrix. Indicates the number of rows from the start row.
/// columnCount: Used in partial get for table/matrix. Indicates the number of columns from the start column.
/// filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value.
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 1) {
callback = options;
}
var result = new Office._AsyncResult("getDataAsync", options.coercionType);
callback(result);
};
this.addHandlerAsync = function (eventType, handler, callback) {
///<summary> Adds an event handler to the object using the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For binding it can be 'bindingDataChanged' and 'bindingSelectionChanged' </param>
///<param name="handler" type="function">The name of the handler </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var events = new Office._BindingDataChangedEvents(eventType);
handler(events);
var result = new Office._AsyncResult("addHandlerAsync");
callback(result);
};
this.removeHandlerAsync = function (eventType, options, callback) {
///<summary> Removes an event handler from the object using the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For binding can be 'bindingDataChanged' and 'bindingSelectionChanged' </param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {handler:eventHandler}
/// handler: Indicates a specific handler to be removed, if not specified all handlers are removed
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var events = new Office._BindingDataChangedEvents(eventType);
handler(events);
Office._extractedCallback(arguments, 3, 2)(new Office._AsyncResult("removeHandlerAsync"));
};
if ((bindingType == undefined) || (bindingType == Office.BindingType.Matrix) || (bindingType == Office.BindingType.Table)) {
this.columnCount = {};
this.rowCount = {};
}
if ((bindingType == undefined) || (bindingType == Office.BindingType.Table)) {
Office._processContents(this, {
hasHeaders: {
value: {}
},
addRowsAsync: {
value: function (data, callback) {
///<summary> Adds the specified rows to the table </summary>
///<param name="data" type="Object"> A 2D array with the rows to add </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
}
},
addColumnsAsync: {
value: function (tableData, callback) {
///<summary> Adds the specified columns to the table </summary>
///<param name="tableData" type="Object"> A TableData object with the headers and rows </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>};
}
},
deleteAllDataValuesAsync: {
value: function (callback) {
///<summary> Clears the table</summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>};
}
},
formattingSpecific: {
metaOnly: true,
conditions: {
hosts: ["excel"],
},
contents: {
clearFormatsAsync: {
conditions: {
reqs: ["method TableBinding.clearFormatsAsync"]
},
value: function (options, callback) {
///<summary> Clears formatting on the bound table. </summary>
///<param name="options" type="Object" optional="true">
/// Syntax example: {asyncContext:context}
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
Office._extractedCallback(arguments, 2, 2)(new Office._AsyncResult("clearFormatsAsync"));
}
},
getFormatsAsync: {
conditions: {
reqs: ["method TableBinding.getFormatsAsync"]
},
value: function (cellReference, formats, options, callback) {
///<summary> Gets the formatting on specified items in the table. </summary>
///<param name="cellReference" type="Object" optional="true">An object literal containing name-value pairs that specify the range of cells to get formatting from.</param>
///<param name="formats" type="Array" optional="true">An array specifying the format properties to get.</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {asyncContext:context}
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
Office._extractedCallback(arguments, 4, 4)(new Office._AsyncResult("getFormatsAsync"));
}
},
setFormatsAsync: {
conditions: {
reqs: ["method TableBinding.setFormatsAsync"]
},
value: function (formatsInfo, options, callback) {
///<summary> Sets formatting on specified items and data in the table. </summary>
///<param name="formatsInfo" type="Array" elementType="Array" optional="true">
/// Array elements are themselves three-element arrays:
/// [target, type, formats]
/// target: The identifier of the item to format. String.
/// type: The kind of item to format. String.
/// formats: An object literal containing a list of property name-value pairs that define the formatting to apply.
///</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {asyncContext:context}
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
Office._extractedCallback(arguments, 3, 3)(new Office._AsyncResult("setFormatsAsync"));
}
},
setTableOptionsAsync: {
conditions: {
reqs: ["method TableBinding.setTableOptionsAsync"]
},
value: function (tableOptions, options, callback) {
///<summary> Updates table formatting options on the bound table. </summary>
///<param name="tableOptions" type="Object">An object literal containing a list of property name-value pairs that define the table options to apply.</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {asyncContext:context}
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
Office._extractedCallback(arguments, 3, 2)(new Office._AsyncResult("setTableOptionsAsync"));
}
}
}
}
});
}
}
Office._TableData = function () {
this.headers = new Array(new Array());
this.rows = new Array(new Array());
}
Office._File = function () {
this.size = {};
this.sliceCount = {};
this.getSliceAsync = function (sliceIndex, callback) {
///<summary> Gets the specified slice. </summary>
///<param name="sliceIndex" type="Integer">The index of the slice to be retrieved </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getSliceAsync");
callback(result);
};
this.closeAsync = function (callback) {
///<summary> Closes the File. </summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>
};
}
Office._Slice = function () {
this.data = {};
this.index = {};
this.size = {};
}
Office._Dialog = function () {
this.data = {};
this.close = function () {
///<summary> Allows the add-in to close its dialog box. </summary>
};
this.addEventHandler = function (eventType, handler) {
///<summary> Registers an event handler. </summary>
///<param name="eventType" type="Office.EventType"> The two supported events are: DialogMessageReceived or DialogEventReceived </param>
///<param name="handler" type="function" optional="true"> The name of the handler </param>
handler(new Office._DialogEventArgs(eventType));
};
}
Office._AsyncResult = function (method, bindingType) {
this.asyncContext = {};
this.error = new Office._Error();
this.status = {};
if ((method == "addfromSelectionAsync") || (method == "addFromNamedItemAsync") || (method == "getByIdAsync") || (method == "addFromPromptAsync")) {
this.value = new Office._Binding(bindingType);
} else if ((method == "getDataAsync") || (method == "getSelectedDataAsync")) {
if (bindingType == "table")
this.value = new Office._TableData();
else if (bindingType == "matrix")
this.value = new Array(new Array);
else
this.value = {};
} else if (method == "getAllAsync") {
this.value = new Array(new Office._Binding(bindingType));
} else if (method == "getByNamespaceAsync") {
this.value = new Array(new Office._CustomXmlPart());
} else if (method == "getNodesAsync") {
this.value = new Array(new Office._CustomXmlNode());
} else if ((method == "XMLgetByIdAsync") || (method == "addAsync")) {
this.value = new Office._CustomXmlPart();
} else if (method == "refreshAsync") {
this.value = new Office._context_document_settings();
} else if (method == "getFileAsync") {
this.value = new Office._File();
} else if (method == "getSliceAsync") {
this.value = new Office._Slice();
} else if (method == "getActiveViewAsync") {
Office._processItem(this,
{
annotate: {
///<field type="String">The presentation's current view.</field>
value: undefined
}
},
"value"
);
} else if (method == "getFilePropertiesAsync") {
this.value = new Office._FileProperties();
} else if (method == "displayDialogAsync") {
this.value = new Office._Dialog();
}else {
this.value = {};
}
}
Office._FileProperties = function () {
///<field type="String" name="url">File's URL</field>
this.url = "";
}
Office._context_document_settings = function () {
this.get = function (settingName) {
///<summary>Retrieves the setting with the specified name.</summary>
///<param name="settingName" type="string">The name of the setting </param>
};
this.remove = function (settingName) {
///<summary>Removes the setting with the specified name.</summary>
///<param name="settingName" type="string">The name of the setting </param>
///
};
this.saveAsync = function (options, callback) {
///<summary>Saves all settings.</summary>
///<param name="options" type="Object" optional="true">
/// Syntax example: {overwriteIfStale:false}
/// overwriteIfStale: Indicates whether the setting will be replaced if stale.
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
///
Office._extractedCallback(arguments, 2, 2)(new Office._AsyncResult("saveAsync", coercionType));
};
this.set = function (settingName, value) {
///<summary>Sets a value for the setting with the specified name.</summary>
///<param name="settingName" type="string">The name of the setting</param>
///<param name="value" type="object">The value for the setting</param>
};
};
Office._context_document_bindings = function () {
this.document = {};
if (Office._AccessWebAppMask & Office._appContext) {
this.addFromSelectionAsync = function (bindingType, options, callback) {
///<summary>Create a binding based on what the user's current selection.</summary>
///<param name="bindingType" type="Office.BindingType">The Office BindingType for the data</param>
///<param name="options" type="Object" optional="true">
/// addFromSelectionAsyncOptions- e.g. {id: "BindingID"}
/// id: Identifier.
/// asyncContext: Object keeping state for the callback
/// columns: The string[] of the columns involved in the binding
/// sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string.
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("addfromSelectionAsync", bindingType);
callback(result);
}
} else {
this.addFromSelectionAsync = function (bindingType, options, callback) {
///<summary>Create a binding based on what the user's current selection.</summary>
///<param name="bindingType" type="Office.BindingType">The Office BindingType for the data</param>
///<param name="options" type="Object" optional="true">
/// addFromSelectionAsyncOptions- e.g. {id: "BindingID"}
/// id: Identifier.
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("addfromSelectionAsync", bindingType);
callback(result);
}
}
if (Office._AccessWebAppMask & Office._appContext) {
this.addFromNamedItemAsync = function (itemName, bindingType, options, callback) {
///<summary>Creates a binding against a named object in the document</summary>
///<param name="itemName" type="String">Name of the bindable object in the document. For Example 'MyExpenses' table in Excel." </param>
///<param name="bindingType" type="Office.BindingType">The Office BindingType for the data</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {id: "BindingID"}
/// id: Name of the binding, autogenerated if not supplied.
/// asyncContext: Object keeping state for the callback
/// columns: The string[] of the columns involved in the binding
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 3) { callback = options; };
var result = new Office._AsyncResult("addFromNamedItemAsync", bindingType);
callback(result);
}
} else {
this.addFromNamedItemAsync = function (itemName, bindingType, options, callback) {
///<summary>Creates a binding against a named object in the document</summary>
///<param name="itemName" type="String">Name of the bindable object in the document. For Example 'MyExpenses' table in Excel." </param>
///<param name="bindingType" type="Office.BindingType">The Office BindingType for the data</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {id: "BindingID"}
/// id: Name of the binding, autogenerated if not supplied.
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 3) { callback = options; };
var result = new Office._AsyncResult("addFromNamedItemAsync", bindingType);
callback(result);
}
}
this.getByIdAsync = function (id, callback) {
///<summary>Retrieves a binding based on its Name</summary>
///<param name="id" type="String">The binding id</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getByIdAsync")
callback(result);
}
this.getAllAsync = function (callback) {
///<summary>Gets an array with all the binding objects in the document.</summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("getAllAsync")
callback(result);
};
this.releaseByIdAsync = function (id, callback) {
///<summary>Removes the binding from the document</summary>
///<param name="id" type="String">The binding id</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("releaseByIdAsync")
callback(result);
};
if (Office._AccessWebAppMask & Office._appContext) {
this.addFromPromptAsync = function (bindingType, options, callback) {
///<summary>(Access only with sample data) Create a binding by prompting the user to make a selection on the document.</summary>
///<param name="bindingType" type="Office.BindingType">The Office BindingType for the data</param>
///<param name="options" type="Object" optional="true">
/// addFromPromptAsyncOptions- e.g. {promptText: "Please select data", id: "mySales"}
/// promptText: Greet your users with a friendly word.
/// asyncContext: Object keeping state for the callback
/// id: Identifier.
/// sampleData: A TableData that gives sample table in the Dialog.TableData.Headers is [][] of string.
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("addFromPromptAsync", bindingType)
callback(result);
}
} else if (Office._ExcelMask & Office._appContext) {
this.addFromPromptAsync = function (bindingType, options, callback) {
///<summary>(Excel only) Create a binding by prompting the user to make a selection on the document.</summary>
///<param name="bindingType" type="Office.BindingType">The Office BindingType for the data</param>
///<param name="options" type="Object" optional="true">
/// addFromPromptAsyncOptions- e.g. {promptText: "Please select data", id: "mySales"}
/// promptText: Greet your users with a friendly word.
/// asyncContext: Object keeping state for the callback
/// id: Identifier.
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("addFromPromptAsync", bindingType)
callback(result);
}
}
};
Office._context_ui = {
displayDialogAsync: {
value: function (startAddress, options, callback) {
///<summary> Displays a dialog box in an Office host. </summary>
///<param name="startAddress" type="string"> Accepts the initial HTTPS(TLS) URL that opens in the dialog box. </param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {width:80}
/// width: Defines the width of the dialog box as a percentage of the current display.
/// height: Defines the height of the dialog box as a percentage of the current display.
/// displayInIFrame: false (defult): The dialog will be displayed as a new browser window
/// true: The dialog will be displayed as a floating overlay with an IFrame.
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
///
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("displayDialogAsync");
callback(result);
}
},
closeContainer: {
value: function () {
///<summary>
/// Closes the UI container where the JavaScript is executing.
/// <br />
/// <br />
/// Supported hosts:
/// <br />
/// * Outlook. Minimum requirement set: Mailbox 1.5
/// <br />
/// <br />
/// The behavior of this method is specified as follows. When called from:
/// <br />
/// * A UI-less command button: No effect. Any dialogs opened by displayDialogAsync will remain open.
/// <br />
/// * A taskpane: The taskpane will close. Any dialogs opened by displayDialogAsync will also close. If the taskpane supports pinning and was pinned by the user, it will be un-pinned.
/// <br />
/// * A module extension: No effect.
/// </summary>
}
},
messageParent: {
value: function (messageObject) {
///<summary> Delivers a message from the dialog box to its parent/opener page. The page calling this API must be on the same domain as the parent. </summary>
///<param name="messageObject" type="string"> Accepts a message from the dialog box to deliver to the add-in.</param>
}
}
}
Office._context_document = {
mode: {
annotate: {
//Gets the document mode
mode: undefined
}
},
url: {
annotate: {
//Gets the document URL
url: undefined
}
},
addHandlerAsync: {
value: function (eventType, handler, callback) {
///<summary> Adds an event handler for the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For document can be 'DocumentSelectionChanged' </param>
///<param name="handler" type="function">The name of the handler </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("addHandlerAsync");
callback(result);
handler(new Office._DocumentEventArgs(eventType));
}
},
removeHandlerAsync: {
value: function (eventType, handler, callback) {
///<summary> Removes an event handler for the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For document can be 'DocumentSelectionChanged' </param>
///<param name="handler" type="function" optional="true">The name of the handler. If not specified all handlers are removed </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
///
var result = new Office._AsyncResult("removeHandlerAsync", coercionType);
callback(result);
}
},
settings: {
conditions: {
hosts: ["word", "excel", "ppt", "accesswebapp"],
reqs: [
"set Settings GE 1.1",
"method Settings.get",
"method Settings.remove",
"method Settings.saveAsync",
"method Settings.set"
]
},
value: new Office._context_document_settings()
},
refreshableSettings: {
name: "settings",
conditions: {
hosts: ["excel", "ppt", "accesswebapp"],
reqs: []
},
partialConditions: true,
contents: {
addHandlerAsync: {
conditions: { reqs: ["method Settings.addHandlerAsync"] },
value: function (eventType, handler, callback) {
///<summary> Adds an event handler for the object using the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For settings can be 'settingsChanged' </param>
///<param name="handler" type="function">The name of the handler </param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("addHandlerAsync", coercionType);
callback(result);
}
},
refreshAsync: {
conditions: { reqs: ["method Settings.refreshAsync"] },
value: function (callback) {
///<summary>Gets the latest version of the settings object.</summary>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("refreshAsync", coercionType);
callback(result);
}
},
removeHandlerAsync: {
conditions: { reqs: ["method Settings.removeHandlerAsync"] },
value: function (eventType, handler, callback) {
///<summary> Removes an event handler for the specified event type. </summary>
///<param name="eventType" type="Office.EventType">The event type. For settings can be 'settingsChanged' </param>
///<param name="handler" type="Object" optional="true">
/// Syntax example: {handler:eventHandler}
/// handler: Indicates a specific handler to be removed, if not specified all handlers are removed
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
var result = new Office._AsyncResult("removeHandlerAsync", coercionType);
callback(result);
}
}
}
},
setSelectedDataAsync: {
conditions: {
hosts: ["word", "excel", "ppt"],
reqs: ["set Selection GE 1.1", "method Document.setSelectedDataAsync"]
},
value: function (data, options, callback) {
///<summary> Writes the specified data into the current selection.</summary>
///<param name="data" type="Object">The data to be set. Either a string or value, 2d array or TableData object</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {coercionType:Office.CoercionType.Matrix} or {coercionType: 'matrix'}
/// coercionType: Explicitly sets the shape of the data object. Use Office.CoercionType or text value. If not supplied is inferred from the data type.
/// imageLeft: Used for image. Sets the left position of the image.
/// imageTop: Used for image. Sets the top position of the image.
/// imageWidth: Used for image. Sets the width of the image.
/// imageHeight: Used for image. Sets the height of the image.
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
///
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("setSelectedDataAsync");
callback(result);
}
},
bindings: {
conditions: {
hosts: ["word", "excel", "accesswebapp"],
reqs: [
"set TextBindings GE 1.1",
"set TableBindings GE 1.1",
"set MatrixBindings GE 1.1",
"method Bindings.addFromPromptAsync",
"method Bindings.addFromNamedItemAsync",
"method Bindings.addFromSelectionAsync",
"method Bindings.getAllAsync",
"method Bindings.getByIdAsync",
"method Bindings.releaseByIdAsync",
"method MatrixBinding.getDataAsync",
"method MatrixBinding.setDataAsync",
"method TableBinding.clearFormatsAsync",
"method TableBinding.setFormatsAsync",
"method TableBinding.setTableOptionsAsync",
"method TableBinding.addColumnsAsync",
"method TableBinding.addRowsAsync",
"method TableBinding.deleteAllDataValuesAsync",
"method TableBinding.getDataAsync",
"method TableBinding.setDataAsync",
"method TextBinding.getDataAsync",
"method TextBinding.setDataAsync"
]
},
value: new Office._context_document_bindings()
},
getFileAsync: {
conditions: {
hosts: ["word", "ppt","excel"],
reqs: ["set File GE 1.1", "method Document.getFileAsync", "method File.closeAsync", "method File.getSliceAsync"]
},
value: function (fileType, options, callback) {
///<summary>(Word and PowerPoint only) Gets the entire file in slices of up to 4MB.</summary>
///<param name="fileType" type="Office.FileType">The format in which the file will be returned</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {sliceSize:1024}
/// sliceSize: Specifies the desired slice size (in bytes) up to 4MB. If not specified a default slice size of 4MB will be used.
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("getFileAsync");
callback(result);
}
},
getSelectedDataAsync: {
conditions: {
hosts: ["excel", "word", "project", "ppt"],
reqs: ["set Selection GE 1.1", "method Document.getSelectedDataAsync"]
},
value: function (coercionType, options, callback) {
///<summary> Returns the current selection.</summary>
///<param name="coercionType" type="Office.CoercionType">The expected shape of the selection.</param>
///<param name="options" type="Object" optional="true">
/// Syntax example: {valueFormat: 'formatted', filterType:'all'}
/// valueFormat: Get data with or without format. Use Office.ValueFormat or text value.
/// filterType: Get the visible or all the data. Useful when filtering data. Use Office.FilterType or text value.
/// asyncContext: Object keeping state for the callback
///</param>
///<param name="callback" type="function" optional="true">The optional callback method</param>
///
if (arguments.length == 2) { callback = options; };
var result = new Office._AsyncResult("getSelectedDataAsync", coercionType);
callback(result);
}
},
customXmlParts: {
conditions: {
hosts: ["word"],
reqs: [
"set CustomXmlParts GE 1.1",
"method CustomXmlNode.getNodesAsync",
"method CustomXmlNode.getNodeValueAsync",
"method CustomXmlNode.getXmlAsync",
"method CustomXmlNode.setNodeValueAsync",
"method CustomXmlNode.setXmlAsync",
"method CustomXmlPart.addHandlerAsync",
"method CustomXmlPart.deleteAsync",
"method CustomXmlPart.getNodesAsync",
"method CustomXmlPart.getXmlAsync",
"method CustomXmlPart.removeHandlerAsync",
"method CustomXmlPrefixMappings.addNamespaceAsync",
"method CustomXmlPrefixMappings.getNamespaceAsync",
"method CustomXmlPrefixMappings.getPrefixAsync"