In OOo, a component is essentially a window owned by the desktop. Use the Desktop object to enumerate the components , including documents, the Basic IDE and the help window along with the actual documents. If a component supports the com.sun.star.frame.XModel interface, the component is a document (rather than the Basic IDE or the help window). Every document supports the XModel interface and each document type has a unique service that it supports (see Table 1 ). Use the OOo Basic function HasUnoInterfaces(obj, interface_name) to determine if an object supports the XModel interface; then use the object method obj.supportsService(service_name) to determine the document type.
Service | Document Type |
---|---|
com.sun.star.text.TextDocument | Writer text document. |
com.sun.star.sheet.Spreadsheet Document | Calc spreadsheet document. |
com.sun.star.drawing.Drawing Document | Draw drawing document. |
com.sun.star.presentation.PresentationDocument | Impress presentation document. |
com.sun.star.formula.FormulaProperties | Math formula document. |
Tip | The method supportsService() is defined by the com.sun.star.lang.XServiceInfo interface. This interface also defines the method getlmplementationName(), which returns a unique string identifying the object type. |
The different document types share a significant amount of functionality. Table 2 lists some of the interfaces that are supported by more than one document type. This list helps to emphasize the document-type similarities.
Interface | Writer | Calc | Impress | Draw | Math |
---|---|---|---|---|---|
com.sun.star.beans.XPropertySet | X | X | X | X | X |
com.sun.star.container.XChild | X | X | X | X | X |
com.sun.star.datatransfer.XTransferable | X | X | X | X | X |
com.sun.star.document.XDocumentlnfoSupplier | X | X | X | X | X |
com.sun.star.document.XEventBroadcaster | X | X | X | X | X |
com.sun.star.document.XEventsSupplier | X | X | X | X | X |
com.sun.star.document.XLinkTargetSupplier | X | X | X | X | |
com.sun.star.document.XViewDataSupplier | X | X | X | X | X |
com.sun.star.drawing.XDrawPagesSupplier | X | X | X | ||
com.sun.star.frame.XLoadable | X | X | X | X | X |
com.sun.star.frame.XModel | X | X | X | X | X |
com.sun.star.frame.XStorable | X | X | X | X | X |
com.sun.star.lang.XComponent | X | X | X | X | X |
com.sun.star.lang.XEventListener | X | X | X | X | X |
com.sun.star.lang.XMultiServiceFactory | X | X | X | X | |
com.sun.star.lang.XServiceInfo | X | X | X | X | X |
com.sun.star.lang.XTypeProvider | X | X | X | X | X |
com.sun.star.script.XStarBasicAccess | X | X | X | X | X |
com.sun.star.style.XStyleFamiliesSupplier | X | X | X | X | |
com.sun.star.util.XCloseBroadcaster | X | X | X | X | X |
com.sun.star.util.XCloseable | X | X | X | X | X |
com.sun.star.util.XModifiable | X | X | X | X | X |
com.sun.star.util.XModify Broadcaster | X | X | X | X | X |
com.sun.star.util.XNumberFormatsSupplier | X | X | |||
com.sun.star.view.XPrintJobBroadcaster | X | X | X | X | X |
com.sun.star.view.XPrintable | X | X | X | X | X |
com.sun.star.view.XRenderable | X | X | X | X | X |
Tip | Table 2 was created by inspecting the dbg_supportedlnterfaces property for each document type. |
The methods that define the search-and-replace functionality are defined in the interfaces XReplaceable and XSearchable, and these are both conspicuously missing from Table 2. Writer supports this functionality directly, but Calc does not. A Calc document is composed of multiple spreadsheets. A significant portion of the functionality, therefore, exists in the spreadsheet objects rather than in the parent Calc document. For example, searching text or obtaining draw pages both exist in spreadsheet objects-draw pages are discussed in depth in Chapter 15, "Draw And Impress Documents."
The OpenOffice.org API Web site contains extensive , detailed help on most of the services and interfaces. The page is built by starting with the Web address "http://api.openoffice.org/docs/common/ref/" and then using the interface name to build the rest of the address. For example, the com.sun.star.beans.XPropertySet interface has an Internet address as follows :
http://api.openoffice.org/docs/common/ref/com/sun/star/beans/XPropertySet.html