Difference between revisions of "Documentation/DevGuide/OfficeDev/Component/Models"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (typo)
m (Document Specific Features)
 
(7 intermediate revisions by 3 users not shown)
Line 10: Line 10:
 
__NOTOC__
 
__NOTOC__
 
<!--<idltopic>com.sun.star.frame.XModel</idltopic>-->
 
<!--<idltopic>com.sun.star.frame.XModel</idltopic>-->
There is not an independent specification for a model service. The interface <idl>com.sun.star.frame.XModel</idl> is currently supported by Writer, Calc, Draw and Impress document components. In our context, we call objects supporting <idl>com.sun.star.frame.XModel</idl>, ''model objects''. All {{PRODUCTNAME}} document components have the service <idl>com.sun.star.document.OfficeDocument</idl> in common. An <code>OfficeDocument</code> implements the following interfaces:  
+
There is not an independent specification for a model service. The interface <idl>com.sun.star.frame.XModel</idl> is currently supported by Writer, Calc, Draw and Impress document components. In our context, we call objects supporting <idl>com.sun.star.frame.XModel</idl>, ''model objects''. All {{AOo}} document components have the service <idl>com.sun.star.document.OfficeDocument</idl> in common. An <code>OfficeDocument</code> implements the following interfaces:  
  
 
=== XModel ===
 
=== XModel ===
Line 16: Line 16:
 
<!--<idltopic>com.sun.star.frame.XModel</idltopic>-->
 
<!--<idltopic>com.sun.star.frame.XModel</idltopic>-->
 
The interface <idl>com.sun.star.frame.XModel</idl> inherits from <idl>com.sun.star.lang.XComponent</idl> and introduces the following methods, which handle the model's resource description, manage its controllers and retrieves the current selection.
 
The interface <idl>com.sun.star.frame.XModel</idl> inherits from <idl>com.sun.star.lang.XComponent</idl> and introduces the following methods, which handle the model's resource description, manage its controllers and retrieves the current selection.
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   string getURL ()
 
   string getURL ()
 
   sequence < com::sun::star::beans::PropertyValue > getArgs ()
 
   sequence < com::sun::star::beans::PropertyValue > getArgs ()
Line 31: Line 31:
 
    
 
    
 
   com::sun::star::uno::XInterface getCurrentSelection ()
 
   com::sun::star::uno::XInterface getCurrentSelection ()
</source>
+
</syntaxhighlight>
 
The method <code>getURL()</code> provides the URL where a document was loaded from or last stored using <code>storeAsURL()</code>. As long as a new document has not been saved, the URL is an empty string. The method <code>getArgs()</code> returns a sequence of property values that report the resource description according to <idl>com.sun.star.document.MediaDescriptor</idl>, specified on loading or saving with s<code>toreAsURL</code>. The method <code>attachResource()</code> is used by the frame loader implementations to inform the model about its URL and <code>MediaDescriptor</code>.
 
The method <code>getURL()</code> provides the URL where a document was loaded from or last stored using <code>storeAsURL()</code>. As long as a new document has not been saved, the URL is an empty string. The method <code>getArgs()</code> returns a sequence of property values that report the resource description according to <idl>com.sun.star.document.MediaDescriptor</idl>, specified on loading or saving with s<code>toreAsURL</code>. The method <code>attachResource()</code> is used by the frame loader implementations to inform the model about its URL and <code>MediaDescriptor</code>.
  
The current or last active controller for a model is retrieved through <code>getCurrentController()</code>. The corresponding method <code>setCurrentController()</code> sets a different current controller at models where additional controllers are available. However, additional controllers can not be created at this time for {{PRODUCTNAME}} components using the component API. The method <code>connectController()</code> is used by frame loader implementations and provides the model with a new controller that has been created for it, without making it the current controller. The <code>disconnectController()</code> tells the model that a controller may no longer be used. Finally, the model holds back screen updates using <code>lockControllers()</code> and <code>unlockControllers()</code>. For each call to <code>lockControllers()</code>, there must be a call to <code>unlockControllers()</code> to remove the lock. The method <code>hasControllersLocked()</code> tells if the controllers are locked.
+
The current or last active controller for a model is retrieved through <code>getCurrentController()</code>. The corresponding method <code>setCurrentController()</code> sets a different current controller at models where additional controllers are available. However, additional controllers can not be created at this time for {{AOo}} components using the component API. The method <code>connectController()</code> is used by frame loader implementations and provides the model with a new controller that has been created for it, without making it the current controller. The <code>disconnectController()</code> tells the model that a controller may no longer be used. Finally, the model holds back screen updates using <code>lockControllers()</code> and <code>unlockControllers()</code>. For each call to <code>lockControllers()</code>, there must be a call to <code>unlockControllers()</code> to remove the lock. The method <code>hasControllersLocked()</code> tells if the controllers are locked.
  
 
The currently selected object is retrieved by a call to <code>getCurrentSelection()</code>. This method is an alternative to <code>getSelection()</code> at the <idl>com.sun.star.view.XSelectionSupplier</idl> interface supported by controller services.
 
The currently selected object is retrieved by a call to <code>getCurrentSelection()</code>. This method is an alternative to <code>getSelection()</code> at the <idl>com.sun.star.view.XSelectionSupplier</idl> interface supported by controller services.
Line 42: Line 42:
 
<!--<idltopic>com.sun.star.util.XModifiable</idltopic>-->
 
<!--<idltopic>com.sun.star.util.XModifiable</idltopic>-->
 
The interface <idl>com.sun.star.util.XModifiable</idl> traces the modified status of a document:
 
The interface <idl>com.sun.star.util.XModifiable</idl> traces the modified status of a document:
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   void addModifyListener ( [in] com::sun::star::util::XModifyListener aListener)
 
   void addModifyListener ( [in] com::sun::star::util::XModifyListener aListener)
 
   void removeModifyListener ( [in] com::sun::star::util::XModifyListener aListener)
 
   void removeModifyListener ( [in] com::sun::star::util::XModifyListener aListener)
 
   boolean isModified ()
 
   boolean isModified ()
 
   void setModified ( [in] boolean bModified)
 
   void setModified ( [in] boolean bModified)
</source>
+
</syntaxhighlight>
 
=== XStorable ===
 
=== XStorable ===
  
Line 55: Line 55:
  
 
The interface <idl>com.sun.star.view.XPrintable</idl> is used to set and get the printer and its settings, and dispatch print jobs. These methods and special printing features for the various document types are described in the chapters [[Documentation/DevGuide/Text/Printing Text Documents|Printing Text Documents]], [[Documentation/DevGuide/Spreadsheets/Printing Spreadsheet Documents|Printing Spreadsheet Documents]], [[Documentation/DevGuide/Drawings/Printing Drawing Documents|Printing Drawing Documents]] and [[Documentation/DevGuide/Drawings/Printing Presentation Documents|Printing Presentation Documents]].
 
The interface <idl>com.sun.star.view.XPrintable</idl> is used to set and get the printer and its settings, and dispatch print jobs. These methods and special printing features for the various document types are described in the chapters [[Documentation/DevGuide/Text/Printing Text Documents|Printing Text Documents]], [[Documentation/DevGuide/Spreadsheets/Printing Spreadsheet Documents|Printing Spreadsheet Documents]], [[Documentation/DevGuide/Drawings/Printing Drawing Documents|Printing Drawing Documents]] and [[Documentation/DevGuide/Drawings/Printing Presentation Documents|Printing Presentation Documents]].
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   sequence< com::sun::star::beans::PropertyValue > getPrinter ()
 
   sequence< com::sun::star::beans::PropertyValue > getPrinter ()
 
   void setPrinter ( [in] sequence< com::sun::star::beans::PropertyValue > aPrinter )  
 
   void setPrinter ( [in] sequence< com::sun::star::beans::PropertyValue > aPrinter )  
 
   void print ( [in] sequence< com::sun::star::beans::PropertyValue > xOptions )
 
   void print ( [in] sequence< com::sun::star::beans::PropertyValue > xOptions )
</source>
+
</syntaxhighlight>
 
=== XEventBroadcaster ===
 
=== XEventBroadcaster ===
  
 
<!--<idltopic>com.sun.star.document.XEventBroadcaster</idltopic>-->
 
<!--<idltopic>com.sun.star.document.XEventBroadcaster</idltopic>-->
 
For versions later than 641, the optional interface <idl>com.sun.star.document.XEventBroadcaster</idl> at office documents enables developers to add listeners for events related to office documents in general, or for events specific for the individual document type.See [[Documentation/DevGuide/OfficeDev/Document Events|Document Events]]).  
 
For versions later than 641, the optional interface <idl>com.sun.star.document.XEventBroadcaster</idl> at office documents enables developers to add listeners for events related to office documents in general, or for events specific for the individual document type.See [[Documentation/DevGuide/OfficeDev/Document Events|Document Events]]).  
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   void addEventListener ( [in] com::sun::star::document::XEventListener xListener)
 
   void addEventListener ( [in] com::sun::star::document::XEventListener xListener)
 
   void removeEventListener ( [in] com::sun::star::document::XEventListener xListener)
 
   void removeEventListener ( [in] com::sun::star::document::XEventListener xListener)
</source>
+
</syntaxhighlight>
 
The <code>XEventListener</code> must implement a single method, besides <code>disposing()</code>:
 
The <code>XEventListener</code> must implement a single method, besides <code>disposing()</code>:
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   [oneway] void notifyEvent ( [in] com::sun::star::document::EventObject Event )
 
   [oneway] void notifyEvent ( [in] com::sun::star::document::EventObject Event )
</source>
+
</syntaxhighlight>
The struct <idl>com.sun.star.document.EventObject</idl> has a string member <code>EventName</code>, that assumes one of the values specified in <idl>com.sun.star.document.Events</idl>. These events are also on the '''Events''' tab of the '''Tools - Configure''' dialog.
+
The struct <idl>com.sun.star.document.EventObject</idl> has a string member <code>EventName</code>, that assumes one of the values specified in <idl>com.sun.star.document.Events</idl>. These events are also on the '''Events''' tab of the {{menu|Tools|Configure}} dialog.
  
 
The general events are the same events as those provided at the <code>XEventBroadcaster</code> interface of the desktop. While the model is only concerned about its own events, the desktop broadcasts the events for all the loaded documents.
 
The general events are the same events as those provided at the <code>XEventBroadcaster</code> interface of the desktop. While the model is only concerned about its own events, the desktop broadcasts the events for all the loaded documents.
Line 79: Line 79:
  
 
<!--<idltopic>com.sun.star.document.XEventsSupplier</idltopic>-->
 
<!--<idltopic>com.sun.star.document.XEventsSupplier</idltopic>-->
The optional interface <idl>com.sun.star.document.XEventsSupplier</idl> binds the execution of dispatch URLs to document events, thus providing a configurable event listener as a simplification for the more general event broadcaster or listener mechanism of the <idl>com.sun.star.document.XEventBroadcaster</idl> interface. This is done programmatically versus manually in '''Tools - Configure - Events'''.  
+
The optional interface <idl>com.sun.star.document.XEventsSupplier</idl> binds the execution of dispatch URLs to document events, thus providing a configurable event listener as a simplification for the more general event broadcaster or listener mechanism of the <idl>com.sun.star.document.XEventBroadcaster</idl> interface. This is done programmatically versus manually in {{menu|Tools|Configure|Events}}.
  
 
=== XDocumentPropertiesSupplier ===
 
=== XDocumentPropertiesSupplier ===
  
 
<!--<idltopic>com.sun.star.document.XDocumentPropertiesSupplier</idltopic>-->
 
<!--<idltopic>com.sun.star.document.XDocumentPropertiesSupplier</idltopic>-->
The optional interface <idl>com.sun.star.document.XDocumentPropertiesSupplier</idl> provides access to document information as described in section [[Documentation/DevGuide/OfficeDev/Document Info|Document Info]]. Document information is presented in the '''File - Properties''' dialog in the GUI.
+
The optional interface <idl>com.sun.star.document.XDocumentPropertiesSupplier</idl> provides access to document information as described in section [[Documentation/DevGuide/OfficeDev/Document Info|Document Info]]. Document information is presented in the {{menu|File|Properties}} dialog in the GUI.
  
{{Documentation/Note|In OpenOffice.org versions before 3.0, use the interface <idl>com.sun.star.document.XDocumentInfoSupplier</idl> instead.}}
+
{{Note|In OpenOffice.org versions before 3.0, use the interface <idl>com.sun.star.document.XDocumentInfoSupplier</idl> instead.}}
  
 
=== XViewDataSupplier ===
 
=== XViewDataSupplier ===
Line 92: Line 92:
 
<!--<idltopic>com.sun.star.document.XViewDataSupplier</idltopic>-->
 
<!--<idltopic>com.sun.star.document.XViewDataSupplier</idltopic>-->
 
The optional <idl>com.sun.star.document.XViewDataSupplier</idl> interface sets and restores view data.
 
The optional <idl>com.sun.star.document.XViewDataSupplier</idl> interface sets and restores view data.
<source lang="idl">
+
<syntaxhighlight lang="idl">
 
   com::sun::star::container::XIndexAccess getViewData ()
 
   com::sun::star::container::XIndexAccess getViewData ()
 
   void setViewData ( [in] com::sun::star::container::XIndexAccess aData)
 
   void setViewData ( [in] com::sun::star::container::XIndexAccess aData)
</source>
+
</syntaxhighlight>
 
The view data are a <idl>com.sun.star.container.XIndexAccess</idl> to sequences of <idl>com.sun.star.beans.PropertyValue</idl> structs. Each sequence represents the settings of a view to the model that supplies the view data.
 
The view data are a <idl>com.sun.star.container.XIndexAccess</idl> to sequences of <idl>com.sun.star.beans.PropertyValue</idl> structs. Each sequence represents the settings of a view to the model that supplies the view data.
  
 
=== Document Specific Features ===
 
=== Document Specific Features ===
  
Every service specification for real model objects provides more interfaces that constitute the actual model functionality For example, a text document service <idl>com.sun.star.text.TextDocument</idl> provides text related interfaces. Having received a reference to a model, developers query for these interfaces. The <idl>com.sun.star.lang.XServiceInfo</idl> interface of a model can be used to ask for supported services. The {{PRODUCTNAME}} document types support the following services:
+
Every service specification for real model objects provides more interfaces that constitute the actual model functionality For example, a text document service <idl>com.sun.star.text.TextDocument</idl> provides text related interfaces. Having received a reference to a model, developers query for these interfaces. The <idl>com.sun.star.lang.XServiceInfo</idl> interface of a model can be used to ask for supported services. The {{AOo}} document types support the following services:
  
 
{|border="1" cellpadding=4 style="border-collapse:collapse;"
 
{|border="1" cellpadding=4 style="border-collapse:collapse;"
Line 129: Line 129:
 
|-
 
|-
 
|Chart  
 
|Chart  
|<idl>com.sun.star.chart.ChartDocument</idl>  
+
|<idl>com.sun.star.chart.ChartDocument</idl> and <idl>com.sun.star.chart2.ChartDocument</idl>
 
|[[Documentation/DevGuide/Charts/Charts|Charts]]  
 
|[[Documentation/DevGuide/Charts/Charts|Charts]]  
 
|}
 
|}
  
Refer to the related chapters for additional information about the interfaces of the documents of {{PRODUCTNAME}}.
+
Refer to the related chapters for additional information about the interfaces of the documents of {{AOo}}.
  
 
{{PDL1}}
 
{{PDL1}}
  
 
[[Category:Documentation/Developer's Guide/Office Development]]
 
[[Category:Documentation/Developer's Guide/Office Development]]

Latest revision as of 13:04, 9 August 2021



There is not an independent specification for a model service. The interface com.sun.star.frame.XModel is currently supported by Writer, Calc, Draw and Impress document components. In our context, we call objects supporting com.sun.star.frame.XModel, model objects. All Apache OpenOffice document components have the service com.sun.star.document.OfficeDocument in common. An OfficeDocument implements the following interfaces:

XModel

The interface com.sun.star.frame.XModel inherits from com.sun.star.lang.XComponent and introduces the following methods, which handle the model's resource description, manage its controllers and retrieves the current selection.

  string getURL ()
  sequence < com::sun::star::beans::PropertyValue > getArgs ()
  boolean attachResource ( [in] string aURL, 
                           [in] sequence < com::sun::star::beans::PropertyValue > aArgs )
 
  com::sun::star::frame::XController getCurrentController ()
  void setCurrentController (com::sun::star::frame::XController xController)
  void connectController (com::sun::star::frame::XController xController)
  void disconnectController (com::sun::star::frame::XController xController)
  void lockControllers ()
  void unlockControllers ()
  boolean hasControllersLocked ()
 
  com::sun::star::uno::XInterface getCurrentSelection ()

The method getURL() provides the URL where a document was loaded from or last stored using storeAsURL(). As long as a new document has not been saved, the URL is an empty string. The method getArgs() returns a sequence of property values that report the resource description according to com.sun.star.document.MediaDescriptor, specified on loading or saving with storeAsURL. The method attachResource() is used by the frame loader implementations to inform the model about its URL and MediaDescriptor.

The current or last active controller for a model is retrieved through getCurrentController(). The corresponding method setCurrentController() sets a different current controller at models where additional controllers are available. However, additional controllers can not be created at this time for Apache OpenOffice components using the component API. The method connectController() is used by frame loader implementations and provides the model with a new controller that has been created for it, without making it the current controller. The disconnectController() tells the model that a controller may no longer be used. Finally, the model holds back screen updates using lockControllers() and unlockControllers(). For each call to lockControllers(), there must be a call to unlockControllers() to remove the lock. The method hasControllersLocked() tells if the controllers are locked.

The currently selected object is retrieved by a call to getCurrentSelection(). This method is an alternative to getSelection() at the com.sun.star.view.XSelectionSupplier interface supported by controller services.

XModifiable

The interface com.sun.star.util.XModifiable traces the modified status of a document:

  void addModifyListener ( [in] com::sun::star::util::XModifyListener aListener)
  void removeModifyListener ( [in] com::sun::star::util::XModifyListener aListener)
  boolean isModified ()
  void setModified ( [in] boolean bModified)

XStorable

The interface com.sun.star.frame.XStorable stores a document under an arbitrary URL or its current location. Details about how to use this interface are discussed in the chapter Handling Documents.

XPrintable

The interface com.sun.star.view.XPrintable is used to set and get the printer and its settings, and dispatch print jobs. These methods and special printing features for the various document types are described in the chapters Printing Text Documents, Printing Spreadsheet Documents, Printing Drawing Documents and Printing Presentation Documents.

  sequence< com::sun::star::beans::PropertyValue > getPrinter ()
  void setPrinter ( [in] sequence< com::sun::star::beans::PropertyValue > aPrinter ) 
  void print ( [in] sequence< com::sun::star::beans::PropertyValue > xOptions )

XEventBroadcaster

For versions later than 641, the optional interface com.sun.star.document.XEventBroadcaster at office documents enables developers to add listeners for events related to office documents in general, or for events specific for the individual document type.See Document Events).

  void addEventListener ( [in] com::sun::star::document::XEventListener xListener)
  void removeEventListener ( [in] com::sun::star::document::XEventListener xListener)

The XEventListener must implement a single method, besides disposing():

  [oneway] void notifyEvent ( [in] com::sun::star::document::EventObject Event )

The struct com.sun.star.document.EventObject has a string member EventName, that assumes one of the values specified in com.sun.star.document.Events. These events are also on the Events tab of the Tools → Configure dialog.

The general events are the same events as those provided at the XEventBroadcaster interface of the desktop. While the model is only concerned about its own events, the desktop broadcasts the events for all the loaded documents.

XEventsSupplier

The optional interface com.sun.star.document.XEventsSupplier binds the execution of dispatch URLs to document events, thus providing a configurable event listener as a simplification for the more general event broadcaster or listener mechanism of the com.sun.star.document.XEventBroadcaster interface. This is done programmatically versus manually in Tools → Configure → Events.

XDocumentPropertiesSupplier

The optional interface com.sun.star.document.XDocumentPropertiesSupplier provides access to document information as described in section Document Info. Document information is presented in the File → Properties dialog in the GUI.

Documentation note.png In OpenOffice.org versions before 3.0, use the interface com.sun.star.document.XDocumentInfoSupplier instead.

XViewDataSupplier

The optional com.sun.star.document.XViewDataSupplier interface sets and restores view data.

  com::sun::star::container::XIndexAccess getViewData ()
  void setViewData ( [in] com::sun::star::container::XIndexAccess aData)

The view data are a com.sun.star.container.XIndexAccess to sequences of com.sun.star.beans.PropertyValue structs. Each sequence represents the settings of a view to the model that supplies the view data.

Document Specific Features

Every service specification for real model objects provides more interfaces that constitute the actual model functionality For example, a text document service com.sun.star.text.TextDocument provides text related interfaces. Having received a reference to a model, developers query for these interfaces. The com.sun.star.lang.XServiceInfo interface of a model can be used to ask for supported services. The Apache OpenOffice document types support the following services:

Document Service Chapter
Calc com.sun.star.sheet.SpreadsheetDocument Spreadsheet Documents
Draw com.sun.star.drawing.DrawingDocument Drawing Documents and Presentation Documents
Impress com.sun.star.presentation.PresentationDocument Drawing Documents and Presentation Documents
Math com.sun.star.formula.FormulaProperties -
Writer (all Writer modules) com.sun.star.text.TextDocument Text Documents
Chart com.sun.star.chart.ChartDocument and com.sun.star.chart2.ChartDocument Charts

Refer to the related chapters for additional information about the interfaces of the documents of Apache OpenOffice.

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