Difference between revisions of "Documentation/DevGuide/FirstSteps/Struct"

From Apache OpenOffice Wiki
Jump to: navigation, search
(FINAL VERSION FOR L10N)
(20 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{FirstSteps|FirstSteps=block|FirstSteps2b=block|PrevNext=block|Prev=Common Types|Next=Any}}
+
{{Documentation/DevGuide/FirstStepsTOC
Structs in the {{PRODUCTNAME}} API are used to create compounds of other UNO types. They correspond to C structs or Java classes consisting of public member variables only.
+
|FirstSteps2b=block
 +
|ShowPrevNext=block
 +
|PrevPage=Documentation/DevGuide/FirstSteps/Common Types
 +
|NextPage=Documentation/DevGuide/FirstSteps/Any
 +
}}
 +
{{Documentation/DevGuideLanguages|Documentation/DevGuide/FirstSteps/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Struct}}
 +
Structs in the {{OOo}} API are used to create compounds of other UNO types. They correspond to C structs or Java classes consisting of public member variables only.
 
While structs do not encapsulate data, they are easier to transport as a whole, instead of marshaling <code>get()</code> and <code>set()</code> calls back and forth. In particular, this has advantages for remote communication.
 
While structs do not encapsulate data, they are easier to transport as a whole, instead of marshaling <code>get()</code> and <code>set()</code> calls back and forth. In particular, this has advantages for remote communication.
  
 
You gain access to struct members through the . (dot) operator as in  
 
You gain access to struct members through the . (dot) operator as in  
  
 +
  <source lang="java">
 
   aProperty.Name = "ReadOnly";
 
   aProperty.Name = "ReadOnly";
 +
  </source>
  
In Java, C++ and {{PRODUCTNAME}} Basic, the keyword new instantiates structs. In OLE automation, use [http://api.openoffice.org/docs/common/ref/com/sun/star/reflection/CoreReflection.html com.sun.star.reflection.CoreReflection] to get a UNO struct. Do not use the service manager to create structs.
+
In Java, C++ and {{OOo}} Basic, the keyword <code>new</code> instantiates structs. In OLE automation, use <idl>com.sun.star.reflection.CoreReflection</idl> to get a UNO struct. Do not use the service manager to create structs.
  
 +
  <source lang="java">
 
   //In Java:
 
   //In Java:
   com.sun.star.beans.PropertyValue aProperty = new com.sun.star.beans.PropertyValue();
+
   com.sun.star.beans.PropertyValue aProperty  
+
            = new com.sun.star.beans.PropertyValue();
   'In StarBasic
+
  </source>
 +
 
 +
 
 +
 
 +
  <source lang="vb">
 +
   'In OpenOffice.org Basic
 
   Dim aProperty as new com.sun.star.beans.PropertyValue
 
   Dim aProperty as new com.sun.star.beans.PropertyValue
 +
  </source>
 +
 +
{{PDL1}}
  
[[Category: Development Concepts]]
+
[[Category:Documentation/Developer's Guide/First Steps]]

Revision as of 09:17, 18 May 2009



Structs in the Apache OpenOffice API are used to create compounds of other UNO types. They correspond to C structs or Java classes consisting of public member variables only. While structs do not encapsulate data, they are easier to transport as a whole, instead of marshaling get() and set() calls back and forth. In particular, this has advantages for remote communication.

You gain access to struct members through the . (dot) operator as in

  aProperty.Name = "ReadOnly";

In Java, C++ and Apache OpenOffice Basic, the keyword new instantiates structs. In OLE automation, use com.sun.star.reflection.CoreReflection to get a UNO struct. Do not use the service manager to create structs.

  //In Java:
  com.sun.star.beans.PropertyValue aProperty 
             = new com.sun.star.beans.PropertyValue();


  'In OpenOffice.org Basic
  Dim aProperty as new com.sun.star.beans.PropertyValue
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages