How to get Objects in

From Apache OpenOffice Wiki
Jump to: navigation, search

An object in our context is a software artifact that has methods you can call. Objects are required to do something with But where do you obtain them?

New objects

In general, new objects or objects which are necessary for a first access are created by service managers in In the FirstLoadComponent example, the remote service manager creates the remote Desktop object, which handles application windows and loaded documents in

  Object desktop = xRemoteServiceManager.createInstanceWithContext(
                   "", xRemoteContext);

Document objects

Document objects represent the files that are opened with They are created by the Desktop object, which has a loadComponentFromURL() method for this purpose.

Objects that are provided by other objects

Objects can hand out other objects. There are two cases:

  • Features which are designed to be an integral part of the object that provides the feature can be obtained by get methods in the API. It is common to get an object from a get method. For instance, getSheets() is required for every Calc document, getText() is essential for every Writer Document and getDrawpages() is an essential part of every Draw document. After loading a document, these methods are used to get the Sheets, Text and Drawpages object of the corresponding document. Object-specific get methods are an important technique to get objects.
  • Features which are not considered integral for the architecture of an object are accessible through a set of universal methods. In the API, these features are called properties, and generic methods are used, such as getPropertyValue(String propertyName) to access them. In some cases such a non-integral feature is provided as an object, therefore the method getPropertyValue() can be another source for objects. For instance, page styles for spreadsheets have the properties "RightPageHeaderContent" and "LeftPageHeaderContent", that contain objects for the page header sections of a spreadsheet document. The generic getPropertyValue() method can sometimes provide an object you need.

Sets of objects

Objects can be elements in a set of similar objects. In sets, to access an object you need to know how to get a particular element from the set. The API allows four ways to provide an element in a set. The first three ways are objects with element access methods that allow access by name, index, or enumeration. The fourth way is a sequence of elements which has no access methods but can be used as an array directly. How these sets of elements are used will be discussed later.

The designer of an object decides which of those opportunities to offer, based on special conditions of the object, such as how it performs remotely or which access methods best work with implementation.

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