Controllers

From Apache OpenOffice Wiki
Jump to: navigation, search




Controller Service

XController

A com.sun.star.frame.XController inherits from com.sun.star.lang.XComponent and introduces the following methods:

  com::sun::star::frame::XFrame getFrame ()
  void attachFrame (com::sun::star::frame::XFrame xFrame)
  com::sun::star::frame::XModel getModel ()
  boolean attachModel (com::sun::star::frame::XModel xModel)
  boolean suspend (boolean bSuspend)
  any getViewData ()
  void restoreViewData (any Data)

The com.sun.star.frame.XController links model and frame through the methods get/attachModel() and get/attachFrame(). These methods and the corresponding methods in the com.sun.star.frame.XModel and com.sun.star.frame.XFrame interfaces act together. Calling attachModel() at the controller must be accompanied by a corresponding call of connectController() at the model, and attachFrame() at the controller must have its counterpart setComponent() at the frame.

The controller is asked for permission to dispose of the entire associated component by using suspend(). The suspend() method shows dialogs, for example, to save changes. To avoid the dialog, close the corresponding frame without using suspend() before. The section Closing Documents provides additional information.

Developers retrieve and restore data used to setup the view at the controller by calling get/restoreViewData(). These methods are usually called on loading and saving the document, but they also allow developers to manipulate the state of a view from the outside. The exact content of this data depends on the concrete controller/model pair.

XDispatchProvider

Through com.sun.star.frame.XDispatchProvider, the controller participates in the dispatch framework. It is described in section Using the Dispatch Framework.

XSelectionSupplier

The optional Controller interface com.sun.star.view.XSelectionSupplier accesses the selected object and informs listeners when the selection changes:

  boolean select ( [in] any aSelection)
  any getSelection ()
  void addSelectionChangeListener ( [in] com::sun::star::view::XSelectionChangeListener xListener)
  void removeSelectionChangeListener ( [in] com::sun::star::view::XSelectionChangeListener xListener)

The type of selection depends on the type of the document and the selected object. It is also possible to get the current selection in the active or last controller of a model by calling the method getCurrentSelection() in the com.sun.star.frame.XModel interface.

XContextMenuInterception

The optional Controller interface com.sun.star.ui.XContextMenuInterception intercepts requests for context menus in the document's window. See chapter Intercepting Context Menus.

Document Specific Controller Services

The com.sun.star.frame.Controller specification is generic and does not describe additional features required for a fully functional document controller specification, such as the controller specifications for Writer, Calc and Draw documents. The following table shows the controller services specified for Apache OpenOffice document components.

Once the reference to a controller is retrieved, you can query for these interfaces. Use the com.sun.star.lang.XServiceInfo interface of the model to ask it for the supported service(s). The component implementations in Apache OpenOffice support the following services. Refer to the related chapters for additional information about the interfaces you get from the controllers of Apache OpenOffice documents.

Component and Chapter Specialized Controller Service General Description
Writer Text Document Controller com.sun.star.text.TextDocumentView The text view supplies a text view cursor that has knowledge about the current page layout and page number. It can walk through document pages, screen pages and lines. The selected ruby text is also available, a special Asian text formatting, comparable to superscript.
Calc Spreadsheet Document Controller com.sun.star.sheet.SpreadsheetView The spreadsheet view is extremely powerful. It includes the services com.sun.star.sheet.SpreadsheetViewPane and com.sun.star.sheet.SpreadsheetViewSettings. The view pane handles the currently visible cell range and provides controllers for form controls in the spreadsheet. The view settings deal with the visibility of spreadsheet elements, such as the grid and current zoom mode. Furthermore, the spreadsheet view provides access to the active sheet in the view and the collection of all view panes, allowing to split and freeze the view, and control the interactive selection of a cell range.
Draw Drawing and Presentation Document Controller com.sun.star.drawing.DrawingDocumentDrawView The drawing document view toggles master page mode and layer mode, controls the current page and supplies the currently visible rectangle.
Impress Drawing and Presentation Document Controller com.sun.star.drawing.DrawingDocumentDrawView

com.sun.star.presentation.PresentationView

The presentation view does not introduce presentation specific features. Running presentations are controlled by the com.sun.star.presentation.XPresentationSupplier interface of the presentation document model.
DataBaseAccess com.sun.star.sdb.DataSourceBrowser This controller has no published functionality that would be useful for developers.
Bibliography (no special controller specified) -
Writer (PagePreview) (no special controller specified) -
Writer/Webdocument (SourceView) (no special controller specified) -
Calc (PagePreview) (no special controller specified) -
Chart Chart Document Controller (no special controller specified) -
Math (no special controller specified) -


Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages