summaryrefslogtreecommitdiff
path: root/l10ntools/source/lngmerge.cxx
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-06-19 12:47:44 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-06-19 12:47:44 +0200
commit941020379b1ea1ec7c564c21e68ea1674cda7683 (patch)
tree40fcaf109d6d585bcdc0faf7ea6c0812b3cc9a39 /l10ntools/source/lngmerge.cxx
parent0692507dcc62e94c7af88388961db1d7d12d6dbd (diff)
parent0d2916e03ea51529e15995830a1a8c36bd72e442 (diff)
Merge branch 'master' into feature/gnumake4
Conflicts: basebmp/prj/d.lst basebmp/test/basictest.cxx basebmp/test/makefile.mk basegfx/inc/basegfx/basegfxdllapi.h basegfx/inc/basegfx/tools/debugplotter.hxx basegfx/inc/basegfx/tuple/b2ituple.hxx basegfx/prj/d.lst basegfx/source/numeric/makefile.mk basegfx/source/polygon/makefile.mk basegfx/source/range/makefile.mk basegfx/source/raster/makefile.mk basegfx/source/tuple/makefile.mk basegfx/source/vector/makefile.mk basegfx/test/basegfx1d.cxx basegfx/test/makefile.mk basegfx/util/makefile.mk canvas/Library_canvasfactory.mk canvas/Module_canvas.mk canvas/prj/build.lst canvas/prj/d.lst canvas/source/cairo/cairo_canvashelper_texturefill.cxx canvas/source/cairo/makefile.mk canvas/source/tools/makefile.mk comphelper/qa/string/makefile.mk cppcanvas/Module_cppcanvas.mk cppcanvas/inc/cppcanvas/cppcanvasdllapi.h cppcanvas/prj/build.lst cppcanvas/prj/d.lst cppcanvas/source/mtfrenderer/makefile.mk cppcanvas/util/makefile.mk i18npool/source/search/makefile.mk regexp/Library_regexp.mk regexp/prj/d.lst sax/CppunitTest_sax.mk sax/Library_sax.mk sax/prj/d.lst sax/qa/cppunit/test_converter.cxx sax/source/expatwrap/attrlistimpl.hxx sax/util/makefile.mk svtools/Library_svt.mk tools/Executable_sspretty.mk ucbhelper/prj/d.lst ucbhelper/source/provider/configureucb.cxx ucbhelper/source/provider/provconf.cxx ucbhelper/util/makefile.mk unotools/Library_utl.mk unotools/Module_unotools.mk unotools/Package_inc.mk unotools/prj/build.lst vcl/Library_desktop_detector.mk vcl/Library_vcl.mk vcl/Library_vclplug_gtk.mk vcl/aqua/source/gdi/salprn.cxx vcl/inc/aqua/saldata.hxx vcl/unx/generic/gdi/salgdi3.cxx
Diffstat (limited to 'l10ntools/source/lngmerge.cxx')
-rw-r--r--l10ntools/source/lngmerge.cxx78
1 files changed, 41 insertions, 37 deletions
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index f63469cff75b..e89640015773 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -31,7 +32,6 @@
// local includes
#include "lngmerge.hxx"
-#include "utf8conv.hxx"
#include <iostream>
using namespace std;
//
@@ -47,7 +47,7 @@ LngParser::LngParser( const ByteString &rLngFile, sal_Bool bUTF8, sal_Bool bULFF
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 );
@@ -62,7 +62,7 @@ LngParser::LngParser( const ByteString &rLngFile, sal_Bool bUTF8, sal_Bool bULFF
bFirstLine = false;
}
- pLines->Insert( new ByteString( sLine ), LIST_APPEND );
+ pLines->push_back( new ByteString( sLine ) );
}
}
else
@@ -76,8 +76,9 @@ LngParser::LngParser( const ByteString &rLngFile, sal_Bool bUTF8, sal_Bool bULFF
LngParser::~LngParser()
/*****************************************************************************/
{
- for ( sal_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;
}
@@ -124,26 +125,25 @@ sal_Bool LngParser::CreateSDF(
sFullEntry.Copy( sPrjEntry.Len() + 1 ), gsl_getSystemTextEncoding());
sActFileName.SearchAndReplaceAll( "/", "\\" );
- sal_uLong nPos = 0;
+ size_t nPos = 0;
sal_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 );
}
}
@@ -176,7 +176,6 @@ sal_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 );
}
}
@@ -194,7 +193,6 @@ sal_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( ' ' );
@@ -217,7 +215,6 @@ sal_Bool LngParser::Merge(
nError = LNG_COULD_NOT_OPEN;
}
nError = LNG_OK;
-// MergeDataFile( const ByteString &rFileName, const ByteString& rFile , sal_Bool bErrLog, CharSet aCharSet, sal_Bool bUTF8 );
MergeDataFile aMergeDataFile( rSDFFile, sSource , sal_False, RTL_TEXTENCODING_MS_1252);//, bDBIsUTF8 );
ByteString sTmp( Export::sLanguages );
@@ -225,13 +222,13 @@ sal_Bool LngParser::Merge(
Export::SetLanguages( aMergeDataFile.GetLanguages() );
aLanguages = Export::GetLanguages();
- sal_uLong nPos = 0;
+ size_t nPos = 0;
sal_Bool bGroup = sal_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 ) == '[' ) &&
@@ -245,7 +242,7 @@ sal_Bool LngParser::Merge(
nPos ++;
}
- while ( nPos < pLines->Count()) {
+ while ( nPos < pLines->size()) {
ByteStringHashMap Text;
ByteString sID( sGroup );
sal_uLong nLastLangPos = 0;
@@ -258,8 +255,8 @@ sal_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 ) == '[' ) &&
@@ -282,7 +279,9 @@ sal_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 )
{
@@ -293,14 +292,13 @@ sal_Bool LngParser::Merge(
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sLang, sal_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;
}
}
@@ -321,9 +319,7 @@ sal_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, sal_True );
@@ -339,7 +335,13 @@ sal_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 ) );
+ }
}
}
}
@@ -348,9 +350,11 @@ sal_Bool LngParser::Merge(
delete pResData;
}
- for ( sal_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 sal_True;
}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */