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

From Apache OpenOffice Wiki
Jump to: navigation, search
Line 1: Line 1:
 
{{DevGuide|FirstSteps=block|FirstSteps2b=block|PrevNext=block|Prev=Common Types|Next=Any}}
 
{{DevGuide|FirstSteps=block|FirstSteps2b=block|PrevNext=block|Prev=Common Types|Next=Any}}
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.
+
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.
While structs do not encapsulate data, they are easier to transport as a whole, instead of marshalling get() and set() 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 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  
 
You gain access to struct members through the . (dot) operator as in  
 +
 
   aProperty.Name = "ReadOnly";
 
   aProperty.Name = "ReadOnly";
 +
 
In Java, C++ und [PRODUCTNAME] Basic, the keyword new instantiates structs. In OLE automation, use [IDL:com.sun.star.reflection.CoreReflection] to get a UNO struct. Do not use the service manager to create structs.
 
In Java, C++ und [PRODUCTNAME] Basic, the keyword new instantiates structs. In OLE automation, use [IDL:com.sun.star.reflection.CoreReflection] to get a UNO struct. Do not use the service manager to create structs.
 +
 
   //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
 
   'In StarBasic
 
   Dim aProperty as new com.sun.star.beans.PropertyValue
 
   Dim aProperty as new com.sun.star.beans.PropertyValue
  
 
[[Category: Development Concepts]]
 
[[Category: Development Concepts]]

Revision as of 10:32, 16 May 2007

Template:DevGuide Structs in the OpenOffice.org 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++ und [PRODUCTNAME] Basic, the keyword new instantiates structs. In OLE automation, use [IDL: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 StarBasic
 Dim aProperty as new com.sun.star.beans.PropertyValue
Personal tools