1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
31 #include <tools/ref.hxx>
32 #include <bastype.hxx>
33 #include <tools/pstm.hxx>
37 class SvAttributeList
;
40 typedef SvMetaObject
* (*CreateMetaObjectType
)();
41 #define IDL_WRITE_COMPILER 0x8000
42 #define IDL_WRITE_BROWSER 0x4000
43 #define IDL_WRITE_CALLING 0x2000
44 #define IDL_WRITE_MASK 0xE000
50 WRITE_IDL
, WRITE_ODL
, WRITE_SLOTMAP
, WRITE_C_HEADER
, WRITE_C_SOURCE
,
51 WRITE_CXX_HEADER
, WRITE_CXX_SOURCE
, WRITE_DOCU
56 WA_METHOD
= 0x1, WA_VARIABLE
= 0x2, WA_ARGUMENT
= 0x4,
57 WA_STRUCT
= 0x8, WA_READONLY
= 0x10
59 typedef int WriteAttribute
;
61 /******************** Meta Factory **************************************/
64 #define PRV_SV_DECL_META_FACTORY( Class ) \
65 static SvAttributeList * pAttribList; \
66 static SvMetaObject * Create() { return new Class; } \
67 static const char * GetClassName() { return #Class; }
69 #define PRV_SV_IMPL_META_FACTORY( Class ) \
70 SvAttributeList * Class::pAttribList = NULL;
74 #define PRV_SV_DECL_META_FACTORY( Class )
76 #define PRV_SV_IMPL_META_FACTORY( Class )
78 #endif // IDL_COMPILER
80 #define SV_DECL_META_FACTORY( Class, CLASS_ID ) \
81 SV_DECL_PERSIST( Class, CLASS_ID ) \
82 PRV_SV_DECL_META_FACTORY( Class )
85 #define SV_DECL_META_FACTORY1( Class, Super1, CLASS_ID ) \
86 SV_DECL_PERSIST1( Class, Super1, CLASS_ID ) \
87 PRV_SV_DECL_META_FACTORY( Class )
89 #define SV_IMPL_META_FACTORY( Class ) \
90 PRV_SV_IMPL_META_FACTORY( Class ) \
91 SV_IMPL_PERSIST( Class )
94 #define SV_IMPL_META_FACTORY1( Class, Super1 ) \
95 PRV_SV_IMPL_META_FACTORY( Class ) \
96 SV_IMPL_PERSIST1( Class, Super1 )
99 /******************** class SvMetaObject ********************************/
100 class SvMetaObject
: public SvPersistBase
103 SV_DECL_META_FACTORY1( SvMetaObject
, SvPersistBase
, 14 )
107 static void WriteTab( SvStream
& rOutStm
, sal_uInt16 nTab
);
108 static sal_Bool
TestAndSeekSpaceOnly( SvStream
&, sal_uLong nBegPos
);
109 static void Back2Delemitter( SvStream
& );
110 static void WriteStars( SvStream
& );
112 virtual sal_Bool
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
113 virtual void WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
);
115 virtual void Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
,
116 WriteType
, WriteAttribute
= 0 );
118 virtual void WriteCxx( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
);
119 virtual void WriteHxx( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
);
122 SV_DECL_IMPL_REF(SvMetaObject
)
123 //SV_DECL_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
124 SV_DECL_PERSIST_LIST(SvMetaObject
,SvMetaObject
*)
125 SV_IMPL_PERSIST_LIST(SvMetaObject
,SvMetaObject
*)
128 class SvMetaObjectMemberStack
130 SvMetaObjectMemberList aList
;
132 SvMetaObjectMemberStack() {;}
134 void Push( SvMetaObject
* pObj
)
135 { aList
.Insert( pObj
, LIST_APPEND
); }
136 SvMetaObject
* Pop() { return aList
.Remove( aList
.Count() -1 ); }
137 SvMetaObject
* Top() const { return aList
.GetObject( aList
.Count() -1 ); }
138 void Clear() { aList
.Clear(); }
139 sal_uLong
Count() const { return aList
.Count(); }
141 SvMetaObject
* Get( TypeId nType
)
143 SvMetaObject
* pObj
= aList
.Last();
146 if( pObj
->IsA( nType
) )
154 /******************** class SvMetaName **********************************/
155 class SvMetaName
: public SvMetaObject
158 SvHelpContext aHelpContext
;
159 SvHelpText aHelpText
;
160 SvString aConfigName
;
161 SvString aDescription
;
165 virtual sal_Bool
ReadNameSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
166 void DoReadContextSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
,
168 virtual void ReadContextSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
169 virtual void WriteContextSvIdl( SvIdlDataBase
& rBase
,
170 SvStream
& rOutStm
, sal_uInt16 nTab
);
171 virtual void ReadAttributesSvIdl( SvIdlDataBase
& rBase
,
172 SvTokenStream
& rInStm
);
173 virtual void WriteAttributesSvIdl( SvIdlDataBase
& rBase
,
174 SvStream
& rOutStm
, sal_uInt16 nTab
);
175 virtual void WriteAttributes( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
,
176 WriteType
, WriteAttribute
= 0);
177 virtual void WriteContext( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
,
178 WriteType
, WriteAttribute
= 0);
181 SV_DECL_META_FACTORY1( SvMetaName
, SvMetaObject
, 15 )
184 virtual sal_Bool
SetName( const ByteString
& rName
, SvIdlDataBase
* = NULL
);
185 void SetDescription( const ByteString
& rText
)
186 { aDescription
= rText
; }
187 const SvHelpContext
& GetHelpContext() const { return aHelpContext
; }
188 virtual const SvString
& GetName() const { return aName
; }
189 virtual const SvString
& GetHelpText() const { return aHelpText
; }
190 virtual const SvString
& GetConfigName() const{ return aConfigName
; }
191 virtual const SvString
& GetDescription() const{ return aDescription
; }
194 virtual sal_Bool
Test( SvIdlDataBase
&, SvTokenStream
& rInStm
);
195 virtual sal_Bool
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
196 virtual void WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
);
197 virtual void Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
,
198 WriteType
, WriteAttribute
= 0);
199 void WriteDescription( SvStream
& rOutStm
);
202 SV_DECL_IMPL_REF(SvMetaName
)
203 SV_DECL_IMPL_PERSIST_LIST(SvMetaName
,SvMetaName
*)
206 /******************** class SvMetaReference *****************************/
207 SV_DECL_REF(SvMetaReference
)
208 class SvMetaReference
: public SvMetaName
211 SvMetaReferenceRef aRef
;
213 SV_DECL_META_FACTORY1( SvMetaReference
, SvMetaName
, 17 )
216 const SvString
& GetName() const
219 || SvMetaName::GetName().Len() )
220 ? SvMetaName::GetName()
224 const SvString
& GetHelpText() const
227 || SvMetaName::GetHelpText().Len() )
228 ? SvMetaName::GetHelpText()
229 : aRef
->GetHelpText();
232 const SvString
& GetConfigName() const
235 || SvMetaName::GetConfigName().Len() )
236 ? SvMetaName::GetConfigName()
237 : aRef
->GetConfigName();
240 const SvString
& GetDescription() const
243 || SvMetaName::GetDescription().Len() )
244 ? SvMetaName::GetDescription()
245 : aRef
->GetDescription();
247 SvMetaReference
* GetRef() const { return aRef
; }
248 void SetRef( SvMetaReference
* pRef
)
251 SV_IMPL_REF(SvMetaReference
)
252 SV_DECL_IMPL_PERSIST_LIST(SvMetaReference
,SvMetaReference
*)
255 /******************** class SvMetaExtern *********************************/
257 class SvMetaExtern
: public SvMetaReference
259 SvMetaModule
* pModule
; // in welchem Modul enthalten
264 sal_Bool bReadVersion
;
266 SV_DECL_META_FACTORY1( SvMetaExtern
, SvMetaName
, 16 )
269 SvMetaModule
* GetModule() const;
271 const SvGlobalName
&GetUUId() const;
272 const SvVersion
& GetVersion() const { return aVersion
; }
274 void SetModule( SvIdlDataBase
& rBase
);
275 virtual sal_Bool
ReadSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
276 virtual void WriteSvIdl( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
);
278 virtual void Write( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
,
279 WriteType
, WriteAttribute
= 0);
281 virtual void ReadAttributesSvIdl( SvIdlDataBase
&, SvTokenStream
& rInStm
);
282 virtual void WriteAttributesSvIdl( SvIdlDataBase
& rBase
,
283 SvStream
& rOutStm
, sal_uInt16 nTab
);
284 virtual void WriteAttributes( SvIdlDataBase
& rBase
, SvStream
& rOutStm
, sal_uInt16 nTab
,
285 WriteType
, WriteAttribute
= 0);
288 SV_DECL_IMPL_REF(SvMetaExtern
)
289 SV_DECL_IMPL_PERSIST_LIST(SvMetaExtern
,SvMetaExtern
*)
292 #endif // _BASOBJ_HXX