com.ibm.productivity.tools.ui.views
Interface RichDocumentView

All Known Implementing Classes:
DefaultRichDocumentView

public interface RichDocumentView

Defines a view to manipulate rich documents. A default implementation is provided as DefaultRichDocumentView. The view is used to start supported rich document operations. It allows adding listeners into the view, which are notified when an operation is started.


The default rich document operations are defined in the com.ibm.productivity.tools.ui.views.operations package.


The interface is not intended to be implemented by the user. To create a new subclass for this interface, extend the DefaultRichDocumentView. Use the interface to access the view, instead of using the DefaultRichDocumentView class directly.

Since:
8.0.1
See Also:
DefaultRichDocumentView, Operation, OperationListener

Method Summary
 void addOperationListener(OperationListener listener)
          Adds an OperationListener into the view.
 void executeOperation(Operation operation)
          Starts the operation in the view.
 RichDocumentType getDocumentType()
          Gets the type of the current document.
 java.lang.String getFilePath()
          Gets the absolute path of the document loaded in the view.
 java.lang.Object getUNOModel()
          Returns the com.sun.star.frame.XModel object when the operation is started.
 void removeOperationListener(OperationListener listener)
          Removes a registered OperationListener from the view.
 

Method Detail

executeOperation

void executeOperation(Operation operation)
                      throws java.lang.UnsupportedOperationException
Starts the operation in the view.

Parameters:
operation - the operation to be started
Throws:
java.lang.UnsupportedOperationException - if an error occurs while running the operation.
See Also:
Operation

addOperationListener

void addOperationListener(OperationListener listener)
Adds an OperationListener into the view. If an operation is invoked, the listener is notified.

Parameters:
listener - a listener to be notified when an operation is started
See Also:
OperationListener

removeOperationListener

void removeOperationListener(OperationListener listener)
Removes a registered OperationListener from the view.

Parameters:
listener - the listener to be removed
See Also:
OperationListener

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 started successfully. It is used to access the UNO APIs provided by the UNO service.

The following 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.

getFilePath

java.lang.String getFilePath()
Gets the absolute path of the document loaded in the view. For example, c:\\test.odt on Windows® operating systems, and /home/test.odt on Linux® operating systems.

Returns:
absolute path of current document

getDocumentType

RichDocumentType getDocumentType()
Gets the type of the current document.

Returns:
type of current document.
See Also:
RichDocumentType