xref: /AOO41X/main/l10ntools/inc/export.hxx (revision ca62e2c2083b5d0995f1245bad6c2edfb455fbec)
1983d4c8aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3983d4c8aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4983d4c8aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5983d4c8aSAndrew Rist  * distributed with this work for additional information
6983d4c8aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7983d4c8aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8983d4c8aSAndrew Rist  * "License"); you may not use this file except in compliance
9983d4c8aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11983d4c8aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13983d4c8aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14983d4c8aSAndrew Rist  * software distributed under the License is distributed on an
15983d4c8aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16983d4c8aSAndrew Rist  * KIND, either express or implied.  See the License for the
17983d4c8aSAndrew Rist  * specific language governing permissions and limitations
18983d4c8aSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20983d4c8aSAndrew Rist  *************************************************************/
21983d4c8aSAndrew Rist 
22983d4c8aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _EXPORT_HXX
25cdf0e10cSrcweir #define _EXPORT_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <l10ntools/directory.hxx>
28cdf0e10cSrcweir 
29*79cb83d0SHerbert Dürr #include <tagtest.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir // #define MERGE_SOURCE_LANGUAGES <- To merge en-US and de resource
32cdf0e10cSrcweir 
33cdf0e10cSrcweir #include <tools/string.hxx>
34cdf0e10cSrcweir #include <tools/list.hxx>
35cdf0e10cSrcweir #include <tools/stream.hxx>
36cdf0e10cSrcweir #include <tools/fsys.hxx>
37cdf0e10cSrcweir #include <osl/file.hxx>
38cdf0e10cSrcweir #include <osl/file.h>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include <hash_map> /* std::hashmap*/
41cdf0e10cSrcweir #include <iterator> /* std::iterator*/
42cdf0e10cSrcweir #include <set>      /* std::set*/
43cdf0e10cSrcweir #include <vector>   /* std::vector*/
44cdf0e10cSrcweir #include <queue>
45cdf0e10cSrcweir #include <string>
46cdf0e10cSrcweir 
47cdf0e10cSrcweir #include <unistd.h>
48cdf0e10cSrcweir #ifdef WNT
49cdf0e10cSrcweir #include <direct.h>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir 
52cdf0e10cSrcweir #define NO_TRANSLATE_ISO		"x-no-translate"
53cdf0e10cSrcweir 
54cdf0e10cSrcweir #define JAPANESE_ISO "ja"
55cdf0e10cSrcweir 
56cdf0e10cSrcweir class PFormEntrys;
57cdf0e10cSrcweir class MergeData;
58cdf0e10cSrcweir typedef std::set<ByteString , lessByteString > ByteStringSet;
59cdf0e10cSrcweir 
60cdf0e10cSrcweir typedef std::hash_map<ByteString , ByteString , hashByteString,equalByteString>
61cdf0e10cSrcweir                                 ByteStringHashMap;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir typedef std::hash_map<ByteString , bool , hashByteString,equalByteString>
64cdf0e10cSrcweir                                 ByteStringBoolHashMap;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir typedef std::hash_map<ByteString , PFormEntrys* , hashByteString,equalByteString>
67cdf0e10cSrcweir                                 PFormEntrysHashMap;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir typedef std::hash_map<ByteString , MergeData* , hashByteString,equalByteString>
70cdf0e10cSrcweir                                 MergeDataHashMap;
71cdf0e10cSrcweir 
72cdf0e10cSrcweir #define SOURCE_LANGUAGE ByteString("en-US")
73cdf0e10cSrcweir #define LIST_REFID  "LIST_REFID"
74cdf0e10cSrcweir 
75cdf0e10cSrcweir typedef ByteStringHashMap ExportListEntry;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir DECLARE_LIST( ExportListBase, ExportListEntry * )
78cdf0e10cSrcweir 
79cdf0e10cSrcweir //
80cdf0e10cSrcweir // class ExportList
81cdf0e10cSrcweir //
82cdf0e10cSrcweir 
83cdf0e10cSrcweir class ExportList : public ExportListBase
84cdf0e10cSrcweir {
85cdf0e10cSrcweir private:
86cdf0e10cSrcweir 	sal_uLong nSourceLanguageListEntryCount;
87cdf0e10cSrcweir 
88cdf0e10cSrcweir public:
ExportList()89cdf0e10cSrcweir 	ExportList() : ExportListBase() { nSourceLanguageListEntryCount = 0; }
GetSourceLanguageListEntryCount()90cdf0e10cSrcweir 	sal_uLong GetSourceLanguageListEntryCount() { return nSourceLanguageListEntryCount; }
NewSourceLanguageListEntry()91cdf0e10cSrcweir 	void NewSourceLanguageListEntry() { nSourceLanguageListEntryCount++; }
92cdf0e10cSrcweir };
93cdf0e10cSrcweir 
94cdf0e10cSrcweir #define REFID_NONE 0xFFFF
95cdf0e10cSrcweir 
96cdf0e10cSrcweir //
97cdf0e10cSrcweir // struct ResData
98cdf0e10cSrcweir //
99cdf0e10cSrcweir 
100cdf0e10cSrcweir /******************************************************************************
101cdf0e10cSrcweir * Purpose: holds mandatory data to export a single res (used with ResStack)
102cdf0e10cSrcweir ******************************************************************************/
103cdf0e10cSrcweir 
104cdf0e10cSrcweir #define ID_LEVEL_NULL		0x0000
105cdf0e10cSrcweir #define ID_LEVEL_AUTOID		0x0001
106cdf0e10cSrcweir #define ID_LEVEL_TEXT		0x0002
107cdf0e10cSrcweir #define ID_LEVEL_FIELDNAME	0x0003
108cdf0e10cSrcweir #define ID_LEVEL_ACCESSPATH	0x0004
109cdf0e10cSrcweir #define ID_LEVEL_IDENTIFIER 0x0005
110cdf0e10cSrcweir #define ID_LEVEL_LISTINDEX	0x0006
111cdf0e10cSrcweir 
112cdf0e10cSrcweir class ResData
113cdf0e10cSrcweir {
114cdf0e10cSrcweir public:
115cdf0e10cSrcweir 	~ResData();
116cdf0e10cSrcweir 	sal_Bool SetId( const ByteString &rId, sal_uInt16 nLevel );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     sal_uInt16 nWidth;
119cdf0e10cSrcweir 	sal_uInt16 nChildIndex;
120cdf0e10cSrcweir 	sal_uInt16 nIdLevel;
121cdf0e10cSrcweir 	sal_Bool bChild;
122cdf0e10cSrcweir 	sal_Bool bChildWithText;
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	sal_Bool bText;
125cdf0e10cSrcweir 	sal_Bool bHelpText;
126cdf0e10cSrcweir 	sal_Bool bQuickHelpText;
127cdf0e10cSrcweir 	sal_Bool bTitle;
128cdf0e10cSrcweir 	sal_Bool bList;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 	sal_Bool bRestMerged;
131cdf0e10cSrcweir 
132cdf0e10cSrcweir     ByteString sResTyp;
133cdf0e10cSrcweir 	ByteString sId;
134cdf0e10cSrcweir 	ByteString sGId;
135cdf0e10cSrcweir 	ByteString sHelpId;
136cdf0e10cSrcweir 	ByteString sFilename;
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     ByteStringHashMap sText;
139cdf0e10cSrcweir     sal_uInt16 nTextRefId;
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 	ByteStringHashMap sHelpText;
142cdf0e10cSrcweir     sal_uInt16 nHelpTextRefId;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir 	ByteStringHashMap sQuickHelpText;
145cdf0e10cSrcweir     sal_uInt16 nQuickHelpTextRefId;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	ByteStringHashMap sTitle;
148cdf0e10cSrcweir     sal_uInt16 nTitleRefId;
149cdf0e10cSrcweir 
150cdf0e10cSrcweir 	ByteString sTextTyp;
151cdf0e10cSrcweir 	ByteStringHashMap aFallbackData;
152cdf0e10cSrcweir 	ByteStringHashMap aMergedLanguages;
153cdf0e10cSrcweir 
154cdf0e10cSrcweir 	ExportList	*pStringList;
155cdf0e10cSrcweir 	ExportList	*pUIEntries;
156cdf0e10cSrcweir 	ExportList	*pItemList;
157cdf0e10cSrcweir     ExportList	*pFilterList;
158cdf0e10cSrcweir     ExportList  *pPairedList;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     ByteString sPForm;
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	void Dump();
163cdf0e10cSrcweir 	void addFallbackData( ByteString& sId , const ByteString& sText );
164cdf0e10cSrcweir 	bool getFallbackData( ByteString& sId , ByteString& sText);
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	void addMergedLanguage( ByteString& sLang );
167cdf0e10cSrcweir 	bool isMerged( ByteString& sLang );
ResData(const ByteString & rPF,const ByteString & rGId)168cdf0e10cSrcweir 	ResData( const ByteString &rPF, const ByteString &rGId )
169cdf0e10cSrcweir 			:
170cdf0e10cSrcweir             nWidth( 0 ),
171cdf0e10cSrcweir             nChildIndex( 0 ),
172cdf0e10cSrcweir             nIdLevel( ID_LEVEL_NULL ),
173cdf0e10cSrcweir             bChild( sal_False ),
174cdf0e10cSrcweir             bChildWithText( sal_False ),
175cdf0e10cSrcweir             bText( sal_False ),
176cdf0e10cSrcweir             bHelpText( sal_False ),
177cdf0e10cSrcweir             bQuickHelpText( sal_False ),
178cdf0e10cSrcweir             bTitle( sal_False ),
179cdf0e10cSrcweir             bList( sal_False ),
180cdf0e10cSrcweir             bRestMerged( sal_False ),
181cdf0e10cSrcweir             sGId( rGId ),
182cdf0e10cSrcweir             nTextRefId( REFID_NONE ),
183cdf0e10cSrcweir             nHelpTextRefId( REFID_NONE ),
184cdf0e10cSrcweir             nQuickHelpTextRefId( REFID_NONE ),
185cdf0e10cSrcweir             nTitleRefId( REFID_NONE ),
186cdf0e10cSrcweir             sTextTyp( "Text" ),
187cdf0e10cSrcweir             pStringList( NULL ),
188cdf0e10cSrcweir             pUIEntries( NULL ),
189cdf0e10cSrcweir             pItemList( NULL ),
190cdf0e10cSrcweir             pFilterList( NULL ),
191cdf0e10cSrcweir             pPairedList( NULL ),
192cdf0e10cSrcweir             sPForm( rPF )
193cdf0e10cSrcweir 	{
194cdf0e10cSrcweir 		sGId.EraseAllChars( '\r' );
195cdf0e10cSrcweir 		sPForm.EraseAllChars( '\r' );
196cdf0e10cSrcweir 	};
ResData(const ByteString & rPF,const ByteString & rGId,const ByteString & rFilename)197cdf0e10cSrcweir 	ResData( const ByteString &rPF, const ByteString &rGId , const ByteString &rFilename )
198cdf0e10cSrcweir 			:
199cdf0e10cSrcweir             nChildIndex( 0 ),
200cdf0e10cSrcweir             nIdLevel( ID_LEVEL_NULL ),
201cdf0e10cSrcweir             bChild( sal_False ),
202cdf0e10cSrcweir             bChildWithText( sal_False ),
203cdf0e10cSrcweir             bText( sal_False ),
204cdf0e10cSrcweir             bHelpText( sal_False ),
205cdf0e10cSrcweir             bQuickHelpText( sal_False ),
206cdf0e10cSrcweir             bTitle( sal_False ),
207cdf0e10cSrcweir             bList( sal_False ),
208cdf0e10cSrcweir             bRestMerged( sal_False ),
209cdf0e10cSrcweir             sGId( rGId ),
210cdf0e10cSrcweir             sFilename( rFilename ),
211cdf0e10cSrcweir             nTextRefId( REFID_NONE ),
212cdf0e10cSrcweir             nHelpTextRefId( REFID_NONE ),
213cdf0e10cSrcweir             nQuickHelpTextRefId( REFID_NONE ),
214cdf0e10cSrcweir             nTitleRefId( REFID_NONE ),
215cdf0e10cSrcweir             sTextTyp( "Text" ),
216cdf0e10cSrcweir             pStringList( NULL ),
217cdf0e10cSrcweir             pUIEntries( NULL ),
218cdf0e10cSrcweir             pItemList( NULL ),
219cdf0e10cSrcweir             pFilterList( NULL ),
220cdf0e10cSrcweir             pPairedList( NULL ),
221cdf0e10cSrcweir             sPForm( rPF )
222cdf0e10cSrcweir 
223cdf0e10cSrcweir 	{
224cdf0e10cSrcweir 		sGId.EraseAllChars( '\r' );
225cdf0e10cSrcweir 		sPForm.EraseAllChars( '\r' );
226cdf0e10cSrcweir 	};
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 
229cdf0e10cSrcweir };
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 
232cdf0e10cSrcweir //
233cdf0e10cSrcweir // class Export
234cdf0e10cSrcweir //
235cdf0e10cSrcweir 
236cdf0e10cSrcweir /******************************************************************************
237cdf0e10cSrcweir * Purpose: syntax check and export of *.src, called from lexer
238cdf0e10cSrcweir ******************************************************************************/
239cdf0e10cSrcweir 
240cdf0e10cSrcweir #define LIST_NON 					0x0000
241cdf0e10cSrcweir #define LIST_STRING 				0x0001
242cdf0e10cSrcweir #define LIST_FILTER					0x0002
243cdf0e10cSrcweir #define LIST_ITEM					0x0004
244cdf0e10cSrcweir #define LIST_PAIRED                 0x0005
245cdf0e10cSrcweir #define LIST_UIENTRIES				0x0008
246cdf0e10cSrcweir #define STRING_TYP_TEXT				0x0010
247cdf0e10cSrcweir #define	STRING_TYP_HELPTEXT			0x0020
248cdf0e10cSrcweir #define STRING_TYP_QUICKHELPTEXT	0x0040
249cdf0e10cSrcweir #define STRING_TYP_TITLE			0x0080
250cdf0e10cSrcweir 
251cdf0e10cSrcweir #define MERGE_MODE_NORMAL			0x0000
252cdf0e10cSrcweir #define MERGE_MODE_LIST				0x0001
253cdf0e10cSrcweir 
254cdf0e10cSrcweir DECLARE_LIST( ResStack, ResData * )
255cdf0e10cSrcweir // forwards
256cdf0e10cSrcweir class WordTransformer;
257cdf0e10cSrcweir class ParserQueue;
258cdf0e10cSrcweir 
259cdf0e10cSrcweir class Export
260cdf0e10cSrcweir {
261cdf0e10cSrcweir private:
262cdf0e10cSrcweir 	WordTransformer	*pWordTransformer;
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 	CharSet	aCharSet;					// used charset in src
265cdf0e10cSrcweir 
266cdf0e10cSrcweir 	SvFileStream aOutput;
267cdf0e10cSrcweir 
268cdf0e10cSrcweir 	ResStack aResStack;					// stack for parsing recursive
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	ByteString sActPForm;				// hold cur. system
271cdf0e10cSrcweir 
272cdf0e10cSrcweir 	sal_Bool bDefine;						// cur. res. in a define?
273cdf0e10cSrcweir 	sal_Bool bNextMustBeDefineEOL;			// define but no \ at lineend
274cdf0e10cSrcweir 	sal_uLong nLevel;						// res. recursiv? how deep?
275cdf0e10cSrcweir 	sal_uInt16 nList;						// cur. res. is String- or FilterList
276cdf0e10cSrcweir     ByteString nListLang;
277cdf0e10cSrcweir     sal_uLong nListIndex;
278cdf0e10cSrcweir 	sal_uLong nListLevel;
279cdf0e10cSrcweir     bool bSkipFile;
280cdf0e10cSrcweir 	ByteString sProject;
281cdf0e10cSrcweir 	ByteString sRoot;
282cdf0e10cSrcweir 	sal_Bool bEnableExport;
283cdf0e10cSrcweir 	sal_Bool bMergeMode;
284cdf0e10cSrcweir 	ByteString sMergeSrc;
285cdf0e10cSrcweir 	ByteString sLastListLine;
286cdf0e10cSrcweir 	sal_Bool bError;						// any errors while export?
287cdf0e10cSrcweir 	sal_Bool bReadOver;
288cdf0e10cSrcweir 	sal_Bool bDontWriteOutput;
289cdf0e10cSrcweir 	ByteString sLastTextTyp;
290cdf0e10cSrcweir     static bool isInitialized;
291cdf0e10cSrcweir 	ByteString sFilename;
292cdf0e10cSrcweir 
293cdf0e10cSrcweir 
294cdf0e10cSrcweir public:
295cdf0e10cSrcweir 	ParserQueue* pParseQueue; // public ?
296cdf0e10cSrcweir     static ByteString sLanguages; // public ?
297cdf0e10cSrcweir     static ByteString sForcedLanguages; // public ?
298cdf0e10cSrcweir 
299cdf0e10cSrcweir 
300cdf0e10cSrcweir     static bool skipProject( ByteString sPrj ) ;
301cdf0e10cSrcweir 	static void InitLanguages( bool bMergeMode = false );
302cdf0e10cSrcweir     static void InitForcedLanguages( bool bMergeMode = false );
303cdf0e10cSrcweir     static std::vector<ByteString> GetLanguages();
304cdf0e10cSrcweir     static std::vector<ByteString> GetForcedLanguages();
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     static void SetLanguages( std::vector<ByteString> val );
307cdf0e10cSrcweir     static void RemoveUTF8ByteOrderMarker( ByteString &rString );
308cdf0e10cSrcweir     static bool hasUTF8ByteOrderMarker( const ByteString &rString );
309cdf0e10cSrcweir     static void RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename );
310cdf0e10cSrcweir     static bool fileHasUTF8ByteOrderMarker( const ByteString &rString );
311cdf0e10cSrcweir 	static ByteString GetIsoLangByIndex( sal_uInt16 nIndex );
312cdf0e10cSrcweir 	static void QuotHTML( ByteString &rString );
313cdf0e10cSrcweir     static bool CopyFile( const ByteString& source , const ByteString& dest );
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 	static void QuotHTMLXRM( ByteString &rString );
316cdf0e10cSrcweir     static void UnquotHTML( ByteString &rString );
317cdf0e10cSrcweir 
318cdf0e10cSrcweir     static const char* GetEnv( const char *pVar );
319cdf0e10cSrcweir 	static int getCurrentDirectory( rtl::OUString& base_fqurl , rtl::OUString& base );
320cdf0e10cSrcweir 
321cdf0e10cSrcweir     static bool isSourceLanguage( const ByteString &sLanguage );
322cdf0e10cSrcweir 	static bool isAllowed( const ByteString &sLanguage );
323cdf0e10cSrcweir 
324cdf0e10cSrcweir     static bool LanguageAllowed( const ByteString &nLanguage );
325cdf0e10cSrcweir     static void Languages( std::vector<ByteString>::const_iterator& begin , std::vector<ByteString>::const_iterator& end );
326cdf0e10cSrcweir 	static void getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix  );
327cdf0e10cSrcweir     static void getRandomName( ByteString& sRandStr );
328cdf0e10cSrcweir     static void getCurrentDir( std::string& dir );
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     static void replaceEncoding( ByteString& rString );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	static ByteString GetFallbackLanguage( const ByteString nLanguage );
333cdf0e10cSrcweir 	static void FillInFallbacks( ResData *pResData );
334cdf0e10cSrcweir     static void FillInListFallbacks( ExportList *pList, const ByteString &nSource, const ByteString &nFallback );
335cdf0e10cSrcweir     static ByteString GetTimeStamp();
336cdf0e10cSrcweir 	static sal_Bool ConvertLineEnds( ByteString sSource, ByteString sDestination );
337cdf0e10cSrcweir 	static ByteString GetNativeFile( ByteString sSource );
338cdf0e10cSrcweir 	static DirEntry GetTempFile();
339cdf0e10cSrcweir 
340cdf0e10cSrcweir 	static void DumpExportList( ByteString& sListName , ExportList& aList );
341cdf0e10cSrcweir 	static ByteString DumpMap( ByteString& sMapName , ByteStringHashMap& aMap );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir private:
344cdf0e10cSrcweir     static std::vector<ByteString> aLanguages;
345cdf0e10cSrcweir     static std::vector<ByteString> aForcedLanguages;
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 	sal_Bool ListExists( ResData *pResData, sal_uInt16 nLst );
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	sal_Bool WriteData( ResData *pResData, sal_Bool bCreateNew = sal_False );// called befor dest. cur ResData
350cdf0e10cSrcweir 	sal_Bool WriteExportList( ResData *pResData, ExportList *pExportList,
351cdf0e10cSrcweir 						const ByteString &rTyp, sal_Bool bCreateNew = sal_False );
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 	ByteString MergePairedList( ByteString& sLine , ByteString& sText );
354cdf0e10cSrcweir 
355cdf0e10cSrcweir 	ByteString FullId();					// creates cur. GID
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 	bool PairedListFallback( ByteString& sText , ResData& aResData );
358cdf0e10cSrcweir 
359cdf0e10cSrcweir 	ByteString GetPairedListID		( const ByteString& sText );
360cdf0e10cSrcweir     ByteString GetPairedListString	( const ByteString& sText );
361cdf0e10cSrcweir 	ByteString StripList	( const ByteString& sText );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 	void UnmergeUTF8( ByteString& sOrig );
364cdf0e10cSrcweir 	void InsertListEntry( const ByteString &rText, const ByteString &rLine );
365cdf0e10cSrcweir 	void CleanValue( ByteString &rValue );
366cdf0e10cSrcweir 	ByteString GetText( const ByteString &rSource, int nToken );
367cdf0e10cSrcweir 
368cdf0e10cSrcweir 	sal_Bool PrepareTextToMerge( ByteString &rText, sal_uInt16 nTyp,
369cdf0e10cSrcweir 		ByteString &nLangIndex, ResData *pResData );
370cdf0e10cSrcweir 
371cdf0e10cSrcweir 	void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL );
372cdf0e10cSrcweir 	void ConvertMergeContent( ByteString &rText );
373cdf0e10cSrcweir 
374cdf0e10cSrcweir   	void WriteToMerged( const ByteString &rText , bool bSDFContent );
375cdf0e10cSrcweir 	void SetChildWithText();
376cdf0e10cSrcweir 
377cdf0e10cSrcweir 	void CutComment( ByteString &rText );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir public:
380cdf0e10cSrcweir 	Export( const ByteString &rOutput, sal_Bool bWrite,
381cdf0e10cSrcweir 			const ByteString &rPrj, const ByteString &rPrjRoot , const ByteString& rFile );
382cdf0e10cSrcweir 	Export( const ByteString &rOutput, sal_Bool bWrite,
383cdf0e10cSrcweir 			const ByteString &rPrj, const ByteString &rPrjRoot,
384cdf0e10cSrcweir 			const ByteString &rMergeSource , const ByteString& rFile );
385cdf0e10cSrcweir 	~Export();
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 	void Init();
388cdf0e10cSrcweir 	int Execute( int nToken, const char * pToken );	// called from lexer
SetError()389cdf0e10cSrcweir 	void SetError() { bError = sal_True; }
GetError()390cdf0e10cSrcweir 	sal_Bool GetError() { return bError; }
391cdf0e10cSrcweir };
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394cdf0e10cSrcweir //
395cdf0e10cSrcweir // class PFormEntrys
396cdf0e10cSrcweir //
397cdf0e10cSrcweir 
398cdf0e10cSrcweir /******************************************************************************
399cdf0e10cSrcweir * Purpose: holds information of data to merge (one pform)
400cdf0e10cSrcweir ******************************************************************************/
401cdf0e10cSrcweir 
402cdf0e10cSrcweir class PFormEntrys : public ByteString
403cdf0e10cSrcweir {
404cdf0e10cSrcweir friend class MergeDataFile;
405cdf0e10cSrcweir private:
406cdf0e10cSrcweir 	ByteString sHelpText; // empty string
407cdf0e10cSrcweir 	ByteStringHashMap sText;
408cdf0e10cSrcweir 	ByteStringBoolHashMap bTextFirst;
409cdf0e10cSrcweir 	ByteStringHashMap sQuickHelpText;
410cdf0e10cSrcweir 	ByteStringBoolHashMap bQuickHelpTextFirst;
411cdf0e10cSrcweir 	ByteStringHashMap sTitle;
412cdf0e10cSrcweir 	ByteStringBoolHashMap bTitleFirst;
413cdf0e10cSrcweir 
414cdf0e10cSrcweir public:
PFormEntrys(const ByteString & rPForm)415cdf0e10cSrcweir 	PFormEntrys( const ByteString &rPForm ) : ByteString( rPForm ) {};
416cdf0e10cSrcweir 	ByteString Dump();
InsertEntry(const ByteString & nId,const ByteString & rText,const ByteString & rQuickHelpText,const ByteString & rTitle)417cdf0e10cSrcweir 	void InsertEntry(
418cdf0e10cSrcweir                     const ByteString &nId ,
419cdf0e10cSrcweir                     const ByteString &rText,
420cdf0e10cSrcweir 					const ByteString &rQuickHelpText,
421cdf0e10cSrcweir 					const ByteString &rTitle
422cdf0e10cSrcweir                     )
423cdf0e10cSrcweir 		{
424cdf0e10cSrcweir 			sText[ nId ] = rText;
425cdf0e10cSrcweir 			bTextFirst[ nId ] = true;
426cdf0e10cSrcweir 			sQuickHelpText[ nId ] = rQuickHelpText;
427cdf0e10cSrcweir 			bQuickHelpTextFirst[ nId ] = true;
428cdf0e10cSrcweir 			sTitle[ nId ] = rTitle;
429cdf0e10cSrcweir 			bTitleFirst[ nId ] = true;
430cdf0e10cSrcweir 		}
431cdf0e10cSrcweir      sal_Bool GetText( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False );
432cdf0e10cSrcweir      sal_Bool GetTransex3Text( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False );
433cdf0e10cSrcweir 
434cdf0e10cSrcweir };
435cdf0e10cSrcweir 
436cdf0e10cSrcweir //
437cdf0e10cSrcweir // class MergeData
438cdf0e10cSrcweir //
439cdf0e10cSrcweir 
440cdf0e10cSrcweir /******************************************************************************
441cdf0e10cSrcweir * Purpose: holds information of data to merge (one ressource)
442cdf0e10cSrcweir ******************************************************************************/
443cdf0e10cSrcweir 
444cdf0e10cSrcweir class MergeDataFile;
445cdf0e10cSrcweir 
446cdf0e10cSrcweir class MergeData
447cdf0e10cSrcweir {
448cdf0e10cSrcweir friend class MergeDataFile;
449cdf0e10cSrcweir private:
450cdf0e10cSrcweir 	ByteString sTyp;
451cdf0e10cSrcweir 	ByteString sGID;
452cdf0e10cSrcweir 	ByteString sLID;
453cdf0e10cSrcweir     ByteString sFilename;
454cdf0e10cSrcweir     PFormEntrysHashMap aMap;
455cdf0e10cSrcweir public:
MergeData(const ByteString & rTyp,const ByteString & rGID,const ByteString & rLID,const ByteString & rFilename)456cdf0e10cSrcweir 	MergeData( const ByteString &rTyp, const ByteString &rGID, const ByteString &rLID , const ByteString &rFilename )
457cdf0e10cSrcweir 			: sTyp( rTyp ), sGID( rGID ), sLID( rLID ) , sFilename( rFilename ) {};
458cdf0e10cSrcweir 	~MergeData();
459cdf0e10cSrcweir 	PFormEntrys* InsertEntry( const ByteString &rPForm );
460cdf0e10cSrcweir 	PFormEntrys* GetPFormEntrys( ResData *pResData );
461cdf0e10cSrcweir 
462cdf0e10cSrcweir     void Insert( const ByteString& rPFO , PFormEntrys* pfEntrys );
463cdf0e10cSrcweir     PFormEntrys* GetPFObject( const ByteString& rPFO );
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 	ByteString Dump();
466cdf0e10cSrcweir 	sal_Bool operator==( ResData *pData );
467cdf0e10cSrcweir };
468cdf0e10cSrcweir 
469cdf0e10cSrcweir //
470cdf0e10cSrcweir // class MergeDataFile
471cdf0e10cSrcweir //
472cdf0e10cSrcweir 
473cdf0e10cSrcweir /******************************************************************************
474cdf0e10cSrcweir * Purpose: holds information of data to merge
475cdf0e10cSrcweir ******************************************************************************/
476cdf0e10cSrcweir 
477cdf0e10cSrcweir class MergeDataFile
478cdf0e10cSrcweir {
479cdf0e10cSrcweir     private:
480cdf0e10cSrcweir         sal_Bool bErrorLog;
481cdf0e10cSrcweir         ByteString sErrorLog;
482cdf0e10cSrcweir         SvFileStream aErrLog;
483cdf0e10cSrcweir         MergeDataHashMap aMap;
484cdf0e10cSrcweir         std::set<ByteString> aLanguageSet;
485cdf0e10cSrcweir 
486cdf0e10cSrcweir         MergeData *GetMergeData( ResData *pResData , bool bCaseSensitve = false );
487cdf0e10cSrcweir         void InsertEntry( const ByteString &rTYP, const ByteString &rGID, const ByteString &rLID,
488cdf0e10cSrcweir             const ByteString &rPFO,
489cdf0e10cSrcweir             const ByteString &nLang, const ByteString &rTEXT,
490cdf0e10cSrcweir             const ByteString &rQHTEXT, const ByteString &rTITLE,
491cdf0e10cSrcweir             const ByteString &sFilename, bool bCaseSensitive
492cdf0e10cSrcweir             );
493cdf0e10cSrcweir         ByteString Dump();
494cdf0e10cSrcweir         void WriteError( const ByteString &rLine );
495cdf0e10cSrcweir 
496cdf0e10cSrcweir     public:
497cdf0e10cSrcweir         MergeDataFile( const ByteString &rFileName, const ByteString& rFile , sal_Bool bErrLog, CharSet aCharSet, bool bCaseSensitive = false );
498cdf0e10cSrcweir         ~MergeDataFile();
499cdf0e10cSrcweir 
500cdf0e10cSrcweir         std::vector<ByteString> GetLanguages();
501cdf0e10cSrcweir 
502cdf0e10cSrcweir         PFormEntrys *GetPFormEntrys( ResData *pResData );
503cdf0e10cSrcweir         PFormEntrys *GetPFormEntrysCaseSensitive( ResData *pResData );
504cdf0e10cSrcweir 
505cdf0e10cSrcweir         static ByteString CreateKey( const ByteString& rTYP , const ByteString& rGID , const ByteString& rLID , const ByteString& rFilename , bool bCaseSensitive = false );
506cdf0e10cSrcweir };
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 
509cdf0e10cSrcweir class QueueEntry
510cdf0e10cSrcweir {
511cdf0e10cSrcweir public:
QueueEntry(int nTypVal,ByteString sLineVal)512cdf0e10cSrcweir     QueueEntry( int nTypVal , ByteString sLineVal ): nTyp( nTypVal ) , sLine( sLineVal ){};
513cdf0e10cSrcweir     int nTyp;
514cdf0e10cSrcweir     ByteString sLine;
515cdf0e10cSrcweir };
516cdf0e10cSrcweir 
517cdf0e10cSrcweir class ParserQueue
518cdf0e10cSrcweir {
519cdf0e10cSrcweir public:
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     ParserQueue( Export& aExportObj );
522cdf0e10cSrcweir     ~ParserQueue();
523cdf0e10cSrcweir 
524cdf0e10cSrcweir     inline void Push( const QueueEntry& aEntry );
525cdf0e10cSrcweir     bool bCurrentIsM;  // public ?
526cdf0e10cSrcweir     bool bNextIsM;   // public ?
527cdf0e10cSrcweir     bool bLastWasM;   // public ?
528cdf0e10cSrcweir     bool bMflag;   // public ?
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     void Close();
531cdf0e10cSrcweir private:
532cdf0e10cSrcweir     // Future / Next
533cdf0e10cSrcweir     std::queue<QueueEntry>* aQueueNext;
534cdf0e10cSrcweir     // Current
535cdf0e10cSrcweir     std::queue<QueueEntry>* aQueueCur;
536cdf0e10cSrcweir     // Ref
537cdf0e10cSrcweir     std::queue<QueueEntry>* aQref;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir     Export& aExport;
540cdf0e10cSrcweir     bool bStart;
541cdf0e10cSrcweir     bool bStartNext;
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     inline void Pop( std::queue<QueueEntry>& aQueue );
544cdf0e10cSrcweir 
545cdf0e10cSrcweir };
546cdf0e10cSrcweir #endif
547cdf0e10cSrcweir 
548