merge the formfield patch from ooo-build
[ooovba.git] / transex3 / source / cfgmerge.cxx
blob84f5e1b0c927e94f9be42e4a800711b1b80d7b7d
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.cxx,v $
10 * $Revision: 1.46 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_transex3.hxx"
33 #include <stdio.h>
34 #include <tools/string.hxx>
35 #include <tools/fsys.hxx>
37 // local includes
38 #include "export.hxx"
39 #include "cfgmerge.hxx"
40 #include "tokens.h"
41 #include "utf8conv.hxx"
43 extern "C" { int yyerror( char * ); }
44 extern "C" { int YYWarning( char * ); }
46 // defines to parse command line
47 #define STATE_NON 0x0001
48 #define STATE_INPUT 0x0002
49 #define STATE_OUTPUT 0x0003
50 #define STATE_PRJ 0x0004
51 #define STATE_ROOT 0x0005
52 #define STATE_MERGESRC 0x0006
53 #define STATE_ERRORLOG 0x0007
54 #define STATE_UTF8 0x0008
55 #define STATE_LANGUAGES 0X0009
56 #define STATE_ISOCODE99 0x000A
57 #define STATE_FORCE 0x000B
59 // set of global variables
60 BOOL bEnableExport;
61 BOOL bMergeMode;
62 BOOL bErrorLog;
63 BOOL bForce;
64 BOOL bUTF8;
65 bool bQuiet;
66 ByteString sPrj;
67 ByteString sPrjRoot;
68 ByteString sInputFileName;
69 ByteString sActFileName;
70 ByteString sFullEntry;
71 ByteString sOutputFile;
72 ByteString sMergeSrc;
73 String sUsedTempFile;
75 CfgParser *pParser;
77 extern "C" {
78 // the whole interface to lexer is in this extern "C" section
80 /*****************************************************************************/
81 extern char *GetOutputFile( int argc, char* argv[])
82 /*****************************************************************************/
84 bEnableExport = FALSE;
85 bMergeMode = FALSE;
86 bErrorLog = TRUE;
87 bForce = FALSE;
88 bUTF8 = TRUE;
89 bQuiet = false;
90 sPrj = "";
91 sPrjRoot = "";
92 sInputFileName = "";
93 sActFileName = "";
95 USHORT nState = STATE_NON;
96 BOOL bInput = FALSE;
98 // parse command line
99 for( int i = 1; i < argc; i++ ) {
100 ByteString sSwitch( argv[ i ] );
101 sSwitch.ToUpperAscii();
103 if ( sSwitch == "-I" ) {
104 nState = STATE_INPUT; // next token specifies source file
106 else if ( sSwitch == "-O" ) {
107 nState = STATE_OUTPUT; // next token specifies the dest file
109 else if ( sSwitch == "-P" ) {
110 nState = STATE_PRJ; // next token specifies the cur. project
112 else if ( sSwitch == "-R" ) {
113 nState = STATE_ROOT; // next token specifies path to project root
115 else if ( sSwitch == "-M" ) {
116 nState = STATE_MERGESRC; // next token specifies the merge database
118 else if ( sSwitch == "-E" ) {
119 nState = STATE_ERRORLOG;
120 bErrorLog = FALSE;
122 else if ( sSwitch == "-UTF8" ) {
123 nState = STATE_UTF8;
124 bUTF8 = TRUE;
126 else if ( sSwitch == "-NOUTF8" ) {
127 nState = STATE_UTF8;
128 bUTF8 = FALSE;
130 else if ( sSwitch == "-F" ) {
131 nState = STATE_FORCE;
132 bForce = TRUE;
134 else if ( sSwitch == "-QQ" ) {
135 bQuiet = true;
137 else if ( sSwitch == "-L" ) {
138 nState = STATE_LANGUAGES;
140 else if ( sSwitch.ToUpperAscii() == "-ISO99" ) {
141 nState = STATE_ISOCODE99;
143 else {
144 switch ( nState ) {
145 case STATE_NON: {
146 return NULL; // no valid command line
148 case STATE_INPUT: {
149 sInputFileName = argv[ i ];
150 bInput = TRUE; // source file found
152 break;
153 case STATE_OUTPUT: {
154 sOutputFile = argv[ i ]; // the dest. file
156 break;
157 case STATE_PRJ: {
158 sPrj = ByteString( argv[ i ]);
159 // sPrj.ToLowerAscii(); // the project
161 break;
162 case STATE_ROOT: {
163 sPrjRoot = ByteString( argv[ i ]); // path to project root
165 break;
166 case STATE_MERGESRC: {
167 sMergeSrc = ByteString( argv[ i ]);
168 bMergeMode = TRUE; // activate merge mode, cause merge database found
170 break;
171 case STATE_LANGUAGES: {
172 Export::sLanguages = ByteString( argv[ i ]);
174 break;
175 case STATE_ISOCODE99: {
176 Export::sIsoCode99 = ByteString( argv[ i ]);
178 break;
183 if ( bInput ) {
184 // command line is valid
185 bEnableExport = TRUE;
186 char *pReturn = new char[ sOutputFile.Len() + 1 ];
187 strcpy( pReturn, sOutputFile.GetBuffer()); // #100211# - checked
188 return pReturn;
191 // command line is not valid
192 return NULL;
194 int isQuiet(){
195 if( bQuiet ) return 1;
196 else return 0;
198 /*****************************************************************************/
199 int InitCfgExport( char *pOutput , char* pFilename )
200 /*****************************************************************************/
202 // instanciate Export
203 ByteString sOutput( pOutput );
204 ByteString sFilename( pFilename );
205 Export::InitLanguages();
207 if ( bMergeMode )
208 pParser = new CfgMerge( sMergeSrc, sOutputFile, sFilename );
209 else if ( sOutputFile.Len())
210 pParser = new CfgExport( sOutputFile, sPrj, sActFileName );
212 return 1;
215 /*****************************************************************************/
216 int EndCfgExport()
217 /*****************************************************************************/
219 delete pParser;
221 return 1;
224 void removeTempFile(){
225 if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
226 DirEntry aTempFile( sUsedTempFile );
227 aTempFile.Kill();
230 extern const char* getFilename()
232 return sInputFileName.GetBuffer();
234 /*****************************************************************************/
235 extern FILE *GetCfgFile()
236 /*****************************************************************************/
238 FILE *pFile = 0;
239 // look for valid filename
240 if ( sInputFileName.Len()) {
241 if( Export::fileHasUTF8ByteOrderMarker( sInputFileName ) ){
242 DirEntry aTempFile = Export::GetTempFile();
243 DirEntry aSourceFile( String( sInputFileName , RTL_TEXTENCODING_ASCII_US ) );
244 aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
245 String sTempFile = aTempFile.GetFull();
246 Export::RemoveUTF8ByteOrderMarkerFromFile( ByteString( sTempFile , RTL_TEXTENCODING_ASCII_US ) );
247 pFile = fopen( ByteString( sTempFile , RTL_TEXTENCODING_ASCII_US ).GetBuffer(), "r" );
248 sUsedTempFile = sTempFile;
249 }else{
250 // able to open file?
251 pFile = fopen( sInputFileName.GetBuffer(), "r" );
252 sUsedTempFile = String::CreateFromAscii("");
254 if ( !pFile ){
255 fprintf( stderr, "Error: Could not open file %s\n",
256 sInputFileName.GetBuffer());
257 exit( 13 );
259 else {
260 // this is a valid file which can be opened, so
261 // create path to project root
262 DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
263 aEntry.ToAbs();
264 sFullEntry= ByteString( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
265 aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
266 aEntry += DirEntry( sPrjRoot );
267 ByteString sPrjEntry( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
269 // create file name, beginnig with project root
270 // (e.g.: source\ui\src\menue.src)
271 // printf("sFullEntry = %s\n",sFullEntry.GetBuffer());
272 sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 );
273 // printf("sActFileName = %s\n",sActFileName.GetBuffer());
274 if( !bQuiet )
275 fprintf( stdout, "\nProcessing File %s ...\n", sInputFileName.GetBuffer());
277 sActFileName.SearchAndReplaceAll( "/", "\\" );
279 return pFile;
282 // this means the file could not be opened
283 return NULL;
286 /*****************************************************************************/
287 int WorkOnTokenSet( int nTyp, char *pTokenText )
288 /*****************************************************************************/
290 pParser->Execute( nTyp, pTokenText );
292 return 1;
296 /*****************************************************************************/
297 int SetError()
298 /*****************************************************************************/
300 return 1;
303 /*****************************************************************************/
304 int GetError()
305 /*****************************************************************************/
307 return 0;
312 // class CfgStackData
315 CfgStackData* CfgStack::Push( const ByteString &rTag, const ByteString &rId )
317 CfgStackData *pD = new CfgStackData( rTag, rId );
318 Insert( pD, LIST_APPEND );
319 return pD;
323 // class CfgStack
326 /*****************************************************************************/
327 CfgStack::~CfgStack()
328 /*****************************************************************************/
330 for ( ULONG i = 0; i < Count(); i++ )
331 delete GetObject( i );
334 /*****************************************************************************/
335 ByteString CfgStack::GetAccessPath( ULONG nPos )
336 /*****************************************************************************/
338 if ( nPos == LIST_APPEND )
339 nPos = Count() - 1;
341 ByteString sReturn;
342 for ( ULONG i = 0; i <= nPos; i++ ) {
343 if ( i )
344 sReturn += ".";
345 sReturn += GetStackData( i )->GetIdentifier();
348 return sReturn;
351 /*****************************************************************************/
352 CfgStackData *CfgStack::GetStackData( ULONG nPos )
353 /*****************************************************************************/
355 if ( nPos == LIST_APPEND )
356 nPos = Count() - 1;
358 return GetObject( nPos );
362 // class CfgParser
365 /*****************************************************************************/
366 CfgParser::CfgParser()
367 /*****************************************************************************/
368 : pStackData( NULL ),
369 bLocalize( FALSE )
373 /*****************************************************************************/
374 CfgParser::~CfgParser()
375 /*****************************************************************************/
380 /*****************************************************************************/
381 BOOL CfgParser::IsTokenClosed( const ByteString &rToken )
382 /*****************************************************************************/
384 return rToken.GetChar( rToken.Len() - 2 ) == '/';
387 /*****************************************************************************/
388 void CfgParser::AddText(
389 ByteString &rText,
390 const ByteString &rIsoLang,
391 const ByteString &rResTyp
393 /*****************************************************************************/
395 USHORT nTextLen = 0;
396 while ( rText.Len() != nTextLen ) {
397 nTextLen = rText.Len();
398 rText.SearchAndReplaceAll( "\n", " " );
399 rText.SearchAndReplaceAll( "\r", " " );
400 rText.SearchAndReplaceAll( "\t", " " );
401 rText.SearchAndReplaceAll( " ", " " );
403 pStackData->sResTyp = rResTyp;
404 WorkOnText( rText, rIsoLang );
406 pStackData->sText[ rIsoLang ] = rText;
410 /*****************************************************************************/
411 void CfgParser::WorkOnRessourceEnd()
412 /*****************************************************************************/
416 /*****************************************************************************/
417 int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
418 /*****************************************************************************/
420 ByteString sToken( pToken );
422 if ( sToken == " " || sToken == "\t" )
423 sLastWhitespace += sToken;
425 ByteString sTokenName;
426 ByteString sTokenId;
428 BOOL bOutput = TRUE;
430 switch ( nToken ) {
431 case CFG_TOKEN_PACKAGE:
432 case CFG_TOKEN_COMPONENT:
433 case CFG_TOKEN_TEMPLATE:
434 case CFG_TOKEN_CONFIGNAME:
435 case CFG_TOKEN_OORNAME:
436 case CFG_TOKEN_OORVALUE:
437 case CFG_TAG:
438 case ANYTOKEN:
439 case CFG_TEXT_START:
441 sTokenName = sToken.GetToken( 1, '<' ).GetToken( 0, '>' ).GetToken( 0, ' ' );
443 if ( !IsTokenClosed( sToken )) {
444 ByteString sSearch;
445 switch ( nToken ) {
446 case CFG_TOKEN_PACKAGE:
447 sSearch = "package-id=";
448 break;
449 case CFG_TOKEN_COMPONENT:
450 sSearch = "component-id=";
451 break;
452 case CFG_TOKEN_TEMPLATE:
453 sSearch = "template-id=";
454 break;
455 case CFG_TOKEN_CONFIGNAME:
456 sSearch = "cfg:name=";
457 break;
458 case CFG_TOKEN_OORNAME:
459 sSearch = "oor:name=";
460 bLocalize = TRUE;
461 break;
462 case CFG_TOKEN_OORVALUE:
463 sSearch = "oor:value=";
464 break;
465 case CFG_TEXT_START: {
466 if ( sCurrentResTyp != sTokenName ) {
467 WorkOnRessourceEnd();
468 ByteString sCur;
469 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
470 sCur = aLanguages[ n ];
471 pStackData->sText[ sCur ] = ByteString("");
474 sCurrentResTyp = sTokenName;
476 ByteString sTemp = sToken.Copy( sToken.Search( "xml:lang=" ));
477 sCurrentIsoLang = sTemp.GetToken( 1, '\"' ).GetToken( 0, '\"' );
479 if ( sCurrentIsoLang == NO_TRANSLATE_ISO )
480 bLocalize = FALSE;
482 pStackData->sTextTag = sToken;
484 sCurrentText = "";
486 break;
488 if ( sSearch.Len()) {
489 ByteString sTemp = sToken.Copy( sToken.Search( sSearch ));
490 sTokenId = sTemp.GetToken( 1, '\"' ).GetToken( 0, '\"' );
492 pStackData = aStack.Push( sTokenName, sTokenId );
494 if ( sSearch == "cfg:name=" ) {
495 ByteString sTemp( sToken );
496 sTemp.ToUpperAscii();
497 bLocalize = (( sTemp.Search( "CFG:TYPE=\"STRING\"" ) != STRING_NOTFOUND ) &&
498 ( sTemp.Search( "CFG:LOCALIZED=\"TRUE\"" ) != STRING_NOTFOUND ));
501 else if ( sTokenName == "label" ) {
502 if ( sCurrentResTyp != sTokenName ) {
503 WorkOnRessourceEnd();
504 ByteString sCur;
505 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
506 sCur = aLanguages[ n ];
507 pStackData->sText[ sCur ] = ByteString("");
510 sCurrentResTyp = sTokenName;
513 break;
514 case CFG_CLOSETAG:
515 sTokenName = sToken.GetToken( 1, '/' ).GetToken( 0, '>' ).GetToken( 0, ' ' );
516 if ( aStack.GetStackData() && ( aStack.GetStackData()->GetTagType() == sTokenName )) {
517 if ( ! sCurrentText.Len())
518 WorkOnRessourceEnd();
519 aStack.Pop();
520 pStackData = aStack.GetStackData();
522 else {
523 ByteString sError( "Missplaced close tag: " );
524 ByteString sInFile(" in file ");
525 sError += sToken;
526 sError += sInFile;
527 sError += sFullEntry;
528 Error( sError );
529 exit ( 13 );
531 break;
533 case CFG_TEXTCHAR:
534 sCurrentText += sToken;
535 bOutput = FALSE;
536 break;
538 case CFG_TOKEN_NO_TRANSLATE:
539 bLocalize = FALSE;
540 break;
543 if ( sCurrentText.Len() && nToken != CFG_TEXTCHAR ) {
544 AddText( sCurrentText, sCurrentIsoLang, sCurrentResTyp );
545 Output( sCurrentText );
546 sCurrentText = "";
547 pStackData->sEndTextTag = sToken;
550 if ( bOutput )
551 Output( sToken );
553 if ( sToken != " " && sToken != "\t" )
554 sLastWhitespace = "";
556 return 1;
559 /*****************************************************************************/
560 void CfgExport::Output( const ByteString& rOutput )
561 /*****************************************************************************/
563 // Dummy operation to suppress warnings caused by poor class design
564 ByteString a( rOutput );
567 /*****************************************************************************/
568 int CfgParser::Execute( int nToken, char * pToken )
569 /*****************************************************************************/
571 ByteString sToken( pToken );
573 switch ( nToken ) {
574 case CFG_TAG:
575 if ( sToken.Search( "package-id=" ) != STRING_NOTFOUND )
576 return ExecuteAnalyzedToken( CFG_TOKEN_PACKAGE, pToken );
577 else if ( sToken.Search( "component-id=" ) != STRING_NOTFOUND )
578 return ExecuteAnalyzedToken( CFG_TOKEN_COMPONENT, pToken );
579 else if ( sToken.Search( "template-id=" ) != STRING_NOTFOUND )
580 return ExecuteAnalyzedToken( CFG_TOKEN_TEMPLATE, pToken );
581 else if ( sToken.Search( "cfg:name=" ) != STRING_NOTFOUND )
582 return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, pToken );
583 else if ( sToken.Search( "oor:name=" ) != STRING_NOTFOUND )
584 return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, pToken );
585 else if ( sToken.Search( "oor:value=" ) != STRING_NOTFOUND )
586 return ExecuteAnalyzedToken( CFG_TOKEN_OORVALUE, pToken );
587 break;
589 return ExecuteAnalyzedToken( nToken, pToken );
593 /*****************************************************************************/
594 void CfgParser::Error( const ByteString &rError )
595 /*****************************************************************************/
597 // ByteString sError( rError );
598 // sError.Append("Error: In file ");
599 // sError.Append( sActFileName );
600 yyerror(( char * ) rError.GetBuffer());
605 // class CfgOutputParser
608 /*****************************************************************************/
609 CfgOutputParser::CfgOutputParser( const ByteString &rOutputFile )
610 /*****************************************************************************/
612 pOutputStream =
613 new SvFileStream(
614 String( rOutputFile, RTL_TEXTENCODING_ASCII_US ),
615 STREAM_STD_WRITE | STREAM_TRUNC
617 pOutputStream->SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
619 if ( !pOutputStream->IsOpen()) {
620 ByteString sError( "ERROR: Unable to open output file: " );
621 sError += rOutputFile;
622 Error( sError );
623 delete pOutputStream;
624 pOutputStream = NULL;
625 exit( 13 );
629 /*****************************************************************************/
630 CfgOutputParser::~CfgOutputParser()
631 /*****************************************************************************/
633 if ( pOutputStream ) {
634 pOutputStream->Close();
635 delete pOutputStream;
640 // class CfgExport
643 /*****************************************************************************/
644 CfgExport::CfgExport(
645 const ByteString &rOutputFile,
646 const ByteString &rProject,
647 const ByteString &rFilePath
649 /*****************************************************************************/
650 : CfgOutputParser( rOutputFile ),
651 sPrj( rProject ),
652 sPath( rFilePath )
654 Export::InitLanguages( false );
655 aLanguages = Export::GetLanguages();
658 /*****************************************************************************/
659 CfgExport::~CfgExport()
660 /*****************************************************************************/
664 /*****************************************************************************/
665 void CfgExport::WorkOnRessourceEnd()
666 /*****************************************************************************/
668 if ( pOutputStream && bLocalize ) {
669 if (( pStackData->sText[ ByteString("en-US") ].Len()
670 ) ||
671 ( bForce &&
672 ( pStackData->sText[ ByteString("de") ].Len() ||
673 pStackData->sText[ ByteString("en-US") ].Len() )))
675 ByteString sFallback = pStackData->sText[ ByteString("en-US") ];
677 //if ( pStackData->sText[ ByteString("en-US") ].Len())
678 // sFallback = pStackData->sText[ ByteString("en-US") ];
680 ByteString sLocalId = pStackData->sIdentifier;
681 ByteString sGroupId;
682 if ( aStack.Count() == 1 ) {
683 sGroupId = sLocalId;
684 sLocalId = "";
686 else {
687 sGroupId = aStack.GetAccessPath( aStack.Count() - 2 );
690 ByteString sTimeStamp( Export::GetTimeStamp());
692 ByteString sCur;
693 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
694 sCur = aLanguages[ n ];
696 ByteString sText = pStackData->sText[ sCur ];
697 if ( !sText.Len())
698 sText = sFallback;
700 Export::UnquotHTML( sText );
702 ByteString sOutput( sPrj ); sOutput += "\t";
703 sOutput += sPath;
704 sOutput += "\t0\t";
705 sOutput += pStackData->sResTyp; sOutput += "\t";
706 sOutput += sGroupId; sOutput += "\t";
707 sOutput += sLocalId; sOutput += "\t\t\t0\t";
708 sOutput += sCur;
709 sOutput += "\t";
711 sOutput += sText; sOutput += "\t\t\t\t";
712 sOutput += sTimeStamp;
714 //if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sPrj ) ) )
715 pOutputStream->WriteLine( sOutput );
721 /*****************************************************************************/
722 void CfgExport::WorkOnText(
723 ByteString &rText,
724 const ByteString &rIsoLang
726 /*****************************************************************************/
728 if( rIsoLang.Len() ) Export::UnquotHTML( rText );
733 // class CfgMerge
736 /*****************************************************************************/
737 CfgMerge::CfgMerge(
738 const ByteString &rMergeSource, const ByteString &rOutputFile,
739 ByteString &rFilename )
740 /*****************************************************************************/
741 : CfgOutputParser( rOutputFile ),
742 pMergeDataFile( NULL ),
743 pResData( NULL ),
744 bGerman( FALSE ),
745 sFilename( rFilename ),
746 bEnglish( FALSE )
748 if ( rMergeSource.Len()){
749 pMergeDataFile = new MergeDataFile(
750 rMergeSource, sInputFileName , bErrorLog, RTL_TEXTENCODING_MS_1252, true );
751 if( Export::sLanguages.EqualsIgnoreCaseAscii("ALL") ){
752 Export::SetLanguages( pMergeDataFile->GetLanguages() );
753 aLanguages = pMergeDataFile->GetLanguages();
755 else aLanguages = Export::GetLanguages();
756 }else
757 aLanguages = Export::GetLanguages();
760 /*****************************************************************************/
761 CfgMerge::~CfgMerge()
762 /*****************************************************************************/
764 delete pMergeDataFile;
765 delete pResData;
768 /*****************************************************************************/
769 void CfgMerge::WorkOnText(
770 ByteString &rText,
771 const ByteString& nLangIndex
773 /*****************************************************************************/
776 if ( pMergeDataFile && bLocalize ) {
777 if ( !pResData ) {
778 ByteString sLocalId = pStackData->sIdentifier;
779 ByteString sGroupId;
780 if ( aStack.Count() == 1 ) {
781 sGroupId = sLocalId;
782 sLocalId = "";
784 else {
785 sGroupId = aStack.GetAccessPath( aStack.Count() - 2 );
788 ByteString sPlatform( "" );
790 pResData = new ResData( sPlatform, sGroupId , sFilename );
791 pResData->sId = sLocalId;
792 pResData->sResTyp = pStackData->sResTyp;
795 //if ( nLangIndex.EqualsIgnoreCaseAscii("de") )
796 // bGerman = TRUE;
797 if (( nLangIndex.EqualsIgnoreCaseAscii("en-US") ))
798 bEnglish = TRUE;
800 PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
801 if ( pEntrys ) {
802 ByteString sContent;
803 pEntrys->GetText( sContent, STRING_TYP_TEXT, nLangIndex );
805 if ( Export::isAllowed( nLangIndex ) &&
806 ( sContent != "-" ) && ( sContent.Len()))
808 #ifdef MERGE_SOURCE_LANGUAGES
809 if( nLangIndex.EqualsIgnoreCaseAscii("de") || nLangIndex.EqualsIgnoreCaseAscii("en-US") )
810 rText = sContent;
811 #endif
812 Export::QuotHTML( rText );
818 /*****************************************************************************/
819 void CfgMerge::Output( const ByteString& rOutput )
820 /*****************************************************************************/
822 if ( pOutputStream )
823 pOutputStream->Write( rOutput.GetBuffer(), rOutput.Len());
826 ULONG CfgStack::Push( CfgStackData *pStackData )
828 Insert( pStackData, LIST_APPEND );
829 return Count() - 1;
832 /*****************************************************************************/
833 void CfgMerge::WorkOnRessourceEnd()
834 /*****************************************************************************/
837 if ( pMergeDataFile && pResData && bLocalize && (( bEnglish ) || bForce )) {
838 PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
839 if ( pEntrys ) {
840 ByteString sCur;
842 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
843 sCur = aLanguages[ n ];
845 ByteString sContent;
846 pEntrys->GetText( sContent, STRING_TYP_TEXT, sCur , TRUE );
847 if (
848 // (!sCur.EqualsIgnoreCaseAscii("de") ) &&
849 ( !sCur.EqualsIgnoreCaseAscii("en-US") ) &&
851 ( sContent != "-" ) && ( sContent.Len()))
854 ByteString sText = sContent;
855 Export::QuotHTML( sText );
857 ByteString sAdditionalLine( "\t" );
859 ByteString sTextTag = pStackData->sTextTag;
860 ByteString sTemp = sTextTag.Copy( sTextTag.Search( "xml:lang=" ));
862 ByteString sSearch = sTemp.GetToken( 0, '\"' );
863 sSearch += "\"";
864 sSearch += sTemp.GetToken( 1, '\"' );
865 sSearch += "\"";
867 ByteString sReplace = sTemp.GetToken( 0, '\"' );
868 sReplace += "\"";
869 sReplace += sCur;
870 sReplace += "\"";
872 sTextTag.SearchAndReplace( sSearch, sReplace );
874 sAdditionalLine += sTextTag;
875 sAdditionalLine += sText;
876 sAdditionalLine += pStackData->sEndTextTag;
878 sAdditionalLine += "\n";
879 sAdditionalLine += sLastWhitespace;
881 Output( sAdditionalLine );
886 delete pResData;
887 pResData = NULL;
888 bGerman = FALSE;
889 bEnglish = FALSE;