结构
From Apache OpenOffice Wiki
< Zh | Documentation
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
struct 类型定义一条记录中的多个元素。struct 中的元素是结构中具有唯一名称的 UNO 类型。结构的缺点是不封装数据,但缺少 get() 和 set() 方法有助于避免通过 UNO 桥进行方法调用所产生的开销。UNO 支持 struct 类型的单继承。派生的 struct 以递归方式继承父对象以及父对象的父对象中的所有元素。
// com.sun.star.lang.EventObject
/** specifies the base for all event objects and identifies the
source of the event.
*/
struct EventObject
{
/** refers to the object that fired the event.
*/
com::sun::star::uno::XInterface Source;
};
// com.sun.star.beans.PropertyChangeEvent
struct PropertyChangeEvent : com::sun::star::lang::EventObject {
string PropertyName;
boolean Further;
long PropertyHandle;
any OldValue;
any NewValue;
};
OpenOffice.org2.0 的一项新功能是多态结构类型。多态结构类型模板与普通结构类型类似,但它有一个或多个类型参数,并且其成员可以将这些参数作为类型。多态结构类型模板本身不是 UNO 类型—它必须使用实际的类型参数来实例化才能作为一个类型使用。
// A polymorphic struct type template with two type parameters:
struct Poly<T,U> {
T member1;
T member2;
U member3;
long member4;
};
// Using an instantiation of Poly as a UNO type:
interface XIfc { Poly<boolean, any> fn(); };
在本例中,Poly<boolean, any> 将是一个具有与普通结构类型相同形式的实例化多态结构类型
struct PolyBooleanAny {
boolean member1;
boolean member2;
any member3;
long member4;
};
添加多态结构类型主要用于支持丰富的接口类型属性,这些属性与 maybeambiguous、maybedefault 或 maybevoid 属性一样富有表达力(请参阅 com.sun.star.beans.Ambiguous、com.sun.star.beans.Defaulted、com.sun.star.beans.Optional),但这些类型也可能用于其他环境中。
| Content on this page is licensed under the Public Documentation License (PDL). |