Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _BASOBJ_HXX
21 : #define _BASOBJ_HXX
22 :
23 : #include <tools/ref.hxx>
24 : #include <bastype.hxx>
25 : #include <tools/pstm.hxx>
26 :
27 : class SvTokenStream;
28 : class SvMetaObject;
29 : class SvIdlDataBase;
30 :
31 : typedef SvMetaObject * (*CreateMetaObjectType)();
32 : #define IDL_WRITE_COMPILER 0x8000
33 : #define IDL_WRITE_BROWSER 0x4000
34 : #define IDL_WRITE_CALLING 0x2000
35 : #define IDL_WRITE_MASK 0xE000
36 :
37 : #define C_PREF "C_"
38 :
39 : enum WriteType
40 : {
41 : WRITE_IDL, WRITE_ODL, WRITE_SLOTMAP, WRITE_C_HEADER, WRITE_C_SOURCE,
42 : WRITE_CXX_HEADER, WRITE_CXX_SOURCE, WRITE_DOCU
43 : };
44 :
45 : enum
46 : {
47 : WA_METHOD = 0x1, WA_VARIABLE = 0x2, WA_ARGUMENT = 0x4,
48 : WA_STRUCT = 0x8, WA_READONLY = 0x10
49 : };
50 : typedef int WriteAttribute;
51 :
52 : #define SV_DECL_META_FACTORY1( Class, Super1, CLASS_ID ) \
53 : SV_DECL_PERSIST1( Class, Super1, CLASS_ID )
54 :
55 : #define SV_IMPL_META_FACTORY1( Class, Super1 ) \
56 : SV_IMPL_PERSIST1( Class, Super1 )
57 :
58 24787 : class SvMetaObject : public SvPersistBase
59 : {
60 : public:
61 8 : SV_DECL_META_FACTORY1( SvMetaObject, SvPersistBase, 14 )
62 : SvMetaObject();
63 :
64 : static void WriteTab( SvStream & rOutStm, sal_uInt16 nTab );
65 : static sal_Bool TestAndSeekSpaceOnly( SvStream &, sal_uLong nBegPos );
66 : static void Back2Delemitter( SvStream & );
67 : static void WriteStars( SvStream & );
68 :
69 : virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
70 : virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
71 :
72 : virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
73 : WriteType, WriteAttribute = 0 );
74 : };
75 : SV_DECL_IMPL_REF(SvMetaObject)
76 :
77 16 : class SvMetaObjectMemberList : public SvDeclPersistList<SvMetaObject *> {};
78 :
79 8 : class SvMetaObjectMemberStack
80 : {
81 : SvMetaObjectMemberList aList;
82 : public:
83 8 : SvMetaObjectMemberStack() {;}
84 :
85 8 : void Push( SvMetaObject * pObj )
86 8 : { aList.push_back( pObj ); }
87 8 : SvMetaObject * Pop() { return aList.pop_back(); }
88 : SvMetaObject * Top() const { return aList.back(); }
89 : void Clear() { aList.clear(); }
90 : sal_uLong Count() const { return aList.size(); }
91 :
92 3368 : SvMetaObject * Get( TypeId nType )
93 : {
94 3368 : for( SvMetaObjectMemberList::reverse_iterator it = aList.rbegin(); it != aList.rend(); ++it )
95 3368 : if( (*it)->IsA( nType ) )
96 3368 : return *it;
97 0 : return NULL;
98 : }
99 : };
100 :
101 24787 : class SvMetaName : public SvMetaObject
102 : {
103 : SvString aName;
104 : SvHelpContext aHelpContext;
105 : SvHelpText aHelpText;
106 : SvString aConfigName;
107 : SvString aDescription;
108 :
109 : protected:
110 : virtual sal_Bool ReadNameSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
111 : void DoReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm,
112 : char c = '\0' );
113 : virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
114 : virtual void WriteContextSvIdl( SvIdlDataBase & rBase,
115 : SvStream & rOutStm, sal_uInt16 nTab );
116 : virtual void ReadAttributesSvIdl( SvIdlDataBase & rBase,
117 : SvTokenStream & rInStm );
118 : virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase,
119 : SvStream & rOutStm, sal_uInt16 nTab );
120 : virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
121 : WriteType, WriteAttribute = 0);
122 : virtual void WriteContext( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
123 : WriteType, WriteAttribute = 0);
124 : public:
125 8 : SV_DECL_META_FACTORY1( SvMetaName, SvMetaObject, 15 )
126 : SvMetaName();
127 :
128 : virtual sal_Bool SetName( const OString& rName, SvIdlDataBase * = NULL );
129 0 : void SetDescription( const OString& rText )
130 0 : { aDescription.setString(rText); }
131 5839 : const SvHelpContext& GetHelpContext() const { return aHelpContext; }
132 6082043 : virtual const SvString & GetName() const { return aName; }
133 0 : virtual const SvString & GetHelpText() const { return aHelpText; }
134 0 : virtual const SvString & GetConfigName() const{ return aConfigName; }
135 0 : virtual const SvString& GetDescription() const{ return aDescription; }
136 :
137 : virtual sal_Bool Test( SvIdlDataBase &, SvTokenStream & rInStm );
138 : virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
139 : virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
140 : virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
141 : WriteType, WriteAttribute = 0);
142 : void WriteDescription( SvStream& rOutStm );
143 : };
144 : SV_DECL_IMPL_REF(SvMetaName)
145 :
146 : class SvMetaNameMemberList : public SvDeclPersistList<SvMetaName *> {};
147 :
148 :
149 6643404 : SV_DECL_REF(SvMetaReference)
150 23459 : class SvMetaReference : public SvMetaName
151 : {
152 : protected:
153 : SvMetaReferenceRef aRef;
154 : public:
155 8 : SV_DECL_META_FACTORY1( SvMetaReference, SvMetaName, 17 )
156 : SvMetaReference();
157 :
158 3613338 : const SvString & GetName() const
159 : {
160 3613338 : return ( !aRef.Is()
161 2465609 : || !SvMetaName::GetName().getString().isEmpty() )
162 3613338 : ? SvMetaName::GetName()
163 7226676 : : aRef->GetName();
164 : }
165 :
166 0 : const SvString & GetHelpText() const
167 : {
168 0 : return ( !aRef.Is()
169 0 : || !SvMetaName::GetHelpText().getString().isEmpty() )
170 0 : ? SvMetaName::GetHelpText()
171 0 : : aRef->GetHelpText();
172 : }
173 :
174 0 : const SvString & GetConfigName() const
175 : {
176 0 : return ( !aRef.Is()
177 0 : || !SvMetaName::GetConfigName().getString().isEmpty() )
178 0 : ? SvMetaName::GetConfigName()
179 0 : : aRef->GetConfigName();
180 : }
181 :
182 0 : const SvString & GetDescription() const
183 : {
184 0 : return ( !aRef.Is()
185 0 : || !SvMetaName::GetDescription().getString().isEmpty() )
186 0 : ? SvMetaName::GetDescription()
187 0 : : aRef->GetDescription();
188 : }
189 2968291 : SvMetaReference * GetRef() const { return aRef; }
190 9631 : void SetRef( SvMetaReference * pRef )
191 9631 : { aRef = pRef; }
192 : };
193 61983 : SV_IMPL_REF(SvMetaReference)
194 :
195 : class SvMetaReferenceMemberList : public SvDeclPersistList<SvMetaReference *> {};
196 :
197 :
198 : class SvMetaModule;
199 5941 : class SvMetaExtern : public SvMetaReference
200 : {
201 : SvMetaModule * pModule; // included in which module
202 :
203 : SvUUId aUUId;
204 : SvVersion aVersion;
205 : sal_Bool bReadUUId;
206 : sal_Bool bReadVersion;
207 : public:
208 8 : SV_DECL_META_FACTORY1( SvMetaExtern, SvMetaName, 16 )
209 : SvMetaExtern();
210 :
211 : SvMetaModule * GetModule() const;
212 :
213 : const SvGlobalName &GetUUId() const;
214 : const SvVersion & GetVersion() const { return aVersion; }
215 : void SetModule( SvIdlDataBase & rBase );
216 : virtual sal_Bool ReadSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
217 : virtual void WriteSvIdl( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab );
218 :
219 : virtual void Write( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
220 : WriteType, WriteAttribute = 0);
221 : protected:
222 : virtual void ReadAttributesSvIdl( SvIdlDataBase &, SvTokenStream & rInStm );
223 : virtual void WriteAttributesSvIdl( SvIdlDataBase & rBase,
224 : SvStream & rOutStm, sal_uInt16 nTab );
225 : virtual void WriteAttributes( SvIdlDataBase & rBase, SvStream & rOutStm, sal_uInt16 nTab,
226 : WriteType, WriteAttribute = 0);
227 : };
228 : SV_DECL_IMPL_REF(SvMetaExtern)
229 :
230 : class SvMetaExternMemberList : public SvDeclPersistList<SvMetaExtern *> {};
231 :
232 : #endif // _BASOBJ_HXX
233 :
234 :
235 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|