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

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


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

setType

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


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


Parameters:
type -
See Also:
RichDocumentType

getUNOModel

public 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();

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

	  XTextTable table = (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