Difference between revisions of "Documentation/DevGuide/FirstSteps/How to get Objects in OpenOffice.org"

From Apache OpenOffice Wiki
Jump to: navigation, search
 
(16 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Documentation/APIGuide/FirstStepsTOC|FirstSteps=block|PrevNext=block|Prev=Documentation/APIGuide/FirstSteps/First Contact|Next=Documentation/APIGuide/FirstSteps/Working with Objects}}
+
{{Documentation/DevGuide/FirstStepsTOC
{{DISPLAYTITLE:How to get Objects in OpenOffice.org}}
+
|ShowPrevNext=block
 +
|PrevPage=Documentation/DevGuide/FirstSteps/First Contact
 +
|NextPage=Documentation/DevGuide/FirstSteps/Working with Objects
 +
}}
 +
{{Documentation/DevGuideLanguages|Documentation/DevGuide/FirstSteps/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:How to get Objects in Apache OpenOffice}}
 
__NOTOC__
 
__NOTOC__
An ''object'' in our context is a software artifact that has methods you can call. Objects are required to do something with {{PRODUCTNAME}}. But where do you obtain them?
+
An ''object'' in our context is a software artifact that has methods you can call. Objects are required to do something with {{AOo}}. But where do you obtain them?
  
 
===New objects===
 
===New objects===
In general, new objects or objects which are necessary for a first access are created by ''service managers'' in {{PRODUCTNAME}} In the <code>FirstLoadComponent</code> example, the remote service manager creates the remote <code>Desktop</code> object, which handles application windows and loaded documents in {{PRODUCTNAME}}:  
+
In general, new objects or objects which are necessary for a first access are created by ''service managers'' in {{AOo}}. In the <code>FirstLoadComponent</code> example, the remote service manager creates the remote <code>Desktop</code> object, which handles application windows and loaded documents in {{AOo}}:  
  
 +
<syntaxhighlight lang="java">
 
   Object desktop = xRemoteServiceManager.createInstanceWithContext(
 
   Object desktop = xRemoteServiceManager.createInstanceWithContext(
 
                   "com.sun.star.frame.Desktop", xRemoteContext);
 
                   "com.sun.star.frame.Desktop", xRemoteContext);
 +
</syntaxhighlight>
  
 
===Document objects===
 
===Document objects===
Document objects represent the files that are opened with {{PRODUCTNAME}}. They are created by the <code>Desktop</code> object, which has a <code>loadComponentFromURL()</code> method for this purpose.
+
Document objects represent the files that are opened with {{AOo}}. They are created by the <code>Desktop</code> object, which has a <code>loadComponentFromURL()</code> method for this purpose.
  
 
===Objects that are provided by other objects===
 
===Objects that are provided by other objects===
 
Objects can hand out other objects. There are two cases:
 
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 {{PRODUCTNAME}} API. It is common to get an object from a get method. For instance, <code>getSheets()</code> is required for every Calc document, <code>getText()</code> is essential for every Writer Document and <code>getDrawpages()</code> 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 designed to be an integral part of the object that provides the feature can be obtained by get methods in the {{AOo}} API. It is common to get an object from a get method. For instance, <code>getSheets()</code> is required for every Calc document, <code>getText()</code> is essential for every Writer Document and <code>getDrawpages()</code> 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 {{PRODUCTNAME}} API, these features are called properties, and generic methods are used, such as <code>getPropertyValue(String propertyName)</code> to access them. In some cases such a non-integral feature is provided as an object, therefore the method <code>getPropertyValue()</code> can be another source for objects. For instance, page styles for spreadsheets have the properties <code>"RightPageHeaderContent"</code> and <code>"LeftPageHeaderContent"</code>, that contain objects for the page header sections of a spreadsheet document. The generic <code>getPropertyValue()</code> method can sometimes provide an object you need.
+
* Features which are not considered integral for the architecture of an object are accessible through a set of universal methods. In the {{AOo}} API, these features are called properties, and generic methods are used, such as <code>getPropertyValue(String propertyName)</code> to access them. In some cases such a non-integral feature is provided as an object, therefore the method <code>getPropertyValue()</code> can be another source for objects. For instance, page styles for spreadsheets have the properties <code>"RightPageHeaderContent"</code> and <code>"LeftPageHeaderContent"</code>, that contain objects for the page header sections of a spreadsheet document. The generic <code>getPropertyValue()</code> method can sometimes provide an object you need.
  
 
===Sets of objects===
 
===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 {{PRODUCTNAME}} 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.
+
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 {{AOo}} 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.
 
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.
  
 
{{PDL1}}
 
{{PDL1}}
[[Category: First Steps]]
+
 
 +
[[Category:Documentation/Developer's Guide/First Steps]]

Latest revision as of 15:26, 22 December 2020



An object in our context is a software artifact that has methods you can call. Objects are required to do something with Apache OpenOffice. 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 Apache OpenOffice. In the FirstLoadComponent example, the remote service manager creates the remote Desktop object, which handles application windows and loaded documents in Apache OpenOffice:

  Object desktop = xRemoteServiceManager.createInstanceWithContext(
                   "com.sun.star.frame.Desktop", xRemoteContext);

Document objects

Document objects represent the files that are opened with Apache OpenOffice. 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 Apache OpenOffice 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 Apache OpenOffice 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 Apache OpenOffice 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