xref: /AOO41X/main/rsc/inc/rscinst.hxx (revision f7c60c9c54b9df31f919e125fa03a7515f4855a8)
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 #ifndef _RSCINST_HXX
24 #define _RSCINST_HXX
25 
26 #include <rscall.h>
27 #include <rscerror.h>
28 #include <rsctools.hxx>
29 
30 /******************* C l a s s e s   F o r w a r d s *********************/
31 class RscTypCont;
32 class RscCmdLine;
33 class REResourceList;
34 class RscTop;
35 class RscInstCopy;
36 
37 /******************* F u n c t i o n   F o r w a r d s *******************/
38 Atom HashId( const char * );          // Gibt zu einem String eine HashId
39 const char * GetHashString( Atom ); // Gibt zu einer Atom einen String
40                                       // NULL, wenn kein Eintrag vorhanden
41 
42 /******************* S t r u c t s ***************************************/
43 
44 /****************** C L A S S E S ****************************************/
45 class RscInst
46 {
47     void            MakeCopy( RSCINST aCopyInst );
48     static RSCINST  GetSysLangInst( RSCINST & rInst );
49 public:
50     RSCINST     aInst;
51 
52                 RscInst();
53                 RscInst( const RscInst & rInst );
54                 RscInst( RSCINST aTmpI );
55     RscInst&    operator =  ( const RscInst& rRscInst );
56                 ~RscInst();
57     void        OverWrite( RscInstCopy & rInst );
IsInst() const58     sal_Bool        IsInst() const { return( aInst.IsInst() ); }
59 
60                 // Listen Methoden
61     ERRTYPE     SetElement( const RscId & rName, RscInstCopy & rInst );
62     ERRTYPE     SetPosEle( sal_uInt32 nPos, RscInstCopy & rInst );
63     ERRTYPE     SetPosRscId( sal_uInt32 nPos, const RscId & rId );
64     SUBINFO_STRUCT  GetInfoEle( sal_uInt32 nPos );
65     sal_uInt32      GetCount();
66     RscInst     GetElement( RscTop * pClass, const RscId & rName );
67     RscInst     GetPosEle( sal_uInt32 nPos );
68     ERRTYPE     MovePosEle( sal_uInt32 nDestPos, sal_uInt32 nSourcePos );
69     ERRTYPE     DeleteElement( RscTop * pClass, const RscId & rName );
70     ERRTYPE     DeletePosEle( sal_uInt32 nPos );
71 
72     ERRTYPE     SetVar( Atom nVarName, RscInstCopy & rInst );
73     ERRTYPE     SetConst( Atom nVarName, Atom nConstId );
74     ERRTYPE     SetBool( Atom nVarName, sal_Bool );
75 
76     // Hack fuer X, Y, Width, Height
77     static ERRTYPE SetCorrectValues( RSCINST & rInst, RSCINST & rVarInst,
78                                     sal_Int32 lValue, sal_uInt32 nTupelIdx );
79     ERRTYPE     SetNumber( Atom nVarName, sal_Int32 );
80 
81     ERRTYPE     SetString( Atom nVarName, const char * );
82     ERRTYPE     SetConst( Atom nConstId );
83     ERRTYPE     SetBool( sal_Bool );
84     ERRTYPE     SetNumber( sal_Int32 );
85     ERRTYPE     SetString( const char * );
86     ERRTYPE     SetRef( const RscId & rRscId );
87     ERRTYPE     SetDefault( Atom nVarName );
88 
89     RscInst     GetVar( Atom nVarName );
90     Atom        GetConst( Atom nVarName = InvalidAtom );
91     sal_uInt32      GetConstPos( Atom nVarName = InvalidAtom );
92     sal_Bool        GetBool( Atom nVarName = InvalidAtom );
93 
94     // Hack fuer X, Y, Width, Height
95     static sal_Int32 GetCorrectValues( RSCINST & rInst, RSCINST & rVarInst,
96                                     sal_uInt32 nTupelIdx );
97     sal_Int32       GetNumber( Atom nVarName = InvalidAtom );
98 
99     const char *GetString( Atom nVarName = InvalidAtom );
100     RscId       GetRef();
101     sal_Bool        IsDefault( Atom nVarName );
102     sal_Bool        IsConsistent( RscInconsList * pList );
103 
104     Atom        GetClassEnum( Atom nVarName, sal_uInt32 nPos );
105     Atom        GetClassEnum( sal_uInt32 nPos );
GetClassType()106     RscTop *    GetClassType(){ return aInst.pClass; };
107     Atom        GetClassName();
108     void        EnumClassVariables( void * pData, VarEnumCallbackProc ) const;
109     ERRTYPE     WriteRc( RscWriteRc & aMem );
110 };
111 
112 class RscInstCopy : public RscInst {
113     void        MakeCopy( RSCINST aCopyInst );
114 public:
115                 RscInstCopy();
116                 RscInstCopy( const RscInstCopy & rInst );
117                 RscInstCopy( const RscInst & rInst );
118                 RscInstCopy( RSCINST aTmpI );
119                 RscInstCopy( RscTop * pNewType, const RscInst & rInst );
120     RscInstCopy&    operator =  ( const RscInstCopy & rRscInst );
121     RscInstCopy&    operator =  ( const RscInst & rRscInst );
122                 ~RscInstCopy();
123 };
124 
125 class RscDataBase
126 {
127 friend class RscHrc;
128 friend class RscSrc;
129 friend class RscInst;
130 
131     RscCmdLine  * pCmdLine;
132     RscTypCont  * pTC;
133     LanguageType   nLangType;
134 public:
135                 RscDataBase( RscError * );
136                 ~RscDataBase();
137 
138 //  void        SetLanguage( LanguageType nTyp ) { nLangType = nTyp; }
139     void        SetLanguage( Atom nId );
140     Atom        GetLanguage() const;
141 
142     ByteString  GetPath() const;
143     void        SetPath( const ByteString & rPath );
144                 // Konvertiert einen Namen in einen Typ
145     RscTop*     GetClassType( Atom nClassName );
146                 // Instanz einer Klasse erzeugen
147     sal_Bool        MakeConsistent( RscInconsList * pList );
148                 // Array mit Dateinamen
149     RscFileTab* GetFileTab();
150                 // Eine Dateinamen-Instanz holen
151     RscFile *   GetFileStruct( sal_uLong lKey );
152 
153     sal_uLong       AddSrcFile( const ByteString & rFileName );
154     sal_uLong       AddHrcFile( const ByteString & rFileName );
155                 // Traegt die Include-Dateien in die Abhaengigkeitsliste
156                 // von lFileKey ein
157     void        ScanForIncFiles( sal_uLong lFileKey );
158     void        RemoveFile( sal_uLong lKey );
159 
160                 // Suche ueber alle DEFINES
161     RscDefine * FindDef( const ByteString & rName );
162     sal_uLong       GetFileKey( const ByteString & rFileName );
163 };
164 
165 class RscHrc
166 {
167 protected:
168     sal_uLong         lFileKey; // Index der Instanz
169     RscDataBase * pDataBase;// Datenbasis
170 public:
171 
172                 // Kompilerinstanz erzeugen
173                 RscHrc( RscDataBase * pDBase, sal_uLong lKey );
174                 ~RscHrc();
175 
176                 // Daten von Datei uebernehmen
177     ERRTYPE     ReadFile();
178 
GetFileKey() const179     sal_uLong       GetFileKey() const { return lFileKey; }
180 
181     void        SetDirty( sal_Bool bSet );
182     sal_Bool        IsDirty();
183     void        SetPathName( const ByteString & );
184     ByteString  GetPathName();
185     void        SetFileName( const ByteString & );
186     ByteString  GetFileName();
187 
188                 //Depend-Datei anhaengen
189     void        InsertDepend( sal_uLong lKey, sal_uLong lPos );
190 
191                 // DefineList holen
192     RscDefineList * GetDefineList();
193                 // Suche ueber all DEFINES im Zugriff
194     RscDefine * FindDef( const ByteString & rName );
195     ERRTYPE     NewDef( const ByteString & rMacroName, sal_Int32 lValue,
196                         sal_uLong lPos );
197     ERRTYPE     NewDef( const ByteString & rMacroName, const ByteString & rMacro,
198                         sal_uLong lPos );
199     ERRTYPE     ChangeDef( const ByteString & rMacroName, sal_Int32 lValue );
200     ERRTYPE     ChangeDef( const ByteString & rMacroName,
201                            const ByteString & rMacro );
202     sal_Bool        IsDefUsed( const ByteString & );
203     void        DeleteDef( const ByteString & rMacroName );
204     ERRTYPE     ChangeDefName( const ByteString & rMacroName,
205                                const ByteString & rNewName );
206 
207                 // Dateinamen-Instanz holen
208     RscFile *   GetFileStruct();
209                 //Abhaengigkeitsliste holen holen
210     RscDependList *   GetDependList();
211 
212                 // Datei schreiben
213     ERRTYPE     WriteFile();
214 };
215 
216 class RscSrc : public RscHrc {
217 public:
218             // Kompilerinstanz erzeugen
219             RscSrc( RscDataBase * pDBase, sal_uLong lKey );
220             ~RscSrc();
221 
222 
223     RscInstCopy CreateRscInst( RscTop * pClass );
224                 // Instanz loeschen
225     ERRTYPE     DeleteRscInst( RscTop * pClass, const RscId & rInstName );
226                 // Datenbasis nach Define Veraenderung wiederherstellen
227     //Instanz global zur Verfuegung stellen
228     ERRTYPE SetRscInst( const RscId & rInstName, RscInstCopy & );
229     //Instanz holen
230     RscInst GetRscInst( RscTop* pClass, const RscId & rInstName );
231 
232     // Namen und Identifier Liste fuellen
233     void    FillNameIdList( REResourceList * pList );
234 
235             // C++ Resourcekonstruktor schreiben
236     ERRTYPE WriteCxxFile( const ByteString &, const ByteString & rHxxName );
237     ERRTYPE WriteHxxFile( const ByteString & );     // C++ Klasskopf schreiben
238 };
239 
240 #endif //_RSCINST_HXX
241