diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-07-01 22:27:20 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-07-01 22:27:20 +0100 |
commit | ce5702fca8e7bc6c6f82a0de24abeafc6b316fef (patch) | |
tree | 9ab451233897e458026b937d9166686958eaf513 /l10ntools | |
parent | 5e692599df6d47b614b488796747f5faadea63f7 (diff) |
ByteString::CreateFromInt32 -> OString::valueOf
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/inc/cfgmerge.hxx | 3 | ||||
-rw-r--r-- | l10ntools/inc/export.hxx | 13 | ||||
-rw-r--r-- | l10ntools/source/cfglex.l | 6 | ||||
-rw-r--r-- | l10ntools/source/cfgmerge.cxx | 44 | ||||
-rw-r--r-- | l10ntools/source/export.cxx | 351 | ||||
-rw-r--r-- | l10ntools/source/export2.cxx | 29 | ||||
-rw-r--r-- | l10ntools/source/gsicheck.cxx | 27 | ||||
-rw-r--r-- | l10ntools/source/lngmerge.cxx | 9 | ||||
-rw-r--r-- | l10ntools/source/tagtest.cxx | 14 | ||||
-rw-r--r-- | l10ntools/source/xrmlex.l | 6 | ||||
-rw-r--r-- | l10ntools/source/xrmmerge.cxx | 16 |
11 files changed, 290 insertions, 228 deletions
diff --git a/l10ntools/inc/cfgmerge.hxx b/l10ntools/inc/cfgmerge.hxx index 9308d0c727a8..c8f3d99a7b14 100644 --- a/l10ntools/inc/cfgmerge.hxx +++ b/l10ntools/inc/cfgmerge.hxx @@ -33,8 +33,7 @@ #include <boost/unordered_map.hpp> #include <vector> -typedef boost::unordered_map<ByteString , ByteString , hashByteString,equalByteString> - ByteStringHashMap; +typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> ByteStringHashMap; // diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index aedf7fdfd956..addfd7a88f7f 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -84,8 +84,7 @@ class PFormEntrys; class MergeData; typedef std::set<ByteString , lessByteString > ByteStringSet; -typedef boost::unordered_map<ByteString , ByteString , hashByteString,equalByteString> - ByteStringHashMap; +typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> ByteStringHashMap; typedef boost::unordered_map<ByteString , bool , hashByteString,equalByteString> ByteStringBoolHashMap; @@ -197,8 +196,8 @@ public: void addFallbackData( ByteString& sId , const ByteString& sText ); bool getFallbackData( ByteString& sId , ByteString& sText); - void addMergedLanguage( ByteString& sLang ); - bool isMerged( ByteString& sLang ); + void addMergedLanguage(rtl::OString& rLang); + bool isMerged(rtl::OString& rLang); ResData( const ByteString &rPF, const ByteString &rGId ) : nWidth( 0 ), @@ -307,7 +306,7 @@ private: sal_Bool bNextMustBeDefineEOL; // define but no \ at lineend sal_uLong nLevel; // res. recursiv? how deep? sal_uInt16 nList; // cur. res. is String- or FilterList - ByteString nListLang; + rtl::OString m_sListLang; sal_uLong nListIndex; sal_uLong nListLevel; bool bSkipFile; @@ -389,8 +388,8 @@ private: void CleanValue( ByteString &rValue ); ByteString GetText( const ByteString &rSource, int nToken ); - sal_Bool PrepareTextToMerge( ByteString &rText, sal_uInt16 nTyp, - ByteString &nLangIndex, ResData *pResData ); + sal_Bool PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp, + rtl::OString &rLangIndex, ResData *pResData); void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL ); void ConvertMergeContent( ByteString &rText ); diff --git a/l10ntools/source/cfglex.l b/l10ntools/source/cfglex.l index a6f6b366a8d5..feb2882632d8 100644 --- a/l10ntools/source/cfglex.l +++ b/l10ntools/source/cfglex.l @@ -137,7 +137,7 @@ int yywrap(void) } /*****************************************************************************/ -void YYWarning( char *s ) +void YYWarning( const char *s ) /*****************************************************************************/ { /* write warning to stderr */ @@ -147,9 +147,9 @@ void YYWarning( char *s ) /*****************************************************************************/ #ifdef GCC -void yyerror ( char *s, ... ) +void yyerror ( const char *s, ... ) #else -void yyerror ( char *s ) +void yyerror ( const char *s ) #endif /*****************************************************************************/ { diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx index f2a713ce5a75..55aed2c4210c 100644 --- a/l10ntools/source/cfgmerge.cxx +++ b/l10ntools/source/cfgmerge.cxx @@ -644,13 +644,13 @@ void CfgExport::WorkOnRessourceEnd() /*****************************************************************************/ { if ( pOutputStream && bLocalize ) { - if (( pStackData->sText[ ByteString("en-US") ].Len() + if (( pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))].getLength() ) || ( bForce && - ( pStackData->sText[ ByteString("de") ].Len() || - pStackData->sText[ ByteString("en-US") ].Len() ))) + ( pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("de"))].getLength() || + pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))].getLength() ))) { - ByteString sFallback = pStackData->sText[ ByteString("en-US") ]; + ByteString sFallback = pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))]; ByteString sLocalId = pStackData->sIdentifier; ByteString sGroupId; if ( aStack.size() == 1 ) { @@ -663,29 +663,29 @@ void CfgExport::WorkOnRessourceEnd() ByteString sTimeStamp( Export::GetTimeStamp()); - ByteString sCur; - for( unsigned int n = 0; n < aLanguages.size(); n++ ){ - sCur = aLanguages[ n ]; + for (size_t n = 0; n < aLanguages.size(); n++) + { + ByteString sCur = aLanguages[ n ]; - ByteString sText = pStackData->sText[ sCur ]; - if ( !sText.Len()) - sText = sFallback; + ByteString sText = pStackData->sText[ sCur ]; + if ( !sText.Len()) + sText = sFallback; - Export::UnquotHTML( sText ); + Export::UnquotHTML( sText ); - ByteString sOutput( sPrj ); sOutput += "\t"; - sOutput += sPath; - sOutput += "\t0\t"; - sOutput += pStackData->sResTyp; sOutput += "\t"; - sOutput += sGroupId; sOutput += "\t"; - sOutput += sLocalId; sOutput += "\t\t\t0\t"; - sOutput += sCur; - sOutput += "\t"; + ByteString sOutput( sPrj ); sOutput += "\t"; + sOutput += sPath; + sOutput += "\t0\t"; + sOutput += pStackData->sResTyp; sOutput += "\t"; + sOutput += sGroupId; sOutput += "\t"; + sOutput += sLocalId; sOutput += "\t\t\t0\t"; + sOutput += sCur; + sOutput += "\t"; - sOutput += sText; sOutput += "\t\t\t\t"; - sOutput += sTimeStamp; + sOutput += sText; sOutput += "\t\t\t\t"; + sOutput += sTimeStamp; - pOutputStream->WriteLine( sOutput ); + pOutputStream->WriteLine( sOutput ); } } } diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 2ef0f1467b9f..94f1650ef4b0 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -35,9 +35,10 @@ #include "tokens.h" #include <iostream> #include <vector> +#include <rtl/strbuf.hxx> -extern "C" { int yyerror( char * ); } -extern "C" { int YYWarning( char * ); } +extern "C" { int yyerror( const char * ); } +extern "C" { int YYWarning( const char * ); } Export *pExport = 0L; @@ -363,11 +364,14 @@ bool ResData::getFallbackData( ByteString& sId_in , ByteString& sText_inout ){ return sText_inout.Len() > 0; } -void ResData::addMergedLanguage( ByteString& sLang ){ - aMergedLanguages[ sLang ]=ByteString("1"); +void ResData::addMergedLanguage(rtl::OString& rLang) +{ + aMergedLanguages[rLang] = rtl::OString(RTL_CONSTASCII_STRINGPARAM("1")); } -bool ResData::isMerged( ByteString& sLang ){ - return aMergedLanguages[ sLang ].Equals("1"); + +bool ResData::isMerged(rtl::OString& rLang) +{ + return aMergedLanguages[rLang].equalsL(RTL_CONSTASCII_STRINGPARAM("1")); } /*****************************************************************************/ @@ -379,10 +383,10 @@ sal_Bool ResData::SetId( const ByteString &rId, sal_uInt16 nLevel ) nIdLevel = nLevel; sId = rId; - if ( bChild && bChildWithText ) { - ByteString sError( "ResId after child definition" ); - yyerror( sError.GetBufferAccess()); - sError.ReleaseBufferAccess(); + if ( bChild && bChildWithText ) + { + rtl::OString sError(RTL_CONSTASCII_STRINGPARAM("ResId after child definition")); + yyerror(sError.getStr()); SetError(); } @@ -500,7 +504,7 @@ void Export::Init() bNextMustBeDefineEOL = sal_False; nLevel = 0; nList = LIST_NON; - nListLang = ByteString( String::CreateFromAscii(""),RTL_TEXTENCODING_ASCII_US ); + m_sListLang = ByteString( String::CreateFromAscii(""),RTL_TEXTENCODING_ASCII_US ); nListIndex = 0; for ( size_t i = 0, n = aResStack.size(); i < n; ++i ) delete aResStack[ i ]; @@ -789,21 +793,21 @@ int Export::Execute( int nToken, const char * pToken ) else if ( sKey == "STRINGLIST" ) { pResData->bList = sal_True; nList = LIST_STRING; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } else if ( sKey == "FILTERLIST" ) { pResData->bList = sal_True; nList = LIST_FILTER; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } else if ( sKey == "UIENTRIES" ) { pResData->bList = sal_True; nList = LIST_UIENTRIES; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } @@ -830,14 +834,14 @@ int Export::Execute( int nToken, const char * pToken ) if ( sKey.ToUpperAscii() == "STRINGLIST" ) { pResData->bList = sal_True; nList = LIST_STRING; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } else if ( sKey == "FILTERLIST" ) { pResData->bList = sal_True; nList = LIST_FILTER; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } @@ -845,7 +849,7 @@ int Export::Execute( int nToken, const char * pToken ) else if ( sKey == "PAIREDLIST" ) { pResData->bList = sal_True; nList = LIST_PAIRED; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } @@ -853,14 +857,14 @@ int Export::Execute( int nToken, const char * pToken ) else if ( sKey == "ITEMLIST" ) { pResData->bList = sal_True; nList = LIST_ITEM; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } else if ( sKey == "UIENTRIES" ) { pResData->bList = sal_True; nList = LIST_UIENTRIES; - nListLang = SOURCE_LANGUAGE; + m_sListLang = SOURCE_LANGUAGE; nListIndex = 0; nListLevel = 0; } @@ -883,7 +887,7 @@ int Export::Execute( int nToken, const char * pToken ) if ( nList ) { ByteString sLang=sToken.GetToken( 1, '[' ).GetToken( 0, ']' ); CleanValue( sLang ); - nListLang = sLang; + m_sListLang = sLang; nListIndex = 0; nListLevel = 0; } @@ -902,8 +906,9 @@ int Export::Execute( int nToken, const char * pToken ) if ( sEntry == "\\\"" ) sEntry = "\""; InsertListEntry( sEntry, sOrig ); - if ( bMergeMode && ( sEntry != "\"" )) { - PrepareTextToMerge( sOrig, nList, nListLang, pResData ); + if ( bMergeMode && ( sEntry != "\"" )) + { + PrepareTextToMerge( sOrig, nList, m_sListLang, pResData ); } } } @@ -926,7 +931,7 @@ int Export::Execute( int nToken, const char * pToken ) sLang = sToken.GetToken( 0, '=' ).GetToken( 1, '[' ).GetToken( 0, ']' ); CleanValue( sLang ); } - ByteString nLangIndex = sLang; + rtl::OString sLangIndex = sLang; ByteString sOrigKey = sKey; if ( sText.Len() && sLang.Len() ) { if (( sKey.ToUpperAscii() == "TEXT" ) || @@ -936,69 +941,82 @@ int Export::Execute( int nToken, const char * pToken ) ( sKey == "UINAME" )) { SetChildWithText(); - if ( Export::isSourceLanguage( nLangIndex ) ) + if ( Export::isSourceLanguage( sLangIndex ) ) pResData->SetId( sText, ID_LEVEL_TEXT ); pResData->bText = sal_True; pResData->sTextTyp = sOrigKey; if ( bMergeMode ) { - PrepareTextToMerge( sOrig, STRING_TYP_TEXT, nLangIndex, pResData ); + PrepareTextToMerge( sOrig, STRING_TYP_TEXT, sLangIndex, pResData ); } - else { - if ( pResData->sText[ nLangIndex ].Len()) { - ByteString sError( "Language " ); - sError += nLangIndex; - sError += " defined twice"; + else + { + if (pResData->sText[ sLangIndex ].getLength()) + { + rtl::OStringBuffer sError(RTL_CONSTASCII_STRINGPARAM("Language ")); + sError.append(sLangIndex); + sError.append(RTL_CONSTASCII_STRINGPARAM("defined twice")); + yyerror(sError.getStr()); } - pResData->sText[ nLangIndex ] = sText; + pResData->sText[ sLangIndex ] = sText; } } else if ( sKey == "HELPTEXT" ) { SetChildWithText(); pResData->bHelpText = sal_True; - if ( bBreakWhenHelpText ) { - ByteString sError( "\"HelpText\" found in source\n" ); - YYWarning( sError.GetBufferAccess()); - sError.ReleaseBufferAccess(); + if ( bBreakWhenHelpText ) + { + rtl::OString sError( + RTL_CONSTASCII_STRINGPARAM("\"HelpText\" found in source\n")); + YYWarning(sError.getStr()); SetError(); } if ( bMergeMode ) - PrepareTextToMerge( sOrig, STRING_TYP_HELPTEXT, nLangIndex, pResData ); - else { - if ( pResData->sHelpText[ nLangIndex ].Len()) { - ByteString sError( "Language " ); - sError += nLangIndex; - sError += " defined twice"; + PrepareTextToMerge( sOrig, STRING_TYP_HELPTEXT, sLangIndex, pResData ); + else + { + if (pResData->sHelpText[ sLangIndex ].getLength()) + { + rtl::OStringBuffer sError(RTL_CONSTASCII_STRINGPARAM("Language ")); + sError.append(sLangIndex); + sError.append(" defined twice"); + YYWarning(sError.getStr()); } - pResData->sHelpText[ nLangIndex ] = sText; + pResData->sHelpText[ sLangIndex ] = sText; } } else if ( sKey == "QUICKHELPTEXT" ) { SetChildWithText(); pResData->bQuickHelpText = sal_True; if ( bMergeMode ) - PrepareTextToMerge( sOrig, STRING_TYP_QUICKHELPTEXT, nLangIndex, pResData ); - else { - if ( pResData->sQuickHelpText[ nLangIndex ].Len()) { - ByteString sError( "Language " ); - sError += nLangIndex; - sError += " defined twice"; + PrepareTextToMerge( sOrig, STRING_TYP_QUICKHELPTEXT, sLangIndex, pResData ); + else + { + if (pResData->sQuickHelpText[ sLangIndex ].getLength()) + { + rtl::OStringBuffer sError(RTL_CONSTASCII_STRINGPARAM("Language ")); + sError.append(sLangIndex); + sError.append(RTL_CONSTASCII_STRINGPARAM(" defined twice")); + YYWarning(sError.getStr()); } - pResData->sQuickHelpText[ nLangIndex ] = sText; + pResData->sQuickHelpText[ sLangIndex ] = sText; } } else if ( sKey == "TITLE" ) { SetChildWithText(); pResData->bTitle = sal_True; if ( bMergeMode ) - PrepareTextToMerge( sOrig, STRING_TYP_TITLE, nLangIndex, pResData ); - else { - if ( pResData->sTitle[ nLangIndex ].Len()) { - ByteString sError( "Language " ); - sError += nLangIndex; - sError += " defined twice"; + PrepareTextToMerge( sOrig, STRING_TYP_TITLE, sLangIndex, pResData ); + else + { + if ( pResData->sTitle[ sLangIndex ].getLength()) + { + rtl::OStringBuffer sError(RTL_CONSTASCII_STRINGPARAM("Language ")); + sError.append(sLangIndex); + sError.append(RTL_CONSTASCII_STRINGPARAM(" defined twice")); + YYWarning(sError.getStr()); } - pResData->sTitle[ nLangIndex ] = sText; + pResData->sTitle[ sLangIndex ] = sText; } } else if ( sKey == "ACCESSPATH" ) { @@ -1169,13 +1187,13 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew ) // mandatory to export: en-US - if (( pResData->sText[ SOURCE_LANGUAGE ].Len()) + if (( pResData->sText[ SOURCE_LANGUAGE ].getLength()) || - ( pResData->sHelpText[ SOURCE_LANGUAGE ].Len()) + ( pResData->sHelpText[ SOURCE_LANGUAGE ].getLength()) || - ( pResData->sQuickHelpText[ SOURCE_LANGUAGE ].Len()) + ( pResData->sQuickHelpText[ SOURCE_LANGUAGE ].getLength()) || - ( pResData->sTitle[ SOURCE_LANGUAGE ].Len())) + ( pResData->sTitle[ SOURCE_LANGUAGE ].getLength())) { FillInFallbacks( pResData ); @@ -1198,35 +1216,35 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew ) for( unsigned int n = 0; n < aLanguages.size(); n++ ){ sCur = aLanguages[ n ]; if ( !sCur.EqualsIgnoreCaseAscii("x-comment") ){ - if ( pResData->sText[ sCur ].Len()) + if (pResData->sText[ sCur ].getLength()) sXText = pResData->sText[ sCur ]; else { sXText = pResData->sText[ SOURCE_LANGUAGE ]; } - if ( pResData->sHelpText[ sCur ].Len()) + if (pResData->sHelpText[ sCur ].getLength()) sXHText = pResData->sHelpText[ sCur ]; else { sXHText = pResData->sHelpText[ SOURCE_LANGUAGE ]; } - if ( pResData->sQuickHelpText[ sCur ].Len()) + if (pResData->sQuickHelpText[ sCur ].getLength()) sXQHText = pResData->sQuickHelpText[ sCur ]; else { sXQHText = pResData->sQuickHelpText[ SOURCE_LANGUAGE ]; } - if ( pResData->sTitle[ sCur ].Len()) + if (pResData->sTitle[ sCur ].getLength()) sXTitle = pResData->sTitle[ sCur ]; - else { + else sXTitle = pResData->sTitle[ SOURCE_LANGUAGE ]; - } if ( !sXText.Len()) sXText = "-"; - if ( !sXHText.Len()) { - if ( pResData->sHelpText[ SOURCE_LANGUAGE ].Len()) + if ( !sXHText.Len()) + { + if (pResData->sHelpText[ SOURCE_LANGUAGE ].getLength()) sXHText = pResData->sHelpText[ SOURCE_LANGUAGE ]; } } @@ -1345,44 +1363,47 @@ sal_Bool Export::WriteExportList( ResData *pResData, ExportList *pExportList, // Export::DumpMap( a, *pEntry ); ByteString sLID(rtl::OString::valueOf(static_cast<sal_Int64>(i + 1))); - for( unsigned int n = 0; n < aLanguages.size(); n++ ){ + for (unsigned int n = 0; n < aLanguages.size(); ++n) + { sCur = aLanguages[ n ]; - if ( (*pEntry)[ SOURCE_LANGUAGE ].Len() ) + if ((*pEntry)[ SOURCE_LANGUAGE ].getLength()) + { + if ( bEnableExport ) { - if ( bEnableExport ) + ByteString sText((*pEntry)[ SOURCE_LANGUAGE ] ); + + // Strip PairList Line String + if( rTyp.EqualsIgnoreCaseAscii("pairedlist") ) { - ByteString sText((*pEntry)[ SOURCE_LANGUAGE ] ); - - // Strip PairList Line String - if( rTyp.EqualsIgnoreCaseAscii("pairedlist") ){ - sLID = GetPairedListID( sText ); - if ((*pEntry)[ sCur ].Len()) - sText = (*pEntry)[ sCur ]; - sText = GetPairedListString( sText ); - } - else{ - sText = StripList( (*pEntry)[ sCur ] ); - if( sText == "\\\"" ) - sText = "\""; - } + sLID = GetPairedListID( sText ); + if ((*pEntry)[ sCur ].getLength()) + sText = (*pEntry)[ sCur ]; + sText = GetPairedListString( sText ); + } + else + { + sText = StripList( (*pEntry)[ sCur ] ); + if( sText == "\\\"" ) + sText = "\""; + } - ByteString sOutput( sProject ); sOutput += "\t"; - if ( sRoot.Len()) - sOutput += sActFileName; - sOutput += "\t0\t"; - sOutput += rTyp; sOutput += "\t"; - sOutput += sGID; sOutput += "\t"; - sOutput += sLID; sOutput += "\t\t"; - sOutput += pResData->sPForm; sOutput += "\t0\t"; - sOutput += sCur; sOutput += "\t"; + ByteString sOutput( sProject ); sOutput += "\t"; + if ( sRoot.Len()) + sOutput += sActFileName; + sOutput += "\t0\t"; + sOutput += rTyp; sOutput += "\t"; + sOutput += sGID; sOutput += "\t"; + sOutput += sLID; sOutput += "\t\t"; + sOutput += pResData->sPForm; sOutput += "\t0\t"; + sOutput += sCur; sOutput += "\t"; - sOutput += sText; sOutput += "\t\t\t\t"; - sOutput += sTimeStamp; + sOutput += sText; sOutput += "\t\t\t\t"; + sOutput += sTimeStamp; - aOutput.WriteLine( sOutput ); + aOutput.WriteLine( sOutput ); - } } + } } if ( bCreateNew ) delete [] pEntry; @@ -1408,11 +1429,11 @@ ByteString Export::FullId() } } } - if ( sFull.Len() > 255 ) { - ByteString sError( "GroupId > 255 chars" ); - printf("GroupID = %s\n",sFull.GetBuffer()); - yyerror( sError.GetBufferAccess()); - sError.ReleaseBufferAccess(); + if ( sFull.Len() > 255 ) + { + rtl::OString sError(RTL_CONSTASCII_STRINGPARAM("GroupId > 255 chars")); + printf("GroupID = %s\n", sFull.GetBuffer()); + yyerror(sError.getStr()); } return sFull; @@ -1468,21 +1489,22 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine ) else return; - if ( nListIndex + 1 > pList->size()) { + if ( nListIndex + 1 > pList->size()) + { ExportListEntry *pNew = new ExportListEntry(); - (*pNew)[ LIST_REFID ] = ByteString::CreateFromInt32( REFID_NONE ); - pList->push_back( pNew ); + (*pNew)[LIST_REFID] = rtl::OString::valueOf(static_cast<sal_Int32>(REFID_NONE)); + pList->push_back(pNew); } ExportListEntry *pCurEntry = (*pList)[ nListIndex ]; // For paired list use the line to set proper lid if( nList == LIST_PAIRED ){ - (*pCurEntry)[ nListLang ] = rLine; + (*pCurEntry)[ m_sListLang ] = rLine; }else - (*pCurEntry)[ nListLang ] = rText; + (*pCurEntry)[ m_sListLang ] = rText; // Remember en-US fallback string, so each list has the same amount of elements - if ( Export::isSourceLanguage( nListLang ) ) { + if ( Export::isSourceLanguage( m_sListLang ) ) { if( nList == LIST_PAIRED ){ const ByteString sPlist("pairedlist"); ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sId , GetPairedListID( rLine ) , sFilename ); @@ -1502,7 +1524,7 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine ) // new fallback } - if ( Export::isSourceLanguage( nListLang ) ) { + if ( Export::isSourceLanguage( m_sListLang ) ) { if( nList == LIST_PAIRED ){ (*pCurEntry)[ SOURCE_LANGUAGE ] = rLine; } @@ -1512,7 +1534,7 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine ) pList->NewSourceLanguageListEntry(); } - //printf("Export::InsertListEntry ResData.id = %s ResData.ListData = %s\n",pResData->sId.GetBuffer() ,(*pCurEntry)[ nListLang ].GetBuffer()); + //printf("Export::InsertListEntry ResData.id = %s ResData.ListData = %s\n",pResData->sId.GetBuffer() ,(*pCurEntry)[ m_sListLang ].GetBuffer()); nListIndex++; } @@ -1727,10 +1749,8 @@ void Export::ConvertMergeContent( ByteString &rText ) rText += "\""; } -/*****************************************************************************/ -sal_Bool Export::PrepareTextToMerge( ByteString &rText, sal_uInt16 nTyp, - ByteString &nLangIndex, ResData *pResData ) -/*****************************************************************************/ +sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp, + rtl::OString &rLangIndex, ResData *pResData) { // position to merge in: sal_uInt16 nStart = 0; @@ -1780,13 +1800,14 @@ sal_Bool Export::PrepareTextToMerge( ByteString &rText, sal_uInt16 nTyp, break; } - if ( pList ) { + if (pList) + { ExportListEntry *pCurEntry = (*pList)[ nListIndex - 1 ]; - if ( pCurEntry ) { + if ( pCurEntry ) + { rText = (*pCurEntry)[ SOURCE_LANGUAGE ]; - if( nTyp == LIST_PAIRED ){ - pResData->addMergedLanguage( nLangIndex ); - } + if( nTyp == LIST_PAIRED ) + pResData->addMergedLanguage(rLangIndex); } } @@ -1818,7 +1839,7 @@ sal_Bool Export::PrepareTextToMerge( ByteString &rText, sal_uInt16 nTyp, if ( pResData->sResTyp.EqualsIgnoreCaseAscii( "pairedlist" ) ){ pResData->sId = GetPairedListID( sLastListLine ); } - else pResData->sId = ByteString::CreateFromInt32( nListIndex ); + else pResData->sId = rtl::OString::valueOf(static_cast<sal_Int32>(nListIndex)); if ( pResData->sGId.Len()) pResData->sGId += "."; @@ -1893,15 +1914,15 @@ sal_Bool Export::PrepareTextToMerge( ByteString &rText, sal_uInt16 nTyp, } ByteString sContent; - pEntrys->GetTransex3Text( sContent, nTyp, nLangIndex ); - if ( !sContent.Len() && ( ! Export::isSourceLanguage( nLangIndex ) )) { + pEntrys->GetTransex3Text(sContent, nTyp, rLangIndex); + if (!sContent.Len() && (!Export::isSourceLanguage(rLangIndex))) + { rText = sOrigText; return sal_False; // no data found } - if ( Export::isSourceLanguage( nLangIndex ) ) { + if (Export::isSourceLanguage(rLangIndex)) return sal_False; - } ByteString sPostFix( rText.Copy( ++nEnd )); rText.Erase( nStart ); @@ -2103,8 +2124,9 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode ) case LIST_ITEM : pResData->sResTyp = "itemlist"; pList = pResData->pItemList; bPairedList = false; break; case LIST_PAIRED : pResData->sResTyp = "pairedlist"; pList = pResData->pPairedList; bPairedList = true; break; } - ByteString sCur; - for( unsigned int n = 0; n < aLanguages.size(); n++ ){ + rtl::OString sCur; + for( unsigned int n = 0; n < aLanguages.size(); n++ ) + { sCur = aLanguages[ n ]; sal_uInt16 nIdx = 1; @@ -2130,46 +2152,65 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode ) bText = pEntrys->GetTransex3Text( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , sal_False ); // Use fallback, if data is missing in sdf file - if( !bText && bPairedList ){ - if( pResData->isMerged( sCur ) ) break; + if( !bText && bPairedList ) + { + if( pResData->isMerged( sCur ) ) + break; const ByteString sPlist("pairedlist"); ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename ); bText = pResData->getFallbackData( sKey , sText ); - }else if ( !bText ){// new fallback + } + else if ( !bText ) // new fallback + { if( pResData->isMerged( sCur ) ) break; const ByteString sPlist("list"); ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename ); bText = pResData->getFallbackData( sKey , sText ); } // new fallback - if ( bText && sText.Len()) { - if ( nIdx == 1 ) { - ByteString sHead; + if ( bText && sText.Len()) + { + if ( nIdx == 1 ) + { + rtl::OStringBuffer sHead; if ( bNextMustBeDefineEOL ) - sHead = "\\\n\t"; - sHead += sSpace; - switch ( nT ) { - case LIST_STRING : sHead += "StringList "; break; - case LIST_FILTER : sHead += "FilterList "; break; - case LIST_ITEM : sHead += "ItemList "; break; - case LIST_PAIRED : sHead += "PairedList "; break; - case LIST_UIENTRIES : sHead += "UIEntries "; break; + sHead.append(RTL_CONSTASCII_STRINGPARAM("\\\n\t")); + sHead.append(sSpace); + switch ( nT ) + { + case LIST_STRING: + sHead.append(RTL_CONSTASCII_STRINGPARAM("StringList ")); + break; + case LIST_FILTER: + sHead.append(RTL_CONSTASCII_STRINGPARAM("FilterList ")); + break; + case LIST_ITEM: + sHead.append(RTL_CONSTASCII_STRINGPARAM("ItemList ")); + break; + case LIST_PAIRED: + sHead.append(RTL_CONSTASCII_STRINGPARAM("PairedList ")); + break; + case LIST_UIENTRIES: + sHead.append(RTL_CONSTASCII_STRINGPARAM("UIEntries ")); + break; } - sHead += "[ "; - sHead += sCur; - sHead += " ] "; + sHead.append(RTL_CONSTASCII_STRINGPARAM("[ ")); + sHead.append(sCur); + sHead.append(RTL_CONSTASCII_STRINGPARAM(" ] ")); //} - if ( bDefine || bNextMustBeDefineEOL ) { - sHead += "= \\\n"; - sHead += sSpace; - sHead += "\t{\\\n\t"; + if ( bDefine || bNextMustBeDefineEOL ) + { + sHead.append(RTL_CONSTASCII_STRINGPARAM("= \\\n")); + sHead.append(sSpace); + sHead.append(RTL_CONSTASCII_STRINGPARAM("\t{\\\n\t")); } - else { - sHead += "= \n"; - sHead += sSpace; - sHead += "\t{\n\t"; + else + { + sHead.append(RTL_CONSTASCII_STRINGPARAM("= \n")); + sHead.append(sSpace); + sHead.append(RTL_CONSTASCII_STRINGPARAM("\t{\n\t")); } - WriteToMerged( sHead , true); + WriteToMerged(sHead.makeStringAndClear() , true); } ByteString sLine; if ( pList && (*pList)[ nLIndex ] ) @@ -2229,7 +2270,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode ) } } else - pResData->sId = ByteString::CreateFromInt32( ++nIdx ); + pResData->sId = rtl::OString::valueOf(static_cast<sal_Int32>(++nIdx)); } else break; @@ -2291,7 +2332,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode ) } } - while( PrepareTextToMerge( sLine, nList, nListLang, pResData ) && ( nListIndex <= nMaxIndex )) { + while( PrepareTextToMerge( sLine, nList, m_sListLang, pResData ) && ( nListIndex <= nMaxIndex )) { ByteString sText( "\t" ); sText += sLine; sText += " ;"; diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx index 35e46da64891..d7d39a453511 100644 --- a/l10ntools/source/export2.cxx +++ b/l10ntools/source/export2.cxx @@ -381,25 +381,27 @@ ByteString Export::GetFallbackLanguage( const ByteString nLanguage ) void Export::FillInFallbacks( ResData *pResData ) /*****************************************************************************/ { - ByteString sCur; - for( unsigned int n = 0; n < aLanguages.size(); n++ ){ - sCur = aLanguages[ n ]; - if( isAllowed( sCur ) ){ + for (size_t n = 0; n < aLanguages.size(); ++n) + { + ByteString sCur = aLanguages[ n ]; + if (isAllowed(sCur)) + { ByteString nFallbackIndex = GetFallbackLanguage( sCur ); - if( nFallbackIndex.Len() ){ - if ( !pResData->sText[ sCur ].Len()) + if( nFallbackIndex.Len() ) + { + if (pResData->sText[ sCur ].isEmpty()) pResData->sText[ sCur ] = pResData->sText[ nFallbackIndex ]; - if ( !pResData->sHelpText[ sCur ].Len()) + if (pResData->sHelpText[ sCur ].isEmpty()) pResData->sHelpText[ sCur ] = pResData->sHelpText[ nFallbackIndex ]; - if ( !pResData->sQuickHelpText[ sCur ].Len()) + if (pResData->sQuickHelpText[ sCur ].isEmpty()) pResData->sQuickHelpText[ sCur ] = pResData->sQuickHelpText[ nFallbackIndex ]; - if ( !pResData->sTitle[ sCur ].Len()) + if (!pResData->sTitle[ sCur ].isEmpty()) pResData->sTitle[ sCur ] = pResData->sTitle[ nFallbackIndex ]; @@ -432,11 +434,12 @@ void Export::FillInListFallbacks( ExportList *pList, const ByteString &nSource, const ByteString &nFallback ) /*****************************************************************************/ { - - for ( size_t i = 0; i < pList->size(); i++ ) { + for (size_t i = 0; i < pList->size(); ++i) + { ExportListEntry *pEntry = (*pList)[ i ]; - if ( !( *pEntry )[ nSource ].Len()){ - ( *pEntry )[ nSource ] = ( *pEntry )[ nFallback ]; + if ( (*pEntry )[nSource].isEmpty() ) + { + ( *pEntry )[ nSource ] = ( *pEntry )[ nFallback ]; ByteString x = ( *pEntry )[ nSource ]; ByteString y = ( *pEntry )[ nFallback ]; } diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx index 89fb66775d54..2fd8b8b540b1 100644 --- a/l10ntools/source/gsicheck.cxx +++ b/l10ntools/source/gsicheck.cxx @@ -32,7 +32,8 @@ #include <tools/fsys.hxx> #include <tools/stream.hxx> -// local includes +#include <rtl/strbuf.hxx> + #include "tagtest.hxx" #include "gsicheck.hxx" @@ -165,7 +166,10 @@ GSILine::GSILine( const ByteString &rLine, sal_uLong nLine ) // limit GID and LID to MAX_GID_LID_LEN chars each for database conformity, see #137575# if ( rLine.GetToken( 4, '\t' ).Len() > MAX_GID_LID_LEN || rLine.GetToken( 5, '\t' ).Len() > MAX_GID_LID_LEN ) { - PrintError( ByteString("GID and LID may only be ").Append( ByteString::CreateFromInt32(MAX_GID_LID_LEN) ).Append( " chars long each!" ), "Line format", aLangId, sal_True, GetLineNumber(), GetUniqId() ); + PrintError(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("GID and LID may only be ")) + .append(static_cast<sal_Int32>(MAX_GID_LID_LEN)) + .append(RTL_CONSTASCII_STRINGPARAM(" chars long each!" )).getStr(), + "Line format", aLangId, sal_True, GetLineNumber(), GetUniqId()); NotOK(); } } @@ -521,7 +525,9 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags ) if ( !IsUTF8( pTestee->GetText(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) ) { ByteString aContext( pTestee->GetText().Copy( nErrorPos, 20 ) ); - PrintError( aErrorMsg.Append(" in Text at Position " ).Append( ByteString::CreateFromInt32( nErrorPos ) ), "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId() ); + PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in Text at Position ")) + .append(static_cast<sal_Int32>(nErrorPos)).getStr(), + "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId()); bError = sal_True; if ( bHasBeenFixed ) { @@ -532,7 +538,9 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags ) if ( !IsUTF8( pTestee->GetQuickHelpText(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) ) { ByteString aContext( pTestee->GetQuickHelpText().Copy( nErrorPos, 20 ) ); - PrintError( aErrorMsg.Append(" in QuickHelpText at Position " ).Append( ByteString::CreateFromInt32( nErrorPos ) ), "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId() ); + PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in QuickHelpText at Position ")) + .append(static_cast<sal_Int32>(nErrorPos)).getStr(), + "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId()); bError = sal_True; if ( bHasBeenFixed ) { @@ -543,7 +551,9 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags ) if ( !IsUTF8( pTestee->GetTitle(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) ) { ByteString aContext( pTestee->GetTitle().Copy( nErrorPos, 20 ) ); - PrintError( aErrorMsg.Append(" in Title at Position " ).Append( ByteString::CreateFromInt32( nErrorPos ) ), "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId() ); + PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in Title at Position ")) + .append(static_cast<sal_Int32>(nErrorPos)).getStr(), + "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId()); bError = sal_True; if ( bHasBeenFixed ) { @@ -568,7 +578,9 @@ sal_Bool GSIBlock::HasSuspiciousChars( GSILine* pTestee, GSILine* pSource ) String aUTF8Tester = String( pTestee->GetText(), 0, nPos, RTL_TEXTENCODING_UTF8 ); sal_uInt16 nErrorPos = aUTF8Tester.Len(); ByteString aContext( pTestee->GetText().Copy( nPos, 20 ) ); - PrintError( ByteString("Found double questionmark in translation only. Looks like an encoding problem at Position " ).Append( ByteString::CreateFromInt32( nErrorPos ) ), "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId() ); + PrintError(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("Found double questionmark in translation only. Looks like an encoding problem at Position ")) + .append(static_cast<sal_Int32>(nErrorPos)).getStr(), + "Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId()); pTestee->NotOK(); return sal_True; } @@ -747,7 +759,8 @@ void Help() fprintf( stdout, "gsicheck checks the syntax of tags in GSI-Files and SDF-Files\n" ); fprintf( stdout, " checks for inconsistencies and malicious UTF8 encoding\n" ); fprintf( stdout, " checks tags in Online Help\n" ); - fprintf( stdout, " checks for *new* KeyIDs and relax GID/LID length to %s\n", ByteString::CreateFromInt32(MAX_GID_LID_LEN).GetBuffer() ); + fprintf( stdout, " checks for *new* KeyIDs and relax GID/LID length to %s\n", + rtl::OString::valueOf(static_cast<sal_Int32>(MAX_GID_LID_LEN)).getStr() ); fprintf( stdout, "\n" ); fprintf( stdout, "Syntax: gsicheck [ -c ] [-f] [ -we ] [ -wef ErrorFilename ] [ -wc ]\n" ); fprintf( stdout, " [ -wcf CorrectFilename ] [ -s | -t ] [ -l LanguageID ]\n" ); diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx index e89640015773..7af3293775f7 100644 --- a/l10ntools/source/lngmerge.cxx +++ b/l10ntools/source/lngmerge.cxx @@ -316,10 +316,13 @@ sal_Bool LngParser::Merge( nPos++; } ByteString sCur; - if ( nLastLangPos ) { - for( unsigned int n = 0; n < aLanguages.size(); n++ ){ + if ( nLastLangPos ) + { + for(size_t n = 0; n < aLanguages.size(); ++n) + { sCur = aLanguages[ n ]; - if( !sCur.EqualsIgnoreCaseAscii("en-US") && !Text[ sCur ].Len() && pEntrys ) { + if( !sCur.EqualsIgnoreCaseAscii("en-US") && Text[sCur].isEmpty() && pEntrys ) + { ByteString sNewText; pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur, sal_True ); diff --git a/l10ntools/source/tagtest.cxx b/l10ntools/source/tagtest.cxx index c3706aa4cd30..1389cfec4749 100644 --- a/l10ntools/source/tagtest.cxx +++ b/l10ntools/source/tagtest.cxx @@ -29,6 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_l10ntools.hxx" #include <tools/string.hxx> +#include <rtl/strbuf.hxx> #include "tagtest.hxx" #if OSL_DEBUG_LEVEL > 1 @@ -1342,20 +1343,21 @@ void TokenParser::ParseError( sal_uInt16 nErrNr, ByteString aErrMsg, const Token ParserMessage::ParserMessage( sal_uInt16 PnErrorNr, ByteString PaErrorText, const TokenInfo &rTag ) : nErrorNr( PnErrorNr ) - , aErrorText( PaErrorText ) , nTagBegin( 0 ) , nTagLength( 0 ) { String aLexem( SimpleParser::GetLexem( rTag ) ); - aErrorText.Append(": "); - aErrorText += ByteString( aLexem, RTL_TEXTENCODING_UTF8 ); + rtl::OStringBuffer aErrorBuffer(PaErrorText); + aErrorBuffer.append(RTL_CONSTASCII_STRINGPARAM(": ")); + aErrorBuffer.append(rtl::OUStringToOString(aLexem, RTL_TEXTENCODING_UTF8)); if ( rTag.nId == TAG_NOMORETAGS ) - aErrorText.Append(" at end of line "); + aErrorBuffer.append(RTL_CONSTASCII_STRINGPARAM(" at end of line ")); else if ( rTag.nPos != TOK_INVALIDPOS ) { - aErrorText.Append(" at Position "); - aErrorText.Append( ByteString::CreateFromInt32( rTag.nPos ) ); + aErrorBuffer.append(RTL_CONSTASCII_STRINGPARAM(" at Position ")); + aErrorBuffer.append(static_cast<sal_Int32>(rTag.nPos)); } + aErrorText = aErrorBuffer.makeStringAndClear(); nTagBegin = rTag.nPos; nTagLength = aLexem.Len(); } diff --git a/l10ntools/source/xrmlex.l b/l10ntools/source/xrmlex.l index 6229525d7e84..034812cf61f5 100644 --- a/l10ntools/source/xrmlex.l +++ b/l10ntools/source/xrmlex.l @@ -144,7 +144,7 @@ int yywrap(void) } /*****************************************************************************/ -void YYWarning( char *s ) +void YYWarning( const char *s ) /*****************************************************************************/ { /* write warning to stderr */ @@ -154,9 +154,9 @@ void YYWarning( char *s ) /*****************************************************************************/ #ifdef GCC -void yyerror ( char *s, ... ) +void yyerror ( const char *s, ... ) #else -void yyerror ( char *s ) +void yyerror ( const char *s ) #endif /*****************************************************************************/ { diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx index e682463bf523..064d908ae04f 100644 --- a/l10ntools/source/xrmmerge.cxx +++ b/l10ntools/source/xrmmerge.cxx @@ -526,14 +526,16 @@ void XRMResExport::WorkOnText( { ByteString sLang( GetAttribute( rOpenTag, "xml:lang" )); - if ( !pResData ) { - ByteString sPlatform( "" ); - pResData = new ResData( sPlatform, GetGID() ); - pResData->sId = GetLID(); - } + if ( !pResData ) + { + ByteString sPlatform( "" ); + pResData = new ResData( sPlatform, GetGID() ); + pResData->sId = GetLID(); + } - pResData->sText[ sLang ] = rText; - ConvertStringToDBFormat( pResData->sText[ sLang ] ); + ByteString sText(rText); + ConvertStringToDBFormat(sText); + pResData->sText[sLang] = sText; } /*****************************************************************************/ |