diff options
-rw-r--r-- | l10ntools/inc/lngmerge.hxx | 3 | ||||
-rw-r--r-- | l10ntools/source/lngmerge.cxx | 74 |
2 files changed, 40 insertions, 37 deletions
diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx index b5df781cc5e2..7dbe884bb868 100644 --- a/l10ntools/inc/lngmerge.hxx +++ b/l10ntools/inc/lngmerge.hxx @@ -27,8 +27,9 @@ ************************************************************************/ // local includes #include "export.hxx" +#include <vector> -DECLARE_LIST( LngLineList, ByteString * ) +typedef ::std::vector< ByteString* > LngLineList; #define LNG_OK 0x0000 #define LNG_FILE_NOTFOUND 0x0001 diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index 570c295c9cf8..5f6273a24ac6 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -48,7 +48,7 @@ LngParser::LngParser( const ByteString &rLngFile, BOOL bUTF8, BOOL bULFFormat ) bDBIsUTF8( bUTF8 ), bULF( bULFFormat ) { - pLines = new LngLineList( 100, 100 ); + pLines = new LngLineList(); DirEntry aEntry( String( sSource, RTL_TEXTENCODING_ASCII_US )); if ( aEntry.Exists()) { SvFileStream aStream( String( sSource, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ ); @@ -63,7 +63,7 @@ LngParser::LngParser( const ByteString &rLngFile, BOOL bUTF8, BOOL bULFFormat ) bFirstLine = false; } - pLines->Insert( new ByteString( sLine ), LIST_APPEND ); + pLines->push_back( new ByteString( sLine ) ); } } else @@ -77,8 +77,9 @@ LngParser::LngParser( const ByteString &rLngFile, BOOL bUTF8, BOOL bULFFormat ) LngParser::~LngParser() /*****************************************************************************/ { - for ( ULONG i = 0; i < pLines->Count(); i++ ) - delete pLines->GetObject( i ); + for ( size_t i = 0, n = pLines->size(); i < n; i++ ) + delete (*pLines)[ i ]; + pLines->clear(); delete pLines; } @@ -125,26 +126,25 @@ BOOL LngParser::CreateSDF( sFullEntry.Copy( sPrjEntry.Len() + 1 ), gsl_getSystemTextEncoding()); sActFileName.SearchAndReplaceAll( "/", "\\" ); - ULONG nPos = 0; + size_t nPos = 0; BOOL bStart = true; ByteString sGroup; - ByteStringHashMap Text; + ByteStringHashMap Text; ByteString sID; ByteString sLine; - while( nPos < pLines->Count() ){ - sLine = *pLines->GetObject( nPos++ ); - while( nPos < pLines->Count() && !isNextGroup( sGroup , sLine ) ){ + while( nPos < pLines->size() ) { + sLine = *(*pLines)[ nPos++ ]; + while( nPos < pLines->size() && !isNextGroup( sGroup , sLine ) ) { ReadLine( sLine , Text ); sID = sGroup; - sLine = *pLines->GetObject( nPos++ ); + sLine = *(*pLines)[ nPos++ ]; }; - if( bStart ){ + if( bStart ) { bStart = false; sID = sGroup; } else { - WriteSDF( aSDFStream , Text , rPrj , rRoot , sActFileName , sID ); } } @@ -177,7 +177,6 @@ BOOL LngParser::CreateSDF( sOutput += sCur; sOutput += "\t"; sOutput += sAct; sOutput += "\t\t\t\t"; sOutput += sTimeStamp; - //if( !sCur.EqualsIgnoreCaseAscii("de") ||( sCur.EqualsIgnoreCaseAscii("de") && !Export::isMergingGermanAllowed( rPrj ) ) ) aSDFStream.WriteLine( sOutput ); } } @@ -195,7 +194,6 @@ BOOL LngParser::CreateSDF( return false; } void LngParser::ReadLine( const ByteString &sLine_in , ByteStringHashMap &rText_inout){ - //printf("sLine -> '%s'\n",sLine_in.GetBuffer()); ByteString sLang = sLine_in.GetToken( 0, '=' ); sLang.EraseLeadingChars( ' ' ); sLang.EraseTrailingChars( ' ' ); @@ -218,7 +216,6 @@ BOOL LngParser::Merge( nError = LNG_COULD_NOT_OPEN; } nError = LNG_OK; -// MergeDataFile( const ByteString &rFileName, const ByteString& rFile , BOOL bErrLog, CharSet aCharSet, BOOL bUTF8 ); MergeDataFile aMergeDataFile( rSDFFile, sSource , FALSE, RTL_TEXTENCODING_MS_1252);//, bDBIsUTF8 ); ByteString sTmp( Export::sLanguages ); @@ -226,13 +223,13 @@ BOOL LngParser::Merge( Export::SetLanguages( aMergeDataFile.GetLanguages() ); aLanguages = Export::GetLanguages(); - ULONG nPos = 0; + size_t nPos = 0; BOOL bGroup = FALSE; ByteString sGroup; // seek to next group - while ( nPos < pLines->Count() && !bGroup ) { - ByteString sLine( *pLines->GetObject( nPos )); + while ( nPos < pLines->size() && !bGroup ) { + ByteString sLine( *(*pLines)[ nPos ] ); sLine.EraseLeadingChars( ' ' ); sLine.EraseTrailingChars( ' ' ); if (( sLine.GetChar( 0 ) == '[' ) && @@ -246,7 +243,7 @@ BOOL LngParser::Merge( nPos ++; } - while ( nPos < pLines->Count()) { + while ( nPos < pLines->size()) { ByteStringHashMap Text; ByteString sID( sGroup ); ULONG nLastLangPos = 0; @@ -259,8 +256,8 @@ BOOL LngParser::Merge( ByteString sLanguagesDone; - while ( nPos < pLines->Count() && !bGroup ) { - ByteString sLine( *pLines->GetObject( nPos )); + while ( nPos < pLines->size() && !bGroup ) { + ByteString sLine( *(*pLines)[ nPos ] ); sLine.EraseLeadingChars( ' ' ); sLine.EraseTrailingChars( ' ' ); if (( sLine.GetChar( 0 ) == '[' ) && @@ -283,7 +280,9 @@ BOOL LngParser::Merge( sSearch += ";"; if (( sLanguagesDone.Search( sSearch ) != STRING_NOTFOUND )) { - pLines->Remove( nPos ); + LngLineList::iterator it = pLines->begin(); + ::std::advance( it, nPos ); + pLines->erase( it ); } if( bULF && pEntrys ) { @@ -294,14 +293,13 @@ BOOL LngParser::Merge( pEntrys->GetText( sNewText, STRING_TYP_TEXT, sLang, TRUE ); if ( sNewText.Len()) { - ByteString *pLine = pLines->GetObject( nPos ); - - ByteString sText1( sLang ); - sText1 += " = \""; - sText1 += sNewText; - sText1 += "\""; - *pLine = sText1; - //} + ByteString *pLine = (*pLines)[ nPos ]; + + ByteString sText1( sLang ); + sText1 += " = \""; + sText1 += sNewText; + sText1 += "\""; + *pLine = sText1; Text[ sLang ] = sNewText; } } @@ -322,9 +320,7 @@ BOOL LngParser::Merge( if ( nLastLangPos ) { for( unsigned int n = 0; n < aLanguages.size(); n++ ){ sCur = aLanguages[ n ]; - if( //( !sCur.EqualsIgnoreCaseAscii("de") || - //( sCur.EqualsIgnoreCaseAscii("de") && Export::isMergingGermanAllowed( rPrj ) ) ) - !sCur.EqualsIgnoreCaseAscii("en-US") && !Text[ sCur ].Len() && pEntrys ){ + if( !sCur.EqualsIgnoreCaseAscii("en-US") && !Text[ sCur ].Len() && pEntrys ) { ByteString sNewText; pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur, TRUE ); @@ -340,7 +336,13 @@ BOOL LngParser::Merge( nLastLangPos++; nPos++; - pLines->Insert( new ByteString( sLine ), nLastLangPos ); + if ( nLastLangPos < pLines->size() ) { + LngLineList::iterator it = pLines->begin(); + ::std::advance( it, nLastLangPos ); + pLines->insert( it, new ByteString( sLine ) ); + } else { + pLines->push_back( new ByteString( sLine ) ); + } } } } @@ -349,8 +351,8 @@ BOOL LngParser::Merge( delete pResData; } - for ( ULONG i = 0; i < pLines->Count(); i++ ) - aDestination.WriteLine( *pLines->GetObject( i )); + for ( size_t i = 0; i < pLines->size(); i++ ) + aDestination.WriteLine( *(*pLines)[ i ] ); aDestination.Close(); return TRUE; |