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