From Apache OpenOffice Wiki
< Zh‎ | Documentation
Revision as of 15:33, 18 February 2012 by X007007007 (Talk | contribs)

Jump to: navigation, search

这是一个独立的说明, 在 有所有被Writer,Calc,Draw 和Impress支持的接口说明. 本文中, 我们称在被支持的模块为 对象模块. 在 是所有 文档都共有的服务. 一个 OfficeDocument 有如下接口:


接口继承自 ,介绍一下方法,处理模型的资源描述,管理控制器和检索当前选择.

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

getURL()方法返回文档文档被加载的地址URL storeAsURL()返回文档被储存的地址.如果文档仅仅被创建,尚未被储存,则放回字符串为空. getArgs()方法返回一个属性值的序列 关于返回值的详细信息可以在这里找到 toreAsURL方法用于指定加载/保存地址. attachResource() 被用作框架加载实现,告知模块关于加载内容的URL和MediaDescriptor信息.

模块近期动作可以通过getCurrentController()恢复 The current or last active controller for a model is retrieved through getCurrentController().

相应的setCurrentController()方法为模块设置当下不同的可用控制器 然而,新增的控制器并不能在此时创建可被OpenOffice.org使用的组建API

However, additional controllers can not be created at this time for components using the component API. 

connectController()方法被用作框架加载实现,它创建一个模型的控制器,但并未使之成为当前的控制器. 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. disconnectController()告知模型控制器不再使用 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 interface supported by controller services.


The interface 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)


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


The interface 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 )


For versions later than 641, the optional interface 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 has a string member EventName, that assumes one of the values specified in 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.


The optional interface 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 interface. This is done programmatically versus manually in Tools - Configure - Events.


The optional interface provides access to document information as described in section Document Info. Document information is presented in the File - Properties dialog in the GUI.



The optional 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 to sequences of 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 provides text related interfaces. Having received a reference to a model, developers query for these interfaces. The interface of a model can be used to ask for supported services. The document types support the following services:

Document Service Chapter
Calc Spreadsheet Documents
Draw Drawing Documents and Presentation Documents
Impress Drawing Documents and Presentation Documents
Math -
Writer (all Writer modules) Text Documents
Chart Charts

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

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