xref: /AOO41X/main/idl/inc/basobj.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir #ifndef _BASOBJ_HXX
29*cdf0e10cSrcweir #define _BASOBJ_HXX
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/ref.hxx>
32*cdf0e10cSrcweir #include <bastype.hxx>
33*cdf0e10cSrcweir #include <tools/pstm.hxx>
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir class SvTokenStream;
36*cdf0e10cSrcweir class SvMetaObject;
37*cdf0e10cSrcweir class SvAttributeList;
38*cdf0e10cSrcweir class SvIdlDataBase;
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir typedef SvMetaObject * (*CreateMetaObjectType)();
41*cdf0e10cSrcweir #define IDL_WRITE_COMPILER  0x8000
42*cdf0e10cSrcweir #define IDL_WRITE_BROWSER   0x4000
43*cdf0e10cSrcweir #define IDL_WRITE_CALLING   0x2000
44*cdf0e10cSrcweir #define IDL_WRITE_MASK      0xE000
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #define C_PREF	"C_"
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir enum WriteType
49*cdf0e10cSrcweir {
50*cdf0e10cSrcweir 	WRITE_IDL, WRITE_ODL, WRITE_SLOTMAP, WRITE_C_HEADER, WRITE_C_SOURCE,
51*cdf0e10cSrcweir 	WRITE_CXX_HEADER, WRITE_CXX_SOURCE, WRITE_DOCU
52*cdf0e10cSrcweir };
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir enum
55*cdf0e10cSrcweir {
56*cdf0e10cSrcweir 	WA_METHOD = 0x1,	WA_VARIABLE = 0x2,	WA_ARGUMENT = 0x4,
57*cdf0e10cSrcweir 	WA_STRUCT = 0x8,	WA_READONLY = 0x10
58*cdf0e10cSrcweir };
59*cdf0e10cSrcweir typedef int WriteAttribute;
60*cdf0e10cSrcweir 
61*cdf0e10cSrcweir /******************** Meta Factory **************************************/
62*cdf0e10cSrcweir #ifdef IDL_COMPILER
63*cdf0e10cSrcweir 
64*cdf0e10cSrcweir #define PRV_SV_DECL_META_FACTORY( Class )                               \
65*cdf0e10cSrcweir     static SvAttributeList * pAttribList;                               \
66*cdf0e10cSrcweir     static SvMetaObject * Create() { return new Class; }                \
67*cdf0e10cSrcweir     static const char *   GetClassName() { return #Class; }
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir #define PRV_SV_IMPL_META_FACTORY( Class )                               \
70*cdf0e10cSrcweir     SvAttributeList * Class::pAttribList = NULL;
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir #else
73*cdf0e10cSrcweir 
74*cdf0e10cSrcweir #define PRV_SV_DECL_META_FACTORY( Class )
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir #define PRV_SV_IMPL_META_FACTORY( Class )
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir #endif // IDL_COMPILER
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir #define SV_DECL_META_FACTORY( Class, CLASS_ID )                         \
81*cdf0e10cSrcweir     SV_DECL_PERSIST( Class, CLASS_ID )                                  \
82*cdf0e10cSrcweir     PRV_SV_DECL_META_FACTORY( Class )
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir #define SV_DECL_META_FACTORY1( Class, Super1, CLASS_ID )                \
86*cdf0e10cSrcweir     SV_DECL_PERSIST1( Class, Super1, CLASS_ID )                         \
87*cdf0e10cSrcweir     PRV_SV_DECL_META_FACTORY( Class )
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir #define SV_IMPL_META_FACTORY( Class )                                   \
90*cdf0e10cSrcweir     PRV_SV_IMPL_META_FACTORY( Class )                                   \
91*cdf0e10cSrcweir     SV_IMPL_PERSIST( Class )
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir #define SV_IMPL_META_FACTORY1( Class, Super1 )                          \
95*cdf0e10cSrcweir     PRV_SV_IMPL_META_FACTORY( Class )                                   \
96*cdf0e10cSrcweir     SV_IMPL_PERSIST1( Class, Super1 )
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir /******************** class SvMetaObject ********************************/
100*cdf0e10cSrcweir class SvMetaObject : public SvPersistBase
101*cdf0e10cSrcweir {
102*cdf0e10cSrcweir public:
103*cdf0e10cSrcweir             SV_DECL_META_FACTORY1( SvMetaObject, SvPersistBase, 14 )
104*cdf0e10cSrcweir             SvMetaObject();
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir #ifdef IDL_COMPILER
107*cdf0e10cSrcweir     static void			WriteTab( SvStream & rOutStm, sal_uInt16 nTab );
108*cdf0e10cSrcweir 	static sal_Bool			TestAndSeekSpaceOnly( SvStream &, sal_uLong nBegPos );
109*cdf0e10cSrcweir 	static void			Back2Delemitter( SvStream & );
110*cdf0e10cSrcweir 	static void 		WriteStars( SvStream & );
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     virtual sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
113*cdf0e10cSrcweir     virtual void        WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
114*cdf0e10cSrcweir 
115*cdf0e10cSrcweir     virtual void        Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
116*cdf0e10cSrcweir 	 						   WriteType, WriteAttribute = 0 );
117*cdf0e10cSrcweir 
118*cdf0e10cSrcweir     virtual void        WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
119*cdf0e10cSrcweir     virtual void        WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
120*cdf0e10cSrcweir #endif
121*cdf0e10cSrcweir };
122*cdf0e10cSrcweir SV_DECL_IMPL_REF(SvMetaObject)
123*cdf0e10cSrcweir //SV_DECL_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
124*cdf0e10cSrcweir SV_DECL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
125*cdf0e10cSrcweir SV_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir class SvMetaObjectMemberStack
129*cdf0e10cSrcweir {
130*cdf0e10cSrcweir     SvMetaObjectMemberList aList;
131*cdf0e10cSrcweir public:
132*cdf0e10cSrcweir             SvMetaObjectMemberStack() {;}
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     void            Push( SvMetaObject * pObj )
135*cdf0e10cSrcweir                     { aList.Insert( pObj, LIST_APPEND ); }
136*cdf0e10cSrcweir     SvMetaObject *  Pop() { return aList.Remove( aList.Count() -1 ); }
137*cdf0e10cSrcweir     SvMetaObject *  Top() const { return aList.GetObject( aList.Count() -1 ); }
138*cdf0e10cSrcweir     void            Clear() { aList.Clear(); }
139*cdf0e10cSrcweir     sal_uLong     Count() const { return aList.Count(); }
140*cdf0e10cSrcweir 
141*cdf0e10cSrcweir     SvMetaObject *  Get( TypeId nType )
142*cdf0e10cSrcweir                     {
143*cdf0e10cSrcweir                         SvMetaObject * pObj = aList.Last();
144*cdf0e10cSrcweir                         while( pObj )
145*cdf0e10cSrcweir                         {
146*cdf0e10cSrcweir                             if( pObj->IsA( nType ) )
147*cdf0e10cSrcweir                                 return pObj;
148*cdf0e10cSrcweir                             pObj = aList.Prev();
149*cdf0e10cSrcweir                         }
150*cdf0e10cSrcweir                         return NULL;
151*cdf0e10cSrcweir                     }
152*cdf0e10cSrcweir };
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir /******************** class SvMetaName **********************************/
155*cdf0e10cSrcweir class SvMetaName : public SvMetaObject
156*cdf0e10cSrcweir {
157*cdf0e10cSrcweir     SvString      aName;
158*cdf0e10cSrcweir     SvHelpContext aHelpContext;
159*cdf0e10cSrcweir     SvHelpText    aHelpText;
160*cdf0e10cSrcweir     SvString      aConfigName;
161*cdf0e10cSrcweir     SvString      aDescription;
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir protected:
164*cdf0e10cSrcweir #ifdef IDL_COMPILER
165*cdf0e10cSrcweir     virtual sal_Bool ReadNameSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
166*cdf0e10cSrcweir     		void DoReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm,
167*cdf0e10cSrcweir 									 char c = '\0' );
168*cdf0e10cSrcweir     virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
169*cdf0e10cSrcweir     virtual void WriteContextSvIdl( SvIdlDataBase & rBase,
170*cdf0e10cSrcweir                                     SvStream & rOutStm, sal_uInt16 nTab );
171*cdf0e10cSrcweir     virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase,
172*cdf0e10cSrcweir                                       SvTokenStream & rInStm );
173*cdf0e10cSrcweir     virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase,
174*cdf0e10cSrcweir                                        SvStream & rOutStm, sal_uInt16 nTab );
175*cdf0e10cSrcweir     virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
176*cdf0e10cSrcweir 	 						   		WriteType, WriteAttribute = 0);
177*cdf0e10cSrcweir     virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
178*cdf0e10cSrcweir 	 						   		WriteType, WriteAttribute = 0);
179*cdf0e10cSrcweir #endif
180*cdf0e10cSrcweir public:
181*cdf0e10cSrcweir             SV_DECL_META_FACTORY1( SvMetaName, SvMetaObject, 15 )
182*cdf0e10cSrcweir             SvMetaName();
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir     virtual sal_Bool        		SetName( const ByteString & rName, SvIdlDataBase * = NULL  );
185*cdf0e10cSrcweir     void        				SetDescription( const ByteString& rText )
186*cdf0e10cSrcweir 								{ aDescription = rText; }
187*cdf0e10cSrcweir     const SvHelpContext& 		GetHelpContext() const { return aHelpContext; }
188*cdf0e10cSrcweir     virtual const SvString &    GetName() const { return aName; }
189*cdf0e10cSrcweir     virtual const SvString &    GetHelpText() const { return aHelpText; }
190*cdf0e10cSrcweir     virtual const SvString &	GetConfigName() const{ return aConfigName; }
191*cdf0e10cSrcweir     virtual const SvString&     GetDescription() const{ return aDescription; }
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir #ifdef IDL_COMPILER
194*cdf0e10cSrcweir 	virtual sal_Bool 		Test( SvIdlDataBase &, SvTokenStream & rInStm );
195*cdf0e10cSrcweir     virtual sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
196*cdf0e10cSrcweir     virtual void        WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
197*cdf0e10cSrcweir     virtual void        Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
198*cdf0e10cSrcweir 	 						  		WriteType, WriteAttribute = 0);
199*cdf0e10cSrcweir 	void				WriteDescription( SvStream& rOutStm );
200*cdf0e10cSrcweir #endif
201*cdf0e10cSrcweir };
202*cdf0e10cSrcweir SV_DECL_IMPL_REF(SvMetaName)
203*cdf0e10cSrcweir SV_DECL_IMPL_PERSIST_LIST(SvMetaName,SvMetaName *)
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir /******************** class SvMetaReference *****************************/
207*cdf0e10cSrcweir SV_DECL_REF(SvMetaReference)
208*cdf0e10cSrcweir class SvMetaReference : public SvMetaName
209*cdf0e10cSrcweir {
210*cdf0e10cSrcweir protected:
211*cdf0e10cSrcweir     SvMetaReferenceRef  aRef;
212*cdf0e10cSrcweir public:
213*cdf0e10cSrcweir             SV_DECL_META_FACTORY1( SvMetaReference, SvMetaName, 17 )
214*cdf0e10cSrcweir             SvMetaReference();
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir     const SvString &    GetName() const
217*cdf0e10cSrcweir                         {
218*cdf0e10cSrcweir 							return ( !aRef.Is()
219*cdf0e10cSrcweir 									|| SvMetaName::GetName().Len() )
220*cdf0e10cSrcweir 								? SvMetaName::GetName()
221*cdf0e10cSrcweir 								: aRef->GetName();
222*cdf0e10cSrcweir                         }
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir     const SvString &    GetHelpText() const
225*cdf0e10cSrcweir 						{
226*cdf0e10cSrcweir 							return ( !aRef.Is()
227*cdf0e10cSrcweir 									|| SvMetaName::GetHelpText().Len() )
228*cdf0e10cSrcweir 								? SvMetaName::GetHelpText()
229*cdf0e10cSrcweir 								: aRef->GetHelpText();
230*cdf0e10cSrcweir 						}
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     const SvString &    GetConfigName() const
233*cdf0e10cSrcweir 						{
234*cdf0e10cSrcweir 							return ( !aRef.Is()
235*cdf0e10cSrcweir 									|| SvMetaName::GetConfigName().Len() )
236*cdf0e10cSrcweir 								? SvMetaName::GetConfigName()
237*cdf0e10cSrcweir 								: aRef->GetConfigName();
238*cdf0e10cSrcweir 						}
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir     const SvString &    GetDescription() const
241*cdf0e10cSrcweir 						{
242*cdf0e10cSrcweir 							return ( !aRef.Is()
243*cdf0e10cSrcweir 									|| SvMetaName::GetDescription().Len() )
244*cdf0e10cSrcweir 								? SvMetaName::GetDescription()
245*cdf0e10cSrcweir 								: aRef->GetDescription();
246*cdf0e10cSrcweir 						}
247*cdf0e10cSrcweir     SvMetaReference *   GetRef() const { return aRef; }
248*cdf0e10cSrcweir     void                SetRef( SvMetaReference * pRef  )
249*cdf0e10cSrcweir                         { aRef = pRef; }
250*cdf0e10cSrcweir };
251*cdf0e10cSrcweir SV_IMPL_REF(SvMetaReference)
252*cdf0e10cSrcweir SV_DECL_IMPL_PERSIST_LIST(SvMetaReference,SvMetaReference *)
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir 
255*cdf0e10cSrcweir /******************** class SvMetaExtern *********************************/
256*cdf0e10cSrcweir class SvMetaModule;
257*cdf0e10cSrcweir class SvMetaExtern : public SvMetaReference
258*cdf0e10cSrcweir {
259*cdf0e10cSrcweir     SvMetaModule *          pModule;    // in welchem Modul enthalten
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir     SvUUId                  aUUId;
262*cdf0e10cSrcweir     SvVersion               aVersion;
263*cdf0e10cSrcweir 	sal_Bool					bReadUUId;
264*cdf0e10cSrcweir 	sal_Bool					bReadVersion;
265*cdf0e10cSrcweir public:
266*cdf0e10cSrcweir                         SV_DECL_META_FACTORY1( SvMetaExtern, SvMetaName, 16 )
267*cdf0e10cSrcweir                         SvMetaExtern();
268*cdf0e10cSrcweir 
269*cdf0e10cSrcweir     SvMetaModule *      GetModule() const;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     const SvGlobalName &GetUUId() const;
272*cdf0e10cSrcweir     const SvVersion &   GetVersion() const { return aVersion; }
273*cdf0e10cSrcweir #ifdef IDL_COMPILER
274*cdf0e10cSrcweir     void				SetModule( SvIdlDataBase & rBase );
275*cdf0e10cSrcweir     virtual sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
276*cdf0e10cSrcweir     virtual void        WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir     virtual void        Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
279*cdf0e10cSrcweir 	 						 	WriteType, WriteAttribute = 0);
280*cdf0e10cSrcweir protected:
281*cdf0e10cSrcweir 	virtual void        ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
282*cdf0e10cSrcweir     virtual void        WriteAttributesSvIdl( SvIdlDataBase & rBase,
283*cdf0e10cSrcweir                                               SvStream & rOutStm, sal_uInt16 nTab );
284*cdf0e10cSrcweir     virtual void        WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
285*cdf0e10cSrcweir 			 						 	WriteType, WriteAttribute = 0);
286*cdf0e10cSrcweir #endif
287*cdf0e10cSrcweir };
288*cdf0e10cSrcweir SV_DECL_IMPL_REF(SvMetaExtern)
289*cdf0e10cSrcweir SV_DECL_IMPL_PERSIST_LIST(SvMetaExtern,SvMetaExtern *)
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir #endif // _BASOBJ_HXX
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir 
295