xref: /aoo41x/main/l10ntools/source/cfgmerge.cxx (revision 3cd96b95)
1*3cd96b95SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*3cd96b95SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*3cd96b95SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*3cd96b95SAndrew Rist  * distributed with this work for additional information
6*3cd96b95SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*3cd96b95SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*3cd96b95SAndrew Rist  * "License"); you may not use this file except in compliance
9*3cd96b95SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*3cd96b95SAndrew Rist  *
11*3cd96b95SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*3cd96b95SAndrew Rist  *
13*3cd96b95SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*3cd96b95SAndrew Rist  * software distributed under the License is distributed on an
15*3cd96b95SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*3cd96b95SAndrew Rist  * KIND, either express or implied.  See the License for the
17*3cd96b95SAndrew Rist  * specific language governing permissions and limitations
18*3cd96b95SAndrew Rist  * under the License.
19*3cd96b95SAndrew Rist  *
20*3cd96b95SAndrew Rist  *************************************************************/
21*3cd96b95SAndrew Rist 
22*3cd96b95SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_l10ntools.hxx"
26cdf0e10cSrcweir #include <stdio.h>
27cdf0e10cSrcweir #include <tools/string.hxx>
28cdf0e10cSrcweir #include <tools/fsys.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir // local includes
31cdf0e10cSrcweir #include "export.hxx"
32cdf0e10cSrcweir #include "cfgmerge.hxx"
33cdf0e10cSrcweir #include "tokens.h"
34cdf0e10cSrcweir #include "utf8conv.hxx"
35cdf0e10cSrcweir 
36cdf0e10cSrcweir extern "C" { int yyerror( char * ); }
37cdf0e10cSrcweir extern "C" { int YYWarning( char * ); }
38cdf0e10cSrcweir 
39cdf0e10cSrcweir // defines to parse command line
40cdf0e10cSrcweir #define STATE_NON  		0x0001
41cdf0e10cSrcweir #define STATE_INPUT		0x0002
42cdf0e10cSrcweir #define STATE_OUTPUT	0x0003
43cdf0e10cSrcweir #define STATE_PRJ		0x0004
44cdf0e10cSrcweir #define STATE_ROOT		0x0005
45cdf0e10cSrcweir #define STATE_MERGESRC	0x0006
46cdf0e10cSrcweir #define STATE_ERRORLOG	0x0007
47cdf0e10cSrcweir #define STATE_UTF8		0x0008
48cdf0e10cSrcweir #define STATE_LANGUAGES	0X0009
49cdf0e10cSrcweir #define STATE_ISOCODE99	0x000A
50cdf0e10cSrcweir #define STATE_FORCE		0x000B
51cdf0e10cSrcweir 
52cdf0e10cSrcweir // set of global variables
53cdf0e10cSrcweir sal_Bool bEnableExport;
54cdf0e10cSrcweir sal_Bool bMergeMode;
55cdf0e10cSrcweir sal_Bool bErrorLog;
56cdf0e10cSrcweir sal_Bool bForce;
57cdf0e10cSrcweir sal_Bool bUTF8;
58cdf0e10cSrcweir ByteString sPrj;
59cdf0e10cSrcweir ByteString sPrjRoot;
60cdf0e10cSrcweir ByteString sInputFileName;
61cdf0e10cSrcweir ByteString sActFileName;
62cdf0e10cSrcweir ByteString sFullEntry;
63cdf0e10cSrcweir ByteString sOutputFile;
64cdf0e10cSrcweir ByteString sMergeSrc;
65cdf0e10cSrcweir String sUsedTempFile;
66cdf0e10cSrcweir 
67cdf0e10cSrcweir CfgParser *pParser;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir extern "C" {
70cdf0e10cSrcweir // the whole interface to lexer is in this extern "C" section
71cdf0e10cSrcweir 
72cdf0e10cSrcweir /*****************************************************************************/
GetOutputFile(int argc,char * argv[])73cdf0e10cSrcweir extern char *GetOutputFile( int argc, char* argv[])
74cdf0e10cSrcweir /*****************************************************************************/
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	bEnableExport   = sal_False;
77cdf0e10cSrcweir 	bMergeMode      = sal_False;
78cdf0e10cSrcweir 	bErrorLog       = sal_True;
79cdf0e10cSrcweir 	bForce          = sal_False;
80cdf0e10cSrcweir 	bUTF8           = sal_True;
81cdf0e10cSrcweir     sPrj            = "";
82cdf0e10cSrcweir 	sPrjRoot        = "";
83cdf0e10cSrcweir 	sInputFileName  = "";
84cdf0e10cSrcweir 	sActFileName    = "";
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	sal_uInt16 nState = STATE_NON;
87cdf0e10cSrcweir 	sal_Bool bInput = sal_False;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	// parse command line
90cdf0e10cSrcweir 	for( int i = 1; i < argc; i++ ) {
91cdf0e10cSrcweir         ByteString sSwitch( argv[ i ] );
92cdf0e10cSrcweir         sSwitch.ToUpperAscii();
93cdf0e10cSrcweir 
94cdf0e10cSrcweir         if ( sSwitch == "-I" ) {
95cdf0e10cSrcweir 			nState = STATE_INPUT; // next token specifies source file
96cdf0e10cSrcweir 		}
97cdf0e10cSrcweir 		else if ( sSwitch == "-O" ) {
98cdf0e10cSrcweir 			nState = STATE_OUTPUT; // next token specifies the dest file
99cdf0e10cSrcweir 		}
100cdf0e10cSrcweir 		else if ( sSwitch == "-P" ) {
101cdf0e10cSrcweir 			nState = STATE_PRJ; // next token specifies the cur. project
102cdf0e10cSrcweir 		}
103cdf0e10cSrcweir 		else if ( sSwitch == "-R" ) {
104cdf0e10cSrcweir 			nState = STATE_ROOT; // next token specifies path to project root
105cdf0e10cSrcweir 		}
106cdf0e10cSrcweir 		else if ( sSwitch == "-M" ) {
107cdf0e10cSrcweir 			nState = STATE_MERGESRC; // next token specifies the merge database
108cdf0e10cSrcweir 		}
109cdf0e10cSrcweir 		else if ( sSwitch == "-E" ) {
110cdf0e10cSrcweir 			nState = STATE_ERRORLOG;
111cdf0e10cSrcweir 			bErrorLog = sal_False;
112cdf0e10cSrcweir 		}
113cdf0e10cSrcweir 		else if ( sSwitch == "-UTF8" ) {
114cdf0e10cSrcweir 			nState = STATE_UTF8;
115cdf0e10cSrcweir 			bUTF8 = sal_True;
116cdf0e10cSrcweir 		}
117cdf0e10cSrcweir 		else if ( sSwitch == "-NOUTF8" ) {
118cdf0e10cSrcweir 			nState = STATE_UTF8;
119cdf0e10cSrcweir 			bUTF8 = sal_False;
120cdf0e10cSrcweir 		}
121cdf0e10cSrcweir 		else if ( sSwitch == "-F" ) {
122cdf0e10cSrcweir 			nState = STATE_FORCE;
123cdf0e10cSrcweir 			bForce = sal_True;
124cdf0e10cSrcweir 		}
125cdf0e10cSrcweir         else if ( sSwitch == "-L" ) {
126cdf0e10cSrcweir 			nState = STATE_LANGUAGES;
127cdf0e10cSrcweir 		}
128cdf0e10cSrcweir 		else if ( sSwitch.ToUpperAscii() == "-ISO99" ) {
129cdf0e10cSrcweir 			nState = STATE_ISOCODE99;
130cdf0e10cSrcweir 		}
131cdf0e10cSrcweir 		else {
132cdf0e10cSrcweir 			switch ( nState ) {
133cdf0e10cSrcweir 				case STATE_NON: {
134cdf0e10cSrcweir 					return NULL;	// no valid command line
135cdf0e10cSrcweir 				}
136cdf0e10cSrcweir 				case STATE_INPUT: {
137cdf0e10cSrcweir 					sInputFileName = argv[ i ];
138cdf0e10cSrcweir 					bInput = sal_True; // source file found
139cdf0e10cSrcweir 				}
140cdf0e10cSrcweir 				break;
141cdf0e10cSrcweir 				case STATE_OUTPUT: {
142cdf0e10cSrcweir 					sOutputFile = argv[ i ]; // the dest. file
143cdf0e10cSrcweir 				}
144cdf0e10cSrcweir 				break;
145cdf0e10cSrcweir 				case STATE_PRJ: {
146cdf0e10cSrcweir 					sPrj = ByteString( argv[ i ]);
147cdf0e10cSrcweir //					sPrj.ToLowerAscii(); // the project
148cdf0e10cSrcweir 				}
149cdf0e10cSrcweir 				break;
150cdf0e10cSrcweir 				case STATE_ROOT: {
151cdf0e10cSrcweir 					sPrjRoot = ByteString( argv[ i ]); // path to project root
152cdf0e10cSrcweir 				}
153cdf0e10cSrcweir 				break;
154cdf0e10cSrcweir 				case STATE_MERGESRC: {
155cdf0e10cSrcweir 					sMergeSrc = ByteString( argv[ i ]);
156cdf0e10cSrcweir 					bMergeMode = sal_True; // activate merge mode, cause merge database found
157cdf0e10cSrcweir 				}
158cdf0e10cSrcweir 				break;
159cdf0e10cSrcweir 				case STATE_LANGUAGES: {
160cdf0e10cSrcweir 					Export::sLanguages = ByteString( argv[ i ]);
161cdf0e10cSrcweir 				}
162cdf0e10cSrcweir 				break;
163cdf0e10cSrcweir 			}
164cdf0e10cSrcweir 		}
165cdf0e10cSrcweir 	}
166cdf0e10cSrcweir 
167cdf0e10cSrcweir 	if ( bInput ) {
168cdf0e10cSrcweir 		// command line is valid
169cdf0e10cSrcweir 		bEnableExport = sal_True;
170cdf0e10cSrcweir 		char *pReturn = new char[ sOutputFile.Len() + 1 ];
171cdf0e10cSrcweir 		strcpy( pReturn, sOutputFile.GetBuffer());  // #100211# - checked
172cdf0e10cSrcweir 		return pReturn;
173cdf0e10cSrcweir 	}
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	// command line is not valid
176cdf0e10cSrcweir 	return NULL;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir /*****************************************************************************/
InitCfgExport(char * pOutput,char * pFilename)179cdf0e10cSrcweir int InitCfgExport( char *pOutput , char* pFilename )
180cdf0e10cSrcweir /*****************************************************************************/
181cdf0e10cSrcweir {
182cdf0e10cSrcweir 	// instanciate Export
183cdf0e10cSrcweir 	ByteString sOutput( pOutput );
184cdf0e10cSrcweir 	ByteString sFilename( pFilename );
185cdf0e10cSrcweir     Export::InitLanguages();
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	if ( bMergeMode )
188cdf0e10cSrcweir 		pParser = new CfgMerge( sMergeSrc, sOutputFile, sFilename );
189cdf0e10cSrcweir   	else if ( sOutputFile.Len())
190cdf0e10cSrcweir 		pParser = new CfgExport( sOutputFile, sPrj, sActFileName );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 	return 1;
193cdf0e10cSrcweir }
194cdf0e10cSrcweir 
195cdf0e10cSrcweir /*****************************************************************************/
EndCfgExport()196cdf0e10cSrcweir int EndCfgExport()
197cdf0e10cSrcweir /*****************************************************************************/
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	delete pParser;
200cdf0e10cSrcweir 
201cdf0e10cSrcweir 	return 1;
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
removeTempFile()204cdf0e10cSrcweir void removeTempFile(){
205cdf0e10cSrcweir     if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
206cdf0e10cSrcweir         DirEntry aTempFile( sUsedTempFile );
207cdf0e10cSrcweir         aTempFile.Kill();
208cdf0e10cSrcweir     }
209cdf0e10cSrcweir }
getFilename()210cdf0e10cSrcweir extern const char* getFilename()
211cdf0e10cSrcweir {
212cdf0e10cSrcweir 	return sInputFileName.GetBuffer();
213cdf0e10cSrcweir }
214cdf0e10cSrcweir /*****************************************************************************/
GetCfgFile()215cdf0e10cSrcweir extern FILE *GetCfgFile()
216cdf0e10cSrcweir /*****************************************************************************/
217cdf0e10cSrcweir {
218cdf0e10cSrcweir 	FILE *pFile = 0;
219cdf0e10cSrcweir     // look for valid filename
220cdf0e10cSrcweir 	if ( sInputFileName.Len()) {
221cdf0e10cSrcweir         if( Export::fileHasUTF8ByteOrderMarker( sInputFileName ) ){
222cdf0e10cSrcweir             DirEntry aTempFile = Export::GetTempFile();
223cdf0e10cSrcweir             DirEntry aSourceFile( String( sInputFileName , RTL_TEXTENCODING_ASCII_US ) );
224cdf0e10cSrcweir             aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
225cdf0e10cSrcweir             String sTempFile = aTempFile.GetFull();
226cdf0e10cSrcweir             Export::RemoveUTF8ByteOrderMarkerFromFile( ByteString( sTempFile , RTL_TEXTENCODING_ASCII_US ) );
227cdf0e10cSrcweir             pFile = fopen( ByteString( sTempFile , RTL_TEXTENCODING_ASCII_US ).GetBuffer(), "r" );
228cdf0e10cSrcweir             sUsedTempFile = sTempFile;
229cdf0e10cSrcweir         }else{
230cdf0e10cSrcweir             // able to open file?
231cdf0e10cSrcweir             pFile = fopen( sInputFileName.GetBuffer(), "r" );
232cdf0e10cSrcweir             sUsedTempFile = String::CreateFromAscii("");
233cdf0e10cSrcweir         }
234cdf0e10cSrcweir 		if ( !pFile ){
235cdf0e10cSrcweir 			fprintf( stderr, "Error: Could not open file %s\n",
236cdf0e10cSrcweir 				sInputFileName.GetBuffer());
237cdf0e10cSrcweir             exit( -13 );
238cdf0e10cSrcweir         }
239cdf0e10cSrcweir 		else {
240cdf0e10cSrcweir 			// this is a valid file which can be opened, so
241cdf0e10cSrcweir 			// create path to project root
242cdf0e10cSrcweir 			DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
243cdf0e10cSrcweir 			aEntry.ToAbs();
244cdf0e10cSrcweir 			sFullEntry= ByteString( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
245cdf0e10cSrcweir 			aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
246cdf0e10cSrcweir 			aEntry += DirEntry( sPrjRoot );
247cdf0e10cSrcweir 			ByteString sPrjEntry( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 			// create file name, beginnig with project root
250cdf0e10cSrcweir 			// (e.g.: source\ui\src\menue.src)
251cdf0e10cSrcweir //			printf("sFullEntry = %s\n",sFullEntry.GetBuffer());
252cdf0e10cSrcweir             sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 );
253cdf0e10cSrcweir //            printf("sActFileName = %s\n",sActFileName.GetBuffer());
254cdf0e10cSrcweir 
255cdf0e10cSrcweir 			sActFileName.SearchAndReplaceAll( "/", "\\" );
256cdf0e10cSrcweir 
257cdf0e10cSrcweir 			return pFile;
258cdf0e10cSrcweir 		}
259cdf0e10cSrcweir 	}
260cdf0e10cSrcweir 	// this means the file could not be opened
261cdf0e10cSrcweir 	return NULL;
262cdf0e10cSrcweir }
263cdf0e10cSrcweir 
264cdf0e10cSrcweir /*****************************************************************************/
WorkOnTokenSet(int nTyp,char * pTokenText)265cdf0e10cSrcweir int WorkOnTokenSet( int nTyp, char *pTokenText )
266cdf0e10cSrcweir /*****************************************************************************/
267cdf0e10cSrcweir {
268cdf0e10cSrcweir 	pParser->Execute( nTyp, pTokenText );
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 	return 1;
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 
274cdf0e10cSrcweir /*****************************************************************************/
SetError()275cdf0e10cSrcweir int SetError()
276cdf0e10cSrcweir /*****************************************************************************/
277cdf0e10cSrcweir {
278cdf0e10cSrcweir 	return 1;
279cdf0e10cSrcweir }
280cdf0e10cSrcweir 
281cdf0e10cSrcweir /*****************************************************************************/
GetError()282cdf0e10cSrcweir int GetError()
283cdf0e10cSrcweir /*****************************************************************************/
284cdf0e10cSrcweir {
285cdf0e10cSrcweir 	return 0;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir //
290cdf0e10cSrcweir // class CfgStackData
291cdf0e10cSrcweir //
292cdf0e10cSrcweir 
Push(const ByteString & rTag,const ByteString & rId)293cdf0e10cSrcweir CfgStackData* CfgStack::Push( const ByteString &rTag, const ByteString &rId )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir     CfgStackData *pD = new CfgStackData( rTag, rId );
296cdf0e10cSrcweir     Insert( pD, LIST_APPEND );
297cdf0e10cSrcweir     return pD;
298cdf0e10cSrcweir }
299cdf0e10cSrcweir 
300cdf0e10cSrcweir //
301cdf0e10cSrcweir // class CfgStack
302cdf0e10cSrcweir //
303cdf0e10cSrcweir 
304cdf0e10cSrcweir /*****************************************************************************/
~CfgStack()305cdf0e10cSrcweir CfgStack::~CfgStack()
306cdf0e10cSrcweir /*****************************************************************************/
307cdf0e10cSrcweir {
308cdf0e10cSrcweir 	for ( sal_uLong i = 0; i < Count(); i++ )
309cdf0e10cSrcweir 		delete GetObject( i );
310cdf0e10cSrcweir }
311cdf0e10cSrcweir 
312cdf0e10cSrcweir /*****************************************************************************/
GetAccessPath(sal_uLong nPos)313cdf0e10cSrcweir ByteString CfgStack::GetAccessPath( sal_uLong nPos )
314cdf0e10cSrcweir /*****************************************************************************/
315cdf0e10cSrcweir {
316cdf0e10cSrcweir 	if ( nPos == LIST_APPEND )
317cdf0e10cSrcweir 		nPos = Count() - 1;
318cdf0e10cSrcweir 
319cdf0e10cSrcweir 	ByteString sReturn;
320cdf0e10cSrcweir 	for ( sal_uLong i = 0; i <= nPos; i++ ) {
321cdf0e10cSrcweir 		if ( i )
322cdf0e10cSrcweir 			sReturn += ".";
323cdf0e10cSrcweir 		sReturn += GetStackData( i )->GetIdentifier();
324cdf0e10cSrcweir 	}
325cdf0e10cSrcweir 
326cdf0e10cSrcweir 	return sReturn;
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir /*****************************************************************************/
GetStackData(sal_uLong nPos)330cdf0e10cSrcweir CfgStackData *CfgStack::GetStackData( sal_uLong nPos )
331cdf0e10cSrcweir /*****************************************************************************/
332cdf0e10cSrcweir {
333cdf0e10cSrcweir 	if ( nPos == LIST_APPEND )
334cdf0e10cSrcweir 		nPos = Count() - 1;
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	return GetObject( nPos );
337cdf0e10cSrcweir }
338cdf0e10cSrcweir 
339cdf0e10cSrcweir //
340cdf0e10cSrcweir // class CfgParser
341cdf0e10cSrcweir //
342cdf0e10cSrcweir 
343cdf0e10cSrcweir /*****************************************************************************/
CfgParser()344cdf0e10cSrcweir CfgParser::CfgParser()
345cdf0e10cSrcweir /*****************************************************************************/
346cdf0e10cSrcweir 				: pStackData( NULL ),
347cdf0e10cSrcweir 				bLocalize( sal_False )
348cdf0e10cSrcweir {
349cdf0e10cSrcweir }
350cdf0e10cSrcweir 
351cdf0e10cSrcweir /*****************************************************************************/
~CfgParser()352cdf0e10cSrcweir CfgParser::~CfgParser()
353cdf0e10cSrcweir /*****************************************************************************/
354cdf0e10cSrcweir {
355cdf0e10cSrcweir }
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 
358cdf0e10cSrcweir /*****************************************************************************/
IsTokenClosed(const ByteString & rToken)359cdf0e10cSrcweir sal_Bool CfgParser::IsTokenClosed( const ByteString &rToken )
360cdf0e10cSrcweir /*****************************************************************************/
361cdf0e10cSrcweir {
362cdf0e10cSrcweir 	return rToken.GetChar( rToken.Len() - 2 ) == '/';
363cdf0e10cSrcweir }
364cdf0e10cSrcweir 
365cdf0e10cSrcweir /*****************************************************************************/
AddText(ByteString & rText,const ByteString & rIsoLang,const ByteString & rResTyp)366cdf0e10cSrcweir void CfgParser::AddText(
367cdf0e10cSrcweir 	ByteString &rText,
368cdf0e10cSrcweir 	const ByteString &rIsoLang,
369cdf0e10cSrcweir 	const ByteString &rResTyp
370cdf0e10cSrcweir )
371cdf0e10cSrcweir /*****************************************************************************/
372cdf0e10cSrcweir {
373cdf0e10cSrcweir 		sal_uInt16 nTextLen = 0;
374cdf0e10cSrcweir 		while ( rText.Len() != nTextLen ) {
375cdf0e10cSrcweir 			nTextLen = rText.Len();
376cdf0e10cSrcweir 			rText.SearchAndReplaceAll( "\n", " " );
377cdf0e10cSrcweir 			rText.SearchAndReplaceAll( "\r", " " );
378cdf0e10cSrcweir 			rText.SearchAndReplaceAll( "\t", " " );
379cdf0e10cSrcweir 			rText.SearchAndReplaceAll( "  ", " " );
380cdf0e10cSrcweir 		}
381cdf0e10cSrcweir 		pStackData->sResTyp = rResTyp;
382cdf0e10cSrcweir         WorkOnText( rText, rIsoLang );
383cdf0e10cSrcweir 
384cdf0e10cSrcweir         pStackData->sText[ rIsoLang ] = rText;
385cdf0e10cSrcweir }
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 
388cdf0e10cSrcweir /*****************************************************************************/
WorkOnRessourceEnd()389cdf0e10cSrcweir void CfgParser::WorkOnRessourceEnd()
390cdf0e10cSrcweir /*****************************************************************************/
391cdf0e10cSrcweir {
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir /*****************************************************************************/
ExecuteAnalyzedToken(int nToken,char * pToken)395cdf0e10cSrcweir int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
396cdf0e10cSrcweir /*****************************************************************************/
397cdf0e10cSrcweir {
398cdf0e10cSrcweir 	ByteString sToken( pToken );
399cdf0e10cSrcweir 
400cdf0e10cSrcweir 	if ( sToken == " " || sToken == "\t" )
401cdf0e10cSrcweir 		sLastWhitespace += sToken;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 	ByteString sTokenName;
404cdf0e10cSrcweir 	ByteString sTokenId;
405cdf0e10cSrcweir 
406cdf0e10cSrcweir 	sal_Bool bOutput = sal_True;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 	switch ( nToken ) {
409cdf0e10cSrcweir 		case CFG_TOKEN_PACKAGE:
410cdf0e10cSrcweir 		case CFG_TOKEN_COMPONENT:
411cdf0e10cSrcweir 		case CFG_TOKEN_TEMPLATE:
412cdf0e10cSrcweir 		case CFG_TOKEN_CONFIGNAME:
413cdf0e10cSrcweir 		case CFG_TOKEN_OORNAME:
414cdf0e10cSrcweir 		case CFG_TOKEN_OORVALUE:
415cdf0e10cSrcweir 		case CFG_TAG:
416cdf0e10cSrcweir 		case ANYTOKEN:
417cdf0e10cSrcweir 		case CFG_TEXT_START:
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 			sTokenName = sToken.GetToken( 1, '<' ).GetToken( 0, '>' ).GetToken( 0, ' ' );
420cdf0e10cSrcweir 
421cdf0e10cSrcweir 	  		if ( !IsTokenClosed( sToken )) {
422cdf0e10cSrcweir 				ByteString sSearch;
423cdf0e10cSrcweir 				switch ( nToken ) {
424cdf0e10cSrcweir 					case CFG_TOKEN_PACKAGE:
425cdf0e10cSrcweir 						sSearch = "package-id=";
426cdf0e10cSrcweir 					break;
427cdf0e10cSrcweir 					case CFG_TOKEN_COMPONENT:
428cdf0e10cSrcweir 						sSearch = "component-id=";
429cdf0e10cSrcweir 					break;
430cdf0e10cSrcweir 					case CFG_TOKEN_TEMPLATE:
431cdf0e10cSrcweir 						sSearch = "template-id=";
432cdf0e10cSrcweir 					break;
433cdf0e10cSrcweir 					case CFG_TOKEN_CONFIGNAME:
434cdf0e10cSrcweir 						sSearch = "cfg:name=";
435cdf0e10cSrcweir 					break;
436cdf0e10cSrcweir 					case CFG_TOKEN_OORNAME:
437cdf0e10cSrcweir 						sSearch = "oor:name=";
438cdf0e10cSrcweir 						bLocalize = sal_True;
439cdf0e10cSrcweir 					break;
440cdf0e10cSrcweir 					case CFG_TOKEN_OORVALUE:
441cdf0e10cSrcweir 						sSearch = "oor:value=";
442cdf0e10cSrcweir 					break;
443cdf0e10cSrcweir 					case CFG_TEXT_START: {
444cdf0e10cSrcweir 						if ( sCurrentResTyp != sTokenName ) {
445cdf0e10cSrcweir 							WorkOnRessourceEnd();
446cdf0e10cSrcweir                             ByteString sCur;
447cdf0e10cSrcweir                             for( unsigned int n = 0; n < aLanguages.size(); n++ ){
448cdf0e10cSrcweir                                 sCur = aLanguages[ n ];
449cdf0e10cSrcweir                                 pStackData->sText[ sCur ] = ByteString("");
450cdf0e10cSrcweir                             }
451cdf0e10cSrcweir                      	}
452cdf0e10cSrcweir 						sCurrentResTyp = sTokenName;
453cdf0e10cSrcweir 
454cdf0e10cSrcweir 						ByteString sTemp = sToken.Copy( sToken.Search( "xml:lang=" ));
455cdf0e10cSrcweir 						sCurrentIsoLang = sTemp.GetToken( 1, '\"' ).GetToken( 0, '\"' );
456cdf0e10cSrcweir 
457cdf0e10cSrcweir 						if ( sCurrentIsoLang == NO_TRANSLATE_ISO )
458cdf0e10cSrcweir 							bLocalize = sal_False;
459cdf0e10cSrcweir 
460cdf0e10cSrcweir 						pStackData->sTextTag = sToken;
461cdf0e10cSrcweir 
462cdf0e10cSrcweir 						sCurrentText = "";
463cdf0e10cSrcweir 					}
464cdf0e10cSrcweir 					break;
465cdf0e10cSrcweir 				}
466cdf0e10cSrcweir 				if ( sSearch.Len()) {
467cdf0e10cSrcweir 					ByteString sTemp = sToken.Copy( sToken.Search( sSearch ));
468cdf0e10cSrcweir 					sTokenId = sTemp.GetToken( 1, '\"' ).GetToken( 0, '\"' );
469cdf0e10cSrcweir 				}
470cdf0e10cSrcweir 				pStackData = aStack.Push( sTokenName, sTokenId );
471cdf0e10cSrcweir 
472cdf0e10cSrcweir 				if ( sSearch == "cfg:name=" ) {
473cdf0e10cSrcweir 					ByteString sTemp( sToken );
474cdf0e10cSrcweir 					sTemp.ToUpperAscii();
475cdf0e10cSrcweir 					bLocalize = (( sTemp.Search( "CFG:TYPE=\"STRING\"" ) != STRING_NOTFOUND ) &&
476cdf0e10cSrcweir 						( sTemp.Search( "CFG:LOCALIZED=\"sal_True\"" ) != STRING_NOTFOUND ));
477cdf0e10cSrcweir 				}
478cdf0e10cSrcweir 			}
479cdf0e10cSrcweir 			else if ( sTokenName == "label" ) {
480cdf0e10cSrcweir 				if ( sCurrentResTyp != sTokenName ) {
481cdf0e10cSrcweir 					WorkOnRessourceEnd();
482cdf0e10cSrcweir                     ByteString sCur;
483cdf0e10cSrcweir                     for( unsigned int n = 0; n < aLanguages.size(); n++ ){
484cdf0e10cSrcweir                         sCur = aLanguages[ n ];
485cdf0e10cSrcweir                         pStackData->sText[ sCur ] = ByteString("");
486cdf0e10cSrcweir                     }
487cdf0e10cSrcweir         		}
488cdf0e10cSrcweir 				sCurrentResTyp = sTokenName;
489cdf0e10cSrcweir 			}
490cdf0e10cSrcweir 		}
491cdf0e10cSrcweir 		break;
492cdf0e10cSrcweir 		case CFG_CLOSETAG:
493cdf0e10cSrcweir 			sTokenName = sToken.GetToken( 1, '/' ).GetToken( 0, '>' ).GetToken( 0, ' ' );
494cdf0e10cSrcweir 		   	if ( aStack.GetStackData() && ( aStack.GetStackData()->GetTagType() == sTokenName )) {
495cdf0e10cSrcweir 				if ( ! sCurrentText.Len())
496cdf0e10cSrcweir 					WorkOnRessourceEnd();
497cdf0e10cSrcweir 				aStack.Pop();
498cdf0e10cSrcweir 				pStackData = aStack.GetStackData();
499cdf0e10cSrcweir 			}
500cdf0e10cSrcweir 			else {
501cdf0e10cSrcweir 				ByteString sError( "Missplaced close tag: " );
502cdf0e10cSrcweir                 ByteString sInFile(" in file ");
503cdf0e10cSrcweir                 sError += sToken;
504cdf0e10cSrcweir                 sError += sInFile;
505cdf0e10cSrcweir                 sError += sFullEntry;
506cdf0e10cSrcweir 				Error( sError );
507cdf0e10cSrcweir                 exit ( 13 );
508cdf0e10cSrcweir 			}
509cdf0e10cSrcweir 		break;
510cdf0e10cSrcweir 
511cdf0e10cSrcweir 		case CFG_TEXTCHAR:
512cdf0e10cSrcweir 			sCurrentText += sToken;
513cdf0e10cSrcweir 			bOutput = sal_False;
514cdf0e10cSrcweir 		break;
515cdf0e10cSrcweir 
516cdf0e10cSrcweir 		case CFG_TOKEN_NO_TRANSLATE:
517cdf0e10cSrcweir 			bLocalize = sal_False;
518cdf0e10cSrcweir 		break;
519cdf0e10cSrcweir 	}
520cdf0e10cSrcweir 
521cdf0e10cSrcweir 	if ( sCurrentText.Len() && nToken != CFG_TEXTCHAR ) {
522cdf0e10cSrcweir 		AddText( sCurrentText, sCurrentIsoLang, sCurrentResTyp );
523cdf0e10cSrcweir 		Output( sCurrentText );
524cdf0e10cSrcweir 		sCurrentText = "";
525cdf0e10cSrcweir 		pStackData->sEndTextTag = sToken;
526cdf0e10cSrcweir 	}
527cdf0e10cSrcweir 
528cdf0e10cSrcweir 	if ( bOutput )
529cdf0e10cSrcweir 		Output( sToken );
530cdf0e10cSrcweir 
531cdf0e10cSrcweir 	if ( sToken != " " && sToken != "\t" )
532cdf0e10cSrcweir 		sLastWhitespace = "";
533cdf0e10cSrcweir 
534cdf0e10cSrcweir 	return 1;
535cdf0e10cSrcweir }
536cdf0e10cSrcweir 
537cdf0e10cSrcweir /*****************************************************************************/
Output(const ByteString & rOutput)538cdf0e10cSrcweir void CfgExport::Output( const ByteString& rOutput )
539cdf0e10cSrcweir /*****************************************************************************/
540cdf0e10cSrcweir {
541cdf0e10cSrcweir     // Dummy operation to suppress warnings caused by poor class design
542cdf0e10cSrcweir     ByteString a( rOutput );
543cdf0e10cSrcweir }
544cdf0e10cSrcweir 
545cdf0e10cSrcweir /*****************************************************************************/
Execute(int nToken,char * pToken)546cdf0e10cSrcweir int CfgParser::Execute( int nToken, char * pToken )
547cdf0e10cSrcweir /*****************************************************************************/
548cdf0e10cSrcweir {
549cdf0e10cSrcweir 	ByteString sToken( pToken );
550cdf0e10cSrcweir 
551cdf0e10cSrcweir 	switch ( nToken ) {
552cdf0e10cSrcweir 		case CFG_TAG:
553cdf0e10cSrcweir 			if ( sToken.Search( "package-id=" ) != STRING_NOTFOUND )
554cdf0e10cSrcweir 				return ExecuteAnalyzedToken( CFG_TOKEN_PACKAGE, pToken );
555cdf0e10cSrcweir 			else if ( sToken.Search( "component-id=" ) != STRING_NOTFOUND )
556cdf0e10cSrcweir 				return ExecuteAnalyzedToken( CFG_TOKEN_COMPONENT, pToken );
557cdf0e10cSrcweir 			else if ( sToken.Search( "template-id=" ) != STRING_NOTFOUND )
558cdf0e10cSrcweir 				return ExecuteAnalyzedToken( CFG_TOKEN_TEMPLATE, pToken );
559cdf0e10cSrcweir 			else if ( sToken.Search( "cfg:name=" ) != STRING_NOTFOUND )
560cdf0e10cSrcweir 				return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, pToken );
561cdf0e10cSrcweir 			else if ( sToken.Search( "oor:name=" ) != STRING_NOTFOUND )
562cdf0e10cSrcweir 				return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, pToken );
563cdf0e10cSrcweir 			else if ( sToken.Search( "oor:value=" ) != STRING_NOTFOUND )
564cdf0e10cSrcweir 				return ExecuteAnalyzedToken( CFG_TOKEN_OORVALUE, pToken );
565cdf0e10cSrcweir 		break;
566cdf0e10cSrcweir 	}
567cdf0e10cSrcweir 	return ExecuteAnalyzedToken( nToken, pToken );
568cdf0e10cSrcweir }
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 
571cdf0e10cSrcweir /*****************************************************************************/
Error(const ByteString & rError)572cdf0e10cSrcweir void CfgParser::Error( const ByteString &rError )
573cdf0e10cSrcweir /*****************************************************************************/
574cdf0e10cSrcweir {
575cdf0e10cSrcweir //	ByteString sError( rError );
576cdf0e10cSrcweir //    sError.Append("Error: In file ");
577cdf0e10cSrcweir //    sError.Append( sActFileName );
578cdf0e10cSrcweir     yyerror(( char * ) rError.GetBuffer());
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir 
582cdf0e10cSrcweir //
583cdf0e10cSrcweir // class CfgOutputParser
584cdf0e10cSrcweir //
585cdf0e10cSrcweir 
586cdf0e10cSrcweir /*****************************************************************************/
CfgOutputParser(const ByteString & rOutputFile)587cdf0e10cSrcweir CfgOutputParser::CfgOutputParser( const ByteString &rOutputFile )
588cdf0e10cSrcweir /*****************************************************************************/
589cdf0e10cSrcweir {
590cdf0e10cSrcweir 	pOutputStream =
591cdf0e10cSrcweir 		new SvFileStream(
592cdf0e10cSrcweir 			String( rOutputFile, RTL_TEXTENCODING_ASCII_US ),
593cdf0e10cSrcweir 			STREAM_STD_WRITE | STREAM_TRUNC
594cdf0e10cSrcweir 		);
595cdf0e10cSrcweir     pOutputStream->SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	if ( !pOutputStream->IsOpen()) {
598cdf0e10cSrcweir 		ByteString sError( "ERROR: Unable to open output file: " );
599cdf0e10cSrcweir 		sError += rOutputFile;
600cdf0e10cSrcweir 		Error( sError );
601cdf0e10cSrcweir 		delete pOutputStream;
602cdf0e10cSrcweir 		pOutputStream = NULL;
603cdf0e10cSrcweir         exit( -13 );
604cdf0e10cSrcweir 	}
605cdf0e10cSrcweir }
606cdf0e10cSrcweir 
607cdf0e10cSrcweir /*****************************************************************************/
~CfgOutputParser()608cdf0e10cSrcweir CfgOutputParser::~CfgOutputParser()
609cdf0e10cSrcweir /*****************************************************************************/
610cdf0e10cSrcweir {
611cdf0e10cSrcweir 	if ( pOutputStream ) {
612cdf0e10cSrcweir 		pOutputStream->Close();
613cdf0e10cSrcweir 		delete pOutputStream;
614cdf0e10cSrcweir 	}
615cdf0e10cSrcweir }
616cdf0e10cSrcweir 
617cdf0e10cSrcweir //
618cdf0e10cSrcweir // class CfgExport
619cdf0e10cSrcweir //
620cdf0e10cSrcweir 
621cdf0e10cSrcweir /*****************************************************************************/
CfgExport(const ByteString & rOutputFile,const ByteString & rProject,const ByteString & rFilePath)622cdf0e10cSrcweir CfgExport::CfgExport(
623cdf0e10cSrcweir 		const ByteString &rOutputFile,
624cdf0e10cSrcweir 		const ByteString &rProject,
625cdf0e10cSrcweir 		const ByteString &rFilePath
626cdf0e10cSrcweir )
627cdf0e10cSrcweir /*****************************************************************************/
628cdf0e10cSrcweir 				: CfgOutputParser( rOutputFile ),
629cdf0e10cSrcweir 				sPrj( rProject ),
630cdf0e10cSrcweir 				sPath( rFilePath )
631cdf0e10cSrcweir {
632cdf0e10cSrcweir     Export::InitLanguages( false );
633cdf0e10cSrcweir     aLanguages = Export::GetLanguages();
634cdf0e10cSrcweir }
635cdf0e10cSrcweir 
636cdf0e10cSrcweir /*****************************************************************************/
~CfgExport()637cdf0e10cSrcweir CfgExport::~CfgExport()
638cdf0e10cSrcweir /*****************************************************************************/
639cdf0e10cSrcweir {
640cdf0e10cSrcweir }
641cdf0e10cSrcweir 
642cdf0e10cSrcweir /*****************************************************************************/
WorkOnRessourceEnd()643cdf0e10cSrcweir void CfgExport::WorkOnRessourceEnd()
644cdf0e10cSrcweir /*****************************************************************************/
645cdf0e10cSrcweir {
646cdf0e10cSrcweir 	if ( pOutputStream && bLocalize ) {
647cdf0e10cSrcweir 	if (( pStackData->sText[ ByteString("en-US") ].Len()
648cdf0e10cSrcweir         ) ||
649cdf0e10cSrcweir 			( bForce &&
650cdf0e10cSrcweir 				( pStackData->sText[ ByteString("de") ].Len() ||
651cdf0e10cSrcweir                     pStackData->sText[ ByteString("en-US") ].Len() )))
652cdf0e10cSrcweir 		{
653cdf0e10cSrcweir             ByteString sFallback = pStackData->sText[ ByteString("en-US") ];
654cdf0e10cSrcweir 
655cdf0e10cSrcweir             //if ( pStackData->sText[ ByteString("en-US") ].Len())
656cdf0e10cSrcweir 			//	sFallback = pStackData->sText[ ByteString("en-US") ];
657cdf0e10cSrcweir 
658cdf0e10cSrcweir 			ByteString sLocalId = pStackData->sIdentifier;
659cdf0e10cSrcweir 			ByteString sGroupId;
660cdf0e10cSrcweir 			if ( aStack.Count() == 1 ) {
661cdf0e10cSrcweir 				sGroupId = sLocalId;
662cdf0e10cSrcweir 				sLocalId = "";
663cdf0e10cSrcweir 			}
664cdf0e10cSrcweir 			else {
665cdf0e10cSrcweir 				sGroupId = aStack.GetAccessPath( aStack.Count() - 2 );
666cdf0e10cSrcweir 			}
667cdf0e10cSrcweir 
668cdf0e10cSrcweir 			ByteString sTimeStamp( Export::GetTimeStamp());
669cdf0e10cSrcweir 
670cdf0e10cSrcweir             ByteString sCur;
671cdf0e10cSrcweir             for( unsigned int n = 0; n < aLanguages.size(); n++ ){
672cdf0e10cSrcweir                 sCur = aLanguages[ n ];
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 					ByteString sText = pStackData->sText[ sCur ];
675cdf0e10cSrcweir 					if ( !sText.Len())
676cdf0e10cSrcweir 						sText = sFallback;
677cdf0e10cSrcweir 
678cdf0e10cSrcweir                     Export::UnquotHTML( sText );
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 					ByteString sOutput( sPrj ); sOutput += "\t";
681cdf0e10cSrcweir 					sOutput += sPath;
682cdf0e10cSrcweir 					sOutput += "\t0\t";
683cdf0e10cSrcweir 					sOutput += pStackData->sResTyp; sOutput += "\t";
684cdf0e10cSrcweir 					sOutput += sGroupId; sOutput += "\t";
685cdf0e10cSrcweir 					sOutput += sLocalId; sOutput += "\t\t\t0\t";
686cdf0e10cSrcweir                     sOutput += sCur;
687cdf0e10cSrcweir 					sOutput += "\t";
688cdf0e10cSrcweir 
689cdf0e10cSrcweir                     sOutput += sText; sOutput += "\t\t\t\t";
690cdf0e10cSrcweir 					sOutput += sTimeStamp;
691cdf0e10cSrcweir 
692cdf0e10cSrcweir                     //if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sPrj ) ) )
693cdf0e10cSrcweir 					pOutputStream->WriteLine( sOutput );
694cdf0e10cSrcweir 			}
695cdf0e10cSrcweir 		}
696cdf0e10cSrcweir 	}
697cdf0e10cSrcweir }
698cdf0e10cSrcweir 
699cdf0e10cSrcweir /*****************************************************************************/
WorkOnText(ByteString & rText,const ByteString & rIsoLang)700cdf0e10cSrcweir void CfgExport::WorkOnText(
701cdf0e10cSrcweir 	ByteString &rText,
702cdf0e10cSrcweir     const ByteString &rIsoLang
703cdf0e10cSrcweir )
704cdf0e10cSrcweir /*****************************************************************************/
705cdf0e10cSrcweir {
706cdf0e10cSrcweir     if( rIsoLang.Len() ) Export::UnquotHTML( rText );
707cdf0e10cSrcweir }
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 
710cdf0e10cSrcweir //
711cdf0e10cSrcweir // class CfgMerge
712cdf0e10cSrcweir //
713cdf0e10cSrcweir 
714cdf0e10cSrcweir /*****************************************************************************/
CfgMerge(const ByteString & rMergeSource,const ByteString & rOutputFile,ByteString & rFilename)715cdf0e10cSrcweir CfgMerge::CfgMerge(
716cdf0e10cSrcweir 	const ByteString &rMergeSource, const ByteString &rOutputFile,
717cdf0e10cSrcweir 	ByteString &rFilename )
718cdf0e10cSrcweir /*****************************************************************************/
719cdf0e10cSrcweir 				: CfgOutputParser( rOutputFile ),
720cdf0e10cSrcweir 				pMergeDataFile( NULL ),
721cdf0e10cSrcweir 				pResData( NULL ),
722cdf0e10cSrcweir 				bGerman( sal_False ),
723cdf0e10cSrcweir 				sFilename( rFilename ),
724cdf0e10cSrcweir 				bEnglish( sal_False )
725cdf0e10cSrcweir {
726cdf0e10cSrcweir     if ( rMergeSource.Len()){
727cdf0e10cSrcweir 		pMergeDataFile = new MergeDataFile(
728cdf0e10cSrcweir 		rMergeSource, sInputFileName  , bErrorLog, RTL_TEXTENCODING_MS_1252, true );
729cdf0e10cSrcweir         if( Export::sLanguages.EqualsIgnoreCaseAscii("ALL") ){
730cdf0e10cSrcweir             Export::SetLanguages( pMergeDataFile->GetLanguages() );
731cdf0e10cSrcweir             aLanguages = pMergeDataFile->GetLanguages();
732cdf0e10cSrcweir         }
733cdf0e10cSrcweir         else aLanguages = Export::GetLanguages();
734cdf0e10cSrcweir     }else
735cdf0e10cSrcweir         aLanguages = Export::GetLanguages();
736cdf0e10cSrcweir }
737cdf0e10cSrcweir 
738cdf0e10cSrcweir /*****************************************************************************/
~CfgMerge()739cdf0e10cSrcweir CfgMerge::~CfgMerge()
740cdf0e10cSrcweir /*****************************************************************************/
741cdf0e10cSrcweir {
742cdf0e10cSrcweir 	delete pMergeDataFile;
743cdf0e10cSrcweir 	delete pResData;
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir /*****************************************************************************/
WorkOnText(ByteString & rText,const ByteString & nLangIndex)747cdf0e10cSrcweir void CfgMerge::WorkOnText(
748cdf0e10cSrcweir 	ByteString &rText,
749cdf0e10cSrcweir     const ByteString& nLangIndex
750cdf0e10cSrcweir )
751cdf0e10cSrcweir /*****************************************************************************/
752cdf0e10cSrcweir {
753cdf0e10cSrcweir 
754cdf0e10cSrcweir     if ( pMergeDataFile && bLocalize ) {
755cdf0e10cSrcweir 		if ( !pResData ) {
756cdf0e10cSrcweir 			ByteString sLocalId = pStackData->sIdentifier;
757cdf0e10cSrcweir 			ByteString sGroupId;
758cdf0e10cSrcweir 			if ( aStack.Count() == 1 ) {
759cdf0e10cSrcweir 				sGroupId = sLocalId;
760cdf0e10cSrcweir 				sLocalId = "";
761cdf0e10cSrcweir 			}
762cdf0e10cSrcweir 			else {
763cdf0e10cSrcweir 				sGroupId = aStack.GetAccessPath( aStack.Count() - 2 );
764cdf0e10cSrcweir 			}
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 			ByteString sPlatform( "" );
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 			pResData = new ResData( sPlatform, sGroupId , sFilename );
769cdf0e10cSrcweir 			pResData->sId = sLocalId;
770cdf0e10cSrcweir 			pResData->sResTyp = pStackData->sResTyp;
771cdf0e10cSrcweir 		}
772cdf0e10cSrcweir 
773cdf0e10cSrcweir         //if ( nLangIndex.EqualsIgnoreCaseAscii("de") )
774cdf0e10cSrcweir 		//	bGerman = sal_True;
775cdf0e10cSrcweir 		if (( nLangIndex.EqualsIgnoreCaseAscii("en-US") ))
776cdf0e10cSrcweir 			bEnglish = sal_True;
777cdf0e10cSrcweir 
778cdf0e10cSrcweir 		PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
779cdf0e10cSrcweir 		if ( pEntrys ) {
780cdf0e10cSrcweir 			ByteString sContent;
781cdf0e10cSrcweir             pEntrys->GetText( sContent, STRING_TYP_TEXT, nLangIndex );
782cdf0e10cSrcweir 
783cdf0e10cSrcweir 			if ( Export::isAllowed( nLangIndex ) &&
784cdf0e10cSrcweir 				( sContent != "-" ) && ( sContent.Len()))
785cdf0e10cSrcweir 			{
786cdf0e10cSrcweir #ifdef MERGE_SOURCE_LANGUAGES
787cdf0e10cSrcweir                     if( nLangIndex.EqualsIgnoreCaseAscii("de") || nLangIndex.EqualsIgnoreCaseAscii("en-US") )
788cdf0e10cSrcweir                         rText = sContent;
789cdf0e10cSrcweir #endif
790cdf0e10cSrcweir                 Export::QuotHTML( rText );
791cdf0e10cSrcweir 			}
792cdf0e10cSrcweir 		}
793cdf0e10cSrcweir 	}
794cdf0e10cSrcweir }
795cdf0e10cSrcweir 
796cdf0e10cSrcweir /*****************************************************************************/
Output(const ByteString & rOutput)797cdf0e10cSrcweir void CfgMerge::Output( const ByteString& rOutput )
798cdf0e10cSrcweir /*****************************************************************************/
799cdf0e10cSrcweir {
800cdf0e10cSrcweir 	if ( pOutputStream )
801cdf0e10cSrcweir 		pOutputStream->Write( rOutput.GetBuffer(), rOutput.Len());
802cdf0e10cSrcweir }
803cdf0e10cSrcweir 
Push(CfgStackData * pStackData)804cdf0e10cSrcweir sal_uLong CfgStack::Push( CfgStackData *pStackData )
805cdf0e10cSrcweir {
806cdf0e10cSrcweir     Insert( pStackData, LIST_APPEND );
807cdf0e10cSrcweir     return Count() - 1;
808cdf0e10cSrcweir }
809cdf0e10cSrcweir 
810cdf0e10cSrcweir /*****************************************************************************/
WorkOnRessourceEnd()811cdf0e10cSrcweir void CfgMerge::WorkOnRessourceEnd()
812cdf0e10cSrcweir /*****************************************************************************/
813cdf0e10cSrcweir {
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 	if ( pMergeDataFile && pResData && bLocalize && (( bEnglish ) || bForce )) {
816cdf0e10cSrcweir 		PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
817cdf0e10cSrcweir 		if ( pEntrys ) {
818cdf0e10cSrcweir             ByteString sCur;
819cdf0e10cSrcweir 
820cdf0e10cSrcweir             for( unsigned int n = 0; n < aLanguages.size(); n++ ){
821cdf0e10cSrcweir                 sCur = aLanguages[ n ];
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 				ByteString sContent;
824cdf0e10cSrcweir                 pEntrys->GetText( sContent, STRING_TYP_TEXT, sCur , sal_True );
825cdf0e10cSrcweir                 if (
826cdf0e10cSrcweir                     // (!sCur.EqualsIgnoreCaseAscii("de") )    &&
827cdf0e10cSrcweir 					( !sCur.EqualsIgnoreCaseAscii("en-US") ) &&
828cdf0e10cSrcweir 
829cdf0e10cSrcweir 					( sContent != "-" ) && ( sContent.Len()))
830cdf0e10cSrcweir 				{
831cdf0e10cSrcweir 
832cdf0e10cSrcweir 					ByteString sText = sContent;
833cdf0e10cSrcweir                     Export::QuotHTML( sText );
834cdf0e10cSrcweir 
835cdf0e10cSrcweir 					ByteString sAdditionalLine( "\t" );
836cdf0e10cSrcweir 
837cdf0e10cSrcweir 					ByteString sTextTag = pStackData->sTextTag;
838cdf0e10cSrcweir 					ByteString sTemp = sTextTag.Copy( sTextTag.Search( "xml:lang=" ));
839cdf0e10cSrcweir 
840cdf0e10cSrcweir 					ByteString sSearch = sTemp.GetToken( 0, '\"' );
841cdf0e10cSrcweir 					sSearch += "\"";
842cdf0e10cSrcweir 					sSearch += sTemp.GetToken( 1, '\"' );
843cdf0e10cSrcweir 					sSearch += "\"";
844cdf0e10cSrcweir 
845cdf0e10cSrcweir 					ByteString sReplace = sTemp.GetToken( 0, '\"' );
846cdf0e10cSrcweir 					sReplace += "\"";
847cdf0e10cSrcweir                     sReplace += sCur;
848cdf0e10cSrcweir 					sReplace += "\"";
849cdf0e10cSrcweir 
850cdf0e10cSrcweir 					sTextTag.SearchAndReplace( sSearch, sReplace );
851cdf0e10cSrcweir 
852cdf0e10cSrcweir 					sAdditionalLine += sTextTag;
853cdf0e10cSrcweir 					sAdditionalLine += sText;
854cdf0e10cSrcweir 					sAdditionalLine += pStackData->sEndTextTag;
855cdf0e10cSrcweir 
856cdf0e10cSrcweir 					sAdditionalLine += "\n";
857cdf0e10cSrcweir 					sAdditionalLine += sLastWhitespace;
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 					Output( sAdditionalLine );
860cdf0e10cSrcweir 				}
861cdf0e10cSrcweir 			}
862cdf0e10cSrcweir 		}
863cdf0e10cSrcweir 	}
864cdf0e10cSrcweir 	delete pResData;
865cdf0e10cSrcweir 	pResData = NULL;
866cdf0e10cSrcweir 	bGerman = sal_False;
867cdf0e10cSrcweir 	bEnglish = sal_False;
868cdf0e10cSrcweir }
869