com.ibm.productivity.tools.ui.views.operations
Interface NewOperation

All Superinterfaces:
Operation

public interface NewOperation
extends Operation

Defines the operation to create a new document in a rich document view. The current document is closed before the creation.

See DefaultRichDocumentView on how to use the operation.

Since:
8.0.1

Method Summary
 RichDocumentType getType()
          Gets the document type to be created.
 java.lang.Object getUNOModel()
          Returns the com.sun.star.frame.XModel object when the operation is started.
 void setType(RichDocumentType type)
          Sets the document type to be created.
 

Method Detail

getType

RichDocumentType getType()
Gets the document type to be created.


Returns:
the document type to be created
See Also:
RichDocumentType

setType

void setType(RichDocumentType type)
Sets the document type to be created.


The user can set the value before the operation is started.


Parameters:
type - the document's type
See Also:
RichDocumentType

getUNOModel

java.lang.Object getUNOModel()
Returns the com.sun.star.frame.XModel object when the operation is started. The object is available after the operation is completed successfully. The model object is used to access the UNO APIs provided by UNO service.

The following example code demonstrates how to use the UNO model.

 private void createTable( ) throws Exception {
        
          NewOperation operation = ...;
          Object obj = operation.getUNOModel();

    com.sun.star.lang.XMultiServiceFactory factory = (com.sun.star.lang.XMultiServiceFactory)
        UnoRuntime.queryInterface(com.sun.star.lang.XMultiServiceFactory.class, obj);
    com.sun.star.text.XTextDocument textDoc = (com.sun.star.text.XTextDocument) 
        UnoRuntime.queryInterface(com.sun.star.text.XTextDocument.class, obj);
    obj = factory.createInstance("com.sun.star.text.TextTable");

    com.sun.star.text.XTextTable table = (com.sun.star.text.XTextTable) 
        UnoRuntime.queryInterface(XTextTable.class, obj);
    table.initialize(10, 10);
    textDoc.getText().insertTextContent(textDoc.getText().getStart(),
        table, false);
 }
 

Returns:
a com.sun.star.frame.XModel object for the created document