xref: /AOO41X/main/rsc/inc/rscrsc.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 _RSCRSC_HXX
24 #define _RSCRSC_HXX
25 
26 #ifndef RSCALL_H
27 #include <rscall.h>
28 #endif
29 #ifndef RSCERROR_H
30 #include <rscerror.h>
31 #endif
32 #ifndef RSCTOOLS_HXX
33 #include <rsctools.hxx>
34 #endif
35 
36 #include <list>
37 
38 class RscTypCont;
39 class DirEntry;
40 
41 /****************** T Y P E S ********************************************/
42 
43 #define MAX_INPUTFILES  100
44 #define MAX_SYMBOLS     10
45 #define MAX_INCLUDES    10
46 
47 /****************** R s c C m d L i n e **********************************/
48 class RscCmdLine
49 {
50     void        Init();
51 
52 public:
53 
54     RscStrList          aInputList;     // Liste der Quelldateien
55     RscStrList          aSymbolList;    // Liste der Symbole
56     ByteString          aPath;          // Liste der Pfade
57     RSCBYTEORDER_TYPE   nByteOrder;
58     unsigned short      nCommands;      // Steuerbits
59     ByteString          aOutputLst;     // Name der List-Ausgabedatei
60     ByteString          aOutputSrs;     // Name der Srs-Ausgabedatei
61     ByteString          aOutputSrc;     // Name der Src-Ausgabedatei
62     ByteString          aOutputRcCtor;  // Name der Ctor-Ausgabedatei
63     ByteString          aOutputCxx;     // Name der Cxx-Ausgabedatei
64     ByteString          aOutputHxx;     // Name der Hxx-Ausgabedatei
65     ByteString          aTouchFile;     // create this file when done in rsc2
66     ByteString          aILDir;
67 
68     struct OutputFile
69     {
70         ByteString                   aLangName;         // language name
71         ByteString                   aOutputRc;         // target file
72         ByteString                   aLangSearchPath;   // language specific search path
73         ::std::list< ByteString >    aSysSearchDirs;    // pathes to search for images
74 
OutputFileRscCmdLine::OutputFile75         OutputFile() {}
76     };
77 
78     std::list<OutputFile>                                   m_aOutputFiles;
79     std::list< std::pair< rtl::OString, rtl::OString > >    m_aReplacements;
80 
81                     RscCmdLine( int argc, char ** argv, RscError * pEH );
82                     RscCmdLine();
83 
84                     ~RscCmdLine();
85 
86   ::rtl::OString     substitutePaths( const ::rtl::OString& rIn );
87 };
88 /****************** R s c ************************************************/
89 
90 struct WriteRcContext;
91 
92 class RscCompiler
93 {
94 private:
95     RscStrList      aTmpFileList;   // Liste der Tmp-Dateien
96     ByteString      aTmpOutputHxx;  // Name der TempHxx-Ausgabedatei
97     ByteString      aTmpOutputCxx;  // Name der TempCxx-Ausgabedatei
98     ByteString      aTmpOutputRcCtor; // Name der Temp Ctor-Ausgabedatei
99     ByteString      aTmpOutputSrc;  // Name der TempSrc-Ausgabedatei
100 
101     void            CreateResFile( const char * pRc );
102     void            Append( const ByteString& rOutputSrs, const ByteString& rTmpFile );
103     void            OpenInput( const ByteString& rInput );
104 
105     bool            GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile,
106                                     const WriteRcContext& rContext,
107                                     const ByteString& rBaseFileName,
108                                     ByteString& rImagePath,
109                                     FILE* pSysListFile );
110     void            PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile,
111                                        const WriteRcContext& rContext,
112                                        const DirEntry& rSrsInPath,
113                                        const DirEntry& rSrsOutPath );
114 
115 public:
116     RscTypCont*     pTC;        // String und Id-Verwalter
117     RscCmdLine*     pCL;        // Kommandozeile
118     FILE *          fListing;   // Ausgabedatei fuer Listings
119     FILE *          fExitFile;  // bei Abbruch muss diese Datei geschlossen werden
120 
121                     RscCompiler( RscCmdLine *, RscTypCont * );
122                     ~RscCompiler();
123 
124     ERRTYPE         Start();
125     ByteString      GetTmpFileName();   // Die Dateien werden geloescht
126 
127                     // Include Statements lesen
128     ERRTYPE         IncludeParser( sal_uLong lFileKey );
129     ERRTYPE         ParseOneFile( sal_uLong lFileKey, const RscCmdLine::OutputFile* pOutputFile, const WriteRcContext* pContext );
130     ERRTYPE         Link();
131     void            EndCompile();
132 };
133 
134 #endif //_RSCRSC_HXX
135