1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: basobj.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include <tools/ref.hxx>
35 #include <bastype.hxx>
36 #include <tools/pstm.hxx>
40 class SvAttributeList
;
43 typedef SvMetaObject
* (*CreateMetaObjectType
)();
44 #define IDL_WRITE_COMPILER 0x8000
45 #define IDL_WRITE_BROWSER 0x4000
46 #define IDL_WRITE_CALLING 0x2000
47 #define IDL_WRITE_MASK 0xE000
53 WRITE_IDL
, WRITE_ODL
, WRITE_SLOTMAP
, WRITE_C_HEADER
, WRITE_C_SOURCE
,
54 WRITE_CXX_HEADER
, WRITE_CXX_SOURCE
, WRITE_DOCU
59 WA_METHOD
= 0x1, WA_VARIABLE
= 0x2, WA_ARGUMENT
= 0x4,
60 WA_STRUCT
= 0x8, WA_READONLY
= 0x10
62 typedef int WriteAttribute
;
64 /******************** Meta Factory **************************************/
67 #define PRV_SV_DECL_META_FACTORY( Class ) \
68 static SvAttributeList * pAttribList; \
69 static SvMetaObject * Create() { return new Class; } \
70 static const char * GetClassName() { return #Class; }
72 #define PRV_SV_IMPL_META_FACTORY( Class ) \
73 SvAttributeList * Class::pAttribList = NULL;
77 #define PRV_SV_DECL_META_FACTORY( Class )
79 #define PRV_SV_IMPL_META_FACTORY( Class )
81 #endif // IDL_COMPILER
83 #define SV_DECL_META_FACTORY( Class, CLASS_ID ) \
84 SV_DECL_PERSIST( Class, CLASS_ID ) \
85 PRV_SV_DECL_META_FACTORY( Class )
88 #define SV_DECL_META_FACTORY1( Class, Super1, CLASS_ID ) \
89 SV_DECL_PERSIST1( Class, Super1, CLASS_ID ) \
90 PRV_SV_DECL_META_FACTORY( Class )
92 #define SV_IMPL_META_FACTORY( Class ) \
93 PRV_SV_IMPL_META_FACTORY( Class ) \
94 SV_IMPL_PERSIST( Class )
97 #define SV_IMPL_META_FACTORY1( Class, Super1 ) \
98 PRV_SV_IMPL_META_FACTORY( Class ) \
99 SV_IMPL_PERSIST1( Class, Super1 )
102 /******************** class SvMetaObject ********************************/
103 class SvMetaObject
: public SvPersistBase
106 SV_DECL_META_FACTORY1( SvMetaObject
, SvPersistBase
, 14 )
110 static void WriteTab( SvStream
& rOutStm
, USHORT nTab
);
111 static BOOL
TestAndSeekSpaceOnly( SvStream
&, ULONG nBegPos
);
112 static void Back2Delemitter( SvStream
& );
113 static void WriteStars( SvStream
& );
115 virtual BOOL
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
116 virtual void WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
);
118 virtual void Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
,
119 WriteType
, WriteAttribute
= 0 );
121 virtual void WriteCxx( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
);
122 virtual void WriteHxx( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
);
125 SV_DECL_IMPL_REF(SvMetaObject
)
126 //SV_DECL_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
127 SV_DECL_PERSIST_LIST(SvMetaObject
,SvMetaObject
*)
128 SV_IMPL_PERSIST_LIST(SvMetaObject
,SvMetaObject
*)
131 class SvMetaObjectMemberStack
133 SvMetaObjectMemberList aList
;
135 SvMetaObjectMemberStack() {;}
137 void Push( SvMetaObject
* pObj
)
138 { aList
.Insert( pObj
, LIST_APPEND
); }
139 SvMetaObject
* Pop() { return aList
.Remove( aList
.Count() -1 ); }
140 SvMetaObject
* Top() const { return aList
.GetObject( aList
.Count() -1 ); }
141 void Clear() { aList
.Clear(); }
142 ULONG
Count() const { return aList
.Count(); }
144 SvMetaObject
* Get( TypeId nType
)
146 SvMetaObject
* pObj
= aList
.Last();
149 if( pObj
->IsA( nType
) )
157 /******************** class SvMetaName **********************************/
158 class SvMetaName
: public SvMetaObject
161 SvHelpContext aHelpContext
;
162 SvHelpText aHelpText
;
163 SvString aConfigName
;
164 SvString aDescription
;
168 virtual BOOL
ReadNameSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
169 void DoReadContextSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
,
171 virtual void ReadContextSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
172 virtual void WriteContextSvIdl( SvIdlDataBase
& rBase
,
173 SvStream
& rOutStm
, USHORT nTab
);
174 virtual void ReadAttributesSvIdl( SvIdlDataBase
& rBase
,
175 SvTokenStream
& rInStm
);
176 virtual void WriteAttributesSvIdl( SvIdlDataBase
& rBase
,
177 SvStream
& rOutStm
, USHORT nTab
);
178 virtual void WriteAttributes( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
,
179 WriteType
, WriteAttribute
= 0);
180 virtual void WriteContext( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
,
181 WriteType
, WriteAttribute
= 0);
184 SV_DECL_META_FACTORY1( SvMetaName
, SvMetaObject
, 15 )
187 virtual BOOL
SetName( const ByteString
& rName
, SvIdlDataBase
* = NULL
);
188 void SetDescription( const ByteString
& rText
)
189 { aDescription
= rText
; }
190 const SvHelpContext
& GetHelpContext() const { return aHelpContext
; }
191 virtual const SvString
& GetName() const { return aName
; }
192 virtual const SvString
& GetHelpText() const { return aHelpText
; }
193 virtual const SvString
& GetConfigName() const{ return aConfigName
; }
194 virtual const SvString
& GetDescription() const{ return aDescription
; }
197 virtual BOOL
Test( SvIdlDataBase
&, SvTokenStream
& rInStm
);
198 virtual BOOL
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
199 virtual void WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
);
200 virtual void Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
,
201 WriteType
, WriteAttribute
= 0);
202 void WriteDescription( SvStream
& rOutStm
);
205 SV_DECL_IMPL_REF(SvMetaName
)
206 SV_DECL_IMPL_PERSIST_LIST(SvMetaName
,SvMetaName
*)
209 /******************** class SvMetaReference *****************************/
210 SV_DECL_REF(SvMetaReference
)
211 class SvMetaReference
: public SvMetaName
214 SvMetaReferenceRef aRef
;
216 SV_DECL_META_FACTORY1( SvMetaReference
, SvMetaName
, 17 )
219 const SvString
& GetName() const
222 || SvMetaName::GetName().Len() )
223 ? SvMetaName::GetName()
227 const SvString
& GetHelpText() const
230 || SvMetaName::GetHelpText().Len() )
231 ? SvMetaName::GetHelpText()
232 : aRef
->GetHelpText();
235 const SvString
& GetConfigName() const
238 || SvMetaName::GetConfigName().Len() )
239 ? SvMetaName::GetConfigName()
240 : aRef
->GetConfigName();
243 const SvString
& GetDescription() const
246 || SvMetaName::GetDescription().Len() )
247 ? SvMetaName::GetDescription()
248 : aRef
->GetDescription();
250 SvMetaReference
* GetRef() const { return aRef
; }
251 void SetRef( SvMetaReference
* pRef
)
254 SV_IMPL_REF(SvMetaReference
)
255 SV_DECL_IMPL_PERSIST_LIST(SvMetaReference
,SvMetaReference
*)
258 /******************** class SvMetaExtern *********************************/
260 class SvMetaExtern
: public SvMetaReference
262 SvMetaModule
* pModule
; // in welchem Modul enthalten
269 SV_DECL_META_FACTORY1( SvMetaExtern
, SvMetaName
, 16 )
272 SvMetaModule
* GetModule() const;
274 const SvGlobalName
&GetUUId() const;
275 const SvVersion
& GetVersion() const { return aVersion
; }
277 void SetModule( SvIdlDataBase
& rBase
);
278 virtual BOOL
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
279 virtual void WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
);
281 virtual void Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
,
282 WriteType
, WriteAttribute
= 0);
284 virtual void ReadAttributesSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
285 virtual void WriteAttributesSvIdl( SvIdlDataBase
& rBase
,
286 SvStream
& rOutStm
, USHORT nTab
);
287 virtual void WriteAttributes( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, USHORT nTab
,
288 WriteType
, WriteAttribute
= 0);
291 SV_DECL_IMPL_REF(SvMetaExtern
)
292 SV_DECL_IMPL_PERSIST_LIST(SvMetaExtern
,SvMetaExtern
*)
295 #endif // _BASOBJ_HXX