merge the formfield patch from ooo-build
[ooovba.git] / transex3 / source / export.cxx
blob7043231efdac7caae8e67d16a676b2361013c5c3
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: export.cxx,v $
10 * $Revision: 1.57 $
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 <stdlib.h>
35 #include <tools/fsys.hxx>
36 #include "export.hxx"
37 #include "tokens.h"
38 #include "utf8conv.hxx"
39 #include <iostream>
41 extern "C" { int yyerror( char * ); }
42 extern "C" { int YYWarning( char * ); }
44 Export *pExport = 0L;
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_BREAKHELP 0x0008
55 #define STATE_UNMERGE 0x0009
56 #define STATE_UTF8 0x000A
57 #define STATE_LANGUAGES 0X000B
59 // set of global variables
60 DECLARE_LIST( FileList, ByteString * )
61 FileList aInputFileList;
62 BOOL bEnableExport;
63 BOOL bMergeMode;
64 BOOL bErrorLog;
65 BOOL bBreakWhenHelpText;
66 BOOL bUnmerge;
67 BOOL bUTF8;
68 bool bQuiet;
69 ByteString sPrj;
70 ByteString sPrjRoot;
71 ByteString sActFileName;
72 ByteString sOutputFile;
73 ByteString sMergeSrc;
74 ByteString sTempFile;
75 ByteString sFile;
76 MergeDataFile *pMergeDataFile;
77 FILE *pTempFile;
80 ByteString sStrBuffer;
81 bool bMarcro = false;
83 extern "C" {
84 // the whole interface to lexer is in this extern "C" section
87 /*****************************************************************************/
88 extern char *GetOutputFile( int argc, char* argv[])
89 /*****************************************************************************/
91 bEnableExport = FALSE;
92 bMergeMode = FALSE;
93 bErrorLog = TRUE;
94 bBreakWhenHelpText = FALSE;
95 bUnmerge = FALSE;
96 bUTF8 = TRUE;
97 sPrj = "";
98 sPrjRoot = "";
99 sActFileName = "";
100 Export::sLanguages = "";
101 Export::sForcedLanguages = "";
102 sTempFile = "";
103 pTempFile = NULL;
104 bQuiet = false;
105 USHORT nState = STATE_NON;
106 BOOL bInput = FALSE;
108 // parse command line
109 for( int i = 1; i < argc; i++ ) {
110 ByteString sSwitch( argv[ i ] );
112 if (sSwitch == "-i" || sSwitch == "-I" ) {
113 nState = STATE_INPUT; // next tokens specifies source files
115 else if (sSwitch == "-o" || sSwitch == "-O" ) {
116 nState = STATE_OUTPUT; // next token specifies the dest file
118 else if (sSwitch == "-p" || sSwitch == "-P" ) {
119 nState = STATE_PRJ; // next token specifies the cur. project
121 else if (sSwitch == "-qq" || sSwitch == "-QQ" ) {
122 bQuiet = true;
125 else if (sSwitch == "-r" || sSwitch == "-R" ) {
126 nState = STATE_ROOT; // next token specifies path to project root
128 else if (sSwitch == "-m" || sSwitch == "-M" ) {
129 nState = STATE_MERGESRC; // next token specifies the merge database
131 else if (sSwitch == "-e" || sSwitch == "-E" ) {
132 nState = STATE_ERRORLOG;
133 bErrorLog = FALSE;
135 else if (sSwitch == "-b" || sSwitch == "-B" ) {
136 nState = STATE_BREAKHELP;
137 bBreakWhenHelpText = TRUE;
139 else if (sSwitch == "-u" || sSwitch == "-U" ) {
140 nState = STATE_UNMERGE;
141 bUnmerge = TRUE;
142 bMergeMode = TRUE;
144 else if ( sSwitch.ToUpperAscii() == "-UTF8" ) {
145 nState = STATE_UTF8;
146 bUTF8 = TRUE;
148 else if ( sSwitch.ToUpperAscii() == "-NOUTF8" ) {
149 nState = STATE_UTF8;
150 bUTF8 = FALSE;
152 else if ( sSwitch == "-l" || sSwitch == "-L" ) {
153 nState = STATE_LANGUAGES;
155 else {
156 switch ( nState ) {
157 case STATE_NON: {
158 return NULL; // no valid command line
160 case STATE_INPUT: {
161 aInputFileList.Insert( new ByteString( argv[ i ]), LIST_APPEND );
162 bInput = TRUE; // min. one source file found
164 break;
165 case STATE_OUTPUT: {
166 sOutputFile = ByteString( argv[ i ]); // the dest. file
168 break;
169 case STATE_PRJ: {
170 sPrj = ByteString( argv[ i ]);
172 break;
173 case STATE_ROOT: {
174 sPrjRoot = ByteString( argv[ i ]); // path to project root
176 break;
177 case STATE_MERGESRC: {
178 sMergeSrc = ByteString( argv[ i ]);
179 bMergeMode = TRUE; // activate merge mode, cause merge database found
181 break;
182 case STATE_LANGUAGES: {
183 Export::sLanguages = ByteString( argv[ i ]);
185 break;
189 if( bUnmerge ) sMergeSrc = ByteString();
190 if ( bInput ) {
191 // command line is valid
192 bEnableExport = TRUE;
193 char *pReturn = new char[ sOutputFile.Len() + 1 ];
194 strcpy( pReturn, sOutputFile.GetBuffer()); // #100211# - checked
195 return pReturn;
198 // command line is not valid
199 return NULL;
201 /*****************************************************************************/
202 int isQuiet(){
203 /*****************************************************************************/
204 if( bQuiet ) return 1;
205 else return 0;
207 /*****************************************************************************/
208 int InitExport( char *pOutput , char* pFilename )
209 /*****************************************************************************/
211 // instanciate Export
212 ByteString sOutput( pOutput );
213 ByteString sFilename( pFilename );
215 if ( bMergeMode && !bUnmerge ) {
216 // merge mode enabled, so read database
217 pExport = new Export(sOutput, bEnableExport, sPrj, sPrjRoot, sMergeSrc , sFilename );
219 else
220 // no merge mode, only export
221 pExport = new Export( sOutput, bEnableExport, sPrj, sPrjRoot , sFilename );
222 return 1;
225 /*****************************************************************************/
226 int EndExport()
227 /*****************************************************************************/
229 delete pExport;
230 return 1;
233 extern const char* getFilename()
235 return (*(aInputFileList.GetObject( 0 ))).GetBuffer();
237 /*****************************************************************************/
238 extern FILE *GetNextFile()
239 /*****************************************************************************/
241 // look for next valid filename in input file list
242 if ( sTempFile.Len()) {
243 fclose( pTempFile );
244 String sTemp( sTempFile, RTL_TEXTENCODING_ASCII_US );
245 DirEntry aTemp( sTemp );
246 aTemp.Kill();
249 while ( aInputFileList.Count()) {
250 ByteString sFileName( *(aInputFileList.GetObject( 0 )));
252 ByteString sOrigFile( sFileName );
254 sFileName = Export::GetNativeFile( sFileName );
255 delete aInputFileList.GetObject(( ULONG ) 0 );
256 aInputFileList.Remove(( ULONG ) 0 );
258 if ( sFileName == "" ) {
259 fprintf( stderr, "ERROR: Could not precompile File %s\n",
260 sOrigFile.GetBuffer());
261 return GetNextFile();
264 sTempFile = sFileName;
265 Export::RemoveUTF8ByteOrderMarkerFromFile( sFileName );
267 // able to open file?
268 FILE *pFile = fopen( sFileName.GetBuffer(), "r" );
269 if ( !pFile )
270 fprintf( stderr, "Error: Could not open File %s\n",
271 sFileName.GetBuffer());
272 else {
273 pTempFile = pFile;
275 // this is a valid file which can be opened, so
276 // create path to project root
277 DirEntry aEntry( String( sOrigFile, RTL_TEXTENCODING_ASCII_US ));
278 aEntry.ToAbs();
279 ByteString sFullEntry( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
280 aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
281 aEntry += DirEntry( sPrjRoot );
282 ByteString sPrjEntry( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US );
284 // create file name, beginnig with project root
285 // (e.g.: source\ui\src\menue.src)
286 sActFileName = sFullEntry.Copy( sPrjEntry.Len() + 1 );
288 if( !bQuiet ) fprintf( stdout, "\nProcessing File %s ...\n", sOrigFile.GetBuffer());
290 sActFileName.SearchAndReplaceAll( "/", "\\" );
291 sFile = sActFileName;
293 if ( pExport ) {
294 // create instance of class export
295 pExport->Init();
297 // return the valid file handle
298 return pFile;
301 // this means the file could not be opened
302 return NULL;
305 int Parse( int nTyp, const char *pTokenText ){
306 pExport->Execute( nTyp , pTokenText );
307 return 1;
309 void Close(){
310 pExport->pParseQueue->Close();
312 /*****************************************************************************/
313 int WorkOnTokenSet( int nTyp, char *pTokenText )
314 /*****************************************************************************/
317 pExport->pParseQueue->Push( QueueEntry( nTyp , ByteString( pTokenText ) ) );
318 return 1;
321 } // extern
323 extern "C" {
324 /*****************************************************************************/
325 int SetError()
326 /*****************************************************************************/
328 // set error at global instance of class Export
329 pExport->SetError();
330 return 1;
334 extern "C" {
335 /*****************************************************************************/
336 int GetError()
337 /*****************************************************************************/
339 // get error at global instance of class Export
340 if ( pExport->GetError())
341 return 1;
342 return FALSE;
347 // class ResData
350 void ResData::Dump(){
351 printf("**************\nResData\n");
352 printf("sPForm = %s , sResTyp = %s , sId = %s , sGId = %s , sHelpId = %s\n",sPForm.GetBuffer()
353 ,sResTyp.GetBuffer(),sId.GetBuffer(),sGId.GetBuffer(),sHelpId.GetBuffer());
355 ByteString a("*pStringList");
356 ByteString b("*pUIEntries");
357 ByteString c("*pFilterList");
358 ByteString d("*pItemList");
359 ByteString e("*pPairedList");
360 ByteString f("sText");
362 Export::DumpMap( f , sText );
364 if( pStringList ) Export::DumpExportList( a , *pStringList );
365 if( pUIEntries ) Export::DumpExportList( b , *pUIEntries );
366 if( pFilterList ) Export::DumpExportList( c , *pFilterList );
367 if( pItemList ) Export::DumpExportList( d , *pItemList );
368 if( pPairedList ) Export::DumpExportList( e , *pPairedList );
369 printf("\n");
372 void ResData::addFallbackData( ByteString& sId_in , const ByteString& sText_in ){
373 //printf(" ResData::addFallbackData ( sId = %s , sText = %s )\n", sId_in.GetBuffer() , sText_in.GetBuffer() );
374 aFallbackData[ sId_in ] = sText_in;
376 bool ResData::getFallbackData( ByteString& sId_in , ByteString& sText_inout ){
377 sText_inout = aFallbackData[ sId_in ];
378 //printf("ResData::getFallbackData( sId = %s , return sText = %s \n" , sId_in.GetBuffer(), sText_inout.GetBuffer());
379 return sText_inout.Len() > 0;
382 void ResData::addMergedLanguage( ByteString& sLang ){
383 aMergedLanguages[ sLang ]=ByteString("1");
385 bool ResData::isMerged( ByteString& sLang ){
386 return aMergedLanguages[ sLang ].Equals("1");
389 /*****************************************************************************/
390 BOOL ResData::SetId( const ByteString &rId, USHORT nLevel )
391 /*****************************************************************************/
393 if ( nLevel > nIdLevel )
395 nIdLevel = nLevel;
396 sId = rId;
398 if ( bChild && bChildWithText ) {
399 ByteString sError( "ResId after child definition" );
400 yyerror( sError.GetBufferAccess());
401 sError.ReleaseBufferAccess();
402 SetError();
405 if ( sId.Len() > 255 ) {
406 ByteString sWarning( "LocalId > 255 chars, truncating..." );
407 YYWarning( sWarning.GetBufferAccess());
408 sWarning.ReleaseBufferAccess();
409 sId.Erase( 255 );
410 sId.EraseTrailingChars( ' ' );
411 sId.EraseTrailingChars( '\t' );
414 return TRUE;
417 return FALSE;
421 // class Export
424 /*****************************************************************************/
425 Export::Export( const ByteString &rOutput, BOOL bWrite,
426 const ByteString &rPrj, const ByteString &rPrjRoot , const ByteString& rFile )
427 /*****************************************************************************/
429 pWordTransformer( NULL ),
430 aCharSet( RTL_TEXTENCODING_MS_1252 ),
431 bDefine( FALSE ),
432 bNextMustBeDefineEOL( FALSE ),
433 nLevel( 0 ),
434 nList( LIST_NON ),
435 nListIndex( 0 ),
436 nListLevel( 0 ),
437 bSkipFile( false ),
438 sProject( sPrj ),
439 sRoot( sPrjRoot ),
440 bEnableExport( bWrite ),
441 bMergeMode( bUnmerge ),
442 bError( FALSE ),
443 bReadOver( FALSE ),
444 bDontWriteOutput( FALSE ),
445 sFilename( rFile )
447 pParseQueue = new ParserQueue( *this );
448 (void) rPrj;
449 (void) rPrjRoot;
450 (void) rFile;
452 if( !isInitialized ) InitLanguages();
453 // used when export is enabled
455 // open output stream
456 if ( bEnableExport ) {
457 aOutput.Open( String( rOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
458 if( !aOutput.IsOpen() ) {
459 printf("ERROR : Can't open file %s\n",rOutput.GetBuffer());
460 exit ( -1 );
462 aOutput.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
464 aOutput.SetLineDelimiter( LINEEND_CRLF );
468 /*****************************************************************************/
469 Export::Export( const ByteString &rOutput, BOOL bWrite,
470 const ByteString &rPrj, const ByteString &rPrjRoot,
471 const ByteString &rMergeSource , const ByteString& rFile )
472 /*****************************************************************************/
474 pWordTransformer( NULL ),
475 aCharSet( RTL_TEXTENCODING_MS_1252 ),
476 bDefine( FALSE ),
477 bNextMustBeDefineEOL( FALSE ),
478 nLevel( 0 ),
479 nList( LIST_NON ),
480 nListIndex( 0 ),
481 nListLevel( 0 ),
482 bSkipFile( false ),
483 sProject( sPrj ),
484 sRoot( sPrjRoot ),
485 bEnableExport( bWrite ),
486 bMergeMode( TRUE ),
487 sMergeSrc( rMergeSource ),
488 bError( FALSE ),
489 bReadOver( FALSE ),
490 bDontWriteOutput( FALSE ),
491 sFilename( rFile )
493 (void) rPrj;
494 (void) rPrjRoot;
495 (void) rFile;
496 pParseQueue = new ParserQueue( *this );
497 if( !isInitialized ) InitLanguages( bMergeMode );
498 // used when merge is enabled
500 // open output stream
501 if ( bEnableExport ) {
502 aOutput.Open( String( rOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
503 aOutput.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
504 aOutput.SetLineDelimiter( LINEEND_CRLF );
509 /*****************************************************************************/
510 void Export::Init()
511 /*****************************************************************************/
513 // resets the internal status, used before parseing another file
514 sActPForm = "";
515 bDefine = FALSE;
516 bNextMustBeDefineEOL = FALSE;
517 nLevel = 0;
518 nList = LIST_NON;
519 nListLang = ByteString( String::CreateFromAscii(""),RTL_TEXTENCODING_ASCII_US );
520 nListIndex = 0;
521 while ( aResStack.Count()) {
522 delete aResStack.GetObject(( ULONG ) 0 );
523 aResStack.Remove(( ULONG ) 0 );
527 /*****************************************************************************/
528 Export::~Export()
529 /*****************************************************************************/
531 if( pParseQueue )
532 delete pParseQueue;
533 // close output stream
534 if ( bEnableExport )
535 aOutput.Close();
536 while ( aResStack.Count()) {
537 delete aResStack.GetObject(( ULONG ) 0 );
538 aResStack.Remove(( ULONG ) 0 );
541 if ( bMergeMode && !bUnmerge ) {
542 if ( !pMergeDataFile )
543 pMergeDataFile = new MergeDataFile( sMergeSrc,sFile , bErrorLog, aCharSet);//, bUTF8 );
545 //pMergeDataFile->WriteErrorLog( sActFileName );
546 delete pMergeDataFile;
550 /*****************************************************************************/
551 int Export::Execute( int nToken, const char * pToken )
552 /*****************************************************************************/
555 ByteString sToken( pToken );
556 ByteString sOrig( sToken );
557 /* printf("+---------------\n");
558 printf("sToken = %s\n",sToken.GetBuffer());
559 printf("nToken = %d\n",nToken);
560 printf("+---------------\n"); */
561 BOOL bWriteToMerged = bMergeMode;
563 if ( nToken == CONDITION ) {
564 ByteString sTestToken( pToken );
565 sTestToken.EraseAllChars( '\t' );
566 sTestToken.EraseAllChars( ' ' );
567 if (( !bReadOver ) && ( sTestToken.Search( "#ifndef__RSC_PARSER" ) == 0 ))
568 bReadOver = TRUE;
569 else if (( bReadOver ) && ( sTestToken.Search( "#endif" ) == 0 ))
570 bReadOver = FALSE;
572 if ((( nToken < FILTER_LEVEL ) || ( bReadOver )) &&
573 (!(( bNextMustBeDefineEOL ) && ( sOrig == "\n" )))) {
574 // this tokens are not mandatory for parsing, so ignore them ...
575 if ( bMergeMode )
576 WriteToMerged( sOrig , false ); // ... ore whrite them directly to dest.
577 return 0;
580 ResData *pResData = NULL;
581 if ( nLevel ) {
582 // res. exists at cur. level
583 pResData = aResStack.GetObject( nLevel-1 );
585 else if (( nToken != RESSOURCE ) &&
586 ( nToken != RESSOURCEEXPR ) &&
587 ( nToken != SMALRESSOURCE ) &&
588 ( nToken != LEVELUP ) &&
589 ( nToken != NORMDEFINE ) &&
590 ( nToken != RSCDEFINE ) &&
591 ( nToken != CONDITION ) &&
592 ( nToken != PRAGMA ))
594 // no res. exists at cur. level so return
595 if ( bMergeMode )
596 WriteToMerged( sOrig , false );
597 return 0;
599 // #define NO_LOCALIZE_EXPORT
600 if( bSkipFile ){
601 if ( bMergeMode ) {
602 WriteToMerged( sOrig , false );
604 return 1;
608 if ( bDefine ) {
609 if (( nToken != EMPTYLINE ) && ( nToken != LEVELDOWN ) && ( nToken != LEVELUP )) {
610 // cur. res. defined in macro
611 if ( bNextMustBeDefineEOL ) {
612 if ( nToken != RSCDEFINELEND ) {
613 // end of macro found, so destroy res.
614 bDefine = FALSE;
615 if ( bMergeMode ) {
616 /*if ( bDontWriteOutput && bUnmerge ) {
617 bDontWriteOutput = FALSE;
618 bNextMustBeDefineEOL = FALSE;
619 bDefine = TRUE;
621 MergeRest( pResData );
623 bNextMustBeDefineEOL = FALSE;
624 Execute( LEVELDOWN, "" );
626 else {
627 // next line also in macro definition
628 bNextMustBeDefineEOL = FALSE;
629 if ( bMergeMode )
630 WriteToMerged( sOrig , false );
631 return 1;
634 else if (( nToken != LISTASSIGNMENT ) && ( nToken != UIENTRIES )){
635 // cur. line has macro line end
636 ByteString sTmpLine( sToken );
637 sTmpLine.EraseAllChars( '\t' ); sTmpLine.EraseAllChars( ' ' );
638 #if 0
639 // impossible, unsigned is never negative
640 if( sTmpLine.Len() < 0 ){
641 if ( sTmpLine.GetChar(( USHORT )( sTmpLine.Len() - 1 )) != '\\' )
642 bNextMustBeDefineEOL = TRUE;
644 #endif
649 BOOL bExecuteDown = FALSE;
650 if ( nToken != LEVELDOWN ) {
651 USHORT nOpen = 0;
652 USHORT nClose = 0;
653 BOOL bReadOver1 = FALSE;
654 USHORT i = 0;
655 for ( i = 0; i < sToken.Len(); i++ ) {
656 if ( sToken.GetChar( i ) == '\"' )
657 bReadOver1 = !bReadOver1;
658 if ( !bReadOver1 && ( sToken.GetChar( i ) == '{' ))
659 nOpen++;
662 bReadOver1 = FALSE;
663 for ( i = 0; i < sToken.Len(); i++ ) {
664 if ( sToken.GetChar( i ) == '\"' )
665 bReadOver1 = !bReadOver1;
666 if ( !bReadOver1 && ( sToken.GetChar( i ) == '}' ))
667 nClose++;
670 if ( nOpen < nClose )
671 bExecuteDown = TRUE;
673 switch ( nToken ) {
675 case NORMDEFINE:
676 //printf("sToken = '%s'",sToken.GetBuffer());
677 while( sToken.SearchAndReplace( "\r", " " ) != STRING_NOTFOUND ) {};
678 while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
679 while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {};
680 if( sToken.EqualsIgnoreCaseAscii( "#define NO_LOCALIZE_EXPORT" ) ){
681 bSkipFile = true;
682 return 0;
684 if ( bMergeMode )
685 WriteToMerged( sOrig , false );
687 return 0;
690 case RSCDEFINE:
691 bDefine = TRUE; // res. defined in macro
693 case RESSOURCE:
694 case RESSOURCEEXPR: {
695 bDontWriteOutput = FALSE;
696 if ( nToken != RSCDEFINE )
697 bNextMustBeDefineEOL = FALSE;
698 // this is the beginning of a new res.
699 nLevel++;
700 if ( nLevel > 1 ) {
701 aResStack.GetObject( nLevel - 2 )->bChild = TRUE;
704 // create new instance for this res. and fill mandatory fields
706 pResData = new ResData( sActPForm, FullId() , sFilename );
707 aResStack.Insert( pResData, LIST_APPEND );
708 ByteString sBackup( sToken );
709 sToken.EraseAllChars( '\n' );
710 sToken.EraseAllChars( '\r' );
711 sToken.EraseAllChars( '{' );
712 while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
713 sToken.EraseTrailingChars( ' ' );
714 ByteString sT = sToken.GetToken( 0, ' ' );
715 pResData->sResTyp = sT.ToLowerAscii();
716 ByteString sId( sToken.Copy( pResData->sResTyp.Len() + 1 ));
717 ByteString sCondition;
718 if ( sId.Search( "#" ) != STRING_NOTFOUND ) {
719 // between ResTyp, Id and paranthes is a precomp. condition
720 sCondition = "#";
721 sCondition += sId.GetToken( 1, '#' );
722 sId = sId.GetToken( 0, '#' );
724 sId = sId.GetToken( 0, '/' );
725 CleanValue( sId );
726 sId = sId.EraseAllChars( '\t' );
727 pResData->SetId( sId, ID_LEVEL_IDENTIFIER );
728 if ( sCondition.Len()) {
729 ByteString sEmpty( "" );
730 Execute( CONDITION, sEmpty.GetBufferAccess()); // execute the
731 // precomp.
732 // condition
733 sEmpty.ReleaseBufferAccess();
736 break;
737 case SMALRESSOURCE: {
738 bDontWriteOutput = FALSE;
739 // this is the beginning of a new res.
740 bNextMustBeDefineEOL = FALSE;
741 nLevel++;
742 if ( nLevel > 1 ) {
743 aResStack.GetObject( nLevel - 2 )->bChild = TRUE;
746 // create new instance for this res. and fill mandatory fields
748 pResData = new ResData( sActPForm, FullId() , sFilename );
749 aResStack.Insert( pResData, LIST_APPEND );
750 sToken.EraseAllChars( '\n' );
751 sToken.EraseAllChars( '\r' );
752 sToken.EraseAllChars( '{' );
753 sToken.EraseAllChars( '\t' );
754 sToken.EraseAllChars( ' ' );
755 sToken.EraseAllChars( '\\' );
756 pResData->sResTyp = sToken.ToLowerAscii();
758 break;
759 case LEVELUP: {
760 // push
761 if ( nList )
762 nListLevel++;
763 if ( nList )
764 break;
766 bDontWriteOutput = FALSE;
767 ByteString sLowerTyp;
768 if ( pResData )
769 sLowerTyp = "unknown";
770 nLevel++;
771 if ( nLevel > 1 ) {
772 aResStack.GetObject( nLevel - 2 )->bChild = TRUE;
775 ResData *pNewData = new ResData( sActPForm, FullId() , sFilename );
776 pNewData->sResTyp = sLowerTyp;
777 aResStack.Insert( pNewData, LIST_APPEND );
779 break;
780 case LEVELDOWN: {
781 // pop
782 if ( !nList ) {
783 bDontWriteOutput = FALSE;
784 if ( nLevel ) {
785 if ( bDefine && (nLevel == 1 )) {
786 bDefine = FALSE;
787 bNextMustBeDefineEOL = FALSE;
789 WriteData( pResData );
790 delete aResStack.GetObject( nLevel - 1 );
791 aResStack.Remove( nLevel - 1 );
792 nLevel--;
795 else {
796 if ( bDefine )
797 bNextMustBeDefineEOL = TRUE;
798 if ( !nListLevel ) {
799 if ( bMergeMode )
800 MergeRest( pResData, MERGE_MODE_LIST );
801 nList = LIST_NON;
803 else
804 nListLevel--;
807 break;
808 case ASSIGNMENT: {
809 bDontWriteOutput = FALSE;
810 // interpret different types of assignement
811 ByteString sKey = sToken.GetToken( 0, '=' );
812 sKey.EraseAllChars( ' ' );
813 sKey.EraseAllChars( '\t' );
814 ByteString sValue = sToken.GetToken( 1, '=' );
815 CleanValue( sValue );
816 if ( sKey.ToUpperAscii() == "IDENTIFIER" ) {
817 ByteString sId( sValue.EraseAllChars( '\t' ));
818 pResData->SetId( sId.EraseAllChars( ' ' ), ID_LEVEL_IDENTIFIER );
820 else if ( sKey == "HELPID" ) {
821 pResData->sHelpId = sValue;
823 else if ( sKey == "STRINGLIST" ) {
824 //if ( bUnmerge ){
825 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
828 pResData->bList = TRUE;
829 nList = LIST_STRING;
830 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
831 nListLang = SOURCE_LANGUAGE;
832 nListIndex = 0;
833 nListLevel = 0;
835 else if ( sKey == "FILTERLIST" ) {
836 //if ( bUnmerge ){
837 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
839 pResData->bList = TRUE;
840 nList = LIST_FILTER;
841 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
842 nListLang = SOURCE_LANGUAGE;
843 nListIndex = 0;
844 nListLevel = 0;
846 else if ( sKey == "UIENTRIES" ) {
847 //if ( bUnmerge ){
848 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));}
849 pResData->bList = TRUE;
850 nList = LIST_UIENTRIES;
851 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
852 nListLang = SOURCE_LANGUAGE;
853 nListIndex = 0;
854 nListLevel = 0;
856 if (( sToken.Search( "{" ) != STRING_NOTFOUND ) &&
857 ( sToken.GetTokenCount( '{' ) > sToken.GetTokenCount( '}' )))
859 //WorkOnTokenSet( LEVELUP, pTkn );
860 Parse( LEVELUP, "" );
862 //if ( bUnmerge && ( nListLang.EqualsIgnoreCaseAscii("de") || nListLang.EqualsIgnoreCaseAscii("en-US") ) && ListExists( pResData, nList ))
863 // bDontWriteOutput = TRUE;
865 break;
866 case UIENTRIES:
867 case LISTASSIGNMENT: {
868 bDontWriteOutput = FALSE;
869 ByteString sTmpToken( sToken);
870 sTmpToken.EraseAllChars(' ');
871 USHORT nPos = 0;
872 //nPos = sTmpToken.ToLowerAscii().Search("[de]=");
873 nPos = sTmpToken.ToLowerAscii().Search("[en-us]=");
874 if( nPos != STRING_NOTFOUND ) {
875 //if ( bUnmerge ){
876 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
878 ByteString sKey = sTmpToken.Copy( 0 , nPos );
879 sKey.EraseAllChars( ' ' );
880 sKey.EraseAllChars( '\t' );
881 ByteString sValue = sToken.GetToken( 1, '=' );
882 CleanValue( sValue );
883 if ( sKey.ToUpperAscii() == "STRINGLIST" ) {
884 pResData->bList = TRUE;
885 nList = LIST_STRING;
886 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
887 nListLang = SOURCE_LANGUAGE;
888 nListIndex = 0;
889 nListLevel = 0;
891 else if ( sKey == "FILTERLIST" ) {
892 pResData->bList = TRUE;
893 nList = LIST_FILTER;
894 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
895 nListLang = SOURCE_LANGUAGE;
896 nListIndex = 0;
897 nListLevel = 0;
899 // PairedList
900 else if ( sKey == "PAIREDLIST" ) {
901 pResData->bList = TRUE;
902 nList = LIST_PAIRED;
903 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
904 nListLang = SOURCE_LANGUAGE;
905 nListIndex = 0;
906 nListLevel = 0;
909 else if ( sKey == "ITEMLIST" ) {
910 pResData->bList = TRUE;
911 nList = LIST_ITEM;
912 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
913 nListLang = SOURCE_LANGUAGE;
914 nListIndex = 0;
915 nListLevel = 0;
917 else if ( sKey == "UIENTRIES" ) {
918 pResData->bList = TRUE;
919 nList = LIST_UIENTRIES;
920 //ByteString sLang("en-US" , RTL_TEXTENCODING_ASCII_US );
921 nListLang = SOURCE_LANGUAGE;
922 nListIndex = 0;
923 nListLevel = 0;
925 /*if ( bUnmerge && ( nListLang.EqualsIgnoreCaseAscii( "de" )
926 || nListLang.EqualsIgnoreCaseAscii("en-US" ) )
927 && ListExists( pResData, nList ))
928 bDontWriteOutput = TRUE;*/
930 else {
931 // new res. is a String- or FilterList
932 ByteString sKey = sToken.GetToken( 0, '[' );
933 sKey.EraseAllChars( ' ' );
934 sKey.EraseAllChars( '\t' );
935 if ( sKey.ToUpperAscii() == "STRINGLIST" )
936 nList = LIST_STRING;
937 else if ( sKey == "FILTERLIST" )
938 nList = LIST_FILTER;
939 else if ( sKey == "PAIREDLIST" )
940 nList = LIST_PAIRED; // abcd
941 else if ( sKey == "ITEMLIST" )
942 nList = LIST_ITEM;
943 else if ( sKey == "UIENTRIES" )
944 nList = LIST_UIENTRIES;
945 if ( nList ) {
946 ByteString sLang=sToken.GetToken( 1, '[' ).GetToken( 0, ']' );
947 CleanValue( sLang );
948 nListLang = sLang;
949 /*if (( bUnmerge ) && ( !nListLang.EqualsIgnoreCaseAscii("de")) && ( !nListLang.EqualsIgnoreCaseAscii("en-US")))
950 bDontWriteOutput = TRUE;*/
951 nListIndex = 0;
952 nListLevel = 0;
953 /*if ( bUnmerge && nListLang.EqualsIgnoreCaseAscii("de") && ListExists( pResData, nList ) )
954 bDontWriteOutput = TRUE;*/
958 break;
959 case TEXT:
960 case _LISTTEXT:
961 case LISTTEXT: {
962 // this is an entry for a String- or FilterList
963 if ( nList ) {
964 SetChildWithText();
965 ByteString sEntry( sToken.GetToken( 1, '\"' ));
966 if ( sToken.GetTokenCount( '\"' ) > 3 )
967 sEntry += "\"";
968 if ( sEntry == "\\\"" )
969 sEntry = "\"";
970 //sEntry = sEntry.Convert( aCharSet, RTL_TEXTENCODING_MS_1252 );
971 //sEntry = sEntry.Convert( RTL_TEXTENCODING_MS_1252, RTL_TEXTENCODING_UTF8 );
972 InsertListEntry( sEntry, sOrig );
973 if ( bMergeMode && ( sEntry != "\"" )) {
974 PrepareTextToMerge( sOrig, nList, nListLang, pResData );
978 break;
979 case LONGTEXTLINE:
980 case TEXTLINE:
981 bDontWriteOutput = FALSE;
982 if ( nLevel ) {
983 CutComment( sToken );
985 // this is a text line!!!
986 ByteString sKey = sToken.GetToken( 0, '=' ).GetToken( 0, '[' );
987 sKey.EraseAllChars( ' ' );
988 sKey.EraseAllChars( '\t' );
989 ByteString sText( GetText( sToken, nToken ));
990 if ( !bMergeMode )
991 sText = sText.Convert( aCharSet, RTL_TEXTENCODING_MS_1252 );
992 ByteString sLang;
993 if ( sToken.GetToken( 0, '=' ).Search( "[" ) != STRING_NOTFOUND ) {
994 sLang = sToken.GetToken( 0, '=' ).GetToken( 1, '[' ).GetToken( 0, ']' );
995 CleanValue( sLang );
997 ByteString nLangIndex = sLang;
998 ByteString sOrigKey = sKey;
999 if ( sText.Len() && sLang.Len() ) {
1000 if (( sKey.ToUpperAscii() == "TEXT" ) ||
1001 ( sKey == "MESSAGE" ) ||
1002 ( sKey == "CUSTOMUNITTEXT" ) ||
1003 ( sKey == "SLOTNAME" ) ||
1004 ( sKey == "UINAME" ))
1006 //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND )
1007 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
1009 SetChildWithText();
1010 //if ( nLangIndex.EqualsIgnoreCaseAscii("en-US") )
1011 if ( Export::isSourceLanguage( nLangIndex ) )
1012 pResData->SetId( sText, ID_LEVEL_TEXT );
1014 pResData->bText = TRUE;
1015 pResData->sTextTyp = sOrigKey;
1016 if ( bMergeMode ) {
1017 PrepareTextToMerge( sOrig, STRING_TYP_TEXT, nLangIndex, pResData );
1018 //if ( bUnmerge )
1019 // pResData->sText[ nLangIndex ] = sText;
1021 else {
1022 if ( pResData->sText[ nLangIndex ].Len()) {
1023 ByteString sError( "Language " );
1024 sError += nLangIndex;
1025 sError += " defined twice";
1027 pResData->sText[ nLangIndex ] = sText;
1030 else if ( sKey == "HELPTEXT" ) {
1031 //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND ){
1032 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
1033 // }
1034 SetChildWithText();
1035 pResData->bHelpText = TRUE;
1036 if ( bBreakWhenHelpText ) {
1037 ByteString sError( "\"HelpText\" found in source\n" );
1038 YYWarning( sError.GetBufferAccess());
1039 sError.ReleaseBufferAccess();
1040 SetError();
1042 if ( bMergeMode )
1043 PrepareTextToMerge( sOrig, STRING_TYP_HELPTEXT, nLangIndex, pResData );
1044 //if ( bUnmerge )
1045 // pResData->sHelpText[ nLangIndex ] = sText;
1046 else {
1047 if ( pResData->sHelpText[ nLangIndex ].Len()) {
1048 ByteString sError( "Language " );
1049 sError += nLangIndex;
1050 sError += " defined twice";
1052 pResData->sHelpText[ nLangIndex ] = sText;
1055 else if ( sKey == "QUICKHELPTEXT" ) {
1056 //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND ){
1057 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
1058 // }
1059 SetChildWithText();
1060 pResData->bQuickHelpText = TRUE;
1061 if ( bMergeMode )
1062 PrepareTextToMerge( sOrig, STRING_TYP_QUICKHELPTEXT, nLangIndex, pResData );
1063 //if ( bUnmerge )
1064 // pResData->sQuickHelpText[ nLangIndex ] = sText;
1065 else {
1066 if ( pResData->sQuickHelpText[ nLangIndex ].Len()) {
1067 ByteString sError( "Language " );
1068 sError += nLangIndex;
1069 sError += " defined twice";
1071 pResData->sQuickHelpText[ nLangIndex ] = sText;
1074 else if ( sKey == "TITLE" ) {
1075 //if ( bUnmerge && sToken.GetToken( 0, '=' ).Search( "[" ) == STRING_NOTFOUND ){
1076 // ( sOrig.SearchAndReplace( "=", "[ de ] =" ));
1077 // }
1078 SetChildWithText();
1079 pResData->bTitle = TRUE;
1080 if ( bMergeMode )
1081 PrepareTextToMerge( sOrig, STRING_TYP_TITLE, nLangIndex, pResData );
1082 //if ( bUnmerge )
1083 // pResData->sTitle[ nLangIndex ] = sText;
1084 else {
1085 if ( pResData->sTitle[ nLangIndex ].Len()) {
1086 ByteString sError( "Language " );
1087 sError += nLangIndex;
1088 sError += " defined twice";
1090 pResData->sTitle[ nLangIndex ] = sText;
1093 else if ( sKey == "ACCESSPATH" ) {
1094 pResData->SetId( sText, ID_LEVEL_ACCESSPATH );
1096 else if ( sKey == "FIELDNAME" ) {
1097 pResData->SetId( sText, ID_LEVEL_FIELDNAME );
1101 break;
1102 case NEWTEXTINRES: {
1103 bDontWriteOutput = TRUE;
1104 // this means something like // ### Achtung : Neuer Text ...
1105 /*ByteString sLang( "GERMAN" );
1106 ByteString sText = sToken.GetToken( 2, ':' ).GetToken( 0, '*' );
1107 CleanValue( sText );
1108 if ( sText.Len())
1109 pResData->sText[ sLang ] = sText;*/
1111 break;
1112 case APPFONTMAPPING: {
1113 bDontWriteOutput = FALSE;
1114 // this is a AppfontMapping, so look if its a definition
1115 // of field size
1116 ByteString sKey = sToken.GetToken( 0, '=' );
1117 sKey.EraseAllChars( ' ' );
1118 sKey.EraseAllChars( '\t' );
1119 ByteString sMapping = sToken.GetToken( 1, '=' );
1120 sMapping = sMapping.GetToken( 1, '(' );
1121 sMapping = sMapping.GetToken( 0, ')' );
1122 sMapping.EraseAllChars( ' ' );
1123 sMapping.EraseAllChars( '\t' );
1124 if ( sKey.ToUpperAscii() == "SIZE" ) {
1125 pResData->nWidth = ( USHORT ) sMapping.GetToken( 0, ',' ).ToInt64();
1127 else if ( sKey == "POSSIZE" ) {
1128 pResData->nWidth = ( USHORT ) sMapping.GetToken( 2, ',' ).ToInt64();
1131 break;
1132 case RSCDEFINELEND:
1133 bDontWriteOutput = FALSE;
1134 break;
1135 case CONDITION: {
1136 bDontWriteOutput = FALSE;
1137 while( sToken.SearchAndReplace( "\r", " " ) != STRING_NOTFOUND ) {};
1138 while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
1139 while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {};
1140 ByteString sCondition = sToken.GetToken( 0, ' ' );
1141 if ( sCondition == "#ifndef" ) {
1142 sActPForm = "!defined ";
1143 sActPForm += sToken.GetToken( 1, ' ' );
1145 else if ( sCondition == "#ifdef" ) {
1146 sActPForm = "defined ";
1147 sActPForm += sToken.GetToken( 1, ' ' );
1149 else if ( sCondition == "#if" ) {
1150 sActPForm = sToken.Copy( 4 );
1151 while ( sActPForm.SearchAndReplace( "||", "\\or" ) != STRING_NOTFOUND ) {};
1153 else if ( sCondition == "#elif" ) {
1154 sActPForm = sToken.Copy( 6 );
1155 while ( sActPForm.SearchAndReplace( "||", "\\or" ) != STRING_NOTFOUND ) {};
1157 else if ( sCondition == "#else" ) {
1158 sActPForm = sCondition;
1160 else if ( sCondition == "#endif" ) {
1161 sActPForm = "";
1163 else break;
1164 if ( nLevel ) {
1165 WriteData( pResData, TRUE );
1166 pResData->sPForm = sActPForm;
1169 break;
1170 case EMPTYLINE : {
1171 bDontWriteOutput = FALSE;
1172 if ( bDefine ) {
1173 bNextMustBeDefineEOL = FALSE;
1174 bDefine = FALSE;
1175 while ( nLevel )
1176 Parse( LEVELDOWN, "" );
1177 //WorkOnTokenSet( LEVELDOWN, pTkn );
1180 break;
1181 case PRAGMA : {
1182 bDontWriteOutput = FALSE;
1183 while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
1184 while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {};
1185 sToken.EraseLeadingChars( ' ' );
1186 sToken.EraseTrailingChars( ' ' );
1188 ByteString sCharset = sToken.GetToken( 1, ' ' );
1189 ByteString sSet = sToken.GetToken( 2, ' ' );
1190 if (( sCharset.ToUpperAscii() == "CHARSET_IBMPC" ) ||
1191 ( sCharset == "RTL_TEXTENCODING_IBM_850" ) ||
1192 (( sCharset == "CHARSET" ) && ( sSet.ToUpperAscii() == "IBMPC" )))
1194 aCharSet = RTL_TEXTENCODING_IBM_850;
1196 else if (( sCharset == "CHARSET_ANSI" ) ||
1197 ( sCharset == "RTL_TEXTENCODING_MS_1252" ) ||
1198 (( sCharset == "CHARSET" ) && ( sSet.ToUpperAscii() == "ANSI" )))
1200 aCharSet = RTL_TEXTENCODING_MS_1252;
1203 break;
1204 case TEXTREFID : {
1205 bDontWriteOutput = TRUE;
1206 /*ByteString sK = sToken.GetToken( 0, '=' );
1207 ByteString sKey = sK.EraseAllChars( '\t' ).EraseAllChars( ' ' );
1208 ByteString sT = sToken.GetToken( 1, '=' ).GetToken( 0, ';' );
1209 USHORT nRefId = ( USHORT ) sT.EraseAllChars( '\t' ).EraseAllChars( ' ' ).ToInt32();
1210 if (( sKey.ToUpperAscii() == "TEXT" ) ||
1211 ( sKey == "MESSAGE" ) ||
1212 ( sKey == "CUSTOMUNITTEXT" ) ||
1213 ( sKey == "SLOTNAME" ) ||
1214 ( sKey == "UINAME" ))
1215 pResData->nTextRefId = nRefId;
1216 else if ( sKey == "HELPTEXT" )
1217 pResData->nHelpTextRefId = nRefId;
1218 else if ( sKey == "QUICKHELPTEXT" )
1219 pResData->nQuickHelpTextRefId = nRefId;
1220 else if ( sKey == "TITLE" )
1221 pResData->nTitleRefId = nRefId;*/
1224 if ( bWriteToMerged ) {
1225 // the current token must be written to dest. without merging
1227 if( bDefine && sOrig.Len() > 2 ){
1228 for( USHORT n = 0 ; n < sOrig.Len() ; n++ ){
1229 if( sOrig.GetChar( n ) == '\n' && sOrig.GetChar( n-1 ) != '\\'){
1230 sOrig.Insert('\\' , n++ );
1234 WriteToMerged( sOrig , false);
1237 if ( bExecuteDown ) {
1238 Parse( LEVELDOWN, "" );
1239 //WorkOnTokenSet( LEVELDOWN, pTkn );
1242 return 1;
1245 /*****************************************************************************/
1246 void Export::CutComment( ByteString &rText )
1247 /*****************************************************************************/
1249 if ( rText.Search( "//" ) != STRING_NOTFOUND ) {
1250 ByteString sWork( rText );
1251 sWork.SearchAndReplaceAll( "\\\"", "XX" );
1252 USHORT i = 0;
1253 BOOL bInner = FALSE;
1255 while ( i < sWork.Len() - 1 ) {
1256 if ( sWork.GetChar( i ) == '\"' )
1257 bInner = !bInner;
1258 else if
1259 (( sWork.GetChar( i ) == '/' ) &&
1260 ( !bInner ) &&
1261 ( sWork.GetChar( i + 1 ) == '/' ))
1263 rText.Erase( i );
1264 return;
1266 i++;
1271 void Export::UnmergeUTF8( ByteString& sOrig ){
1272 USHORT nPos1 = sOrig.Search('\"');
1273 USHORT nPos2 = sOrig.SearchBackward('\"');
1274 if( nPos1 > 0 && nPos2 > 0 && nPos1 < nPos2){
1275 ByteString sPart = sOrig.Copy(nPos1+1 , nPos2-1);
1276 ByteString sPartUTF8 = sPart;
1277 sPartUTF8.Convert( RTL_TEXTENCODING_MS_1252 , RTL_TEXTENCODING_UTF8 );
1278 sOrig.SearchAndReplace( sPart , sPartUTF8 );
1282 /*****************************************************************************/
1283 BOOL Export::ListExists( ResData *pResData, USHORT nLst )
1284 /*****************************************************************************/
1286 switch ( nLst ) {
1287 case LIST_STRING: return pResData->pStringList != NULL;
1288 case LIST_FILTER: return pResData->pFilterList != NULL;
1289 case LIST_ITEM: return pResData->pItemList != NULL;
1290 case LIST_PAIRED: return pResData->pPairedList != NULL;
1291 case LIST_UIENTRIES: return pResData->pUIEntries != NULL;
1293 return FALSE;
1296 /*****************************************************************************/
1297 BOOL Export::WriteData( ResData *pResData, BOOL bCreateNew )
1298 /*****************************************************************************/
1300 if ( bMergeMode ) {
1301 MergeRest( pResData );
1302 return TRUE;
1305 if ( bUnmerge )
1306 return TRUE;
1308 /* ByteStringHashMap::iterator pos3 = pResData->sText.begin();
1309 ByteStringHashMap::iterator end3 = pResData->sText.end();
1310 for(;pos3!=end3;++pos3){
1312 printf("[%s]=%s\n", pos3->first.GetBuffer(), pos3->second.GetBuffer() );
1314 // mandatory to export: en-US
1316 if (( //pResData->sText[ ByteString("de") ].Len() &&
1317 ( pResData->sText[ SOURCE_LANGUAGE ].Len()))
1319 ( //pResData->sHelpText[ ByteString("de") ].Len() &&
1320 ( pResData->sHelpText[ SOURCE_LANGUAGE ].Len()))
1322 ( //pResData->sQuickHelpText[ ByteString("de") ].Len() &&
1323 ( pResData->sQuickHelpText[ SOURCE_LANGUAGE ].Len()))
1325 ( //pResData->sTitle[ ByteString("de") ].Len() &&
1326 ( pResData->sTitle[ SOURCE_LANGUAGE ].Len())))
1329 FillInFallbacks( pResData );
1331 ByteString sGID = pResData->sGId;
1332 ByteString sLID;
1333 if ( !sGID.Len())
1334 sGID = pResData->sId;
1335 else
1336 sLID = pResData->sId;
1338 ByteString sXText;
1339 ByteString sXHText;
1340 ByteString sXQHText;
1341 ByteString sXTitle;
1343 ByteString sTimeStamp( Export::GetTimeStamp());
1344 ByteString sCur;
1346 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
1347 sCur = aLanguages[ n ];
1348 if ( !sCur.EqualsIgnoreCaseAscii("x-comment") ){
1349 if ( pResData->sText[ sCur ].Len())
1350 sXText = pResData->sText[ sCur ];
1351 else {
1352 sXText = pResData->sText[ SOURCE_LANGUAGE ];
1353 /*if ( !sXText.Len())
1354 sXText = pResData->sText[ ByteString("en") ];
1355 if ( !sXText.Len())
1356 sXText = pResData->sText[ ByteString("de") ];*/
1359 if ( pResData->sHelpText[ sCur ].Len())
1360 sXHText = pResData->sHelpText[ sCur ];
1361 else {
1362 sXHText = pResData->sHelpText[ SOURCE_LANGUAGE ];
1363 /*if ( !sXHText.Len())
1364 sXHText = pResData->sHelpText[ ByteString("en") ];
1365 if ( !sXText.Len())
1366 sXHText = pResData->sHelpText[ ByteString("de") ];*/
1369 if ( pResData->sQuickHelpText[ sCur ].Len())
1370 sXQHText = pResData->sQuickHelpText[ sCur ];
1371 else {
1372 sXQHText = pResData->sQuickHelpText[ SOURCE_LANGUAGE ];
1373 /*if ( !sXQHText.Len())
1374 sXQHText = pResData->sQuickHelpText[ ByteString("en") ];
1375 if ( !sXQHText.Len())
1376 sXQHText = pResData->sQuickHelpText[ ByteString("de") ];*/
1379 if ( pResData->sTitle[ sCur ].Len())
1380 sXTitle = pResData->sTitle[ sCur ];
1381 else {
1382 sXTitle = pResData->sTitle[ SOURCE_LANGUAGE ];
1383 /*if ( !sXTitle.Len())
1384 sXTitle = pResData->sTitle[ ByteString("en") ];
1385 if ( !sXTitle.Len())
1386 sXTitle = pResData->sTitle[ ByteString("de") ];*/
1389 if ( !sXText.Len())
1390 sXText = "-";
1392 if ( !sXHText.Len()) {
1393 /*if ( pResData->sHelpText[ ByteString("de") ].Len())
1394 sXHText = pResData->sHelpText[ ByteString("de") ];*/
1395 if ( pResData->sHelpText[ SOURCE_LANGUAGE ].Len())
1396 sXHText = pResData->sHelpText[ SOURCE_LANGUAGE ];
1397 /*else if ( pResData->sHelpText[ ByteString("en") ].Len())
1398 sXHText = pResData->sHelpText[ ByteString("en") ];*/
1401 else
1402 sXText = pResData->sText[ sCur ];
1404 if ( bEnableExport ) {
1405 ByteString sOutput( sProject ); sOutput += "\t";
1406 if ( sRoot.Len())
1407 sOutput += sActFileName;
1408 sOutput += "\t0\t";
1409 sOutput += pResData->sResTyp; sOutput += "\t";
1410 sOutput += sGID; sOutput += "\t";
1411 sOutput += sLID; sOutput += "\t";
1412 sOutput += pResData->sHelpId; sOutput += "\t";
1413 sOutput += pResData->sPForm; sOutput += "\t";
1414 sOutput += ByteString::CreateFromInt64( pResData->nWidth ); sOutput += "\t";
1415 sOutput += sCur; sOutput += "\t";
1418 sOutput += sXText; sOutput += "\t";
1419 sOutput += sXHText; sOutput += "\t";
1420 sOutput += sXQHText; sOutput+= "\t";
1421 sOutput += sXTitle; sOutput += "\t";
1422 sOutput += sTimeStamp;
1424 // if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sProject ) ) )
1425 aOutput.WriteLine( sOutput );
1428 if ( bCreateNew ) {
1429 pResData->sText[ sCur ] = "";
1430 pResData->sHelpText[ sCur ] = "";
1431 pResData->sQuickHelpText[ sCur ]= "";
1432 pResData->sTitle[ sCur ] = "";
1436 FillInFallbacks( pResData );
1437 if ( pResData->pStringList ) {
1438 ByteString sList( "stringlist" );
1439 WriteExportList( pResData, pResData->pStringList, sList, bCreateNew );
1440 if ( bCreateNew )
1441 pResData->pStringList = 0;
1443 if ( pResData->pFilterList ) {
1444 ByteString sList( "filterlist" );
1445 WriteExportList( pResData, pResData->pFilterList, sList, bCreateNew );
1446 if ( bCreateNew )
1447 pResData->pFilterList = 0;
1449 if ( pResData->pItemList ) {
1450 ByteString sList( "itemlist" );
1451 WriteExportList( pResData, pResData->pItemList, sList, bCreateNew );
1452 if ( bCreateNew )
1453 pResData->pItemList = 0;
1455 if ( pResData->pPairedList ) {
1456 ByteString sList( "pairedlist" );
1457 WriteExportList( pResData, pResData->pPairedList, sList, bCreateNew );
1458 if ( bCreateNew )
1459 pResData->pItemList = 0;
1461 if ( pResData->pUIEntries ) {
1462 ByteString sList( "uientries" );
1463 WriteExportList( pResData, pResData->pUIEntries, sList, bCreateNew );
1464 if ( bCreateNew )
1465 pResData->pUIEntries = 0;
1467 return TRUE;
1469 ByteString Export::GetPairedListID( const ByteString& sText ){
1470 // < "STRING" ; IDENTIFIER ; > ;
1471 ByteString sIdent = sText.GetToken( 1, ';' );
1472 sIdent.ToUpperAscii();
1473 while( sIdent.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
1474 sIdent.EraseTrailingChars( ' ' );
1475 sIdent.EraseLeadingChars( ' ' );
1476 return sIdent;
1478 ByteString Export::GetPairedListString( const ByteString& sText ){
1479 // < "STRING" ; IDENTIFIER ; > ;
1480 ByteString sString = sText.GetToken( 0, ';' );
1481 while( sString.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
1482 sString.EraseTrailingChars( ' ' );
1483 ByteString s1 = sString.Copy( sString.Search( '\"' )+1 );
1484 sString = s1.Copy( 0 , s1.SearchBackward( '\"' ) );
1485 sString.EraseTrailingChars( ' ' );
1486 sString.EraseLeadingChars( ' ' );
1487 return sString;
1489 ByteString Export::StripList( const ByteString& sText ){
1490 ByteString s1 = sText.Copy( sText.Search( '\"' ) + 1 );
1491 return s1.Copy( 0 , s1.SearchBackward( '\"' ) );
1494 /*****************************************************************************/
1495 BOOL Export::WriteExportList( ResData *pResData, ExportList *pExportList,
1496 const ByteString &rTyp, BOOL bCreateNew )
1497 /*****************************************************************************/
1499 ByteString sGID = pResData->sGId;
1500 if ( !sGID.Len())
1501 sGID = pResData->sId;
1502 else {
1503 sGID += ".";
1504 sGID += pResData->sId;
1505 sGID.EraseTrailingChars( '.' );
1508 ByteString sTimeStamp( Export::GetTimeStamp());
1509 ByteString sCur;
1510 for ( ULONG i = 0; pExportList != NULL && i < pExportList->Count(); i++ ) {
1511 ExportListEntry *pEntry = pExportList->GetObject( i );
1512 // mandatory for export: german and eng. and/or enus
1513 //ByteString a("Export::WriteExportList::pEntry");
1514 //Export::DumpMap( a, *pEntry );
1516 ByteString sLID( ByteString::CreateFromInt64( i + 1 ));
1517 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
1518 sCur = aLanguages[ n ];
1519 if ( //1 )
1520 //(*pEntry)[ ByteString("de") ].Len() &&
1521 (*pEntry)[ SOURCE_LANGUAGE ].Len() )
1522 //||
1523 // (*pEntry)[ ByteString("en") ].Len()))
1525 if ( bEnableExport )
1527 ByteString sText((*pEntry)[ SOURCE_LANGUAGE ] );
1529 // Strip PairList Line String
1530 if( rTyp.EqualsIgnoreCaseAscii("pairedlist") ){
1531 sLID = GetPairedListID( sText );
1532 if ((*pEntry)[ sCur ].Len())
1533 sText = (*pEntry)[ sCur ];
1534 sText = GetPairedListString( sText );
1536 else{
1537 //if ((*pEntry)[ sCur ].Len()){
1538 // if( sCur.EqualsIgnoreCaseAscii("de") ){
1539 // sText = StripList( (*pEntry)[ sCur ] );
1540 // }
1541 // else
1542 sText = StripList( (*pEntry)[ sCur ] );
1543 if( sText == "\\\"" )
1544 sText = "\"";
1548 ByteString sOutput( sProject ); sOutput += "\t";
1549 if ( sRoot.Len())
1550 sOutput += sActFileName;
1551 sOutput += "\t0\t";
1552 sOutput += rTyp; sOutput += "\t";
1553 sOutput += sGID; sOutput += "\t";
1554 sOutput += sLID; sOutput += "\t\t";
1555 sOutput += pResData->sPForm; sOutput += "\t0\t";
1556 sOutput += sCur; sOutput += "\t";
1558 sOutput += sText; sOutput += "\t\t\t\t";
1559 sOutput += sTimeStamp;
1561 //if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( sProject ) ) )
1562 aOutput.WriteLine( sOutput );
1567 if ( bCreateNew )
1568 delete [] pEntry;
1570 if ( bCreateNew )
1571 delete pExportList;
1573 return TRUE;
1576 /*****************************************************************************/
1577 ByteString Export::FullId()
1578 /*****************************************************************************/
1580 ByteString sFull;
1581 if ( nLevel > 1 ) {
1582 sFull = aResStack.GetObject( 0 )->sId;
1583 for ( USHORT i = 1; i < nLevel - 1; i++ ) {
1584 ByteString sToAdd = aResStack.GetObject( i )->sId;
1585 if ( sToAdd.Len()) {
1586 sFull += ".";
1587 sFull += sToAdd;
1591 if ( sFull.Len() > 255 ) {
1592 ByteString sError( "GroupId > 255 chars" );
1593 printf("GroupID = %s\n",sFull.GetBuffer());
1594 yyerror( sError.GetBufferAccess());
1595 sError.ReleaseBufferAccess();
1598 return sFull;
1601 /*****************************************************************************/
1602 void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
1603 /*****************************************************************************/
1605 ResData *pResData = aResStack.GetObject( nLevel-1 );
1607 ExportList *pList = NULL;
1608 if ( nList == LIST_STRING ) {
1609 pList = pResData->pStringList;
1610 if ( !pList ) {
1611 pResData->pStringList = new ExportList();
1612 pList = pResData->pStringList;
1613 nListIndex = 0;
1616 else if ( nList == LIST_FILTER ) {
1617 pList = pResData->pFilterList;
1618 if ( !pList ) {
1619 pResData->pFilterList = new ExportList();
1620 pList = pResData->pFilterList;
1621 nListIndex = 0;
1624 else if ( nList == LIST_ITEM ) {
1625 pList = pResData->pItemList;
1626 if ( !pList ) {
1627 pResData->pItemList = new ExportList();
1628 pList = pResData->pItemList;
1629 nListIndex = 0;
1632 else if ( nList == LIST_PAIRED ) {
1633 pList = pResData->pPairedList;
1634 if ( !pList ) {
1635 pResData->pPairedList = new ExportList();
1636 pList = pResData->pPairedList;
1637 nListIndex = 0;
1640 else if ( nList == LIST_UIENTRIES ) {
1641 pList = pResData->pUIEntries;
1642 if ( !pList ) {
1643 pResData->pUIEntries = new ExportList();
1644 pList = pResData->pUIEntries;
1645 nListIndex = 0;
1648 else
1649 return;
1651 if ( nListIndex + 1 > pList->Count()) {
1652 ExportListEntry *pNew = new ExportListEntry();
1653 (*pNew)[ LIST_REFID ] = ByteString::CreateFromInt32( REFID_NONE );
1654 pList->Insert( pNew, LIST_APPEND );
1656 ExportListEntry *pCurEntry = pList->GetObject( nListIndex );
1658 // For paired list use the line to set proper lid
1659 if( nList == LIST_PAIRED ){
1660 (*pCurEntry)[ nListLang ] = rLine;
1661 }else
1662 (*pCurEntry)[ nListLang ] = rText;
1664 // Remember en-US fallback string, so each list has the same amount of elements
1665 //if ( nListLang.EqualsIgnoreCaseAscii("en-US") ) {
1666 if ( Export::isSourceLanguage( nListLang ) ) {
1667 if( nList == LIST_PAIRED ){
1668 const ByteString sPlist("pairedlist");
1669 ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sId , GetPairedListID( rLine ) , sFilename );
1670 pResData->addFallbackData( sKey , rText );
1672 // new fallback
1673 else{
1674 const ByteString sPlist("list");
1675 ByteString a( pResData->sGId );
1676 a.Append( "." );
1677 a.Append( pResData->sId );
1678 sal_Int64 x = nListIndex+1;
1679 ByteString b( ByteString::CreateFromInt64( x ) );
1680 ByteString sKey = MergeDataFile::CreateKey( sPlist , a , b , sFilename );
1681 pResData->addFallbackData( sKey , rText );
1683 // new fallback
1686 //if ( nListLang.EqualsIgnoreCaseAscii("en-US") ) {
1687 if ( Export::isSourceLanguage( nListLang ) ) {
1688 if( nList == LIST_PAIRED ){
1689 (*pCurEntry)[ SOURCE_LANGUAGE ] = rLine;
1691 else
1692 (*pCurEntry)[ SOURCE_LANGUAGE ] = rLine;
1694 pList->NewSourceLanguageListEntry();
1697 //printf("Export::InsertListEntry ResData.id = %s ResData.ListData = %s\n",pResData->sId.GetBuffer() ,(*pCurEntry)[ nListLang ].GetBuffer());
1698 nListIndex++;
1701 /*****************************************************************************/
1702 void Export::CleanValue( ByteString &rValue )
1703 /*****************************************************************************/
1705 while ( rValue.Len()) {
1706 if (( rValue.GetChar( 0 ) == ' ' ) || ( rValue.GetChar( 0 ) == '\t' ))
1707 rValue = rValue.Copy( 1 );
1708 else
1709 break;
1712 if ( rValue.Len()) {
1713 for ( USHORT i = rValue.Len() - 1; i > 0; i-- ) {
1714 if (( rValue.GetChar( i ) == ' ' ) || ( rValue.GetChar( i ) == '\t' ) ||
1715 ( rValue.GetChar( i ) == '\n' ) || ( rValue.GetChar( i ) == ';' ) ||
1716 ( rValue.GetChar( i ) == '{' ) || ( rValue.GetChar( i ) == '\\' ) ||
1717 ( rValue.GetChar( i ) == '\r' ))
1718 rValue.Erase( i );
1719 else
1720 break;
1726 /*****************************************************************************/
1727 ByteString Export::GetText( const ByteString &rSource, int nToken )
1728 /*****************************************************************************/
1729 #define TXT_STATE_NON 0x000
1730 #define TXT_STATE_TEXT 0x001
1731 #define TXT_STATE_MACRO 0x002
1733 ByteString sReturn;
1734 switch ( nToken ) {
1735 case TEXTLINE:
1736 case LONGTEXTLINE: {
1737 ByteString sTmp( rSource.Copy( rSource.Search( "=" )));
1738 CleanValue( sTmp );
1739 sTmp.EraseAllChars( '\n' );
1740 sTmp.EraseAllChars( '\r' );
1742 while ( sTmp.SearchAndReplace( "\\\\\"", "-=<[BSlashBSlashHKom]>=-\"" )
1743 != STRING_NOTFOUND ) {};
1744 while ( sTmp.SearchAndReplace( "\\\"", "-=<[Hochkomma]>=-" )
1745 != STRING_NOTFOUND ) {};
1746 while ( sTmp.SearchAndReplace( "\\\x7f", "-=<[0x7F]>=-" )
1747 != STRING_NOTFOUND ) {};
1748 while ( sTmp.SearchAndReplace( "\\0x7F", "-=<[0x7F]>=-" )
1749 != STRING_NOTFOUND ) {};
1751 USHORT nStart = 0;
1752 USHORT nState = TXT_STATE_MACRO;
1754 nState = TXT_STATE_TEXT;
1755 nStart = 1;
1758 for ( USHORT i = nStart; i < sTmp.GetTokenCount( '\"' ); i++ ) {
1759 ByteString sToken = sTmp.GetToken( i, '\"' );
1760 if ( sToken.Len()) {
1761 if ( nState == TXT_STATE_TEXT ) {
1762 sReturn += sToken;
1763 nState = TXT_STATE_MACRO;
1765 else {
1766 while( sToken.SearchAndReplace( "\t", " " ) !=
1767 STRING_NOTFOUND ) {};
1768 while( sToken.SearchAndReplace( " ", " " ) !=
1769 STRING_NOTFOUND ) {};
1770 sToken.EraseLeadingChars( ' ' );
1771 sToken.EraseTrailingChars( ' ' );
1772 if ( sToken.Len()) {
1773 sReturn += "\\\" ";
1774 sReturn += sToken;
1775 sReturn += " \\\"";
1777 nState = TXT_STATE_TEXT;
1782 while ( sReturn.SearchAndReplace( "-=<[0x7F]>=-", "\x7f" )
1783 != STRING_NOTFOUND ) {};
1784 while ( sReturn.SearchAndReplace( "-=<[Hochkomma]>=-", "\"" )
1785 != STRING_NOTFOUND ) {};
1786 while ( sReturn.SearchAndReplace( "-=<[BSlashBSlashHKom]>=-", "\\\\" )
1787 != STRING_NOTFOUND ) {};
1790 while ( sReturn.SearchAndReplace( "\\\\", "-=<[BSlashBSlash]>=-" )
1791 != STRING_NOTFOUND ) {};
1792 while ( sReturn.SearchAndReplace( "-=<[BSlashBSlash]>=-", "\\" )
1793 != STRING_NOTFOUND ) {};
1796 break;
1798 return sReturn;
1801 /*****************************************************************************/
1802 void Export::WriteToMerged( const ByteString &rText , bool bSDFContent )
1803 /*****************************************************************************/
1805 static ByteString SLASH ('\\');
1806 static ByteString RETURN ('\n');
1807 //printf("%s\n",rText.GetBuffer() );
1809 #if 0
1810 // statement has no effect
1811 if( pParseQueue->bMflag && !bSDFContent ) pParseQueue->bMflag;
1812 #endif
1814 if ( !bDontWriteOutput || !bUnmerge ) {
1815 ByteString sText( rText );
1816 while ( sText.SearchAndReplace( " \n", "\n" ) != STRING_NOTFOUND ) {};
1817 if( pParseQueue->bNextIsM && bSDFContent && sText.Len() > 2 ){
1818 for( USHORT n = 0 ; n < sText.Len() ; n++ ){
1819 if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
1820 sText.Insert('\\' , n++ );
1825 else if( pParseQueue->bLastWasM && sText.Len() > 2 ){
1826 for( USHORT n = 0 ; n < sText.Len() ; n++ ){
1827 if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
1828 sText.Insert('\\' , n++ );
1830 if( sText.GetChar( n ) == '\n' )pParseQueue->bMflag=true;
1833 else if( pParseQueue->bCurrentIsM && bSDFContent && sText.Len() > 2 ){
1834 for( USHORT n = 0 ; n < sText.Len() ; n++ ){
1835 if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
1836 sText.Insert('\\' , n++ );
1837 pParseQueue->bMflag=true;
1841 else if( pParseQueue->bMflag ){
1842 for( USHORT n = 1 ; n < sText.Len() ; n++ ){
1843 if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
1844 sText.Insert('\\' , n++ );
1848 for ( USHORT i = 0; i < sText.Len(); i++ ) {
1849 if ( sText.GetChar( i ) != '\n' ){
1850 aOutput.Write( ByteString( sText.GetChar( i )).GetBuffer(), 1 );
1853 else{
1854 aOutput.WriteLine( ByteString());
1861 /*****************************************************************************/
1862 void Export::ConvertMergeContent( ByteString &rText )
1863 /*****************************************************************************/
1865 BOOL bNoOpen = ( rText.Search( "\\\"" ) != 0 );
1866 ByteString sClose( rText.Copy( rText.Len() - 2 ));
1867 BOOL bNoClose = ( sClose != "\\\"" );
1868 ByteString sNew;
1869 for ( USHORT i = 0; i < rText.Len(); i++ ) {
1870 ByteString sChar( rText.GetChar( i ));
1871 if ( sChar == "\\" ) {
1872 if (( i + 1 ) < rText.Len()) {
1873 ByteString sNext( rText.GetChar( i + 1 ));
1874 if ( sNext == "\"" ) {
1875 sChar = "\"";
1876 i++;
1878 else if ( sNext == "n" ) {
1879 sChar = "\\n";
1880 i++;
1882 else if ( sNext == "t" ) {
1883 sChar = "\\t";
1884 i++;
1886 else if ( sNext == "\'" ) {
1887 sChar = "\\\'";
1888 i++;
1890 else
1891 sChar = "\\\\";
1893 else {
1894 sChar = "\\\\";
1897 else if ( sChar == "\"" ) {
1898 sChar = "\\\"";
1900 else if ( sChar == "\x7f" ) {
1901 sChar = "\\0x7F";
1903 sNew += sChar;
1906 rText = sNew;
1908 if ( bNoOpen ) {
1909 ByteString sTmp( rText );
1910 rText = "\"";
1911 rText += sTmp;
1913 if ( bNoClose )
1914 rText += "\"";
1917 /*****************************************************************************/
1918 BOOL Export::PrepareTextToMerge( ByteString &rText, USHORT nTyp,
1919 ByteString &nLangIndex, ResData *pResData )
1920 /*****************************************************************************/
1922 // position to merge in:
1923 USHORT nStart = 0;
1924 USHORT nEnd = 0;
1925 ByteString sOldId = pResData->sId;
1926 ByteString sOldGId = pResData->sGId;
1927 ByteString sOldTyp = pResData->sResTyp;
1929 ByteString sOrigText( rText );
1931 switch ( nTyp ) {
1932 case LIST_STRING :
1933 case LIST_UIENTRIES :
1934 case LIST_FILTER :
1935 case LIST_PAIRED:
1936 case LIST_ITEM :
1938 if ( bUnmerge )
1939 return TRUE;
1941 ExportList *pList = NULL;
1942 switch ( nTyp ) {
1943 case LIST_STRING : {
1944 pResData->sResTyp = "stringlist";
1945 pList = pResData->pStringList;
1947 break;
1948 case LIST_UIENTRIES : {
1949 pResData->sResTyp = "uientries";
1950 pList = pResData->pUIEntries;
1952 break;
1953 case LIST_FILTER : {
1954 pResData->sResTyp = "filterlist";
1955 pList = pResData->pFilterList;
1957 break;
1958 case LIST_ITEM : {
1959 pResData->sResTyp = "itemlist";
1960 pList = pResData->pItemList;
1962 break;
1963 case LIST_PAIRED : {
1964 pResData->sResTyp = "pairedlist";
1965 pList = pResData->pPairedList;
1967 break;
1970 if ( pList ) {
1971 ExportListEntry *pCurEntry = pList->GetObject( nListIndex - 1 );
1972 if ( pCurEntry ) {
1973 //printf("%s\n",Export::DumpMap( "pCurEntry", *pCurEntry ).GetBuffer() );
1974 //ByteString a("pCurEntry");
1975 //Export::DumpMap( a , *pCurEntry );
1976 rText = (*pCurEntry)[ SOURCE_LANGUAGE ];
1977 if( nTyp == LIST_PAIRED ){
1978 pResData->addMergedLanguage( nLangIndex );
1983 nStart = rText.Search( "\"" );
1984 if ( nStart == STRING_NOTFOUND ) {
1985 rText = sOrigText;
1986 return FALSE;
1989 BOOL bFound = FALSE;
1990 for ( nEnd = nStart + 1; nEnd < rText.Len() && !bFound; nEnd++ ) {
1991 if ( rText.GetChar( nEnd ) == '\"' )
1992 bFound = TRUE;
1994 if ( !bFound ) {
1995 rText = sOrigText;
1996 return FALSE;
1999 nEnd --;
2000 sLastListLine = rText;
2001 if (( sLastListLine.Search( ">" ) != STRING_NOTFOUND ) &&
2002 ( sLastListLine.Search( "<" ) == STRING_NOTFOUND ))
2004 ByteString sTmp = sLastListLine;
2005 sLastListLine = "<";
2006 sLastListLine += sTmp;
2008 if ( pResData->sResTyp.EqualsIgnoreCaseAscii( "pairedlist" ) ){
2009 pResData->sId = GetPairedListID( sLastListLine );
2011 else pResData->sId = ByteString::CreateFromInt32( nListIndex );
2013 if ( pResData->sGId.Len())
2014 pResData->sGId += ".";
2015 pResData->sGId += sOldId;
2016 nTyp = STRING_TYP_TEXT;
2018 break;
2019 case STRING_TYP_TEXT :
2020 case STRING_TYP_HELPTEXT :
2021 case STRING_TYP_QUICKHELPTEXT :
2022 case STRING_TYP_TITLE :
2024 /*if ( bUnmerge ) {
2025 if (( nLangIndex != ByteString("de") ) &&
2026 ( nLangIndex != ByteString("en-US") ))
2028 bDontWriteOutput = TRUE;
2030 return TRUE;
2033 nStart = rText.Search( "=" );
2034 if ( nStart == STRING_NOTFOUND ) {
2035 rText = sOrigText;
2036 return FALSE;
2039 nStart++;
2040 BOOL bFound = FALSE;
2041 while(( nStart < rText.Len()) && !bFound ) {
2042 if (( rText.GetChar( nStart ) != ' ' ) && ( rText.GetChar( nStart ) != '\t' ))
2043 bFound = TRUE;
2044 else
2045 nStart ++;
2048 // no start position found
2049 if ( !bFound ) {
2050 rText = sOrigText;
2051 return FALSE;
2054 // position to end mergeing in
2055 nEnd = rText.Len() - 1;
2056 bFound = FALSE;
2058 while (( nEnd > nStart ) && !bFound ) {
2059 if (( rText.GetChar( nEnd ) != ' ' ) && ( rText.GetChar( nEnd ) != '\t' ) &&
2060 ( rText.GetChar( nEnd ) != '\n' ) && ( rText.GetChar( nEnd ) != ';' ) &&
2061 ( rText.GetChar( nEnd ) != '{' ) && ( rText.GetChar( nEnd ) != '\\' ))
2063 bFound = TRUE;
2065 else
2066 nEnd --;
2069 break;
2072 // search for merge data
2073 if ( !pMergeDataFile ){
2074 pMergeDataFile = new MergeDataFile( sMergeSrc, sFile , bErrorLog, aCharSet);//, bUTF8 );
2076 // Init Languages
2077 ByteString sTmp = Export::sLanguages;
2078 if( sTmp.ToUpperAscii().Equals("ALL") )
2079 SetLanguages( pMergeDataFile->GetLanguages() );
2080 else if( !isInitialized )InitLanguages();
2083 // printf("*************DUMPING****************\n");
2084 // printf("%s\n",pMergeDataFile->Dump().GetBuffer());
2085 // printf("*************DUMPING****************\n");
2087 // printf("Dumping ResData\n");
2088 // pResData->Dump();
2089 PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
2090 //printf("Dumping pEntrys\n");
2091 //if( pEntrys ) pEntrys->Dump();
2092 pResData->sId = sOldId;
2093 pResData->sGId = sOldGId;
2094 pResData->sResTyp = sOldTyp;
2096 if ( !pEntrys ) {
2097 rText = sOrigText;
2098 return FALSE; // no data found
2101 ByteString sContent;
2102 pEntrys->GetText( sContent, nTyp, nLangIndex );
2103 //if ( !sContent.Len() && ( ! nLangIndex.EqualsIgnoreCaseAscii("en-US") )) {
2104 if ( !sContent.Len() && ( ! Export::isSourceLanguage( nLangIndex ) )) {
2105 rText = sOrigText;
2106 return FALSE; // no data found
2109 //if ( nLangIndex.EqualsIgnoreCaseAscii("en-US") ) {
2110 if ( Export::isSourceLanguage( nLangIndex ) ) {
2111 return FALSE;
2114 ByteString sPostFix( rText.Copy( ++nEnd ));
2115 rText.Erase( nStart );
2117 //ConvertMergeContent( sContent, nTyp );
2118 ConvertMergeContent( sContent );
2122 //printf("Merged %s\n",nLangIndex.GetBuffer());
2123 // merge new res. in text line
2124 rText += sContent;
2125 rText += sPostFix;
2127 return TRUE;
2130 /*****************************************************************************/
2131 void Export::MergeRest( ResData *pResData, USHORT nMode )
2132 /*****************************************************************************/
2134 //if ( bUnmerge ) { return;}
2136 //pResData->Dump();
2138 if ( !pMergeDataFile ){
2139 pMergeDataFile = new MergeDataFile( sMergeSrc, sFile ,bErrorLog, aCharSet);//, bUTF8 );
2141 // Init Languages
2142 ByteString sTmp = Export::sLanguages;
2143 if( sTmp.ToUpperAscii().Equals("ALL") )
2144 SetLanguages( pMergeDataFile->GetLanguages() );
2145 else if( !isInitialized )InitLanguages();
2148 switch ( nMode ) {
2149 case MERGE_MODE_NORMAL : {
2150 PFormEntrys *pEntry = pMergeDataFile->GetPFormEntrys( pResData );
2152 bool bWriteNoSlash = false;
2153 if ( pEntry && pResData->bText ) {
2155 BOOL bAddSemikolon = FALSE;
2156 BOOL bFirst = TRUE;
2157 ByteString sCur;
2158 ByteString sTmp = Export::sLanguages;
2160 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
2161 sCur = aLanguages[ n ];
2163 ByteString sText;
2164 BOOL bText = pEntry->GetText( sText, STRING_TYP_TEXT, sCur , TRUE );
2165 if ( bText && sText.Len() && sText != "-" ) {
2166 ByteString sOutput;
2167 if ( bNextMustBeDefineEOL) {
2168 if ( bFirst )
2169 sOutput += "\t\\\n";
2170 else
2171 sOutput += ";\t\\\n";
2173 bFirst=FALSE;
2174 sOutput += "\t";
2175 sOutput += pResData->sTextTyp;
2176 //if ( !sCur.EqualsIgnoreCaseAscii("en-US")) {
2177 if ( ! Export::isSourceLanguage( sCur ) ) {
2178 sOutput += "[ ";
2179 sOutput += sCur;
2180 sOutput += " ] ";
2182 sOutput += "= ";
2183 ConvertMergeContent( sText );
2184 sOutput += sText;
2186 if ( bDefine && bWriteNoSlash )
2187 sOutput += ";\n";
2189 if ( bDefine )
2190 sOutput += ";\\\n";
2191 else if ( !bNextMustBeDefineEOL )
2192 sOutput += ";\n";
2193 else
2194 bAddSemikolon = TRUE;
2195 for ( USHORT j = 1; j < nLevel; j++ )
2196 sOutput += "\t";
2197 WriteToMerged( sOutput , true );
2202 if ( bAddSemikolon ) {
2203 ByteString sOutput( ";" );
2204 WriteToMerged( sOutput , false );
2208 if ( pEntry && pResData->bQuickHelpText ) {
2209 BOOL bAddSemikolon = FALSE;
2210 BOOL bFirst = TRUE;
2211 ByteString sCur;
2213 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
2214 sCur = aLanguages[ n ];
2216 ByteString sText;
2217 BOOL bText = pEntry->GetText( sText, STRING_TYP_QUICKHELPTEXT, sCur, TRUE );
2218 if ( bText && sText.Len() && sText != "-" ) {
2219 ByteString sOutput;
2220 if ( bNextMustBeDefineEOL) {
2221 if ( bFirst )
2222 sOutput += "\t\\\n";
2223 else
2224 sOutput += ";\t\\\n";
2226 bFirst=FALSE;
2227 sOutput += "\t";
2228 sOutput += "QuickHelpText";
2229 //if ( !sCur.EqualsIgnoreCaseAscii("en-US") ) {
2230 if ( ! Export::isSourceLanguage( sCur ) ) {
2231 sOutput += "[ ";
2232 sOutput += sCur;
2233 sOutput += " ] ";
2235 sOutput += "= ";
2236 ConvertMergeContent( sText );
2237 sOutput += sText;
2238 if ( bDefine )
2239 sOutput += ";\\\n";
2240 else if ( !bNextMustBeDefineEOL )
2241 sOutput += ";\n";
2242 else
2243 bAddSemikolon = TRUE;
2244 for ( USHORT j = 1; j < nLevel; j++ )
2245 sOutput += "\t";
2246 WriteToMerged( sOutput ,true );
2249 if ( bAddSemikolon ) {
2250 ByteString sOutput( ";" );
2251 WriteToMerged( sOutput , false );
2255 if ( pEntry && pResData->bTitle ) {
2256 BOOL bAddSemikolon = FALSE;
2257 BOOL bFirst = TRUE;
2258 ByteString sCur;
2260 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
2261 sCur = aLanguages[ n ];
2263 ByteString sText;
2264 BOOL bText = pEntry->GetText( sText, STRING_TYP_TITLE, sCur, TRUE );
2265 if ( bText && sText.Len() && sText != "-" ) {
2266 ByteString sOutput;
2267 if ( bNextMustBeDefineEOL) {
2268 if ( bFirst )
2269 sOutput += "\t\\\n";
2270 else
2271 sOutput += ";\t\\\n";
2273 bFirst=FALSE;
2274 sOutput += "\t";
2275 sOutput += "Title";
2276 //if ( !sCur.EqualsIgnoreCaseAscii("en-US") ) {
2277 if ( ! Export::isSourceLanguage( sCur ) ) {
2278 sOutput += "[ ";
2279 sOutput += sCur;
2280 sOutput += " ] ";
2282 sOutput += "= ";
2283 ConvertMergeContent( sText );
2284 sOutput += sText;
2285 if ( bDefine )
2286 sOutput += ";\\\n";
2287 else if ( !bNextMustBeDefineEOL )
2288 sOutput += ";\n";
2289 else
2290 bAddSemikolon = TRUE;
2291 for ( USHORT j = 1; j < nLevel; j++ )
2292 sOutput += "\t";
2293 WriteToMerged( sOutput ,true );
2296 if ( bAddSemikolon ) {
2297 ByteString sOutput( ";" );
2298 WriteToMerged( sOutput ,false);
2301 // Merge Lists
2303 if ( pResData->bList ) {
2304 //printf("Dumping ResData\n");
2305 //pResData->Dump();
2307 bool bPairedList = false;
2308 ByteString sOldId = pResData->sId;
2309 ByteString sOldGId = pResData->sGId;
2310 ByteString sOldTyp = pResData->sResTyp;
2311 if ( pResData->sGId.Len())
2312 pResData->sGId += ".";
2313 pResData->sGId += sOldId;
2314 ByteString sSpace;
2315 for ( USHORT i = 1; i < nLevel-1; i++ )
2316 sSpace += "\t";
2317 for ( USHORT nT = LIST_STRING; nT <= LIST_UIENTRIES; nT++ ) {
2318 ExportList *pList = NULL;
2319 switch ( nT ) {
2320 case LIST_STRING : pResData->sResTyp = "stringlist"; pList = pResData->pStringList; bPairedList = false; break;
2321 case LIST_FILTER : pResData->sResTyp = "filterlist"; pList = pResData->pFilterList; bPairedList = false; break;
2322 case LIST_UIENTRIES : pResData->sResTyp = "uientries"; pList = pResData->pUIEntries;bPairedList = false; break;
2323 case LIST_ITEM : pResData->sResTyp = "itemlist"; pList = pResData->pItemList; bPairedList = false; break;
2324 case LIST_PAIRED : pResData->sResTyp = "pairedlist"; pList = pResData->pPairedList; bPairedList = true; break;
2326 ByteString sCur;
2327 for( unsigned int n = 0; n < aLanguages.size(); n++ ){
2328 sCur = aLanguages[ n ];
2329 USHORT nIdx = 1;
2331 // Set matching pairedlist identifier
2332 if( bPairedList && pResData->pPairedList && ( nIdx == 1 ) ){
2333 ExportListEntry* pListE = ( ExportListEntry* ) pResData->pPairedList->GetObject( nIdx-1 );
2334 pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
2336 else
2337 pResData->sId = ByteString("1");
2339 PFormEntrys *pEntrys;
2340 ULONG nLIndex = 0;
2341 ULONG nMaxIndex = 0;
2342 if ( pList )
2343 nMaxIndex = pList->GetSourceLanguageListEntryCount();
2344 pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
2345 while( pEntrys && ( nLIndex < nMaxIndex )) {
2346 //printf("Lang %s, List Index %d\n",sCur.GetBuffer(),(int)nLIndex);
2347 ByteString sText;
2348 BOOL bText;
2349 bText = pEntrys->GetText( sText, STRING_TYP_TEXT, sCur, TRUE );
2350 if( !bText )
2351 bText = pEntrys->GetText( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , FALSE );
2353 // Use fallback, if data is missing in sdf file
2354 //if( !bText && pResData->sResTyp.Equals( "pairedlist" ) ){
2355 if( !bText && bPairedList ){
2356 if( pResData->isMerged( sCur ) ) break;
2357 const ByteString sPlist("pairedlist");
2358 ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
2359 bText = pResData->getFallbackData( sKey , sText );
2360 }else if ( !bText ){// new fallback
2361 if( pResData->isMerged( sCur ) ) break;
2362 const ByteString sPlist("list");
2363 ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
2364 bText = pResData->getFallbackData( sKey , sText );
2365 } // new fallback
2367 if ( bText && sText.Len()) {
2368 //if( pEntrys ) pEntrys->Dump();
2369 if ( nIdx == 1 ) {
2370 ByteString sHead;
2371 if ( bNextMustBeDefineEOL )
2372 sHead = "\\\n\t";
2373 sHead += sSpace;
2374 switch ( nT ) {
2375 case LIST_STRING : sHead += "StringList "; break;
2376 case LIST_FILTER : sHead += "FilterList "; break;
2377 case LIST_ITEM : sHead += "ItemList "; break;
2378 case LIST_PAIRED : sHead += "PairedList "; break;
2379 case LIST_UIENTRIES : sHead += "UIEntries "; break;
2381 sHead += "[ ";
2382 sHead += sCur;
2383 sHead += " ] ";
2385 if ( bDefine || bNextMustBeDefineEOL ) {
2386 sHead += "= \\\n";
2387 sHead += sSpace;
2388 sHead += "\t{\\\n\t";
2390 else {
2391 sHead += "= \n";
2392 sHead += sSpace;
2393 sHead += "\t{\n\t";
2395 WriteToMerged( sHead , true);
2397 ByteString sLine;
2398 if ( pList && pList->GetObject( nLIndex ))
2399 sLine = ( *pList->GetObject( nLIndex ))[ SOURCE_LANGUAGE ];
2400 if ( !sLine.Len())
2401 sLine = sLastListLine;
2403 if ( sLastListLine.Search( "<" ) != STRING_NOTFOUND ) {
2404 if (( nT != LIST_UIENTRIES ) &&
2405 (( sLine.Search( "{" ) == STRING_NOTFOUND ) ||
2406 ( sLine.Search( "{" ) >= sLine.Search( "\"" ))) &&
2407 (( sLine.Search( "<" ) == STRING_NOTFOUND ) ||
2408 ( sLine.Search( "<" ) >= sLine.Search( "\"" ))))
2410 sLine.SearchAndReplace( "\"", "< \"" );
2414 USHORT nStart, nEnd;
2415 nStart = sLine.Search( "\"" );
2417 ByteString sPostFix;
2418 if( !bPairedList ){
2419 nEnd = sLine.SearchBackward( '\"' );
2420 sPostFix = ByteString( sLine.Copy( ++nEnd ));
2421 sLine.Erase( nStart );
2425 ConvertMergeContent( sText );
2427 // merge new res. in text line
2428 if( bPairedList ){
2429 sLine = MergePairedList( sLine , sText );
2431 else{
2432 sLine += sText;
2433 sLine += sPostFix;
2436 ByteString sText1( "\t" );
2437 sText1 += sLine;
2438 if ( bDefine || bNextMustBeDefineEOL )
2439 sText1 += " ;\\\n";
2440 else
2441 sText1 += " ;\n";
2442 sText1 += sSpace;
2443 sText1 += "\t";
2444 //printf("Writing '%s'\n",sText1.GetBuffer());
2445 WriteToMerged( sText1 ,true );
2447 // Set matching pairedlist identifier
2448 if ( bPairedList ){
2449 nIdx++;
2450 ExportListEntry* pListE = ( ExportListEntry* ) pResData->pPairedList->GetObject( ( nIdx ) -1 );
2451 if( pListE ){
2452 pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
2455 else
2456 pResData->sId = ByteString::CreateFromInt32( ++nIdx );
2458 else
2459 break;
2460 nLIndex ++;
2461 PFormEntrys *oldEntry = pEntrys;
2462 pEntrys = pMergeDataFile->GetPFormEntrys( pResData ); // <--- game over
2463 if( !pEntrys )
2464 pEntrys = oldEntry;
2466 if ( nIdx > 1 ) {
2467 ByteString sFooter( sSpace.Copy( 1 ));
2468 if ( bNextMustBeDefineEOL )
2469 sFooter += "};";
2470 else if ( !bDefine )
2471 sFooter += "};\n\t";
2472 else
2473 sFooter += "\n\n";
2474 WriteToMerged( sFooter ,true );
2479 pResData->sId = sOldId;
2480 pResData->sGId = sOldGId;
2481 pResData->sResTyp = sOldTyp;
2484 break;
2485 case MERGE_MODE_LIST : {
2486 ExportList *pList = NULL;
2487 switch ( nList ) {
2488 // PairedList
2489 case LIST_STRING : pList = pResData->pStringList; break;
2490 case LIST_FILTER : pList = pResData->pFilterList; break;
2491 case LIST_UIENTRIES : pList = pResData->pUIEntries; break;
2492 case LIST_ITEM : pList = pResData->pItemList; break;
2493 case LIST_PAIRED : pList = pResData->pPairedList; break;
2497 nListIndex++;
2498 ULONG nMaxIndex = 0;
2499 if ( pList )
2500 nMaxIndex = pList->GetSourceLanguageListEntryCount();
2501 ByteString sLine;
2502 if ( pList && pList->GetObject( nListIndex ))
2503 sLine = ( *pList->GetObject( nListIndex ))[ SOURCE_LANGUAGE ];
2504 if ( !sLine.Len())
2505 sLine = sLastListLine;
2507 if ( sLastListLine.Search( "<" ) != STRING_NOTFOUND ) {
2508 if (( nList != LIST_UIENTRIES ) &&
2509 (( sLine.Search( "{" ) == STRING_NOTFOUND ) ||
2510 ( sLine.Search( "{" ) >= sLine.Search( "\"" ))) &&
2511 (( sLine.Search( "<" ) == STRING_NOTFOUND ) ||
2512 ( sLine.Search( "<" ) >= sLine.Search( "\"" ))))
2514 sLine.SearchAndReplace( "\"", "< \"" );
2518 while( PrepareTextToMerge( sLine, nList, nListLang, pResData ) && ( nListIndex <= nMaxIndex )) {
2519 ByteString sText( "\t" );
2520 sText += sLine;
2521 sText += " ;";
2522 sText += "\n";
2523 for ( USHORT i = 0; i < nLevel; i++ )
2524 sText += "\t";
2525 WriteToMerged( sText ,false );
2526 nListIndex++;
2527 if ( pList && pList->GetObject( nListIndex ))
2528 sLine = ( *pList->GetObject( nListIndex ))[ SOURCE_LANGUAGE ];
2529 if ( !sLine.Len())
2530 sLine = sLastListLine;
2531 sLine += " ;";
2534 break;
2536 pParseQueue->bMflag = false;
2539 ByteString Export::MergePairedList( ByteString& sLine , ByteString& sText ){
2540 // < "xy" ; IDENTIFIER ; >
2541 ByteString sPre = sLine.Copy( 0 , sLine.Search('\"') );
2542 ByteString sPost = sLine.Copy( sLine.SearchBackward('\"') + 1 , sLine.Len() );
2543 sPre.Append( sText );
2544 sPre.Append( sPost );
2545 return sPre;
2548 /*****************************************************************************/
2549 void Export::SetChildWithText()
2550 /*****************************************************************************/
2552 if ( aResStack.Count() > 1 ) {
2553 for ( ULONG i = 0; i < aResStack.Count() - 1; i++ ) {
2554 aResStack.GetObject( i )->bChildWithText = TRUE;
2559 void ParserQueue::Push( const QueueEntry& aEntry ){
2560 // printf("nTyp = %d ",aEntry.nTyp);
2561 USHORT nLen = aEntry.sLine.Len();
2563 if( !bStart ){
2564 aQueueCur->push( aEntry );
2565 if( nLen > 1 && aEntry.sLine.GetChar( nLen-1 ) == '\n' )
2566 bStart = true;
2567 else if ( aEntry.nTyp != IGNOREDTOKENS ){
2568 if( nLen > 1 && ( aEntry.sLine.GetChar( nLen-1 ) == '\\') ){
2569 // Next is Macro
2570 bCurrentIsM = true;
2571 }else{
2572 // Next is no Macro
2573 bCurrentIsM = false;
2577 else{
2578 aQueueNext->push( aEntry );
2579 if( nLen > 1 && aEntry.sLine.GetChar( nLen-1 ) != '\n' ){
2580 if( nLen > 1 && ( aEntry.sLine.GetChar( nLen-1 ) == '\\') ){
2581 // Next is Macro
2582 bNextIsM = true;
2584 else{
2585 // Next is no Macro
2586 bNextIsM = false;
2588 }else if( nLen > 2 && aEntry.sLine.GetChar( nLen-1 ) == '\n' ){
2589 if( aEntry.nTyp != IGNOREDTOKENS ){
2590 if( nLen > 2 && ( aEntry.sLine.GetChar( nLen-2 ) == '\\') ){
2591 // Next is Macro
2592 bNextIsM = true;
2594 else{
2595 // Next is no Macro
2596 bNextIsM = false;
2599 // Pop current
2600 Pop( *aQueueCur );
2601 bLastWasM = bCurrentIsM;
2602 // next -> current
2603 bCurrentIsM = bNextIsM;
2604 aQref = aQueueCur;
2605 aQueueCur = aQueueNext;
2606 aQueueNext = aQref;
2610 else{
2611 // Pop current
2612 Pop( *aQueueCur );
2613 bLastWasM = bCurrentIsM;
2614 // next -> current
2615 bCurrentIsM = bNextIsM;
2616 aQref = aQueueCur;
2617 aQueueCur = aQueueNext;
2618 aQueueNext = aQref;
2623 void ParserQueue::Close(){
2624 // Pop current
2625 Pop( *aQueueCur );
2626 // next -> current
2627 bLastWasM = bCurrentIsM;
2628 bCurrentIsM = bNextIsM;
2629 aQref = aQueueCur;
2630 aQueueCur = aQueueNext;
2631 aQueueNext = aQref;
2632 bNextIsM = false;
2633 Pop( *aQueueNext );
2635 void ParserQueue::Pop( std::queue<QueueEntry>& aQueue ){
2636 while( !aQueue.empty() ){
2637 QueueEntry aEntry = aQueue.front();
2638 aQueue.pop();
2639 aExport.Execute( aEntry.nTyp , (char*) aEntry.sLine.GetBuffer() );
2642 ParserQueue::ParserQueue( Export& aExportObj )
2644 bCurrentIsM( false ),
2645 bNextIsM( false ) ,
2646 bLastWasM( false ),
2647 bMflag( false ) ,
2648 aExport( aExportObj ) ,
2649 bStart( false ) ,
2650 bStartNext( false )
2652 aQueueNext = new std::queue<QueueEntry>;
2653 aQueueCur = new std::queue<QueueEntry>;
2657 ParserQueue::~ParserQueue(){
2658 if( aQueueNext ) delete aQueueNext;
2659 if( aQueueCur ) delete aQueueCur;