diff options
author | Caolán McNamara <caolanm@redhat.com> | 2012-01-30 20:44:22 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2012-01-31 11:37:24 +0000 |
commit | b8b1b1d68351765bbafe331a95909e47c661b664 (patch) | |
tree | f746c4a52fa5c9e5706c6073443f08e40bffee2e | |
parent | c1d04217e87e175017898f918cd77fe6529ec0da (diff) |
ByteString->rtl::OString
-rw-r--r-- | l10ntools/inc/cfgmerge.hxx | 4 | ||||
-rw-r--r-- | l10ntools/inc/export.hxx | 75 | ||||
-rw-r--r-- | l10ntools/inc/helpmerge.hxx | 4 | ||||
-rw-r--r-- | l10ntools/source/cfgmerge.cxx | 33 | ||||
-rw-r--r-- | l10ntools/source/export.cxx | 148 | ||||
-rw-r--r-- | l10ntools/source/export2.cxx | 60 | ||||
-rw-r--r-- | l10ntools/source/helpmerge.cxx | 21 | ||||
-rw-r--r-- | l10ntools/source/lngex.cxx | 40 | ||||
-rw-r--r-- | l10ntools/source/localize.cxx | 48 | ||||
-rw-r--r-- | l10ntools/source/srciter.cxx | 9 |
10 files changed, 217 insertions, 225 deletions
diff --git a/l10ntools/inc/cfgmerge.hxx b/l10ntools/inc/cfgmerge.hxx index ca59278ad369..d85271536660 100644 --- a/l10ntools/inc/cfgmerge.hxx +++ b/l10ntools/inc/cfgmerge.hxx @@ -123,7 +123,7 @@ protected: virtual void Output(const rtl::OString & rOutput)=0; - void Error( const ByteString &rError ); + void Error(const rtl::OString &rError); private: int ExecuteAnalyzedToken( int nToken, char *pToken ); @@ -151,7 +151,7 @@ class CfgOutputParser : public CfgParser protected: SvFileStream *pOutputStream; public: - CfgOutputParser ( const ByteString &rOutputFile ); + CfgOutputParser(const rtl::OString &rOutputFile); virtual ~CfgOutputParser(); }; diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx index 7e04866a7a2b..e0fcf058fe1e 100644 --- a/l10ntools/inc/export.hxx +++ b/l10ntools/inc/export.hxx @@ -306,23 +306,23 @@ public: static void SetLanguages( std::vector<rtl::OString> val ); static void RemoveUTF8ByteOrderMarker( rtl::OString &rString ); static bool hasUTF8ByteOrderMarker( const rtl::OString &rString ); - static void RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ); - static bool fileHasUTF8ByteOrderMarker( const ByteString &rString ); + static void RemoveUTF8ByteOrderMarkerFromFile(const rtl::OString &rFilename); + static bool fileHasUTF8ByteOrderMarker(const rtl::OString &rString); static void QuotHTML( ByteString &rString ); - static bool CopyFile( const ByteString& source , const ByteString& dest ); + static bool CopyFile(const rtl::OString& rSource , const rtl::OString& rDest); static void UnquotHTML( ByteString &rString ); static const char* GetEnv( const char *pVar ); - static bool isSourceLanguage( const ByteString &sLanguage ); - static bool isAllowed( const ByteString &sLanguage ); + static bool isSourceLanguage(const rtl::OString &rLanguage); + static bool isAllowed(const rtl::OString &rLanguage); static void Languages( std::vector<rtl::OString>::const_iterator& begin , std::vector<rtl::OString>::const_iterator& end ); - static void getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix ); + static rtl::OString getRandomName(const rtl::OString& rPrefix, const rtl::OString & sPostfix); static void getCurrentDir( std::string& dir ); - static ByteString GetTimeStamp(); + static rtl::OString GetTimeStamp(); static sal_Bool ConvertLineEnds( ByteString sSource, ByteString sDestination ); static ByteString GetNativeFile( ByteString sSource ); static DirEntry GetTempFile(); @@ -338,19 +338,19 @@ private: sal_Bool WriteData( ResData *pResData, sal_Bool bCreateNew = sal_False );// called befor dest. cur ResData sal_Bool WriteExportList( ResData *pResData, ExportList *pExportList, - const ByteString &rTyp, sal_Bool bCreateNew = sal_False ); + const rtl::OString &rTyp, sal_Bool bCreateNew = sal_False ); ByteString MergePairedList( ByteString& sLine , ByteString& sText ); - ByteString FullId(); // creates cur. GID + rtl::OString FullId(); // creates cur. GID - ByteString GetPairedListID ( const ByteString& sText ); - ByteString GetPairedListString ( const ByteString& sText ); - ByteString StripList ( const ByteString& sText ); + rtl::OString GetPairedListID(const rtl::OString & rText); + rtl::OString GetPairedListString(const rtl::OString& rText); + rtl::OString StripList(const rtl::OString& rText); - void InsertListEntry( const ByteString &rText, const ByteString &rLine ); + void InsertListEntry(const rtl::OString &rText, const rtl::OString &rLine); void CleanValue( ByteString &rValue ); - ByteString GetText( const ByteString &rSource, int nToken ); + rtl::OString GetText(const rtl::OString &rSource, int nToken); sal_Bool PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp, rtl::OString &rLangIndex, ResData *pResData); @@ -358,17 +358,17 @@ private: void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL ); void ConvertMergeContent( ByteString &rText ); - void WriteToMerged( const ByteString &rText , bool bSDFContent ); + void WriteToMerged(const rtl::OString &rText , bool bSDFContent); void SetChildWithText(); void CutComment( ByteString &rText ); public: - Export( const ByteString &rOutput, sal_Bool bWrite, - const ByteString &rPrj, const ByteString &rPrjRoot , const ByteString& rFile ); - Export( const ByteString &rOutput, sal_Bool bWrite, - const ByteString &rPrj, const ByteString &rPrjRoot, - const ByteString &rMergeSource , const ByteString& rFile ); + Export(const rtl::OString &rOutput, sal_Bool bWrite, + const rtl::OString &rPrj, const rtl::OString &rPrjRoot, const rtl::OString& rFile); + Export(const rtl::OString &rOutput, sal_Bool bWrite, + const rtl::OString &rPrj, const rtl::OString &rPrjRoot, + const rtl::OString &rMergeSource, const rtl::OString& rFile ); ~Export(); void Init(); @@ -401,23 +401,19 @@ private: public: PFormEntrys( const ByteString &rPForm ) : ByteString( rPForm ) {}; rtl::OString Dump(); - void InsertEntry( - const ByteString &nId , - const ByteString &rText, - const ByteString &rQuickHelpText, - const ByteString &rTitle - ) - { + void InsertEntry(const rtl::OString &rId, const rtl::OString &rText, + const rtl::OString &rQuickHelpText, const rtl::OString &rTitle) + { - sText[ nId ] = rText; - bTextFirst[ nId ] = true; - sQuickHelpText[ nId ] = rQuickHelpText; - bQuickHelpTextFirst[ nId ] = true; - sTitle[ nId ] = rTitle; - bTitleFirst[ nId ] = true; - } - sal_Bool GetText( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); - sal_Bool GetTransex3Text( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); + sText[ rId ] = rText; + bTextFirst[ rId ] = true; + sQuickHelpText[ rId ] = rQuickHelpText; + bQuickHelpTextFirst[ rId ] = true; + sTitle[ rId ] = rTitle; + bTitleFirst[ rId ] = true; + } + sal_Bool GetText( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); + sal_Bool GetTransex3Text( ByteString &rReturn, sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel = sal_False ); }; @@ -496,9 +492,12 @@ class MergeDataFile class QueueEntry { public: - QueueEntry( int nTypVal , ByteString sLineVal ): nTyp( nTypVal ) , sLine( sLineVal ){}; + QueueEntry(int nTypVal, const rtl::OString &rLineVal) + : nTyp(nTypVal), sLine(rLineVal) + { + } int nTyp; - ByteString sLine; + rtl::OString sLine; }; class ParserQueue diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx index c4e457af27aa..3e8383ac1da0 100644 --- a/l10ntools/inc/helpmerge.hxx +++ b/l10ntools/inc/helpmerge.hxx @@ -70,13 +70,13 @@ public: , const std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir ); private: - static ByteString makeAbsolutePath( const ByteString& sHelpFile , const ByteString& rRoot_in ); + static rtl::OString makeAbsolutePath(const rtl::OString& sHelpFile , const rtl::OString& rRoot_in); ByteString GetOutpath( const ByteString& rPathX , const ByteString& sCur , const ByteString& rPathY ); bool MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const ByteString& sLanguage , ByteString sPath ); void ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile ); - void MakeDir( const ByteString& sPath ); + void MakeDir(const rtl::OString& rPath); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx index 30c894228bcb..13cf715ba1f7 100644 --- a/l10ntools/source/cfgmerge.cxx +++ b/l10ntools/source/cfgmerge.cxx @@ -38,8 +38,8 @@ using comphelper::string::getToken; -extern "C" { int yyerror( char * ); } -extern "C" { int YYWarning( char * ); } +extern "C" { int yyerror(const char *); } +extern "C" { int YYWarning(const char *); } // defines to parse command line #define STATE_NON 0x0001 @@ -63,7 +63,7 @@ ByteString sPrj; ByteString sPrjRoot; ByteString sInputFileName; ByteString sActFileName; -ByteString sFullEntry; +rtl::OString sFullEntry; rtl::OString sOutputFile; rtl::OString sMergeSrc; String sUsedTempFile; @@ -240,8 +240,8 @@ extern FILE *GetCfgFile() // create file name, beginnig with project root // (e.g.: source\ui\src\menue.src) -// printf("sFullEntry = %s\n",sFullEntry.GetBuffer()); - sActFileName = sFullEntry.Copy( sPrjEntry.getLength() + 1 ); +// printf("sFullEntry = %s\n",sFullEntry.getStr()); + sActFileName = sFullEntry.copy(sPrjEntry.getLength() + 1); // printf("sActFileName = %s\n",sActFileName.GetBuffer()); sActFileName.SearchAndReplaceAll( "/", "\\" ); @@ -552,34 +552,29 @@ int CfgParser::Execute( int nToken, char * pToken ) return ExecuteAnalyzedToken( nToken, pToken ); } - -/*****************************************************************************/ -void CfgParser::Error( const ByteString &rError ) -/*****************************************************************************/ +void CfgParser::Error(const rtl::OString& rError) { - yyerror(( char * ) rError.GetBuffer()); + yyerror(rError.getStr()); } - // // class CfgOutputParser // -/*****************************************************************************/ -CfgOutputParser::CfgOutputParser( const ByteString &rOutputFile ) -/*****************************************************************************/ +CfgOutputParser::CfgOutputParser(const rtl::OString &rOutputFile) { pOutputStream = new SvFileStream( - String( rOutputFile, RTL_TEXTENCODING_ASCII_US ), + rtl::OStringToOUString(rOutputFile, RTL_TEXTENCODING_ASCII_US), STREAM_STD_WRITE | STREAM_TRUNC ); pOutputStream->SetStreamCharSet( RTL_TEXTENCODING_UTF8 ); - if ( !pOutputStream->IsOpen()) { - ByteString sError( "ERROR: Unable to open output file: " ); - sError += rOutputFile; - Error( sError ); + if ( !pOutputStream->IsOpen()) + { + rtl::OStringBuffer sError(RTL_CONSTASCII_STRINGPARAM("ERROR: Unable to open output file: ")); + sError.append(rOutputFile); + Error(sError.makeStringAndClear()); delete pOutputStream; pOutputStream = NULL; exit( -13 ); diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx index 39b8d041c6e6..8909a1eed945 100644 --- a/l10ntools/source/export.cxx +++ b/l10ntools/source/export.cxx @@ -297,12 +297,11 @@ int Parse( int nTyp, const char *pTokenText ){ void Close(){ pExport->pParseQueue->Close(); } -/*****************************************************************************/ + int WorkOnTokenSet( int nTyp, char *pTokenText ) -/*****************************************************************************/ { - pExport->pParseQueue->Push( QueueEntry( nTyp , ByteString( pTokenText ) ) ); + pExport->pParseQueue->Push( QueueEntry( nTyp , rtl::OString(pTokenText) ) ); return 1; } @@ -392,9 +391,9 @@ sal_Bool ResData::SetId( const rtl::OString& rId, sal_uInt16 nLevel ) // class Export // -Export::Export(const ByteString &rOutput, sal_Bool bWrite, - const ByteString &rPrj, const ByteString &rPrjRoot, - const ByteString& rFile) +Export::Export(const rtl::OString &rOutput, sal_Bool bWrite, + const rtl::OString &rPrj, const rtl::OString &rPrjRoot, + const rtl::OString& rFile) : pWordTransformer( NULL ), bDefine( sal_False ), @@ -425,7 +424,7 @@ Export::Export(const ByteString &rOutput, sal_Bool bWrite, if ( bEnableExport ) { aOutput.Open( String( rOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC ); if( !aOutput.IsOpen() ) { - fprintf(stderr, "ERROR : Can't open file %s\n",rOutput.GetBuffer()); + fprintf(stderr, "ERROR : Can't open file %s\n", rOutput.getStr()); exit ( -1 ); } aOutput.SetStreamCharSet( RTL_TEXTENCODING_UTF8 ); @@ -434,11 +433,9 @@ Export::Export(const ByteString &rOutput, sal_Bool bWrite, } } -/*****************************************************************************/ -Export::Export( const ByteString &rOutput, sal_Bool bWrite, - const ByteString &rPrj, const ByteString &rPrjRoot, - const ByteString &rMergeSource , const ByteString& rFile ) -/*****************************************************************************/ +Export::Export(const rtl::OString &rOutput, sal_Bool bWrite, + const rtl::OString &rPrj, const rtl::OString &rPrjRoot, + const rtl::OString &rMergeSource, const rtl::OString& rFile) : pWordTransformer( NULL ), bDefine( sal_False ), @@ -761,7 +758,7 @@ int Export::Execute( int nToken, const char * pToken ) sKey = sKey.toAsciiUpperCase(); if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("IDENTIFIER"))) { - ByteString sId(comphelper::string::remove(sValue, '\t')); + rtl::OString sId(comphelper::string::remove(sValue, '\t')); sId = comphelper::string::remove(sId, ' '); pResData->SetId(sId, ID_LEVEL_IDENTIFIER); } @@ -1286,18 +1283,22 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew ) } return sal_True; } -ByteString Export::GetPairedListID( const ByteString& sText ){ + +rtl::OString Export::GetPairedListID(const rtl::OString& rText) +{ // < "STRING" ; IDENTIFIER ; > ; - ByteString sIdent = getToken(sText, 1, ';'); + ByteString sIdent = getToken(rText, 1, ';'); sIdent.ToUpperAscii(); while( sIdent.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {}; sIdent = comphelper::string::stripEnd(sIdent, ' '); sIdent = comphelper::string::stripStart(sIdent, ' '); return sIdent; } -ByteString Export::GetPairedListString( const ByteString& sText ){ + +rtl::OString Export::GetPairedListString(const rtl::OString& rText) +{ // < "STRING" ; IDENTIFIER ; > ; - ByteString sString = getToken(sText, 0, ';'); + ByteString sString = getToken(rText, 0, ';'); while( sString.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {}; sString = comphelper::string::stripEnd(sString, ' '); ByteString s1 = sString.Copy( sString.Search( '\"' )+1 ); @@ -1306,15 +1307,15 @@ ByteString Export::GetPairedListString( const ByteString& sText ){ sString = comphelper::string::stripStart(sString, ' '); return sString; } -ByteString Export::StripList( const ByteString& sText ){ - ByteString s1 = sText.Copy( sText.Search( '\"' ) + 1 ); - return s1.Copy( 0 , s1.SearchBackward( '\"' ) ); + +rtl::OString Export::StripList(const rtl::OString & rText) +{ + rtl::OString s1 = rText.copy( rText.indexOf('\"') + 1); + return s1.copy( 0 , s1.lastIndexOf('\"')); } -/*****************************************************************************/ -sal_Bool Export::WriteExportList( ResData *pResData, ExportList *pExportList, - const ByteString &rTyp, sal_Bool bCreateNew ) -/*****************************************************************************/ +sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList, + const rtl::OString &rTyp, sal_Bool bCreateNew) { ByteString sGID = pResData->sGId; if ( !sGID.Len()) @@ -1342,7 +1343,7 @@ sal_Bool Export::WriteExportList( ResData *pResData, ExportList *pExportList, ByteString sText((*pEntry)[ SOURCE_LANGUAGE ] ); // Strip PairList Line String - if( rTyp.EqualsIgnoreCaseAscii("pairedlist") ) + if (rTyp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("pairedlist"))) { sLID = GetPairedListID( sText ); if (!(*pEntry)[ sCur ].isEmpty()) @@ -1356,20 +1357,21 @@ sal_Bool Export::WriteExportList( ResData *pResData, ExportList *pExportList, sText = "\""; } - ByteString sOutput( sProject ); sOutput += "\t"; + rtl::OStringBuffer sOutput(sProject); + sOutput.append('\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.append(sActFileName); + sOutput.append("\t0\t"); + sOutput.append(rTyp).append('\t'); + sOutput.append(sGID).append('\t'); + sOutput.append(sLID).append("\t\t"); + sOutput.append(pResData->sPForm).append("\t0\t"); + sOutput.append(sCur).append('\t'); - sOutput += sText; sOutput += "\t\t\t\t"; - sOutput += sTimeStamp; + sOutput.append(sText).append("\t\t\t\t"); + sOutput.append(sTimeStamp); - aOutput.WriteLine( sOutput ); + aOutput.WriteLine(sOutput.makeStringAndClear()); } } @@ -1383,34 +1385,30 @@ sal_Bool Export::WriteExportList( ResData *pResData, ExportList *pExportList, return sal_True; } -/*****************************************************************************/ -ByteString Export::FullId() -/*****************************************************************************/ +rtl::OString Export::FullId() { - ByteString sFull; - if ( nLevel > 1 ) { - sFull = aResStack[ 0 ]->sId; - for ( size_t i = 1; i < nLevel - 1; i++ ) { - ByteString sToAdd = aResStack[ i ]->sId; - if ( sToAdd.Len()) { - sFull += "."; - sFull += sToAdd; - } + rtl::OStringBuffer sFull; + if ( nLevel > 1 ) + { + sFull.append(aResStack[ 0 ]->sId); + for ( size_t i = 1; i < nLevel - 1; ++i ) + { + rtl::OString sToAdd = aResStack[ i ]->sId; + if (!sToAdd.isEmpty()) + sFull.append('.').append(sToAdd); } } - if ( sFull.Len() > 255 ) + if (sFull.getLength() > 255) { rtl::OString sError(RTL_CONSTASCII_STRINGPARAM("GroupId > 255 chars")); - printf("GroupID = %s\n", sFull.GetBuffer()); + printf("GroupID = %s\n", sFull.getStr()); yyerror(sError.getStr()); } - return sFull; + return sFull.makeStringAndClear(); } -/*****************************************************************************/ -void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine ) -/*****************************************************************************/ +void Export::InsertListEntry(const rtl::OString &rText, const rtl::OString &rLine) { ResData *pResData = ( nLevel-1 < aResStack.size() ) ? aResStack[ nLevel-1 ] : NULL; @@ -1509,13 +1507,11 @@ void Export::CleanValue( ByteString &rValue ) } } - -/*****************************************************************************/ -ByteString Export::GetText( const ByteString &rSource, int nToken ) -/*****************************************************************************/ #define TXT_STATE_NON 0x000 #define TXT_STATE_TEXT 0x001 #define TXT_STATE_MACRO 0x002 + +rtl::OString Export::GetText(const rtl::OString &rSource, int nToken) { ByteString sReturn; switch ( nToken ) @@ -1523,7 +1519,7 @@ ByteString Export::GetText( const ByteString &rSource, int nToken ) case TEXTLINE: case LONGTEXTLINE: { - ByteString sTmp( rSource.Copy( rSource.Search( "=" ))); + ByteString sTmp(rSource.copy(rSource.indexOf("="))); CleanValue( sTmp ); sTmp = comphelper::string::remove(sTmp, '\n'); sTmp = comphelper::string::remove(sTmp, '\r'); @@ -1588,11 +1584,10 @@ ByteString Export::GetText( const ByteString &rSource, int nToken ) return sReturn; } -/*****************************************************************************/ -void Export::WriteToMerged( const ByteString &rText , bool bSDFContent ) -/*****************************************************************************/ +void Export::WriteToMerged(const rtl::OString &rText , bool bSDFContent) { - if ( !bDontWriteOutput || !bUnmerge ) { + if ( !bDontWriteOutput || !bUnmerge ) + { ByteString sText( rText ); while ( sText.SearchAndReplace( " \n", "\n" ) != STRING_NOTFOUND ) {}; if( pParseQueue->bNextIsM && bSDFContent && sText.Len() > 2 ){ @@ -2314,15 +2309,16 @@ void Export::SetChildWithText() } } -void ParserQueue::Push( const QueueEntry& aEntry ){ - sal_uInt16 nLen = aEntry.sLine.Len(); +void ParserQueue::Push( const QueueEntry& aEntry ) +{ + sal_Int32 nLen = aEntry.sLine.getLength(); if( !bStart ){ aQueueCur->push( aEntry ); - if( nLen > 1 && aEntry.sLine.GetChar( nLen-1 ) == '\n' ) + if( nLen > 1 && aEntry.sLine[nLen-1] == '\n' ) bStart = true; else if ( aEntry.nTyp != IGNOREDTOKENS ){ - if( nLen > 1 && ( aEntry.sLine.GetChar( nLen-1 ) == '\\') ){ + if( nLen > 1 && ( aEntry.sLine[nLen-1] == '\\') ){ // Next is Macro bCurrentIsM = true; }else{ @@ -2333,8 +2329,8 @@ void ParserQueue::Push( const QueueEntry& aEntry ){ } else{ aQueueNext->push( aEntry ); - if( nLen > 1 && aEntry.sLine.GetChar( nLen-1 ) != '\n' ){ - if( nLen > 1 && ( aEntry.sLine.GetChar( nLen-1 ) == '\\') ){ + if( nLen > 1 && aEntry.sLine[nLen-1] != '\n' ){ + if( nLen > 1 && ( aEntry.sLine[nLen-1] == '\\') ){ // Next is Macro bNextIsM = true; } @@ -2342,9 +2338,9 @@ void ParserQueue::Push( const QueueEntry& aEntry ){ // Next is no Macro bNextIsM = false; } - }else if( nLen > 2 && aEntry.sLine.GetChar( nLen-1 ) == '\n' ){ + }else if( nLen > 2 && aEntry.sLine[nLen-1] == '\n' ){ if( aEntry.nTyp != IGNOREDTOKENS ){ - if( nLen > 2 && ( aEntry.sLine.GetChar( nLen-2 ) == '\\') ){ + if( nLen > 2 && ( aEntry.sLine[nLen-2] == '\\') ){ // Next is Macro bNextIsM = true; } @@ -2389,13 +2385,17 @@ void ParserQueue::Close(){ bNextIsM = false; Pop( *aQueueNext ); }; -void ParserQueue::Pop( std::queue<QueueEntry>& aQueue ){ - while( !aQueue.empty() ){ + +void ParserQueue::Pop( std::queue<QueueEntry>& aQueue ) +{ + while (!aQueue.empty()) + { QueueEntry aEntry = aQueue.front(); aQueue.pop(); - aExport.Execute( aEntry.nTyp , (char*) aEntry.sLine.GetBuffer() ); + aExport.Execute(aEntry.nTyp, aEntry.sLine.getStr()); } } + ParserQueue::ParserQueue( Export& aExportObj ) : bCurrentIsM( false ), diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx index e88d3fb03245..1c0af7d44506 100644 --- a/l10ntools/source/export2.cxx +++ b/l10ntools/source/export2.cxx @@ -95,9 +95,10 @@ rtl::OString Export::sForcedLanguages; void Export::DumpExportList(const rtl::OString& rListName, ExportList& aList) { printf( "%s\n", rListName.getStr() ); - ByteString l(""); + rtl::OString l; ExportListEntry* aEntry; - for( unsigned int x = 0; x < aList.size() ; x++ ){ + for( unsigned int x = 0; x < aList.size() ; ++x ) + { aEntry = (ExportListEntry*) aList[ x ]; Export::DumpMap( l , *aEntry ); } @@ -205,9 +206,9 @@ bool Export::hasUTF8ByteOrderMarker( const rtl::OString &rString ) rString[1] == '\xBB' && rString[2] == '\xBF' ; } -bool Export::fileHasUTF8ByteOrderMarker( const ByteString &rString ) +bool Export::fileHasUTF8ByteOrderMarker(const rtl::OString &rString) { - SvFileStream aFileIn( String( rString , RTL_TEXTENCODING_ASCII_US ) , STREAM_READ ); + SvFileStream aFileIn(rtl::OStringToOUString(rString, RTL_TEXTENCODING_ASCII_US), STREAM_READ); rtl::OString sLine; if( !aFileIn.IsEof() ) { @@ -220,9 +221,9 @@ bool Export::fileHasUTF8ByteOrderMarker( const ByteString &rString ) return false; } -void Export::RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ) +void Export::RemoveUTF8ByteOrderMarkerFromFile(const rtl::OString &rFilename) { - SvFileStream aFileIn( String( rFilename , RTL_TEXTENCODING_ASCII_US ) , STREAM_READ ); + SvFileStream aFileIn(rtl::OStringToOUString(rFilename , RTL_TEXTENCODING_ASCII_US) , STREAM_READ ); rtl::OString sLine; if( !aFileIn.IsEof() ) { @@ -244,31 +245,31 @@ void Export::RemoveUTF8ByteOrderMarkerFromFile( const ByteString &rFilename ) } if( aFileIn.IsOpen() ) aFileIn.Close(); if( aNewFile.IsOpen() ) aNewFile.Close(); - DirEntry aEntry( rFilename.GetBuffer() ); + DirEntry aEntry( rFilename.getStr() ); aEntry.Kill(); - DirEntry( sTempFile ).MoveTo( DirEntry( rFilename.GetBuffer() ) ); + DirEntry( sTempFile ).MoveTo( DirEntry( rFilename.getStr() ) ); } } if( aFileIn.IsOpen() ) aFileIn.Close(); } -bool Export::CopyFile( const ByteString& source , const ByteString& dest ) +bool Export::CopyFile(const rtl::OString& rSource, const rtl::OString& rDest) { const int BUFFERSIZE = 8192; char buf[ BUFFERSIZE ]; - FILE* IN_FILE = fopen( source.GetBuffer() , "r" ); + FILE* IN_FILE = fopen( rSource.getStr() , "r" ); if( IN_FILE == NULL ) { - cerr << "Export::CopyFile WARNING: Could not open " << source.GetBuffer() << "\n"; + cerr << "Export::CopyFile WARNING: Could not open " << rSource.getStr() << "\n"; return false; } - FILE* OUT_FILE = fopen( dest.GetBuffer() , "w" ); + FILE* OUT_FILE = fopen( rDest.getStr() , "w" ); if( OUT_FILE == NULL ) { - cerr << "Export::CopyFile WARNING: Could not open/create " << dest.GetBuffer() << " for writing\n"; + cerr << "Export::CopyFile WARNING: Could not open/create " << rDest.getStr() << " for writing\n"; fclose( IN_FILE ); return false; } @@ -277,7 +278,7 @@ bool Export::CopyFile( const ByteString& source , const ByteString& dest ) { if( fputs( buf , OUT_FILE ) == EOF ) { - cerr << "Export::CopyFile WARNING: Write problems " << source.GetBuffer() << "\n"; + cerr << "Export::CopyFile WARNING: Write problems " << rSource.getStr() << "\n"; fclose( IN_FILE ); fclose( OUT_FILE ); return false; @@ -285,7 +286,7 @@ bool Export::CopyFile( const ByteString& source , const ByteString& dest ) } if( ferror( IN_FILE ) ) { - cerr << "Export::CopyFile WARNING: Read problems " << dest.GetBuffer() << "\n"; + cerr << "Export::CopyFile WARNING: Read problems " << rDest.getStr() << "\n"; fclose( IN_FILE ); fclose( OUT_FILE ); return false; @@ -337,12 +338,15 @@ void Export::UnquotHTML( ByteString &rString ) } rString = sReturn.makeStringAndClear(); } -bool Export::isSourceLanguage( const ByteString &sLanguage ) + +bool Export::isSourceLanguage(const rtl::OString &rLanguage) { - return !isAllowed( sLanguage ); + return !isAllowed(rLanguage); } -bool Export::isAllowed( const ByteString &sLanguage ){ - return ! ( sLanguage.EqualsIgnoreCaseAscii("en-US") ); + +bool Export::isAllowed(const rtl::OString &rLanguage) +{ + return !rLanguage.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")); } bool Export::isInitialized = false; @@ -392,9 +396,7 @@ void Export::InitForcedLanguages( bool bMergeMode ){ while ( nIndex >= 0 ); } -/*****************************************************************************/ -ByteString Export::GetTimeStamp() -/*****************************************************************************/ +rtl::OString Export::GetTimeStamp() { // return "xx.xx.xx"; char buf[20]; @@ -402,7 +404,7 @@ ByteString Export::GetTimeStamp() snprintf(buf, sizeof(buf), "%8d %02d:%02d:%02d", int(Date( Date::SYSTEM).GetDate()), int(aTime.GetHour()), int(aTime.GetMin()), int(aTime.GetSec())); - return ByteString(buf); + return rtl::OString(buf); } /*****************************************************************************/ @@ -479,11 +481,12 @@ void Export::getCurrentDir( string& dir ) #define RAND_NAME_LENGTH 6 -void Export::getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix ) +rtl::OString Export::getRandomName(const rtl::OString& rPrefix, const rtl::OString& rPostfix) { static const char LETTERS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; static const int COUNT_OF_LETTERS = SAL_N_ELEMENTS(LETTERS) - 1; - sRandStr.Append( sPrefix ); + + rtl::OStringBuffer sRandStr(rPrefix); static sal_uInt64 value; char buffer[RAND_NAME_LENGTH]; @@ -501,14 +504,15 @@ void Export::getRandomName( const ByteString& sPrefix , ByteString& sRandStr , c v = value; - for (i = 0; i < RAND_NAME_LENGTH; i++) + for (i = 0; i < RAND_NAME_LENGTH; ++i) { buffer[i] = LETTERS[v % COUNT_OF_LETTERS]; v /= COUNT_OF_LETTERS; } - sRandStr.Append( buffer , RAND_NAME_LENGTH ); - sRandStr.Append( sPostfix ); + sRandStr.append(buffer , RAND_NAME_LENGTH); + sRandStr.append(rPostfix); + return sRandStr.makeStringAndClear(); } /*****************************************************************************/ diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx index 7b1be3cb18ab..ffe31bb6d654 100644 --- a/l10ntools/source/helpmerge.cxx +++ b/l10ntools/source/helpmerge.cxx @@ -216,9 +216,9 @@ bool HelpParser::CreateSDF( return sal_True; } -ByteString HelpParser::makeAbsolutePath( const ByteString& sHelpFile , const ByteString& rRoot_in ) +rtl::OString HelpParser::makeAbsolutePath(const rtl::OString& sHelpFile, const rtl::OString& rRoot_in) { - DirEntry aEntry( String( sHelpFile, RTL_TEXTENCODING_ASCII_US )); + DirEntry aEntry(rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US)); aEntry.ToAbs(); String sFullEntry = aEntry.GetFull(); aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US )); @@ -357,7 +357,8 @@ bool HelpParser::Merge( ByteString sFilepath; if( bISO ) sFilepath = GetOutpath( rPathX , sCur , rPathY ); else sFilepath = rPathX; - if( bCreateDir ) MakeDir( sFilepath ); + if( bCreateDir ) + MakeDir(sFilepath); XMLFile* file = new XMLFile( *xmlfile ); sFilepath.Append( sHelpFile ); @@ -408,9 +409,9 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile ByteString sTargetFile( sPath ); ByteString sTempFileCopy; - static const ByteString INPATH = Export::GetEnv( "INPATH" ); - Export::getRandomName( sPath , sTempFile , INPATH ); - Export::getRandomName( sPath , sTempFileCopy , INPATH ); + static const rtl::OString INPATH = Export::GetEnv("INPATH"); + sTempFile = Export::getRandomName(sPath, INPATH); + sTempFileCopy = Export::getRandomName(sPath, INPATH); // Write in the temp file bool hasNoError = file->Write ( sTempFile ); if( !hasNoError ) @@ -517,11 +518,11 @@ ByteString HelpParser::GetOutpath( const ByteString& rPathX , const ByteString& return testpath; } -void HelpParser::MakeDir( const ByteString& sPath ) +void HelpParser::MakeDir(const rtl::OString& rPath) { - ByteString sTPath( sPath ); - rtl::OString sDelimiter(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US)); - sTPath.SearchAndReplaceAll( sDelimiter , rtl::OString('/') ); + rtl::OString sDelimiter(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), + RTL_TEXTENCODING_ASCII_US)); + rtl::OString sTPath(comphelper::string::replace(rPath, sDelimiter, rtl::OString('/'))); sal_uInt16 cnt = comphelper::string::getTokenCount(sTPath, '/'); rtl::OStringBuffer sCreateDir; for (sal_uInt16 i = 0; i < cnt; ++i) diff --git a/l10ntools/source/lngex.cxx b/l10ntools/source/lngex.cxx index 7ab8e52f6667..e921a74cb56e 100644 --- a/l10ntools/source/lngex.cxx +++ b/l10ntools/source/lngex.cxx @@ -45,16 +45,16 @@ #define STATE_LANGUAGES 0x000B // set of global variables -ByteString sInputFile; +rtl::OString sInputFile; sal_Bool bEnableExport; sal_Bool bMergeMode; sal_Bool bErrorLog; sal_Bool bUTF8; sal_Bool bULF; // ULF = Unicode Language File -ByteString sPrj; -ByteString sPrjRoot; -ByteString sOutputFile; -ByteString sMergeSrc; +rtl::OString sPrj; +rtl::OString sPrjRoot; +rtl::OString sOutputFile; +rtl::OString sMergeSrc; /*****************************************************************************/ sal_Bool ParseCommandLine( int argc, char* argv[]) @@ -74,31 +74,26 @@ sal_Bool ParseCommandLine( int argc, char* argv[]) // parse command line for( int i = 1; i < argc; i++ ) { - ByteString sSwitch( argv[ i ] ); - sSwitch.ToUpperAscii(); - if ( sSwitch == "-I" ) { + rtl::OString sSwitch(rtl::OString(argv[i]).toAsciiUpperCase()); + if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-I"))) nState = STATE_INPUT; // next tokens specifies source files - } - else if ( sSwitch == "-O" ) { + else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-O"))) nState = STATE_OUTPUT; // next token specifies the dest file - } - else if ( sSwitch == "-P" ) { + else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-P"))) nState = STATE_PRJ; // next token specifies the cur. project - } - else if ( sSwitch == "-R" ) { + else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-R"))) nState = STATE_ROOT; // next token specifies path to project root - } - else if ( sSwitch == "-M" ) { + else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-M"))) nState = STATE_MERGESRC; // next token specifies the merge database - } - else if ( sSwitch == "-E" ) { + else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-E"))) + { nState = STATE_ERRORLOG; bErrorLog = sal_False; } - else if ( sSwitch == "-L" ) { + else if (sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-L"))) nState = STATE_LANGUAGES; - } - else { + else + { switch ( nState ) { case STATE_NON: { return sal_False; // no valid command line @@ -173,7 +168,8 @@ int _cdecl main( int argc, char *argv[] ) return 1; } - if ( sOutputFile.Len()) { + if (!sOutputFile.isEmpty()) + { LngParser aParser( sInputFile, bUTF8, bULF ); if ( bMergeMode ) aParser.Merge(sMergeSrc, sOutputFile); diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index c00beee90fec..5dfd761eef77 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -204,7 +204,7 @@ private: const ByteString &rParameter, const ByteString &rCollectMode ); - void WorkOnDirectory( const ByteString &rDirectory ); + void WorkOnDirectory(const rtl::OString &rDirectory); public: SourceTreeLocalizer(const ByteString &rRoot, bool skip_links); ~SourceTreeLocalizer(); @@ -212,7 +212,7 @@ public: void SetLanguageRestriction( const ByteString& rRestrictions ) { sLanguageRestriction = rRestrictions; } int getFileCnt(); - sal_Bool Extract( const ByteString &rDestinationFile ); + sal_Bool Extract(const rtl::OString &rDestinationFile); int GetFileCnt(); virtual void OnExecuteDirectory( const rtl::OUString &rDirectory ); }; @@ -478,11 +478,9 @@ void SourceTreeLocalizer::WorkOnFileType( } } -/*****************************************************************************/ -void SourceTreeLocalizer::WorkOnDirectory( const ByteString &rDirectory ) -/*****************************************************************************/ +void SourceTreeLocalizer::WorkOnDirectory(const rtl::OString &rDirectory) { - //printf("Working on Directory %s\n",rDirectory.GetBuffer()); + //printf("Working on Directory %s\n",rDirectory.getStr()); sal_uLong nIndex = 0; ByteString sExtension( ExeTable[ nIndex ][ 0 ] ); ByteString sExecutable( ExeTable[ nIndex ][ 1 ] ); @@ -507,32 +505,32 @@ void SourceTreeLocalizer::WorkOnDirectory( const ByteString &rDirectory ) } } -void SourceTreeLocalizer::OnExecuteDirectory( const rtl::OUString &aDirectory ) +void SourceTreeLocalizer::OnExecuteDirectory(const rtl::OUString &aDirectory) { - ByteString rDirectory( rtl::OUStringToOString( aDirectory , RTL_TEXTENCODING_UTF8 , aDirectory.getLength() ) ) ; - if ( nMode == LOCALIZE_NONE ){ - } - else + if ( nMode != LOCALIZE_NONE ) + { + rtl::OString rDirectory(rtl::OUStringToOString(aDirectory, RTL_TEXTENCODING_UTF8)); WorkOnDirectory( rDirectory ); + } } -/*****************************************************************************/ -sal_Bool SourceTreeLocalizer::Extract( const ByteString &rDestinationFile ) -/*****************************************************************************/ +sal_Bool SourceTreeLocalizer::Extract(const rtl::OString &rDestinationFile) { nMode = LOCALIZE_EXTRACT; - aSDF.Open( String( rDestinationFile , RTL_TEXTENCODING_ASCII_US ) , STREAM_STD_WRITE ); + aSDF.Open(rtl::OStringToOUString(rDestinationFile, RTL_TEXTENCODING_ASCII_US) , STREAM_STD_WRITE); aSDF.SetLineDelimiter( LINEEND_CRLF ); sal_Bool bReturn = aSDF.IsOpen(); - if ( bReturn ) { + if ( bReturn ) + { aSDF.Seek( STREAM_SEEK_TO_END ); bReturn = StartExecute(); aSDF.Close(); } - else{ - printf("ERROR: Can't create file %s\n", rDestinationFile.GetBuffer() ); + else + { + printf("ERROR: Can't create file %s\n", rDestinationFile.getStr()); } nMode = LOCALIZE_NONE; aSDF.Close(); @@ -580,20 +578,18 @@ int _cdecl main( int argc, char *argv[] ) bool bSkipLinks = false; - ByteString sLanguages; - ByteString sFileName; + rtl::OString sFileName; - sLanguages = ByteString( "en-US" ); + rtl::OString sLanguages(RTL_CONSTASCII_STRINGPARAM("en-US")); - ByteString sSwitch( argv[ 1 ] ); - sSwitch.ToUpperAscii(); + rtl::OString sSwitch(rtl::OString(argv[1]).toAsciiUpperCase()); - if ( ( argc == 3 ) && sSwitch.Equals( "-F" ) ) - sFileName = ByteString( argv[ 2 ] ); + if ( ( argc == 3 ) && sSwitch.equalsL(RTL_CONSTASCII_STRINGPARAM("-F")) ) + sFileName = rtl::OString( argv[ 2 ] ); else return Error(); - DirEntry aEntry( String( sFileName , RTL_TEXTENCODING_ASCII_US )); + DirEntry aEntry(rtl::OStringToOUString(sFileName, RTL_TEXTENCODING_ASCII_US)); aEntry.ToAbs(); String sFullEntry = aEntry.GetFull(); rtl::OString sFileABS(rtl::OUStringToOString(aEntry.GetFull(), osl_getThreadTextEncoding())); diff --git a/l10ntools/source/srciter.cxx b/l10ntools/source/srciter.cxx index c3e4988e3d2c..9c18fd5fe837 100644 --- a/l10ntools/source/srciter.cxx +++ b/l10ntools/source/srciter.cxx @@ -29,6 +29,7 @@ #include "srciter.hxx" #include <stdio.h> +#include <rtl/strbuf.hxx> #include <tools/fsys.hxx> // @@ -83,16 +84,16 @@ void SourceTreeIterator::ExecuteDirectory( transex::Directory& aDirectory ) //printf("**** %s \n", OUStringToOString( sDirName , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() ); rtl::OUString sDirNameTmp = aDirectory.getFullName(); - ByteString sDirNameTmpB( rtl::OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() ); + rtl::OStringBuffer sDirNameTmpB( rtl::OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() ); #ifdef WNT - sDirNameTmpB.Append( ByteString("\\no_localization") ); + sDirNameTmpB.append(RTL_CONSTASCII_STRINGPARAM("\\no_localization")); #else - sDirNameTmpB.Append( ByteString("/no_localization") ); + sDirNameTmpB.append(RTL_CONSTASCII_STRINGPARAM("/no_localization")); #endif //printf("**** %s \n", OUStringToOString( sDirNameTmp , RTL_TEXTENCODING_UTF8 , sDirName.getLength() ).getStr() ); - DirEntry aDE( sDirNameTmpB.GetBuffer() ); + DirEntry aDE(sDirNameTmpB.getStr()); if( aDE.Exists() ) { //printf("#### no_localization file found ... skipping"); |