Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include "sal/config.h"
21 :
22 : #include <cstddef>
23 : #include <cstring>
24 :
25 : #include "helper.hxx"
26 : #include "srclex.hxx"
27 :
28 : #include "boost/scoped_ptr.hpp"
29 : #include <stdio.h>
30 : #include <stdlib.h>
31 : #include "common.hxx"
32 : #include "export.hxx"
33 : #include "tokens.h"
34 : #include <iostream>
35 : #include <rtl/strbuf.hxx>
36 :
37 : void yyerror( const char * );
38 : void YYWarning( const char * );
39 :
40 : namespace {
41 :
42 : MergeDataFile * pMergeDataFile = 0; //TODO
43 :
44 : namespace global {
45 :
46 11 : OString inputPathname;
47 11 : boost::scoped_ptr< Export > exporter;
48 :
49 : }
50 :
51 0 : static OString lcl_GetListTyp( const sal_uInt16 nTyp, const bool bUpperCamelCase )
52 : {
53 0 : OString sType;
54 0 : switch (nTyp)
55 : {
56 : case LIST_STRING:
57 0 : sType = bUpperCamelCase ? "StringList" : "stringlist";
58 0 : break;
59 : case LIST_FILTER:
60 0 : sType = bUpperCamelCase ? "FilterList" : "filterlist";
61 0 : break;
62 : case LIST_ITEM:
63 0 : sType = bUpperCamelCase ? "ItemList" : "itemlist";
64 0 : break;
65 : case LIST_PAIRED:
66 0 : sType = bUpperCamelCase ? "PairedList" : "pairedlist";
67 0 : break;
68 0 : default: break;
69 : }
70 0 : return sType;
71 : }
72 :
73 : }
74 :
75 : extern "C" {
76 :
77 11 : FILE * init(int argc, char ** argv) {
78 :
79 11 : common::HandledArgs aArgs;
80 11 : if ( !common::handleArguments(argc, argv, aArgs) )
81 : {
82 0 : common::writeUsage("transex3","*.src/*.hrc");
83 0 : std::exit(EXIT_FAILURE);
84 : }
85 11 : global::inputPathname = aArgs.m_sInputFile;
86 :
87 11 : FILE * pFile = std::fopen(global::inputPathname.getStr(), "r");
88 11 : if (pFile == 0) {
89 : std::fprintf(
90 : stderr, "Error: Cannot open file \"%s\"\n",
91 0 : global::inputPathname.getStr());
92 0 : std::exit(EXIT_FAILURE);
93 : }
94 :
95 11 : if (aArgs.m_bMergeMode) {
96 : global::exporter.reset(new Export(aArgs.m_sMergeSrc, aArgs.m_sOutputFile,
97 11 : aArgs.m_sLanguage, aArgs.m_bUTF8BOM));
98 : } else {
99 0 : global::exporter.reset(new Export(aArgs.m_sOutputFile));
100 : }
101 :
102 11 : global::exporter->Init();
103 :
104 11 : return pFile;
105 : }
106 :
107 260 : int Parse( int nTyp, const char *pTokenText ){
108 260 : global::exporter->Execute( nTyp , pTokenText );
109 260 : return 1;
110 : }
111 11 : void Close(){
112 11 : global::exporter->pParseQueue->Close();
113 11 : global::exporter.reset();
114 : // avoid nontrivial Export dtor being executed during exit
115 11 : }
116 :
117 28839 : int WorkOnTokenSet( int nTyp, char *pTokenText )
118 : {
119 :
120 28839 : global::exporter->pParseQueue->Push( QueueEntry( nTyp , OString(pTokenText) ) );
121 28839 : return 1;
122 : }
123 :
124 : } // extern
125 :
126 : extern "C" {
127 :
128 0 : int SetError()
129 : {
130 : // set error at global instance of class Export
131 0 : global::exporter->SetError();
132 0 : return 1;
133 : }
134 : }
135 :
136 : extern "C" {
137 :
138 11 : int GetError()
139 : {
140 : // get error at global instance of class Export
141 11 : if (global::exporter->GetError())
142 0 : return 1;
143 11 : return sal_False;
144 : }
145 : }
146 :
147 :
148 : // class ResData
149 :
150 :
151 983 : bool ResData::SetId( const OString& rId, sal_uInt16 nLevel )
152 : {
153 983 : if ( nLevel > nIdLevel )
154 : {
155 619 : nIdLevel = nLevel;
156 619 : sId = rId;
157 :
158 619 : if ( bChild && bChildWithText )
159 : {
160 0 : OString sError("ResId after child definition");
161 0 : yyerror(sError.getStr());
162 0 : SetError();
163 : }
164 :
165 619 : if ( sId.getLength() > 255 )
166 : {
167 0 : YYWarning( "LocalId > 255 chars, truncating..." );
168 0 : sId = sId.copy(0, 255).trim();
169 : }
170 :
171 619 : return true;
172 : }
173 :
174 364 : return false;
175 : }
176 :
177 :
178 : // class Export
179 :
180 :
181 : namespace
182 : {
183 :
184 1164 : static sal_Int32 lcl_countOccurrences(const OString& text, char c)
185 : {
186 1164 : sal_Int32 n = 0;
187 3492 : for (sal_Int32 i = 0;; ++i) {
188 3492 : i = text.indexOf(c, i);
189 3492 : if (i == -1) {
190 1164 : break;
191 : }
192 2328 : ++n;
193 2328 : }
194 1164 : return n;
195 : }
196 :
197 : }
198 :
199 0 : Export::Export(const OString &rOutput)
200 : :
201 : bDefine( false ),
202 : bNextMustBeDefineEOL( false ),
203 : nLevel( 0 ),
204 : nList( LIST_NON ),
205 : nListIndex( 0 ),
206 : nListLevel( 0 ),
207 : bMergeMode( false ),
208 : bError( false ),
209 : bReadOver( false ),
210 : sFilename( global::inputPathname ),
211 : sLanguages( OString() ),
212 0 : pParseQueue( new ParserQueue( *this ) )
213 : {
214 0 : aOutput.mPo = new PoOfstream( rOutput, PoOfstream::APP );
215 0 : if (!aOutput.mPo->isOpen()) {
216 0 : fprintf(stderr, "ERROR : Can't open file %s\n", rOutput.getStr());
217 0 : exit ( -1 );
218 : }
219 0 : }
220 :
221 11 : Export::Export(
222 : const OString &rMergeSource, const OString &rOutput,
223 : const OString &rLanguage, bool bUTF8BOM)
224 : :
225 : bDefine( false ),
226 : bNextMustBeDefineEOL( false ),
227 : nLevel( 0 ),
228 : nList( LIST_NON ),
229 : nListIndex( 0 ),
230 : nListLevel( 0 ),
231 : bMergeMode( true ),
232 : sMergeSrc( rMergeSource ),
233 : bError( false ),
234 : bReadOver( false ),
235 : sFilename( global::inputPathname ),
236 : sLanguages( rLanguage ),
237 11 : pParseQueue( new ParserQueue( *this ) )
238 : {
239 11 : aOutput.mSimple = new std::ofstream();
240 11 : aOutput.mSimple->open(rOutput.getStr(), std::ios_base::out | std::ios_base::trunc);
241 :
242 11 : if ( bUTF8BOM ) WriteUTF8ByteOrderMarkToOutput();
243 11 : }
244 :
245 11 : void Export::Init()
246 : {
247 : // resets the internal status, used before parseing another file
248 11 : bDefine = false;
249 11 : bNextMustBeDefineEOL = false;
250 11 : nLevel = 0;
251 11 : nList = LIST_NON;
252 11 : nListIndex = 0;
253 11 : for ( size_t i = 0, n = aResStack.size(); i < n; ++i )
254 0 : delete aResStack[ i ];
255 11 : aResStack.clear();
256 11 : }
257 :
258 22 : Export::~Export()
259 : {
260 11 : if( pParseQueue )
261 11 : delete pParseQueue;
262 11 : if ( bMergeMode )
263 : {
264 11 : aOutput.mSimple->close();
265 11 : delete aOutput.mSimple;
266 : }
267 : else
268 : {
269 0 : aOutput.mPo->close();
270 0 : delete aOutput.mPo;
271 : }
272 11 : for ( size_t i = 0, n = aResStack.size(); i < n; ++i )
273 0 : delete aResStack[ i ];
274 11 : aResStack.clear();
275 :
276 11 : if ( bMergeMode ) {
277 11 : if ( !pMergeDataFile )
278 0 : pMergeDataFile = new MergeDataFile(sMergeSrc, global::inputPathname, false);
279 :
280 11 : delete pMergeDataFile;
281 : }
282 11 : }
283 :
284 29121 : int Export::Execute( int nToken, const char * pToken )
285 : {
286 :
287 29121 : OString sToken( pToken );
288 58242 : OString sOrig( sToken );
289 :
290 29121 : if ( nToken == CONDITION )
291 : {
292 151 : OString sTestToken(pToken);
293 302 : sTestToken = sTestToken.replaceAll("\t", OString()).
294 151 : replaceAll(" ", OString());
295 151 : if (( !bReadOver ) && ( sTestToken.startsWith("#ifndef__RSC_PARSER")))
296 0 : bReadOver = true;
297 151 : else if (( bReadOver ) && ( sTestToken.startsWith("#endif") ))
298 0 : bReadOver = false;
299 : }
300 79387 : if ((( nToken < FILTER_LEVEL ) || ( bReadOver )) &&
301 25133 : (!(( bNextMustBeDefineEOL ) && ( sOrig == "\n" )))) {
302 : // this tokens are not mandatory for parsing, so ignore them ...
303 25133 : if ( bMergeMode )
304 25133 : WriteToMerged( sOrig , false ); // ... or write them directly to dest.
305 25133 : return 0;
306 : }
307 :
308 3988 : ResData *pResData = NULL;
309 3988 : if ( nLevel ) {
310 : // res. exists at cur. level
311 3365 : pResData = ( (nLevel-1) < aResStack.size() ) ? aResStack[ nLevel-1 ] : NULL;
312 : }
313 623 : else if (( nToken != RESOURCE ) &&
314 591 : ( nToken != RESOURCEEXPR ) &&
315 591 : ( nToken != SMALRESOURCE ) &&
316 591 : ( nToken != LEVELUP ) &&
317 524 : ( nToken != NORMDEFINE ) &&
318 268 : ( nToken != RSCDEFINE ) &&
319 208 : ( nToken != CONDITION ) &&
320 : ( nToken != PRAGMA ))
321 : {
322 : // no res. exists at cur. level so return
323 208 : if ( bMergeMode )
324 208 : WriteToMerged( sOrig , false );
325 208 : return 0;
326 : }
327 :
328 3780 : if ( bDefine ) {
329 2155 : if (( nToken != EMPTYLINE ) && ( nToken != LEVELDOWN ) && ( nToken != LEVELUP )) {
330 : // cur. res. defined in macro
331 1574 : if ( bNextMustBeDefineEOL ) {
332 0 : if ( nToken != RSCDEFINELEND ) {
333 : // end of macro found, so destroy res.
334 0 : bDefine = false;
335 0 : Execute( LEVELDOWN, "" );
336 0 : bNextMustBeDefineEOL = false;
337 : }
338 : else {
339 : // next line also in macro definition
340 0 : bNextMustBeDefineEOL = false;
341 0 : if ( bMergeMode )
342 0 : WriteToMerged( sOrig , false );
343 0 : return 1;
344 : }
345 : }
346 : }
347 : }
348 :
349 3780 : bool bExecuteDown = false;
350 3780 : if ( nToken != LEVELDOWN ) {
351 3000 : sal_uInt16 nOpen = 0;
352 3000 : sal_uInt16 nClose = 0;
353 3000 : bool bReadOver1 = false;
354 3000 : sal_uInt16 i = 0;
355 97782 : for ( i = 0; i < sToken.getLength(); i++ ) {
356 94782 : if ( sToken[i] == '"' )
357 790 : bReadOver1 = !bReadOver1;
358 94782 : if ( !bReadOver1 && ( sToken[i] == '{' ))
359 524 : nOpen++;
360 : }
361 :
362 3000 : bReadOver1 = false;
363 97782 : for ( i = 0; i < sToken.getLength(); i++ ) {
364 94782 : if ( sToken[i] == '"' )
365 790 : bReadOver1 = !bReadOver1;
366 94782 : if ( !bReadOver1 && ( sToken[i] == '}' ))
367 3 : nClose++;
368 : }
369 :
370 3000 : if ( nOpen < nClose )
371 0 : bExecuteDown = true;
372 : }
373 :
374 3780 : bool bWriteToMerged = bMergeMode;
375 3780 : switch ( nToken ) {
376 :
377 : case NORMDEFINE:
378 67 : if ( bMergeMode )
379 67 : WriteToMerged( sOrig , false );
380 67 : return 0;
381 : case RSCDEFINE:
382 261 : bDefine = true; // res. defined in macro
383 :
384 : case RESOURCE:
385 : case RESOURCEEXPR: {
386 337 : if ( nToken != RSCDEFINE )
387 76 : bNextMustBeDefineEOL = false;
388 : // this is the beginning of a new res.
389 337 : nLevel++;
390 337 : if ( nLevel > 1 ) {
391 49 : aResStack[ nLevel - 2 ]->bChild = true;
392 : }
393 :
394 : // create new instance for this res. and fill mandatory fields
395 :
396 337 : pResData = new ResData( FullId() , sFilename );
397 337 : aResStack.push_back( pResData );
398 674 : sToken = sToken.replaceAll("\n", OString()).
399 : replaceAll("\r", OString()).
400 337 : replaceAll("{", OString()).replace('\t', ' ');
401 337 : sToken = sToken.trim();
402 337 : OString sTLower = sToken.getToken(0, ' ').toAsciiLowerCase();
403 337 : pResData->sResTyp = sTLower;
404 674 : OString sId( sToken.copy( pResData->sResTyp.getLength() + 1 ));
405 674 : OString sCondition;
406 337 : if ( sId.indexOf( '#' ) != -1 )
407 : {
408 : // between ResTyp, Id and paranthes is a precomp. condition
409 22 : sCondition = "#";
410 22 : sal_Int32 n = 0;
411 22 : sId = sId.getToken(0, '#', n);
412 22 : sCondition += sId.getToken(0, '#', n);
413 : }
414 337 : sId = sId.getToken(0, '/');
415 337 : CleanValue( sId );
416 337 : sId = sId.replaceAll("\t", OString());
417 337 : pResData->SetId( sId, ID_LEVEL_IDENTIFIER );
418 337 : if (!sCondition.isEmpty())
419 : {
420 22 : Execute( CONDITION, ""); // execute the precomp. condition
421 337 : }
422 : }
423 337 : break;
424 : case SMALRESOURCE: {
425 : // this is the beginning of a new res.
426 384 : bNextMustBeDefineEOL = false;
427 384 : nLevel++;
428 384 : if ( nLevel > 1 ) {
429 384 : aResStack[ nLevel - 2 ]->bChild = true;
430 : }
431 :
432 : // create new instance for this res. and fill mandatory fields
433 :
434 384 : pResData = new ResData( FullId() , sFilename );
435 384 : aResStack.push_back( pResData );
436 768 : sToken = sToken.replaceAll("\n", OString()).
437 : replaceAll("\r", OString()).
438 : replaceAll("{", OString()).
439 : replaceAll("\t", OString()).
440 : replaceAll(" ", OString()).
441 384 : replaceAll("\\", OString()).toAsciiLowerCase();
442 384 : pResData->sResTyp = sToken;
443 : }
444 384 : break;
445 : case LEVELUP: {
446 : // push
447 59 : if ( nList )
448 : {
449 0 : nListLevel++;
450 0 : break;
451 : }
452 :
453 59 : OString sLowerTyp;
454 59 : if ( pResData )
455 59 : sLowerTyp = "unknown";
456 59 : nLevel++;
457 59 : if ( nLevel > 1 ) {
458 59 : aResStack[ nLevel - 2 ]->bChild = true;
459 : }
460 :
461 59 : ResData *pNewData = new ResData( FullId() , sFilename );
462 59 : pNewData->sResTyp = sLowerTyp;
463 59 : aResStack.push_back( pNewData );
464 : }
465 59 : break;
466 : case LEVELDOWN: {
467 : // pop
468 780 : if ( !nList || !nListLevel ) {
469 780 : if ( nLevel ) {
470 780 : if ( bDefine && (nLevel == 1 )) {
471 1 : bDefine = false;
472 1 : bNextMustBeDefineEOL = false;
473 : }
474 780 : WriteData( pResData );
475 780 : ResStack::iterator it = aResStack.begin();
476 780 : ::std::advance( it, nLevel-1 );
477 780 : delete *it;
478 780 : aResStack.erase( it );
479 780 : nLevel--;
480 : }
481 780 : if( nList )
482 : {
483 0 : nList = LIST_NON;
484 0 : nListLevel = 1;
485 780 : }
486 : }
487 : else
488 : {
489 0 : if ( bDefine )
490 0 : bNextMustBeDefineEOL = true;
491 0 : nListLevel--;
492 : }
493 : }
494 780 : break;
495 : case ASSIGNMENT:
496 : {
497 : // interpret different types of assignement
498 1012 : sal_Int32 n = 0;
499 : OString sKey = sToken.getToken(0, '=', n).
500 : replaceAll(" ", OString()).
501 1012 : replaceAll("\t", OString());
502 2024 : OString sValue = sToken.getToken(0, '=', n);
503 1012 : CleanValue( sValue );
504 1012 : sKey = sKey.toAsciiUpperCase();
505 1012 : if (sKey == "IDENTIFIER")
506 : {
507 : OString sId(
508 : sValue.replaceAll("\t", OString()).
509 363 : replaceAll(" ", OString()));
510 363 : pResData->SetId(sId, ID_LEVEL_IDENTIFIER);
511 : }
512 649 : else if (sKey =="STRINGLIST")
513 : {
514 0 : nList = LIST_STRING;
515 0 : nListIndex = 0;
516 0 : nListLevel = 1;
517 : }
518 649 : else if (sKey == "FILTERLIST")
519 : {
520 0 : nList = LIST_FILTER;
521 0 : nListIndex = 0;
522 0 : nListLevel = 1;
523 : }
524 2024 : if (sToken.indexOf( '{' ) != -1
525 1012 : && (lcl_countOccurrences(sToken, '{')
526 0 : > lcl_countOccurrences(sToken, '}')))
527 : {
528 0 : Parse( LEVELUP, "" );
529 1012 : }
530 : }
531 1012 : break;
532 : case LISTASSIGNMENT:
533 : {
534 : OString sTmpToken(
535 2 : sToken.replaceAll(" ", OString()).toAsciiLowerCase());
536 2 : sal_Int32 nPos = sTmpToken.indexOf("[en-us]=");
537 2 : if (nPos != -1) {
538 : OString sKey(
539 : sTmpToken.copy(0 , nPos).replaceAll(" ", OString()).
540 0 : replaceAll("\t", OString()));
541 0 : OString sValue = sToken.getToken(1, '=');
542 0 : CleanValue( sValue );
543 0 : sKey = sKey.toAsciiUpperCase();
544 0 : if (sKey == "STRINGLIST")
545 : {
546 0 : nList = LIST_STRING;
547 : }
548 0 : else if (sKey == "FILTERLIST")
549 : {
550 0 : nList = LIST_FILTER;
551 : }
552 0 : else if (sKey == "PAIREDLIST")
553 : {
554 0 : nList = LIST_PAIRED;
555 : }
556 0 : else if (sKey == "ITEMLIST")
557 : {
558 0 : nList = LIST_ITEM;
559 : }
560 0 : if( nList )
561 : {
562 0 : nListIndex = 0;
563 0 : nListLevel = 1;
564 0 : }
565 2 : }
566 : }
567 2 : break;
568 : case TEXT:
569 : case _LISTTEXT:
570 : case LISTTEXT: {
571 : // this is an entry for a List
572 6 : if ( nList )
573 : {
574 0 : SetChildWithText();
575 0 : InsertListEntry( sOrig );
576 : }
577 : }
578 6 : break;
579 : case LONGTEXTLINE:
580 : case TEXTLINE:
581 388 : if ( nLevel )
582 : {
583 388 : CutComment( sToken );
584 :
585 : // this is a text line!!!
586 388 : OString t(sToken.getToken(0, '='));
587 : OString sKey(
588 : t.getToken(0, '[').replaceAll(" ", OString()).
589 776 : replaceAll("\t", OString()));
590 776 : OString sText( GetText( sToken, nToken ));
591 776 : OString sLang;
592 388 : if ( sToken.getToken(0, '=').indexOf('[') != -1 )
593 : {
594 576 : sLang = sToken.getToken(0, '=').getToken(1, '[').
595 288 : getToken(0, ']');
596 288 : CleanValue( sLang );
597 : }
598 776 : OString sLangIndex = sLang;
599 776 : OString sOrigKey = sKey;
600 388 : if ( !sText.isEmpty() && !sLang.isEmpty() )
601 : {
602 284 : sKey = sKey.toAsciiUpperCase();
603 284 : if (sKey == "TEXT" || sKey == "MESSAGE" || sKey == "CUSTOMUNITTEXT")
604 : {
605 284 : SetChildWithText();
606 284 : if ( sLangIndex.equalsIgnoreAsciiCase("en-US") )
607 283 : pResData->SetId( sText, ID_LEVEL_TEXT );
608 :
609 284 : pResData->bText = true;
610 284 : pResData->sTextTyp = sOrigKey;
611 284 : if ( !bMergeMode )
612 : {
613 0 : pResData->sText[ sLangIndex ] = sText;
614 : }
615 : }
616 0 : else if ( sKey == "QUICKHELPTEXT" ) {
617 0 : SetChildWithText();
618 0 : pResData->bQuickHelpText = true;
619 0 : if ( !bMergeMode )
620 : {
621 0 : pResData->sQuickHelpText[ sLangIndex ] = sText;
622 : }
623 : }
624 0 : else if ( sKey == "TITLE" ) {
625 0 : SetChildWithText();
626 0 : pResData->bTitle = true;
627 0 : if ( !bMergeMode )
628 : {
629 0 : pResData->sTitle[ sLangIndex ] = sText;
630 : }
631 : }
632 388 : }
633 : }
634 388 : break;
635 : case APPFONTMAPPING:
636 99 : break;
637 : case RSCDEFINELEND:
638 136 : break;
639 : case CONDITION: {
640 151 : if ( nLevel ) {
641 91 : WriteData( pResData, true );
642 : }
643 : }
644 151 : break;
645 : case EMPTYLINE : {
646 359 : if ( bDefine ) {
647 255 : bNextMustBeDefineEOL = false;
648 255 : bDefine = false;
649 770 : while ( nLevel )
650 260 : Parse( LEVELDOWN, "" );
651 : }
652 : }
653 359 : break;
654 : case PRAGMA : {
655 0 : fprintf(stderr, "ERROR: archaic PRAGMA %s\n", sToken.getStr());
656 0 : exit(-1);
657 : }
658 : break;
659 : }
660 3713 : if ( bWriteToMerged ) {
661 : // the current token must be written to dest. without merging
662 :
663 3713 : if( bDefine && sOrig.getLength() > 2 ){
664 75320 : for( sal_uInt16 n = 0 ; n < sOrig.getLength() ; n++ ){
665 73493 : if( sOrig[n] == '\n' && sOrig[n-1] != '\\'){
666 0 : sOrig = sOrig.replaceAt(n++, 0, "\\");
667 : }
668 : }
669 : }
670 3713 : WriteToMerged( sOrig , false);
671 : }
672 :
673 3713 : if ( bExecuteDown ) {
674 0 : Parse( LEVELDOWN, "" );
675 : }
676 :
677 32834 : return 1;
678 : }
679 :
680 388 : void Export::CutComment( OString &rText )
681 : {
682 388 : if (rText.indexOf("//") != -1) {
683 0 : OString sWork(rText.replaceAll("\\\"", "XX"));
684 0 : bool bInner = false;
685 0 : for (sal_Int32 i = 0; i < sWork.getLength() - 1; ++i) {
686 0 : if (sWork[i] == '"') {
687 0 : bInner = !bInner;
688 0 : } else if (sWork[i] == '/' && !bInner && sWork[i + 1] == '/' ) {
689 0 : rText = rText.copy(0, i);
690 0 : break;
691 : }
692 0 : }
693 : }
694 388 : }
695 :
696 871 : bool Export::WriteData( ResData *pResData, bool bCreateNew )
697 : {
698 871 : if ( bMergeMode ) {
699 871 : MergeRest( pResData );
700 871 : return true;
701 : }
702 :
703 : // mandatory to export: en-US
704 :
705 0 : if (( !pResData->sText[ SOURCE_LANGUAGE ].isEmpty())
706 0 : ||
707 0 : ( !pResData->sQuickHelpText[ SOURCE_LANGUAGE ].isEmpty())
708 0 : ||
709 0 : ( !pResData->sTitle[ SOURCE_LANGUAGE ].isEmpty()))
710 :
711 : {
712 0 : OString sGID = pResData->sGId;
713 0 : OString sLID;
714 0 : if (sGID.isEmpty())
715 0 : sGID = pResData->sId;
716 : else
717 0 : sLID = pResData->sId;
718 :
719 0 : OString sXText = pResData->sText[ SOURCE_LANGUAGE ];
720 0 : OString sXHText = pResData->sText[ X_COMMENT ];
721 0 : OString sXQHText = pResData->sQuickHelpText[ SOURCE_LANGUAGE ];
722 0 : OString sXTitle = pResData->sTitle[ SOURCE_LANGUAGE ];
723 :
724 0 : if( !sXText.isEmpty() )
725 : {
726 0 : ConvertExportContent(sXText);
727 0 : ConvertExportContent(sXHText);
728 : common::writePoEntry(
729 : "Transex3", *aOutput.mPo, global::inputPathname,
730 0 : pResData->sResTyp, sGID, sLID, sXHText, sXText);
731 : }
732 0 : if( !sXQHText.isEmpty() )
733 : {
734 0 : ConvertExportContent(sXQHText);
735 : common::writePoEntry(
736 : "Transex3", *aOutput.mPo, global::inputPathname, pResData->sResTyp,
737 0 : sGID, sLID, OString(), sXQHText, PoEntry::TQUICKHELPTEXT );
738 : }
739 0 : if( !sXTitle.isEmpty() )
740 : {
741 0 : ConvertExportContent(sXTitle);
742 : common::writePoEntry(
743 : "Transex3", *aOutput.mPo, global::inputPathname, pResData->sResTyp,
744 0 : sGID, sLID, OString(), sXTitle, PoEntry::TTITLE );
745 : }
746 :
747 0 : if ( bCreateNew ) {
748 0 : pResData->sText[ SOURCE_LANGUAGE ] = "";
749 0 : pResData->sQuickHelpText[ SOURCE_LANGUAGE ]= "";
750 0 : pResData->sTitle[ SOURCE_LANGUAGE ] = "";
751 0 : }
752 : }
753 :
754 0 : if( nList )
755 : {
756 0 : WriteExportList( pResData, pResData->m_aList, nList );
757 0 : if ( bCreateNew )
758 0 : pResData->m_aList.clear();
759 : }
760 0 : return true;
761 : }
762 :
763 0 : OString Export::GetPairedListID(const OString& rText)
764 : {
765 : // < "STRING" ; IDENTIFIER ; > ;
766 0 : return rText.getToken(1, ';').toAsciiUpperCase().replace('\t', ' ').trim();
767 : }
768 :
769 0 : OString Export::GetPairedListString(const OString& rText)
770 : {
771 : // < "STRING" ; IDENTIFIER ; > ;
772 0 : OString sString(rText.getToken(0, ';').replace('\t', ' '));
773 0 : sString = sString.trim();
774 0 : OString s1(sString.copy(sString.indexOf('"') + 1));
775 0 : sString = s1.copy(0, s1.lastIndexOf('"'));
776 0 : return sString.trim();
777 : }
778 :
779 0 : OString Export::StripList(const OString & rText)
780 : {
781 0 : OString s1 = rText.copy( rText.indexOf('\"') + 1);
782 0 : return s1.copy( 0 , s1.lastIndexOf('\"'));
783 : }
784 :
785 0 : bool Export::WriteExportList(ResData *pResData, ExportList& rExportList,
786 : const sal_uInt16 nTyp)
787 : {
788 0 : OString sGID(pResData->sGId);
789 0 : if (sGID.isEmpty())
790 0 : sGID = pResData->sId;
791 : else {
792 0 : sGID += ".";
793 0 : sGID += pResData->sId;
794 0 : while (sGID.endsWith(".")) {
795 0 : sGID = sGID.copy(0, sGID.getLength() - 1);
796 : }
797 : }
798 :
799 0 : for ( size_t i = 0; i < rExportList.size(); i++ )
800 : {
801 0 : OString sLID;
802 0 : OString sText(rExportList[ i ]);
803 :
804 : // Strip PairList Line String
805 0 : if (nTyp == LIST_PAIRED)
806 : {
807 0 : sLID = GetPairedListID( sText );
808 0 : sText = GetPairedListString( sText );
809 : }
810 : else
811 : {
812 0 : sText = StripList( sText );
813 0 : if( sText == "\\\"" )
814 0 : sText = "\"";
815 : }
816 0 : ConvertExportContent(sText);
817 :
818 0 : if (nTyp != LIST_PAIRED)
819 0 : sLID = sText;
820 :
821 0 : OString sType = lcl_GetListTyp( nList, false );
822 :
823 : common::writePoEntry(
824 : "Transex3", *aOutput.mPo, global::inputPathname,
825 0 : sType, sGID, sLID, OString(), sText);
826 0 : }
827 :
828 0 : return true;
829 : }
830 :
831 780 : OString Export::FullId()
832 : {
833 780 : OStringBuffer sFull;
834 780 : if ( nLevel > 1 )
835 : {
836 492 : sFull.append(aResStack[ 0 ]->sId);
837 895 : for ( size_t i = 1; i < nLevel - 1; ++i )
838 : {
839 403 : OString sToAdd = aResStack[ i ]->sId;
840 403 : if (!sToAdd.isEmpty())
841 105 : sFull.append('.').append(sToAdd);
842 403 : }
843 : }
844 780 : if (sFull.getLength() > 255)
845 : {
846 0 : OString sError("GroupId > 255 chars");
847 0 : printf("GroupID = %s\n", sFull.getStr());
848 0 : yyerror(sError.getStr());
849 : }
850 :
851 780 : return sFull.makeStringAndClear();
852 : }
853 :
854 0 : void Export::InsertListEntry(const OString &rLine)
855 : {
856 0 : ResData *pResData = ( nLevel-1 < aResStack.size() ) ? aResStack[ nLevel-1 ] : NULL;
857 :
858 0 : if (!pResData)
859 0 : std::exit(EXIT_FAILURE);
860 :
861 0 : if( pResData->m_aList.empty() )
862 0 : nListIndex = 0;
863 :
864 0 : pResData->m_aList.push_back(rLine);
865 0 : }
866 :
867 2025 : void Export::CleanValue( OString &rValue )
868 : {
869 5325 : while ( !rValue.isEmpty()) {
870 3274 : if (( rValue[0] == ' ' ) || ( rValue[0] == '\t' ))
871 1275 : rValue = rValue.copy( 1 );
872 : else
873 1999 : break;
874 : }
875 :
876 2025 : if ( !rValue.isEmpty()) {
877 18682 : for ( sal_Int32 i = rValue.getLength() - 1; i > 0; i-- ) {
878 47538 : if (( rValue[i] == ' ' ) || ( rValue[i] == '\t' ) ||
879 13193 : ( rValue[i] == '\n' ) || ( rValue[i] == ';' ) ||
880 27393 : ( rValue[i] == '{' ) || ( rValue[i] == '\\' ) ||
881 1982 : ( rValue[i] == '\r' ))
882 16683 : rValue = rValue.copy(0, i);
883 : else
884 1982 : break;
885 : }
886 : }
887 2025 : }
888 :
889 : #define TXT_STATE_TEXT 0x001
890 : #define TXT_STATE_MACRO 0x002
891 :
892 388 : OString Export::GetText(const OString &rSource, int nToken)
893 : {
894 388 : OString sReturn;
895 388 : switch ( nToken )
896 : {
897 : case TEXTLINE:
898 : case LONGTEXTLINE:
899 : {
900 388 : OString sTmp(rSource.copy(rSource.indexOf('=')));
901 388 : CleanValue( sTmp );
902 776 : sTmp = sTmp.replaceAll("\n", OString()).
903 : replaceAll("\r", OString()).
904 : replaceAll("\\\\\"", "-=<[BSlashBSlashHKom]>=-\"").
905 : replaceAll("\\\"", "-=<[Hochkomma]>=-").
906 : replaceAll("\\", "-=<[0x7F]>=-").
907 388 : replaceAll("\\0x7F", "-=<[0x7F]>=-");
908 :
909 388 : sal_uInt16 nState = TXT_STATE_TEXT;
910 1164 : for (sal_Int32 i = 1; i <= lcl_countOccurrences(sTmp, '"'); ++i)
911 : {
912 776 : OString sToken(sTmp.getToken(i, '"'));
913 776 : if (!sToken.isEmpty()) {
914 384 : if ( nState == TXT_STATE_TEXT ) {
915 384 : sReturn += sToken;
916 384 : nState = TXT_STATE_MACRO;
917 : }
918 : else {
919 0 : sToken = sToken.replace('\t', ' ');
920 : for (;;) {
921 0 : sal_Int32 n = 0;
922 0 : sToken = sToken.replaceFirst(" ", " ", &n);
923 0 : if (n == -1) {
924 0 : break;
925 : }
926 0 : }
927 0 : sToken = sToken.trim();
928 0 : if (!sToken.isEmpty()) {
929 0 : sReturn += "\\\" ";
930 0 : sReturn += sToken;
931 0 : sReturn += " \\\"";
932 : }
933 0 : nState = TXT_STATE_TEXT;
934 : }
935 : }
936 776 : }
937 :
938 776 : sReturn = sReturn.replaceAll("-=<[0x7F]>=-", "").
939 : replaceAll("-=<[Hochkomma]>=-", "\"").
940 : replaceAll("-=<[BSlashBSlashHKom]>=-", "\\\\").
941 : replaceAll("\\\\", "-=<[BSlashBSlash]>=-").
942 776 : replaceAll("-=<[BSlashBSlash]>=-", "\\");
943 : }
944 388 : break;
945 : }
946 388 : return sReturn;
947 : }
948 :
949 29121 : void Export::WriteToMerged(const OString &rText , bool bSDFContent)
950 : {
951 29121 : OString sText(rText);
952 : for (;;) {
953 29121 : sal_Int32 n = 0;
954 29121 : sText = sText.replaceFirst(" \n", "\n", &n);
955 29121 : if (n == -1) {
956 29121 : break;
957 : }
958 0 : }
959 35868 : if (pParseQueue->bNextIsM && bSDFContent && sText.getLength() > 2) {
960 0 : for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
961 0 : if (sText[n] == '\n' && sText[n - 1] != '\\') {
962 0 : sText = sText.replaceAt(n++, 0, "\\");
963 : }
964 : }
965 29121 : } else if (pParseQueue->bLastWasM && sText.getLength() > 2) {
966 70880 : for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
967 68673 : if (sText[n] == '\n' && sText[n - 1] != '\\') {
968 0 : sText = sText.replaceAt(n++, 0, "\\");
969 : }
970 68673 : if (sText[n] == '\n') {
971 541 : pParseQueue->bMflag = true;
972 : }
973 : }
974 26914 : } else if (pParseQueue->bCurrentIsM && bSDFContent && sText.getLength() > 2)
975 : {
976 0 : for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
977 0 : if (sText[n] == '\n' && sText[n - 1] != '\\') {
978 0 : sText = sText.replaceAt(n++, 0, "\\");
979 0 : pParseQueue->bMflag = true;
980 : }
981 : }
982 26914 : } else if (pParseQueue->bMflag) {
983 4953 : for (sal_Int32 n = 1; n < sText.getLength(); ++n) {
984 3392 : if (sText[n] == '\n' && sText[n - 1] != '\\') {
985 0 : sText = sText.replaceAt(n++, 0, "\\");
986 : }
987 : }
988 183288 : } for (sal_Int32 i = 0; i < sText.getLength(); ++i) {
989 154167 : if (sText[i] == '\n') {
990 4844 : *aOutput.mSimple << '\n';
991 : } else {
992 149323 : char cChar = sText[i];
993 149323 : *aOutput.mSimple << cChar;
994 : }
995 29121 : }
996 29121 : }
997 :
998 0 : void Export::ConvertMergeContent( OString &rText )
999 : {
1000 0 : rText = rText.replaceAll("\\\'","\'"); // Temporary: until PO files contain escaped single quotes
1001 : // (Maybe next PO update solve this)
1002 0 : rText =
1003 : helper::escapeAll(
1004 : rText.replaceAll("","\\0x7F"),
1005 0 : "\n""\t""\\""\"","\\n""\\t""\\\\""\\\"");
1006 :
1007 0 : rText = "\"" + rText + "\"";
1008 0 : }
1009 :
1010 0 : void Export::ConvertExportContent( OString& rText )
1011 : {
1012 0 : rText = helper::unEscapeAll(rText,"\\n""\\t""\\\\""\\\"","\n""\t""\\""\"");
1013 0 : }
1014 :
1015 0 : void Export::ResData2Output( MergeEntrys *pEntry, sal_uInt16 nType, const OString& rTextType )
1016 : {
1017 0 : bool bAddSemicolon = false;
1018 0 : bool bFirst = true;
1019 0 : OString sCur;
1020 :
1021 0 : for( unsigned int n = 0; n < aLanguages.size(); n++ ){
1022 0 : sCur = aLanguages[ n ];
1023 :
1024 0 : OString sText;
1025 0 : bool bText = pEntry->GetText( sText, nType, sCur , true );
1026 0 : if ( bText && !sText.isEmpty() ) {
1027 0 : OStringBuffer sOutput;
1028 0 : if ( bNextMustBeDefineEOL) {
1029 0 : if ( bFirst )
1030 0 : sOutput.append("\t\\\n");
1031 : else
1032 0 : sOutput.append(";\t\\\n");
1033 : }
1034 0 : bFirst=false;
1035 0 : sOutput.append("\t" + rTextType);
1036 :
1037 0 : if ( !sCur.equalsIgnoreAsciiCase("en-US") ) {
1038 0 : sOutput.append("[ " + sCur + " ] ");
1039 : }
1040 :
1041 0 : ConvertMergeContent( sText );
1042 0 : sOutput.append("= " + sText);
1043 :
1044 0 : if ( bDefine )
1045 0 : sOutput.append(";\\\n");
1046 0 : else if ( !bNextMustBeDefineEOL )
1047 0 : sOutput.append(";\n");
1048 : else
1049 0 : bAddSemicolon = true;
1050 0 : for ( sal_uInt16 j = 1; j < nLevel; j++ )
1051 0 : sOutput.append("\t");
1052 0 : WriteToMerged( sOutput.makeStringAndClear() , true );
1053 : }
1054 0 : }
1055 :
1056 :
1057 0 : if ( bAddSemicolon ) {
1058 0 : WriteToMerged( ";" , false );
1059 0 : }
1060 0 : }
1061 :
1062 871 : void Export::MergeRest( ResData *pResData )
1063 : {
1064 871 : if ( !pMergeDataFile ){
1065 11 : pMergeDataFile = new MergeDataFile( sMergeSrc, global::inputPathname, false );
1066 11 : aLanguages = pMergeDataFile->GetLanguages();
1067 :
1068 : }
1069 :
1070 871 : MergeEntrys *pEntry = 0;
1071 871 : if( pResData->bText || pResData->bQuickHelpText || pResData->bTitle )
1072 283 : pEntry = pMergeDataFile->GetMergeEntrys( pResData );
1073 :
1074 871 : if ( pEntry )
1075 : {
1076 0 : if ( pResData->bText )
1077 0 : ResData2Output( pEntry, STRING_TYP_TEXT, pResData->sTextTyp );
1078 :
1079 0 : if ( pResData->bQuickHelpText )
1080 0 : ResData2Output( pEntry, STRING_TYP_QUICKHELPTEXT, OString("QuickHelpText") );
1081 :
1082 0 : if ( pResData->bTitle )
1083 0 : ResData2Output( pEntry, STRING_TYP_TITLE, OString("Title") );
1084 : }
1085 :
1086 : // Merge Lists
1087 871 : if ( nList )
1088 : {
1089 0 : OString sOldId = pResData->sId;
1090 0 : OString sOldGId = pResData->sGId;
1091 0 : OString sOldTyp = pResData->sResTyp;
1092 :
1093 : // Set pResData so we can find the corresponding string
1094 0 : if (!pResData->sGId.isEmpty())
1095 0 : pResData->sGId = pResData->sGId + OString('.');
1096 0 : pResData->sGId = pResData->sGId + pResData->sId;
1097 :
1098 0 : pResData->sResTyp = lcl_GetListTyp( nList, false );
1099 :
1100 0 : OString sSpace;
1101 0 : for ( sal_uInt16 i = 1; i < nLevel-1; i++ )
1102 0 : sSpace += "\t";
1103 :
1104 0 : OString sCur;
1105 0 : for( unsigned int n = 0; n < aLanguages.size(); n++ )
1106 : {
1107 0 : sCur = aLanguages[ n ];
1108 :
1109 0 : sal_uInt16 nLIndex = 0;
1110 0 : sal_uInt16 nMaxIndex = pResData->m_aList.size();
1111 0 : while( nLIndex < nMaxIndex )
1112 : {
1113 0 : if ( nLIndex == 0 )
1114 : {
1115 0 : OStringBuffer sHead;
1116 0 : if ( bNextMustBeDefineEOL )
1117 0 : sHead.append("\\\n\t");
1118 0 : sHead.append(sSpace + lcl_GetListTyp( nList, true ) + " [ " + sCur + " ] ");
1119 :
1120 0 : if ( bDefine || bNextMustBeDefineEOL )
1121 : {
1122 0 : sHead.append("= \\\n" + sSpace + "\t{\\\n\t");
1123 : }
1124 : else
1125 : {
1126 0 : sHead.append("= \n" + sSpace + "\t{\n\t");
1127 : }
1128 0 : WriteToMerged(sHead.makeStringAndClear() , true);
1129 : }
1130 :
1131 0 : OString sLine = pResData->m_aList[ nLIndex ];
1132 0 : if ( sLine.indexOf( '>' ) != -1 )
1133 : {
1134 0 : if ((( sLine.indexOf( '{' ) == -1 ) ||
1135 0 : ( sLine.indexOf( '{' ) >= sLine.indexOf( '"' ))) &&
1136 0 : (( sLine.indexOf( '<' ) == -1 ) ||
1137 0 : ( sLine.indexOf( '<' ) >= sLine.indexOf( '"' ))))
1138 : {
1139 0 : sLine = sLine.replaceFirst("\"", "< \"" );
1140 : }
1141 : }
1142 :
1143 : // Set matching identifier
1144 0 : if ( nList == LIST_PAIRED )
1145 : {
1146 0 : pResData->sId = GetPairedListID ( sLine );
1147 : }
1148 : else
1149 : {
1150 0 : pResData->sId =
1151 : sLine.copy(
1152 0 : sLine.indexOf('"')+1,
1153 0 : sLine.lastIndexOf('"')-sLine.indexOf('"')-1);
1154 0 : ConvertExportContent( pResData->sId );
1155 : }
1156 :
1157 0 : MergeEntrys* pEntrys = pMergeDataFile->GetMergeEntrys( pResData );
1158 0 : OString sText;
1159 0 : bool bText = pEntrys ? pEntrys->GetText( sText, STRING_TYP_TEXT, sCur, true ) : false;
1160 :
1161 0 : if( bText && !sText.isEmpty())
1162 : {
1163 0 : ConvertMergeContent( sText );
1164 0 : sLine =
1165 0 : sLine.copy( 0 , sLine.indexOf('"') ) +
1166 0 : sText +
1167 0 : sLine.copy( sLine.lastIndexOf('"') + 1 );
1168 : }
1169 :
1170 0 : OString sText1( "\t" );
1171 0 : sText1 += sLine;
1172 0 : if ( bDefine || bNextMustBeDefineEOL )
1173 0 : sText1 += " ;\\\n";
1174 : else
1175 0 : sText1 += " ;\n";
1176 0 : sText1 += sSpace;
1177 0 : sText1 += "\t";
1178 0 : WriteToMerged( sText1 ,true );
1179 0 : ++nLIndex;
1180 0 : }
1181 :
1182 0 : if ( nLIndex > 0 )
1183 : {
1184 0 : OString sFooter;
1185 0 : if (!sSpace.isEmpty())
1186 0 : sFooter = sSpace.copy(1);
1187 :
1188 0 : if ( bNextMustBeDefineEOL )
1189 0 : sFooter += "};";
1190 0 : else if ( !bDefine )
1191 0 : sFooter += "};\n\t";
1192 : else
1193 0 : sFooter += "\n\n";
1194 0 : WriteToMerged( sFooter ,true );
1195 : }
1196 : }
1197 0 : pResData->sId = sOldId;
1198 0 : pResData->sGId = sOldGId;
1199 0 : pResData->sResTyp = sOldTyp;
1200 : }
1201 871 : pParseQueue->bMflag = false;
1202 871 : }
1203 :
1204 284 : void Export::SetChildWithText()
1205 : {
1206 284 : if ( aResStack.size() > 1 ) {
1207 595 : for ( size_t i = 0; i < aResStack.size() - 1; i++ ) {
1208 387 : aResStack[ i ]->bChildWithText = true;
1209 : }
1210 : }
1211 284 : }
1212 :
1213 28839 : void ParserQueue::Push( const QueueEntry& aEntry )
1214 : {
1215 28839 : sal_Int32 nLen = aEntry.sLine.getLength();
1216 :
1217 28839 : if( !bStart ){
1218 21883 : aQueueCur->push( aEntry );
1219 21883 : if( nLen > 1 && aEntry.sLine[nLen-1] == '\n' )
1220 9 : bStart = true;
1221 21874 : else if ( aEntry.nTyp != IGNOREDTOKENS ){
1222 18742 : if( nLen > 1 && ( aEntry.sLine[nLen-1] == '\\') ){
1223 : // Next is Macro
1224 338 : bCurrentIsM = true;
1225 : }else{
1226 : // Next is no Macro
1227 18404 : bCurrentIsM = false;
1228 : }
1229 : }
1230 : }
1231 : else{
1232 6956 : aQueueNext->push( aEntry );
1233 6956 : if( nLen > 1 && aEntry.sLine[nLen-1] != '\n' ){
1234 2575 : if( nLen > 1 && ( aEntry.sLine[nLen-1] == '\\') ){
1235 : // Next is Macro
1236 1128 : bNextIsM = true;
1237 : }
1238 : else{
1239 : // Next is no Macro
1240 1447 : bNextIsM = false;
1241 : }
1242 4381 : }else if( nLen > 2 && aEntry.sLine[nLen-1] == '\n' ){
1243 379 : if( aEntry.nTyp != IGNOREDTOKENS ){
1244 379 : if( nLen > 2 && ( aEntry.sLine[nLen-2] == '\\') ){
1245 : // Next is Macro
1246 360 : bNextIsM = true;
1247 : }
1248 : else{
1249 : // Next is no Macro
1250 19 : bNextIsM = false;
1251 : }
1252 : }
1253 : // Pop current
1254 379 : Pop( *aQueueCur );
1255 379 : bLastWasM = bCurrentIsM;
1256 : // next -> current
1257 379 : bCurrentIsM = bNextIsM;
1258 379 : std::queue<QueueEntry>* aQref = aQueueCur;
1259 379 : aQueueCur = aQueueNext;
1260 379 : aQueueNext = aQref;
1261 :
1262 : }
1263 :
1264 : else{
1265 : // Pop current
1266 4002 : Pop( *aQueueCur );
1267 4002 : bLastWasM = bCurrentIsM;
1268 : // next -> current
1269 4002 : bCurrentIsM = bNextIsM;
1270 4002 : std::queue<QueueEntry>* aQref = aQueueCur;
1271 4002 : aQueueCur = aQueueNext;
1272 4002 : aQueueNext = aQref;
1273 : }
1274 : }
1275 28839 : }
1276 :
1277 11 : void ParserQueue::Close(){
1278 : // Pop current
1279 11 : Pop( *aQueueCur );
1280 : // next -> current
1281 11 : bLastWasM = bCurrentIsM;
1282 11 : bCurrentIsM = bNextIsM;
1283 11 : std::queue<QueueEntry>* aQref = aQueueCur;
1284 11 : aQueueCur = aQueueNext;
1285 11 : aQueueNext = aQref;
1286 11 : bNextIsM = false;
1287 11 : Pop( *aQueueNext );
1288 11 : };
1289 :
1290 4403 : void ParserQueue::Pop( std::queue<QueueEntry>& aQueue )
1291 : {
1292 37645 : while (!aQueue.empty())
1293 : {
1294 28839 : QueueEntry aEntry = aQueue.front();
1295 28839 : aQueue.pop();
1296 28839 : aExport.Execute(aEntry.nTyp, aEntry.sLine.getStr());
1297 28839 : }
1298 4403 : }
1299 :
1300 11 : ParserQueue::ParserQueue( Export& aExportObj )
1301 : :
1302 : bCurrentIsM( false ),
1303 : bNextIsM( false ) ,
1304 : bLastWasM( false ),
1305 : bMflag( false ) ,
1306 : aExport( aExportObj ) ,
1307 11 : bStart( false )
1308 : {
1309 11 : aQueueNext = new std::queue<QueueEntry>;
1310 11 : aQueueCur = new std::queue<QueueEntry>;
1311 11 : }
1312 :
1313 :
1314 11 : ParserQueue::~ParserQueue(){
1315 11 : if( aQueueNext ) delete aQueueNext;
1316 11 : if( aQueueCur ) delete aQueueCur;
1317 44 : }
1318 :
1319 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|