Update ooo320-m1
[ooovba.git] / transex3 / inc / cfgmerge.hxx
blobc0efa6e2e3c2aa93fb04ed681b146ae491ae9413
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cfgmerge.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CFG_MERGE_HXX
32 #define _CFG_MERGE_HXX
34 #include <tools/string.hxx>
35 #include <tools/list.hxx>
36 #include <hash_map>
38 typedef std::hash_map<ByteString , ByteString , hashByteString,equalByteString>
39 ByteStringHashMap;
43 // class CfgStackData
46 class CfgStackData
48 friend class CfgParser;
49 friend class CfgExport;
50 friend class CfgMerge;
51 private:
52 ByteString sTagType;
53 ByteString sIdentifier;
55 ByteString sResTyp;
57 ByteString sTextTag;
58 ByteString sEndTextTag;
60 ByteStringHashMap sText;
61 public:
62 CfgStackData( const ByteString &rTag, const ByteString &rId )
63 : sTagType( rTag ), sIdentifier( rId ) {};
65 ByteString &GetTagType() { return sTagType; }
66 ByteString &GetIdentifier() { return sIdentifier; }
71 // class CfgStack
74 DECLARE_LIST( CfgStackList, CfgStackData * )
76 class CfgStack : public CfgStackList
78 public:
79 CfgStack() : CfgStackList( 10, 10 ) {}
80 ~CfgStack();
82 ULONG Push( CfgStackData *pStackData );
83 CfgStackData *Push( const ByteString &rTag, const ByteString &rId );
84 CfgStackData *Pop() { return Remove( Count() - 1 ); }
86 CfgStackData *GetStackData( ULONG nPos = LIST_APPEND );
88 ByteString GetAccessPath( ULONG nPos = LIST_APPEND );
92 // class CfgParser
95 class CfgParser
97 protected:
98 ByteString sCurrentResTyp;
99 ByteString sCurrentIsoLang;
100 ByteString sCurrentText;
102 ByteString sLastWhitespace;
104 CfgStack aStack;
105 CfgStackData *pStackData;
107 BOOL bLocalize;
109 virtual void WorkOnText(
110 ByteString &rText,
111 const ByteString &nLangIndex )=0;
113 virtual void WorkOnRessourceEnd()=0;
115 virtual void Output( const ByteString& rOutput )=0;
117 void Error( const ByteString &rError );
119 private:
120 int ExecuteAnalyzedToken( int nToken, char *pToken );
121 std::vector<ByteString> aLanguages;
122 void AddText(
123 ByteString &rText,
124 const ByteString &rIsoLang,
125 const ByteString &rResTyp );
127 BOOL IsTokenClosed( const ByteString &rToken );
129 public:
130 CfgParser();
131 virtual ~CfgParser();
133 int Execute( int nToken, char * pToken );
137 // class CfgOutputParser
140 class CfgOutputParser : public CfgParser
142 protected:
143 SvFileStream *pOutputStream;
144 public:
145 CfgOutputParser ( const ByteString &rOutputFile );
146 virtual ~CfgOutputParser();
150 // class CfgExport
153 class CfgExport : public CfgOutputParser
155 private:
156 ByteString sPrj;
157 ByteString sPath;
158 std::vector<ByteString> aLanguages;
159 protected:
160 void WorkOnText(
161 ByteString &rText,
162 const ByteString &rIsoLang
165 void WorkOnRessourceEnd();
166 void Output( const ByteString& rOutput );
167 public:
168 CfgExport(
169 const ByteString &rOutputFile,
170 const ByteString &rProject,
171 const ByteString &rFilePath
173 ~CfgExport();
177 // class CfgMerge
180 class CfgMerge : public CfgOutputParser
182 private:
183 MergeDataFile *pMergeDataFile;
184 std::vector<ByteString> aLanguages;
185 ResData *pResData;
187 BOOL bGerman;
188 ByteString sFilename;
189 BOOL bEnglish;
191 protected:
192 void WorkOnText(
193 ByteString &rText,
194 const ByteString &nLangIndex );
196 void WorkOnRessourceEnd();
198 void Output( const ByteString& rOutput );
199 public:
200 CfgMerge(
201 const ByteString &rMergeSource,
202 const ByteString &rOutputFile,
203 ByteString &rFilename
205 ~CfgMerge();
208 #endif