xref: /AOO41X/main/idl/inc/basobj.hxx (revision 67e470dafe1997e73f56ff7ff4878983707e3e07)
1*f3ea6674SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f3ea6674SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f3ea6674SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f3ea6674SAndrew Rist  * distributed with this work for additional information
6*f3ea6674SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f3ea6674SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f3ea6674SAndrew Rist  * "License"); you may not use this file except in compliance
9*f3ea6674SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*f3ea6674SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*f3ea6674SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f3ea6674SAndrew Rist  * software distributed under the License is distributed on an
15*f3ea6674SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f3ea6674SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f3ea6674SAndrew Rist  * specific language governing permissions and limitations
18*f3ea6674SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*f3ea6674SAndrew Rist  *************************************************************/
21*f3ea6674SAndrew Rist 
22*f3ea6674SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _BASOBJ_HXX
25cdf0e10cSrcweir #define _BASOBJ_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/ref.hxx>
28cdf0e10cSrcweir #include <bastype.hxx>
29cdf0e10cSrcweir #include <tools/pstm.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir class SvTokenStream;
32cdf0e10cSrcweir class SvMetaObject;
33cdf0e10cSrcweir class SvAttributeList;
34cdf0e10cSrcweir class SvIdlDataBase;
35cdf0e10cSrcweir 
36cdf0e10cSrcweir typedef SvMetaObject * (*CreateMetaObjectType)();
37cdf0e10cSrcweir #define IDL_WRITE_COMPILER  0x8000
38cdf0e10cSrcweir #define IDL_WRITE_BROWSER   0x4000
39cdf0e10cSrcweir #define IDL_WRITE_CALLING   0x2000
40cdf0e10cSrcweir #define IDL_WRITE_MASK      0xE000
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #define C_PREF	"C_"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir enum WriteType
45cdf0e10cSrcweir {
46cdf0e10cSrcweir 	WRITE_IDL, WRITE_ODL, WRITE_SLOTMAP, WRITE_C_HEADER, WRITE_C_SOURCE,
47cdf0e10cSrcweir 	WRITE_CXX_HEADER, WRITE_CXX_SOURCE, WRITE_DOCU
48cdf0e10cSrcweir };
49cdf0e10cSrcweir 
50cdf0e10cSrcweir enum
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	WA_METHOD = 0x1,	WA_VARIABLE = 0x2,	WA_ARGUMENT = 0x4,
53cdf0e10cSrcweir 	WA_STRUCT = 0x8,	WA_READONLY = 0x10
54cdf0e10cSrcweir };
55cdf0e10cSrcweir typedef int WriteAttribute;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir /******************** Meta Factory **************************************/
58cdf0e10cSrcweir #ifdef IDL_COMPILER
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #define PRV_SV_DECL_META_FACTORY( Class )                               \
61cdf0e10cSrcweir     static SvAttributeList * pAttribList;                               \
62cdf0e10cSrcweir     static SvMetaObject * Create() { return new Class; }                \
63cdf0e10cSrcweir     static const char *   GetClassName() { return #Class; }
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #define PRV_SV_IMPL_META_FACTORY( Class )                               \
66cdf0e10cSrcweir     SvAttributeList * Class::pAttribList = NULL;
67cdf0e10cSrcweir 
68cdf0e10cSrcweir #else
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #define PRV_SV_DECL_META_FACTORY( Class )
71cdf0e10cSrcweir 
72cdf0e10cSrcweir #define PRV_SV_IMPL_META_FACTORY( Class )
73cdf0e10cSrcweir 
74cdf0e10cSrcweir #endif // IDL_COMPILER
75cdf0e10cSrcweir 
76cdf0e10cSrcweir #define SV_DECL_META_FACTORY( Class, CLASS_ID )                         \
77cdf0e10cSrcweir     SV_DECL_PERSIST( Class, CLASS_ID )                                  \
78cdf0e10cSrcweir     PRV_SV_DECL_META_FACTORY( Class )
79cdf0e10cSrcweir 
80cdf0e10cSrcweir 
81cdf0e10cSrcweir #define SV_DECL_META_FACTORY1( Class, Super1, CLASS_ID )                \
82cdf0e10cSrcweir     SV_DECL_PERSIST1( Class, Super1, CLASS_ID )                         \
83cdf0e10cSrcweir     PRV_SV_DECL_META_FACTORY( Class )
84cdf0e10cSrcweir 
85cdf0e10cSrcweir #define SV_IMPL_META_FACTORY( Class )                                   \
86cdf0e10cSrcweir     PRV_SV_IMPL_META_FACTORY( Class )                                   \
87cdf0e10cSrcweir     SV_IMPL_PERSIST( Class )
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90cdf0e10cSrcweir #define SV_IMPL_META_FACTORY1( Class, Super1 )                          \
91cdf0e10cSrcweir     PRV_SV_IMPL_META_FACTORY( Class )                                   \
92cdf0e10cSrcweir     SV_IMPL_PERSIST1( Class, Super1 )
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /******************** class SvMetaObject ********************************/
96cdf0e10cSrcweir class SvMetaObject : public SvPersistBase
97cdf0e10cSrcweir {
98cdf0e10cSrcweir public:
99cdf0e10cSrcweir             SV_DECL_META_FACTORY1( SvMetaObject, SvPersistBase, 14 )
100cdf0e10cSrcweir             SvMetaObject();
101cdf0e10cSrcweir 
102cdf0e10cSrcweir #ifdef IDL_COMPILER
103cdf0e10cSrcweir     static void			WriteTab( SvStream & rOutStm, sal_uInt16 nTab );
104cdf0e10cSrcweir 	static sal_Bool			TestAndSeekSpaceOnly( SvStream &, sal_uLong nBegPos );
105cdf0e10cSrcweir 	static void			Back2Delemitter( SvStream & );
106cdf0e10cSrcweir 	static void 		WriteStars( SvStream & );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir     virtual sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
109cdf0e10cSrcweir     virtual void        WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     virtual void        Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
112cdf0e10cSrcweir 	 						   WriteType, WriteAttribute = 0 );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir     virtual void        WriteCxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
115cdf0e10cSrcweir     virtual void        WriteHxx( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
116cdf0e10cSrcweir #endif
117cdf0e10cSrcweir };
118cdf0e10cSrcweir SV_DECL_IMPL_REF(SvMetaObject)
119cdf0e10cSrcweir //SV_DECL_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
120cdf0e10cSrcweir SV_DECL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
121cdf0e10cSrcweir SV_IMPL_PERSIST_LIST(SvMetaObject,SvMetaObject *)
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir class SvMetaObjectMemberStack
125cdf0e10cSrcweir {
126cdf0e10cSrcweir     SvMetaObjectMemberList aList;
127cdf0e10cSrcweir public:
SvMetaObjectMemberStack()128cdf0e10cSrcweir             SvMetaObjectMemberStack() {;}
129cdf0e10cSrcweir 
Push(SvMetaObject * pObj)130cdf0e10cSrcweir     void            Push( SvMetaObject * pObj )
131cdf0e10cSrcweir                     { aList.Insert( pObj, LIST_APPEND ); }
Pop()132cdf0e10cSrcweir     SvMetaObject *  Pop() { return aList.Remove( aList.Count() -1 ); }
Top() const133cdf0e10cSrcweir     SvMetaObject *  Top() const { return aList.GetObject( aList.Count() -1 ); }
Clear()134cdf0e10cSrcweir     void            Clear() { aList.Clear(); }
Count() const135cdf0e10cSrcweir     sal_uLong     Count() const { return aList.Count(); }
136cdf0e10cSrcweir 
Get(TypeId nType)137cdf0e10cSrcweir     SvMetaObject *  Get( TypeId nType )
138cdf0e10cSrcweir                     {
139cdf0e10cSrcweir                         SvMetaObject * pObj = aList.Last();
140cdf0e10cSrcweir                         while( pObj )
141cdf0e10cSrcweir                         {
142cdf0e10cSrcweir                             if( pObj->IsA( nType ) )
143cdf0e10cSrcweir                                 return pObj;
144cdf0e10cSrcweir                             pObj = aList.Prev();
145cdf0e10cSrcweir                         }
146cdf0e10cSrcweir                         return NULL;
147cdf0e10cSrcweir                     }
148cdf0e10cSrcweir };
149cdf0e10cSrcweir 
150cdf0e10cSrcweir /******************** class SvMetaName **********************************/
151cdf0e10cSrcweir class SvMetaName : public SvMetaObject
152cdf0e10cSrcweir {
153cdf0e10cSrcweir     SvString      aName;
154cdf0e10cSrcweir     SvHelpContext aHelpContext;
155cdf0e10cSrcweir     SvHelpText    aHelpText;
156cdf0e10cSrcweir     SvString      aConfigName;
157cdf0e10cSrcweir     SvString      aDescription;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir protected:
160cdf0e10cSrcweir #ifdef IDL_COMPILER
161cdf0e10cSrcweir     virtual sal_Bool ReadNameSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
162cdf0e10cSrcweir     		void DoReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm,
163cdf0e10cSrcweir 									 char c = '\0' );
164cdf0e10cSrcweir     virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
165cdf0e10cSrcweir     virtual void WriteContextSvIdl( SvIdlDataBase & rBase,
166cdf0e10cSrcweir                                     SvStream & rOutStm, sal_uInt16 nTab );
167cdf0e10cSrcweir     virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase,
168cdf0e10cSrcweir                                       SvTokenStream & rInStm );
169cdf0e10cSrcweir     virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase,
170cdf0e10cSrcweir                                        SvStream & rOutStm, sal_uInt16 nTab );
171cdf0e10cSrcweir     virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
172cdf0e10cSrcweir 	 						   		WriteType, WriteAttribute = 0);
173cdf0e10cSrcweir     virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
174cdf0e10cSrcweir 	 						   		WriteType, WriteAttribute = 0);
175cdf0e10cSrcweir #endif
176cdf0e10cSrcweir public:
177cdf0e10cSrcweir             SV_DECL_META_FACTORY1( SvMetaName, SvMetaObject, 15 )
178cdf0e10cSrcweir             SvMetaName();
179cdf0e10cSrcweir 
180cdf0e10cSrcweir     virtual sal_Bool        		SetName( const ByteString & rName, SvIdlDataBase * = NULL  );
SetDescription(const ByteString & rText)181cdf0e10cSrcweir     void        				SetDescription( const ByteString& rText )
182cdf0e10cSrcweir 								{ aDescription = rText; }
GetHelpContext() const183cdf0e10cSrcweir     const SvHelpContext& 		GetHelpContext() const { return aHelpContext; }
GetName() const184cdf0e10cSrcweir     virtual const SvString &    GetName() const { return aName; }
GetHelpText() const185cdf0e10cSrcweir     virtual const SvString &    GetHelpText() const { return aHelpText; }
GetConfigName() const186cdf0e10cSrcweir     virtual const SvString &	GetConfigName() const{ return aConfigName; }
GetDescription() const187cdf0e10cSrcweir     virtual const SvString&     GetDescription() const{ return aDescription; }
188cdf0e10cSrcweir 
189cdf0e10cSrcweir #ifdef IDL_COMPILER
190cdf0e10cSrcweir 	virtual sal_Bool 		Test( SvIdlDataBase &, SvTokenStream & rInStm );
191cdf0e10cSrcweir     virtual sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
192cdf0e10cSrcweir     virtual void        WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
193cdf0e10cSrcweir     virtual void        Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
194cdf0e10cSrcweir 	 						  		WriteType, WriteAttribute = 0);
195cdf0e10cSrcweir 	void				WriteDescription( SvStream& rOutStm );
196cdf0e10cSrcweir #endif
197cdf0e10cSrcweir };
198cdf0e10cSrcweir SV_DECL_IMPL_REF(SvMetaName)
199cdf0e10cSrcweir SV_DECL_IMPL_PERSIST_LIST(SvMetaName,SvMetaName *)
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 
202cdf0e10cSrcweir /******************** class SvMetaReference *****************************/
203cdf0e10cSrcweir SV_DECL_REF(SvMetaReference)
204cdf0e10cSrcweir class SvMetaReference : public SvMetaName
205cdf0e10cSrcweir {
206cdf0e10cSrcweir protected:
207cdf0e10cSrcweir     SvMetaReferenceRef  aRef;
208cdf0e10cSrcweir public:
209cdf0e10cSrcweir             SV_DECL_META_FACTORY1( SvMetaReference, SvMetaName, 17 )
210cdf0e10cSrcweir             SvMetaReference();
211cdf0e10cSrcweir 
GetName() const212cdf0e10cSrcweir     const SvString &    GetName() const
213cdf0e10cSrcweir                         {
214cdf0e10cSrcweir 							return ( !aRef.Is()
215cdf0e10cSrcweir 									|| SvMetaName::GetName().Len() )
216cdf0e10cSrcweir 								? SvMetaName::GetName()
217cdf0e10cSrcweir 								: aRef->GetName();
218cdf0e10cSrcweir                         }
219cdf0e10cSrcweir 
GetHelpText() const220cdf0e10cSrcweir     const SvString &    GetHelpText() const
221cdf0e10cSrcweir 						{
222cdf0e10cSrcweir 							return ( !aRef.Is()
223cdf0e10cSrcweir 									|| SvMetaName::GetHelpText().Len() )
224cdf0e10cSrcweir 								? SvMetaName::GetHelpText()
225cdf0e10cSrcweir 								: aRef->GetHelpText();
226cdf0e10cSrcweir 						}
227cdf0e10cSrcweir 
GetConfigName() const228cdf0e10cSrcweir     const SvString &    GetConfigName() const
229cdf0e10cSrcweir 						{
230cdf0e10cSrcweir 							return ( !aRef.Is()
231cdf0e10cSrcweir 									|| SvMetaName::GetConfigName().Len() )
232cdf0e10cSrcweir 								? SvMetaName::GetConfigName()
233cdf0e10cSrcweir 								: aRef->GetConfigName();
234cdf0e10cSrcweir 						}
235cdf0e10cSrcweir 
GetDescription() const236cdf0e10cSrcweir     const SvString &    GetDescription() const
237cdf0e10cSrcweir 						{
238cdf0e10cSrcweir 							return ( !aRef.Is()
239cdf0e10cSrcweir 									|| SvMetaName::GetDescription().Len() )
240cdf0e10cSrcweir 								? SvMetaName::GetDescription()
241cdf0e10cSrcweir 								: aRef->GetDescription();
242cdf0e10cSrcweir 						}
GetRef() const243cdf0e10cSrcweir     SvMetaReference *   GetRef() const { return aRef; }
SetRef(SvMetaReference * pRef)244cdf0e10cSrcweir     void                SetRef( SvMetaReference * pRef  )
245cdf0e10cSrcweir                         { aRef = pRef; }
246cdf0e10cSrcweir };
247cdf0e10cSrcweir SV_IMPL_REF(SvMetaReference)
248cdf0e10cSrcweir SV_DECL_IMPL_PERSIST_LIST(SvMetaReference,SvMetaReference *)
249cdf0e10cSrcweir 
250cdf0e10cSrcweir 
251cdf0e10cSrcweir /******************** class SvMetaExtern *********************************/
252cdf0e10cSrcweir class SvMetaModule;
253cdf0e10cSrcweir class SvMetaExtern : public SvMetaReference
254cdf0e10cSrcweir {
255cdf0e10cSrcweir     SvMetaModule *          pModule;    // in welchem Modul enthalten
256cdf0e10cSrcweir 
257cdf0e10cSrcweir     SvUUId                  aUUId;
258cdf0e10cSrcweir     SvVersion               aVersion;
259cdf0e10cSrcweir 	sal_Bool					bReadUUId;
260cdf0e10cSrcweir 	sal_Bool					bReadVersion;
261cdf0e10cSrcweir public:
262cdf0e10cSrcweir                         SV_DECL_META_FACTORY1( SvMetaExtern, SvMetaName, 16 )
263cdf0e10cSrcweir                         SvMetaExtern();
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     SvMetaModule *      GetModule() const;
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     const SvGlobalName &GetUUId() const;
GetVersion() const268cdf0e10cSrcweir     const SvVersion &   GetVersion() const { return aVersion; }
269cdf0e10cSrcweir #ifdef IDL_COMPILER
270cdf0e10cSrcweir     void				SetModule( SvIdlDataBase & rBase );
271cdf0e10cSrcweir     virtual sal_Bool        ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
272cdf0e10cSrcweir     virtual void        WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
273cdf0e10cSrcweir 
274cdf0e10cSrcweir     virtual void        Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
275cdf0e10cSrcweir 	 						 	WriteType, WriteAttribute = 0);
276cdf0e10cSrcweir protected:
277cdf0e10cSrcweir 	virtual void        ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
278cdf0e10cSrcweir     virtual void        WriteAttributesSvIdl( SvIdlDataBase & rBase,
279cdf0e10cSrcweir                                               SvStream & rOutStm, sal_uInt16 nTab );
280cdf0e10cSrcweir     virtual void        WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
281cdf0e10cSrcweir 			 						 	WriteType, WriteAttribute = 0);
282cdf0e10cSrcweir #endif
283cdf0e10cSrcweir };
284cdf0e10cSrcweir SV_DECL_IMPL_REF(SvMetaExtern)
285cdf0e10cSrcweir SV_DECL_IMPL_PERSIST_LIST(SvMetaExtern,SvMetaExtern *)
286cdf0e10cSrcweir 
287cdf0e10cSrcweir 
288cdf0e10cSrcweir #endif // _BASOBJ_HXX
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 
291