summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-08-29 23:03:08 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-08-30 09:32:23 +0100
commit98f246d83db8f1a3e90dd794f48c390593a3ef62 (patch)
treeda17ce5516a0d2fbe4778f08aa5facc0d6d49250 /l10ntools
parent8fd3e7c09177a856fb9ba6de0e42af5d12b67652 (diff)
ByteString->rtl::OString
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/export.cxx50
-rw-r--r--l10ntools/source/export2.cxx6
-rw-r--r--l10ntools/source/gsicheck.cxx10
-rw-r--r--l10ntools/source/helpmerge.cxx13
-rw-r--r--l10ntools/source/lngmerge.cxx19
-rw-r--r--l10ntools/source/merge.cxx4
6 files changed, 57 insertions, 45 deletions
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 9cfb032cfbfa..e75550d7acf9 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -38,6 +38,8 @@
#include <rtl/strbuf.hxx>
#include <comphelper/string.hxx>
+using comphelper::string::getToken;
+
extern "C" { int yyerror( const char * ); }
extern "C" { int YYWarning( const char * ); }
@@ -680,17 +682,17 @@ int Export::Execute( int nToken, const char * pToken )
sToken.EraseAllChars( '{' );
while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
sToken.EraseTrailingChars( ' ' );
- ByteString sT = sToken.GetToken( 0, ' ' );
+ ByteString sT = getToken(sToken, 0, ' ');
pResData->sResTyp = sT.ToLowerAscii();
ByteString sId( sToken.Copy( pResData->sResTyp.Len() + 1 ));
ByteString sCondition;
if ( sId.Search( "#" ) != STRING_NOTFOUND ) {
// between ResTyp, Id and paranthes is a precomp. condition
sCondition = "#";
- sCondition += sId.GetToken( 1, '#' );
- sId = sId.GetToken( 0, '#' );
+ sCondition += ByteString(getToken(sId, 1, '#'));
+ sId = getToken(sId, 0, '#');
}
- sId = sId.GetToken( 0, '/' );
+ sId = getToken(sId, 0, '/');
CleanValue( sId );
sId = sId.EraseAllChars( '\t' );
pResData->SetId( sId, ID_LEVEL_IDENTIFIER );
@@ -779,10 +781,10 @@ int Export::Execute( int nToken, const char * pToken )
case ASSIGNMENT: {
bDontWriteOutput = sal_False;
// interpret different types of assignement
- ByteString sKey = sToken.GetToken( 0, '=' );
+ ByteString sKey = getToken(sToken, 0, '=');
sKey.EraseAllChars( ' ' );
sKey.EraseAllChars( '\t' );
- ByteString sValue = sToken.GetToken( 1, '=' );
+ ByteString sValue = getToken(sToken, 1, '=');
CleanValue( sValue );
if ( sKey.ToUpperAscii() == "IDENTIFIER" ) {
ByteString sId( sValue.EraseAllChars( '\t' ));
@@ -830,7 +832,7 @@ int Export::Execute( int nToken, const char * pToken )
ByteString sKey = sTmpToken.Copy( 0 , nPos );
sKey.EraseAllChars( ' ' );
sKey.EraseAllChars( '\t' );
- ByteString sValue = sToken.GetToken( 1, '=' );
+ ByteString sValue = getToken(sToken, 1, '=');
CleanValue( sValue );
if ( sKey.ToUpperAscii() == "STRINGLIST" ) {
pResData->bList = sal_True;
@@ -872,7 +874,7 @@ int Export::Execute( int nToken, const char * pToken )
}
else {
// new res. is a String- or FilterList
- ByteString sKey = sToken.GetToken( 0, '[' );
+ ByteString sKey = getToken(sToken, 0, '[');
sKey.EraseAllChars( ' ' );
sKey.EraseAllChars( '\t' );
if ( sKey.ToUpperAscii() == "STRINGLIST" )
@@ -886,7 +888,7 @@ int Export::Execute( int nToken, const char * pToken )
else if ( sKey == "UIENTRIES" )
nList = LIST_UIENTRIES;
if ( nList ) {
- ByteString sLang=sToken.GetToken( 1, '[' ).GetToken( 0, ']' );
+ ByteString sLang = getToken(getToken(sToken, 1, '['), 0, ']');
CleanValue( sLang );
m_sListLang = sLang;
nListIndex = 0;
@@ -901,7 +903,7 @@ int Export::Execute( int nToken, const char * pToken )
// this is an entry for a String- or FilterList
if ( nList ) {
SetChildWithText();
- ByteString sEntry( sToken.GetToken( 1, '\"' ));
+ ByteString sEntry(getToken(sToken, 1, '\"'));
if ( sToken.GetTokenCount( '\"' ) > 3 )
sEntry += "\"";
if ( sEntry == "\\\"" )
@@ -921,15 +923,16 @@ int Export::Execute( int nToken, const char * pToken )
CutComment( sToken );
// this is a text line!!!
- ByteString sKey = sToken.GetToken( 0, '=' ).GetToken( 0, '[' );
+ ByteString sKey = getToken(getToken(sToken, 0, '='), 0, '[');
sKey.EraseAllChars( ' ' );
sKey.EraseAllChars( '\t' );
ByteString sText( GetText( sToken, nToken ));
if ( !bMergeMode )
sText = sText.Convert( aCharSet, RTL_TEXTENCODING_MS_1252 );
ByteString sLang;
- if ( sToken.GetToken( 0, '=' ).Search( "[" ) != STRING_NOTFOUND ) {
- sLang = sToken.GetToken( 0, '=' ).GetToken( 1, '[' ).GetToken( 0, ']' );
+ if ( getToken(sToken, 0, '=').indexOf('[') != -1 )
+ {
+ sLang = getToken(getToken(getToken(sToken, 0, '='), 1, '['), 0, ']');
CleanValue( sLang );
}
rtl::OString sLangIndex = sLang;
@@ -1036,15 +1039,14 @@ int Export::Execute( int nToken, const char * pToken )
case APPFONTMAPPING:
{
using comphelper::string::replace;
- using comphelper::string::getToken;
bDontWriteOutput = sal_False;
// this is a AppfontMapping, so look if its a definition
// of field size
- ByteString sKey = sToken.GetToken( 0, '=' );
+ ByteString sKey = getToken(sToken, 0, '=');
sKey.EraseAllChars( ' ' );
sKey.EraseAllChars( '\t' );
- rtl::OString sMapping = sToken.GetToken( 1, '=' );
+ rtl::OString sMapping = getToken(sToken, 1, '=');
sMapping = getToken(sMapping, 1, '(');
sMapping = getToken(sMapping, 0, ')');
sMapping = replace(sMapping, rtl::OString(' '), rtl::OString());
@@ -1067,14 +1069,14 @@ int Export::Execute( int nToken, const char * pToken )
while( sToken.SearchAndReplace( "\r", " " ) != STRING_NOTFOUND ) {};
while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {};
- ByteString sCondition = sToken.GetToken( 0, ' ' );
+ ByteString sCondition = getToken(sToken, 0, ' ');
if ( sCondition == "#ifndef" ) {
sActPForm = "!defined ";
- sActPForm += sToken.GetToken( 1, ' ' );
+ sActPForm += ByteString(getToken(sToken, 1, ' '));
}
else if ( sCondition == "#ifdef" ) {
sActPForm = "defined ";
- sActPForm += sToken.GetToken( 1, ' ' );
+ sActPForm += ByteString(getToken(sToken, 1, ' '));
}
else if ( sCondition == "#if" ) {
sActPForm = sToken.Copy( 4 );
@@ -1114,8 +1116,8 @@ int Export::Execute( int nToken, const char * pToken )
sToken.EraseLeadingChars( ' ' );
sToken.EraseTrailingChars( ' ' );
- ByteString sCharset = sToken.GetToken( 1, ' ' );
- ByteString sSet = sToken.GetToken( 2, ' ' );
+ ByteString sCharset = getToken(sToken, 1, ' ');
+ ByteString sSet = getToken(sToken, 2, ' ');
if (( sCharset.ToUpperAscii() == "CHARSET_IBMPC" ) ||
( sCharset == "RTL_TEXTENCODING_IBM_850" ) ||
(( sCharset == "CHARSET" ) && ( sSet.ToUpperAscii() == "IBMPC" )))
@@ -1324,7 +1326,7 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
}
ByteString Export::GetPairedListID( const ByteString& sText ){
// < "STRING" ; IDENTIFIER ; > ;
- ByteString sIdent = sText.GetToken( 1, ';' );
+ ByteString sIdent = getToken(sText, 1, ';');
sIdent.ToUpperAscii();
while( sIdent.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
sIdent.EraseTrailingChars( ' ' );
@@ -1333,7 +1335,7 @@ ByteString Export::GetPairedListID( const ByteString& sText ){
}
ByteString Export::GetPairedListString( const ByteString& sText ){
// < "STRING" ; IDENTIFIER ; > ;
- ByteString sString = sText.GetToken( 0, ';' );
+ ByteString sString = getToken(sText, 0, ';');
while( sString.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
sString.EraseTrailingChars( ' ' );
ByteString s1 = sString.Copy( sString.Search( '\"' )+1 );
@@ -1603,7 +1605,7 @@ ByteString Export::GetText( const ByteString &rSource, int nToken )
for ( sal_uInt16 i = nStart; i < sTmp.GetTokenCount( '\"' ); i++ ) {
- ByteString sToken = sTmp.GetToken( i, '\"' );
+ ByteString sToken = getToken(sTmp, i, '\"');
if ( sToken.Len()) {
if ( nState == TXT_STATE_TEXT ) {
sReturn += sToken;
diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index d7d39a453511..1494787cadf7 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -39,10 +39,12 @@
#include <iostream>
#include <iomanip>
#include <tools/urlobj.hxx>
+#include <comphelper/string.hxx>
#include <time.h>
#include <stdlib.h>
using namespace std;
+using comphelper::string::getToken;
//
// class ResData();
//
@@ -343,7 +345,7 @@ void Export::InitLanguages( bool bMergeMode ){
ByteString sTmp;
ByteStringBoolHashMap aEnvLangs;
for ( sal_uInt16 x = 0; x < sLanguages.GetTokenCount( ',' ); x++ ){
- sTmp = sLanguages.GetToken( x, ',' ).GetToken( 0, '=' );
+ sTmp = getToken(getToken(sLanguages, x, ','), 0, '=');
sTmp.EraseLeadingAndTrailingChars();
if( bMergeMode && !isAllowed( sTmp ) ){}
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) ){
@@ -360,7 +362,7 @@ void Export::InitForcedLanguages( bool bMergeMode ){
ByteString sTmp;
ByteStringBoolHashMap aEnvLangs;
for ( sal_uInt16 x = 0; x < sForcedLanguages.GetTokenCount( ',' ); x++ ){
- sTmp = sForcedLanguages.GetToken( x, ',' ).GetToken( 0, '=' );
+ sTmp = getToken(getToken(sForcedLanguages, x, ','), 0, '=');
sTmp.EraseLeadingAndTrailingChars();
if( bMergeMode && isAllowed( sTmp ) ){}
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) )
diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index 0b05de086b83..9f1485b6d1c1 100644
--- a/l10ntools/source/gsicheck.cxx
+++ b/l10ntools/source/gsicheck.cxx
@@ -37,6 +37,8 @@
#include "tagtest.hxx"
#include "gsicheck.hxx"
+using comphelper::string::getToken;
+
#define MAX_GID_LID_LEN 250
/*****************************************************************************/
@@ -78,8 +80,8 @@ sal_Bool LanguageOK( ByteString aLang )
return islowerAsciiString(aLang);
else if ( aLang.GetTokenCount( '-' ) == 2 )
{
- ByteString aTok0( aLang.GetToken( 0, '-' ) );
- ByteString aTok1( aLang.GetToken( 1, '-' ) );
+ ByteString aTok0( getToken(aLang, 0, '-') );
+ ByteString aTok1( getToken(aLang, 1, '-') );
return aTok0.Len() && islowerAsciiString(aTok0)
&& aTok1.Len() && isupperAsciiString(aTok1)
&& !aTok1.EqualsIgnoreCaseAscii( aTok0 );
@@ -147,7 +149,7 @@ GSILine::GSILine( const ByteString &rLine, sal_uLong nLine )
if ( rLine.GetTokenCount( '\t' ) == 15 )
{
aFormat = FORMAT_SDF;
- aUniqId = rLine.GetToken( 0, '\t' );
+ aUniqId = getToken(rLine, 0, '\t');
aUniqId.Append("/").Append( rLine.GetToken( 1, '\t' ) ).Append("/").Append( rLine.GetToken( 3, '\t' ) ).Append("/").Append( rLine.GetToken( 4, '\t' ) ).Append("/").Append( rLine.GetToken( 5, '\t' ) ).Append("/").Append( rLine.GetToken( 6, '\t' ) ).Append("/").Append( rLine.GetToken( 7, '\t' ) );
aLineType = "";
aLangId = rLine.GetToken( 9, '\t' );
@@ -468,7 +470,7 @@ sal_Bool GSIBlock::IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uIn
{ // test for old KeyIDs 5 to 6 digits followed by a dot '44373.'
bNewId = sal_False;
nErrorPos = 1;
- aID = aID.GetToken( 0, '.' );
+ aID = getToken(aID, 0, '.');
nAfterID = nAfterID + aID.Len();
}
else
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 6e7019c7bfe4..8b2eee4ad3a3 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -40,7 +40,8 @@
#include <iostream>
#include <fstream>
#include <vector>
-#include "rtl/strbuf.hxx"
+#include <rtl/strbuf.hxx>
+#include <comphelper/string.hxx>
#ifdef WNT
#include <windows.h>
#undef CopyFile
@@ -569,15 +570,15 @@ void HelpParser::MakeDir( const ByteString& sPath ){
ByteString sDelimiter( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US );
sTPath.SearchAndReplaceAll( sDelimiter , '/' );
sal_uInt16 cnt = sTPath.GetTokenCount( '/' );
- ByteString sCreateDir;
+ rtl::OStringBuffer sCreateDir;
for( sal_uInt16 i = 0 ; i < cnt ; i++ )
{
- sCreateDir += sTPath.GetToken( i , '/' );
- sCreateDir += sDelimiter;
+ sCreateDir.append(comphelper::string::getToken(sTPath, i , '/'));
+ sCreateDir.append(sDelimiter);
#ifdef WNT
- _mkdir( sCreateDir.GetBuffer() );
+ _mkdir( sCreateDir.getStr() );
#else
- mkdir( sCreateDir.GetBuffer() , S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
+ mkdir( sCreateDir.getStr() , S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH );
#endif
}
}
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index a9296e3ec841..066fb014ea8d 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -29,11 +29,14 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_l10ntools.hxx"
#include <tools/fsys.hxx>
+#include <comphelper/string.hxx>
-// local includes
#include "lngmerge.hxx"
#include <iostream>
+
using namespace std;
+using comphelper::string::getToken;
+
//
// class LngParser
//
@@ -185,7 +188,7 @@ sal_Bool LngParser::CreateSDF(
sLine_in.EraseTrailingChars( ' ' );
if (( sLine_in.GetChar( 0 ) == '[' ) &&
( sLine_in.GetChar( sLine_in.Len() - 1 ) == ']' )){
- sGroup_out = sLine_in.GetToken( 1, '[' ).GetToken( 0, ']' );
+ sGroup_out = getToken(getToken(sLine_in, 1, '['), 0, ']');
sGroup_out.EraseLeadingChars( ' ' );
sGroup_out.EraseTrailingChars( ' ' );
return true;
@@ -193,10 +196,10 @@ sal_Bool LngParser::CreateSDF(
return false;
}
void LngParser::ReadLine( const ByteString &sLine_in , ByteStringHashMap &rText_inout){
- ByteString sLang = sLine_in.GetToken( 0, '=' );
+ ByteString sLang = getToken(sLine_in, 0, '=');
sLang.EraseLeadingChars( ' ' );
sLang.EraseTrailingChars( ' ' );
- ByteString sText = sLine_in.GetToken( 1, '\"' ).GetToken( 0, '\"' );
+ ByteString sText = getToken(getToken(sLine_in, 1, '\"'), 0, '\"');
if( sLang.Len() )
rText_inout[ sLang ] = sText;
}
@@ -234,7 +237,7 @@ sal_Bool LngParser::Merge(
if (( sLine.GetChar( 0 ) == '[' ) &&
( sLine.GetChar( sLine.Len() - 1 ) == ']' ))
{
- sGroup = sLine.GetToken( 1, '[' ).GetToken( 0, ']' );
+ sGroup = getToken(getToken(sLine, 1, '['), 0, ']');
sGroup.EraseLeadingChars( ' ' );
sGroup.EraseTrailingChars( ' ' );
bGroup = sal_True;
@@ -262,7 +265,7 @@ sal_Bool LngParser::Merge(
if (( sLine.GetChar( 0 ) == '[' ) &&
( sLine.GetChar( sLine.Len() - 1 ) == ']' ))
{
- sGroup = sLine.GetToken( 1, '[' ).GetToken( 0, ']' );
+ sGroup = getToken(getToken(sLine, 1, '['), 0, ']');
sGroup.EraseLeadingChars( ' ' );
sGroup.EraseTrailingChars( ' ' );
bGroup = sal_True;
@@ -270,7 +273,7 @@ sal_Bool LngParser::Merge(
sLanguagesDone = "";
}
else if ( sLine.GetTokenCount( '=' ) > 1 ) {
- ByteString sLang = sLine.GetToken( 0, '=' );
+ ByteString sLang = getToken(sLine, 0, '=');
sLang.EraseLeadingChars( ' ' );
sLang.EraseTrailingChars( ' ' );
@@ -286,7 +289,7 @@ sal_Bool LngParser::Merge(
if( bULF && pEntrys )
{
// this is a valid text line
- ByteString sText = sLine.GetToken( 1, '\"' ).GetToken( 0, '\"' );
+ ByteString sText = getToken(getToken(sLine, 1, '\"'), 0, '\"');
if( sLang.Len() ){
ByteString sNewText;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sLang, sal_True );
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 12ce24323cb9..f196f27e288e 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -30,10 +30,12 @@
#include "precompiled_l10ntools.hxx"
#include <stdio.h>
#include <tools/fsys.hxx>
+#include <comphelper/string.hxx>
#include "export.hxx"
#include <iostream>
using namespace std;
+using comphelper::string::getToken;
namespace
{
@@ -207,7 +209,7 @@ MergeDataFile::MergeDataFile(
if ( nToks == 15 )
{
// Skip all wrong filenames
- const ::rtl::OString filename = lcl_NormalizeFilename(sLine.GetToken( 1 , '\t' ));
+ const ::rtl::OString filename = lcl_NormalizeFilename(getToken(sLine, 1 , '\t'));
if(isFileEmpty || sFileNormalized.equals("") || (!isFileEmpty && filename.equals(sFileNormalized)) )
{
xub_StrLen rIdx = 0;