com.aspose.words
Class BaseWebExtensionCollection

java.lang.Object
    extended by com.aspose.words.BaseWebExtensionCollection
All Implemented Interfaces:
java.lang.Iterable
Direct Known Subclasses:
TaskPaneCollection, WebExtensionBindingCollection, WebExtensionPropertyCollection, WebExtensionReferenceCollection

public abstract class BaseWebExtensionCollection 
extends java.lang.Object

Base class for TaskPaneCollection, WebExtensionBindingCollection, WebExtensionPropertyCollection and WebExtensionReferenceCollection collections. Type of a collection item.

Example:

Shows how to work with a document's collection of web extensions.
Document doc = new Document(getMyDir() + "Web extension.docx");

Assert.assertEquals(1, doc.getWebExtensionTaskPanes().getCount());

// Print all properties of the document's web extension.
WebExtensionPropertyCollection webExtensionPropertyCollection = doc.getWebExtensionTaskPanes().get(0).getWebExtension().getProperties();
Iterator<WebExtensionProperty> enumerator = webExtensionPropertyCollection.iterator();

while (enumerator.hasNext()) {
    WebExtensionProperty webExtensionProperty = enumerator.next();
    System.out.println("Binding name: {webExtensionProperty.Name}; Binding value: {webExtensionProperty.Value}");
}

// Remove the web extension.
doc.getWebExtensionTaskPanes().remove(0);

Assert.assertEquals(0, doc.getWebExtensionTaskPanes().getCount());

Property Getters/Setters Summary
intgetCount()
           Gets the number of elements contained in the collection.
java.lang.Objectget(int index)
voidset(int index, java.lang.Object value)
           Gets or sets an item at the specified index.
 
Method Summary
voidadd(java.lang.Object item)
          
voidclear()
           Removes all elements from the collection.
java.util.Iteratoriterator()
           Returns an enumerator that can iterate through a collection.
voidremove(int index)
           Removes the item at the specified index from the collection.
 

Property Getters/Setters Detail

getCount

public int getCount()
Gets the number of elements contained in the collection.

Example:

Shows how to work with a document's collection of web extensions.
Document doc = new Document(getMyDir() + "Web extension.docx");

Assert.assertEquals(1, doc.getWebExtensionTaskPanes().getCount());

// Print all properties of the document's web extension.
WebExtensionPropertyCollection webExtensionPropertyCollection = doc.getWebExtensionTaskPanes().get(0).getWebExtension().getProperties();
Iterator<WebExtensionProperty> enumerator = webExtensionPropertyCollection.iterator();

while (enumerator.hasNext()) {
    WebExtensionProperty webExtensionProperty = enumerator.next();
    System.out.println("Binding name: {webExtensionProperty.Name}; Binding value: {webExtensionProperty.Value}");
}

// Remove the web extension.
doc.getWebExtensionTaskPanes().remove(0);

Assert.assertEquals(0, doc.getWebExtensionTaskPanes().getCount());

get/set

public java.lang.Object get(int index) / public void set(int index, java.lang.Object value)
Gets or sets an item at the specified index.
Parameters:
index - Zero-based index of the item.

Example:

Shows how to work with a document's collection of web extensions.
Document doc = new Document(getMyDir() + "Web extension.docx");

Assert.assertEquals(1, doc.getWebExtensionTaskPanes().getCount());

// Print all properties of the document's web extension.
WebExtensionPropertyCollection webExtensionPropertyCollection = doc.getWebExtensionTaskPanes().get(0).getWebExtension().getProperties();
Iterator<WebExtensionProperty> enumerator = webExtensionPropertyCollection.iterator();

while (enumerator.hasNext()) {
    WebExtensionProperty webExtensionProperty = enumerator.next();
    System.out.println("Binding name: {webExtensionProperty.Name}; Binding value: {webExtensionProperty.Value}");
}

// Remove the web extension.
doc.getWebExtensionTaskPanes().remove(0);

Assert.assertEquals(0, doc.getWebExtensionTaskPanes().getCount());

Method Detail

add

public void add(java.lang.Object item)

clear

public void clear()
Removes all elements from the collection.

Example:

Shows how to add a web extension to a document.
Document doc = new Document();

// Create task pane with "MyScript" add-in, which will be used by the document,
// then set its default location.
TaskPane myScriptTaskPane = new TaskPane();
doc.getWebExtensionTaskPanes().add(myScriptTaskPane);
myScriptTaskPane.setDockState(TaskPaneDockState.RIGHT);
myScriptTaskPane.isVisible(true);
myScriptTaskPane.setWidth(300.0);
myScriptTaskPane.isLocked(true);

// If there are multiple task panes in the same docking location, we can set this index to arrange them.
myScriptTaskPane.setRow(1);

// Create an add-in called "MyScript Math Sample", which the task pane will display within.
WebExtension webExtension = myScriptTaskPane.getWebExtension();

// Set application store reference parameters for our add-in, such as the ID.
webExtension.getReference().setId("WA104380646");
webExtension.getReference().setVersion("1.0.0.0");
webExtension.getReference().setStoreType(WebExtensionStoreType.OMEX);
webExtension.getReference().setStore("English (United States)");
webExtension.getProperties().add(new WebExtensionProperty("MyScript", "MyScript Math Sample"));
webExtension.getBindings().add(new WebExtensionBinding("MyScript", WebExtensionBindingType.TEXT, "104380646"));

// Allow the user to interact with the add-in.
webExtension.isFrozen(false);

// We can access the web extension in Microsoft Word via Developer -> Add-ins.
doc.save(getArtifactsDir() + "Document.WebExtension.docx");

// Remove all web extension task panes at once like this.
doc.getWebExtensionTaskPanes().clear();

Assert.assertEquals(0, doc.getWebExtensionTaskPanes().getCount());

iterator

public java.util.Iterator iterator()
Returns an enumerator that can iterate through a collection.
Returns:

Example:

Shows how to work with a document's collection of web extensions.
Document doc = new Document(getMyDir() + "Web extension.docx");

Assert.assertEquals(1, doc.getWebExtensionTaskPanes().getCount());

// Print all properties of the document's web extension.
WebExtensionPropertyCollection webExtensionPropertyCollection = doc.getWebExtensionTaskPanes().get(0).getWebExtension().getProperties();
Iterator<WebExtensionProperty> enumerator = webExtensionPropertyCollection.iterator();

while (enumerator.hasNext()) {
    WebExtensionProperty webExtensionProperty = enumerator.next();
    System.out.println("Binding name: {webExtensionProperty.Name}; Binding value: {webExtensionProperty.Value}");
}

// Remove the web extension.
doc.getWebExtensionTaskPanes().remove(0);

Assert.assertEquals(0, doc.getWebExtensionTaskPanes().getCount());

remove

public void remove(int index)
Removes the item at the specified index from the collection.
Parameters:
index - The zero-based index of the collection item.

Example:

Shows how to work with a document's collection of web extensions.
Document doc = new Document(getMyDir() + "Web extension.docx");

Assert.assertEquals(1, doc.getWebExtensionTaskPanes().getCount());

// Print all properties of the document's web extension.
WebExtensionPropertyCollection webExtensionPropertyCollection = doc.getWebExtensionTaskPanes().get(0).getWebExtension().getProperties();
Iterator<WebExtensionProperty> enumerator = webExtensionPropertyCollection.iterator();

while (enumerator.hasNext()) {
    WebExtensionProperty webExtensionProperty = enumerator.next();
    System.out.println("Binding name: {webExtensionProperty.Name}; Binding value: {webExtensionProperty.Value}");
}

// Remove the web extension.
doc.getWebExtensionTaskPanes().remove(0);

Assert.assertEquals(0, doc.getWebExtensionTaskPanes().getCount());

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.