[Libreoffice-commits] .: l10ntools/source
Stephan Bergmann
sbergmann at kemper.freedesktop.org
Tue Feb 7 02:20:53 PST 2012
l10ntools/source/helper.hxx | 15 ++
l10ntools/source/helpmerge.cxx | 176 ++++++++++++++++------------------
l10ntools/source/lngmerge.cxx | 64 ++++++------
l10ntools/source/localize.cxx | 183 +++++++++++++++++------------------
l10ntools/source/merge.cxx | 13 --
l10ntools/source/xmlparse.cxx | 212 +++++++++++++++++++++++++++--------------
l10ntools/source/xrmmerge.cxx | 203 +++++++++++++++++++--------------------
7 files changed, 473 insertions(+), 393 deletions(-)
New commits:
commit cc3cabd5fd416860de91229a04c918968bf91172
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Tue Feb 7 11:19:48 2012 +0100
Freed l10ntools from tools/string
diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx
index de70c02..27ee642 100644
--- a/l10ntools/source/helper.hxx
+++ b/l10ntools/source/helper.hxx
@@ -71,6 +71,21 @@ inline void searchAndReplaceAll(
}
}
+inline void searchAndReplaceAll(
+ rtl::OUString * text, rtl::OUString const & search,
+ rtl::OUString const & replace)
+{
+ assert(text != 0);
+ for (sal_Int32 i = 0;;) {
+ i = text->indexOf(search, i);
+ if (i == -1) {
+ break;
+ }
+ *text = text->replaceAt(i, search.getLength(), replace);
+ i += replace.getLength();
+ }
+}
+
inline rtl::OString getToken(
rtl::OString const & text, sal_Int32 token, char separator)
{
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 125f266..ff1c7c7 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -26,6 +26,10 @@
*
************************************************************************/
+#include "sal/config.h"
+
+#include <functional>
+
#include <tools/fsys.hxx>
#include <osl/file.hxx>
// local includes
@@ -46,6 +50,8 @@
#include <direct.h>
#endif
+#include "helper.hxx"
+
#if OSL_DEBUG_LEVEL > 2
void HelpParser::Dump(XMLHashMap* rElem_in)
{
@@ -81,34 +87,25 @@ bool HelpParser::CreateSDF(
/*****************************************************************************/
const rtl::OString &rSDFFile_in, const rtl::OString &rPrj_in,const rtl::OString &rRoot_in,
const rtl::OString &sHelpFile, XMLFile *pXmlFile, const rtl::OString &rGsi1){
- // GSI File constants
- static const String GSI_SEQUENCE1( String::CreateFromAscii("\t0\t") );
- static const String GSI_SEQUENCE2( String::CreateFromAscii("\t\t\t0\t") );
- static const String GSI_TAB ( String::CreateFromAscii("\t") );
- static const String GSI_SEQUENCE4( String::CreateFromAscii("\t\t\t\t") );
- static const String ret ( String::CreateFromAscii("\n") );
- static const String ret_char ( String::CreateFromAscii("") );
- static const String tab ( String::CreateFromAscii("\t") );
- static const String tab_char ( String::CreateFromAscii("") );
-
SimpleXMLParser aParser;
- String sUsedTempFile;
- String sXmlFile;
+ rtl::OUString sUsedTempFile;
+ rtl::OUString sXmlFile;
if( Export::fileHasUTF8ByteOrderMarker( sHelpFile ) )
{
DirEntry aTempFile = Export::GetTempFile();
- DirEntry aSourceFile( String( sHelpFile , RTL_TEXTENCODING_ASCII_US ) );
+ DirEntry aSourceFile(
+ rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
- String sTempFile = aTempFile.GetFull();
- Export::RemoveUTF8ByteOrderMarkerFromFile(rtl::OUStringToOString(sTempFile , RTL_TEXTENCODING_ASCII_US));
+ rtl::OUString sTempFile(aTempFile.GetFull());
+ Export::RemoveUTF8ByteOrderMarkerFromFile(
+ rtl::OUStringToOString(sTempFile, RTL_TEXTENCODING_ASCII_US));
sUsedTempFile = sTempFile;
sXmlFile = sTempFile;
}
else
{
- sUsedTempFile = String::CreateFromAscii("");
- sXmlFile = String( sHelpFile , RTL_TEXTENCODING_ASCII_US );
+ sXmlFile = rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US);
}
rtl::OString fullFilePath = rPrj_in;
@@ -131,8 +128,9 @@ bool HelpParser::CreateSDF(
if( !file->CheckExportStatus() ){
return true;
}
- SvFileStream aSDFStream( String( rSDFFile_in, RTL_TEXTENCODING_ASCII_US ),
- STREAM_STD_WRITE | STREAM_TRUNC );
+ SvFileStream aSDFStream(
+ rtl::OStringToOUString(rSDFFile_in, RTL_TEXTENCODING_ASCII_US),
+ STREAM_STD_WRITE | STREAM_TRUNC);
if ( !aSDFStream.IsOpen()) {
fprintf(stdout,"Can't open file %s\n",rSDFFile_in.getStr());
@@ -165,7 +163,7 @@ bool HelpParser::CreateSDF(
{
posm = aXMLStrHM->find( *pos );
pElem = posm->second;
- ByteString sCur;
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ )
{
@@ -175,40 +173,41 @@ bool HelpParser::CreateSDF(
if( pXMLElement != NULL )
{
OUString data = pXMLElement->ToOUString();
- String sTmp = String(data.getStr());
- sTmp.SearchAndReplaceAll(ret,ret_char); // Remove \n
- sTmp.SearchAndReplaceAll(tab,tab_char); // Remove \t
-
- data = OUString( sTmp );
+ helper::searchAndReplaceAll(
+ &data, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n")),
+ rtl::OUString()); // remove \n
+ helper::searchAndReplaceAll(
+ &data, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t")),
+ rtl::OUString()); // remove \t
sBuffer.append( sOUPrj );
- sBuffer.append( GSI_TAB ); //"\t";
+ sBuffer.append('\t');
if ( !rRoot_in.isEmpty())
sBuffer.append( sOUActFileName );
- sBuffer.append( GSI_SEQUENCE1 ); //"\t0\t";
+ sBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\t0\t"));
sBuffer.append( sOUGsi1 ); //"help";
- sBuffer.append( GSI_TAB ); //"\t";
- ByteString sID = posm->first; // ID
- sBuffer.append( OUString( sID.GetBuffer() , sID.Len() , RTL_TEXTENCODING_UTF8 ) );
- sBuffer.append( GSI_TAB ); //"\t";
- ByteString sOldRef = pXMLElement->GetOldref(); // oldref
- sBuffer.append( OUString(sOldRef.GetBuffer() , sOldRef.Len() , RTL_TEXTENCODING_UTF8 ) );
- sBuffer.append( GSI_SEQUENCE2 ); //"\t\t\t0\t";
- sBuffer.append( OUString( sCur.GetBuffer() , sCur.Len() , RTL_TEXTENCODING_UTF8 ) );
- sBuffer.append( GSI_TAB ); //"\t";
+ sBuffer.append('\t');
+ rtl::OString sID = posm->first; // ID
+ sBuffer.append( rtl::OStringToOUString( sID, RTL_TEXTENCODING_UTF8 ) );
+ sBuffer.append('\t');
+ rtl::OString sOldRef = pXMLElement->GetOldref(); // oldref
+ sBuffer.append( rtl::OStringToOUString(sOldRef, RTL_TEXTENCODING_UTF8 ) );
+ sBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\t\t\t0\t"));
+ sBuffer.append( rtl::OStringToOUString( sCur, RTL_TEXTENCODING_UTF8 ) );
+ sBuffer.append('\t');
sBuffer.append( data );
- sBuffer.append( GSI_SEQUENCE4 ); //"\t\t\t\t";
+ sBuffer.appendAscii(RTL_CONSTASCII_STRINGPARAM("\t\t\t\t"));
sBuffer.append( sOUTimeStamp );
rtl::OString sOut(rtl::OUStringToOString(sBuffer.makeStringAndClear().getStr() , RTL_TEXTENCODING_UTF8));
if( !data.isEmpty() )
aSDFStream.WriteLine( sOut );
pXMLElement=NULL;
- }else fprintf(stdout,"\nDBG: NullPointer in HelpParser::CreateSDF , Language %s\n",sCur.GetBuffer() );
+ }else fprintf(stdout,"\nDBG: NullPointer in HelpParser::CreateSDF , Language %s\n",sCur.getStr() );
}
}
aSDFStream.Close();
- if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
+ if( !sUsedTempFile.isEmpty() ){
DirEntry aTempFile( sUsedTempFile );
aTempFile.Kill();
}
@@ -219,12 +218,13 @@ rtl::OString HelpParser::makeAbsolutePath(const rtl::OString& sHelpFile, const r
{
DirEntry aEntry(rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
aEntry.ToAbs();
- String sFullEntry = aEntry.GetFull();
- aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
+ rtl::OUString sFullEntry(aEntry.GetFull());
+ aEntry += DirEntry(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("..")));
aEntry += DirEntry( rRoot_in );
rtl::OString sPrjEntry(rtl::OUStringToOString(aEntry.GetFull(), osl_getThreadTextEncoding()));
rtl::OString sActFileName(rtl::OUStringToOString(
- sFullEntry.Copy(sPrjEntry.getLength() + 1), osl_getThreadTextEncoding()));
+ sFullEntry.copy(sPrjEntry.getLength() + 1),
+ osl_getThreadTextEncoding()));
return sActFileName.replace('/', '\\');
}
@@ -238,54 +238,45 @@ bool HelpParser::Merge( const rtl::OString &rSDFFile, const rtl::OString &rDesti
SimpleXMLParser aParser;
- String sUsedTempFile;
- String sXmlFile;
+ rtl::OUString sUsedTempFile;
+ rtl::OUString sXmlFile;
if( Export::fileHasUTF8ByteOrderMarker( sHelpFile ) ){
DirEntry aTempFile = Export::GetTempFile();
- DirEntry aSourceFile( String( sHelpFile , RTL_TEXTENCODING_ASCII_US ) );
+ DirEntry aSourceFile(
+ rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
- String sTempFile = aTempFile.GetFull();
- Export::RemoveUTF8ByteOrderMarkerFromFile(rtl::OUStringToOString(sTempFile, RTL_TEXTENCODING_ASCII_US));
+ rtl::OUString sTempFile(aTempFile.GetFull());
+ Export::RemoveUTF8ByteOrderMarkerFromFile(
+ rtl::OUStringToOString(sTempFile, RTL_TEXTENCODING_ASCII_US));
sUsedTempFile = sTempFile;
sXmlFile = sTempFile;
}else{
- sUsedTempFile = String::CreateFromAscii("");
- sXmlFile = String( sHelpFile , RTL_TEXTENCODING_ASCII_US );
+ sXmlFile = rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US);
}
OUString sOUHelpFile( sXmlFile );
- String fullFilePath;
DirEntry aFile( sXmlFile );
XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( rtl::OUString('0') ) ) );
hasNoError = MergeSingleFile( xmlfile , aMergeDataFile , rLanguage , rDestinationFile );
delete xmlfile;
- if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
+ if( !sUsedTempFile.isEmpty() ){
DirEntry aTempFile( sUsedTempFile );
aTempFile.Kill();
}
return hasNoError;
}
-bool ByteStringEqual( const ByteString& rKey1, const ByteString& rKey2 ) {
- return rKey1.CompareTo( rKey2 )==COMPARE_EQUAL;
-};
-bool ByteStringLess( const ByteString& rKey1, const ByteString& rKey2 ) {
- return rKey1.CompareTo( rKey2 )==COMPARE_LESS;
-}
-
void HelpParser::parse_languages( std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile ){
std::vector<rtl::OString> aTmp;
- const ByteString ENUS ("en-US");
-
Export::InitLanguages( false );
if (Export::sLanguages.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("ALL")))
{
aLanguages = aMergeDataFile.GetLanguages();
- aLanguages.push_back( ENUS );
+ aLanguages.push_back(rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US")));
if( !Export::sForcedLanguages.isEmpty() )
{
@@ -294,8 +285,8 @@ void HelpParser::parse_languages( std::vector<rtl::OString>& aLanguages , MergeD
aFL.end() ,
back_inserter( aLanguages )
);
- std::sort( aLanguages.begin() , aLanguages.end() , ByteStringLess );
- std::vector<rtl::OString>::iterator unique_iter = std::unique( aLanguages.begin() , aLanguages.end() , ByteStringEqual );
+ std::sort( aLanguages.begin() , aLanguages.end() , std::less< rtl::OString >() );
+ std::vector<rtl::OString>::iterator unique_iter = std::unique( aLanguages.begin() , aLanguages.end() , std::equal_to< rtl::OString >() );
std::copy( aLanguages.begin() , unique_iter , back_inserter( aTmp ) );
aLanguages = aTmp;
}
@@ -315,28 +306,28 @@ bool HelpParser::Merge(
(void) rSDFFile ;
bool hasNoError = true;
SimpleXMLParser aParser;
- String sUsedTempFile;
- String sXmlFile;
+ rtl::OUString sUsedTempFile;
+ rtl::OUString sXmlFile;
if( Export::fileHasUTF8ByteOrderMarker( sHelpFile ) )
{
DirEntry aTempFile = Export::GetTempFile();
- DirEntry aSourceFile( String( sHelpFile , RTL_TEXTENCODING_ASCII_US ) );
+ DirEntry aSourceFile(
+ rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US));
aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
- String sTempFile = aTempFile.GetFull();
- Export::RemoveUTF8ByteOrderMarkerFromFile(rtl::OUStringToOString(sTempFile , RTL_TEXTENCODING_ASCII_US));
+ rtl::OUString sTempFile(aTempFile.GetFull());
+ Export::RemoveUTF8ByteOrderMarkerFromFile(
+ rtl::OUStringToOString(sTempFile , RTL_TEXTENCODING_ASCII_US));
sUsedTempFile = sTempFile;
sXmlFile = sTempFile;
}
else
{
- sUsedTempFile = String::CreateFromAscii("");
- sXmlFile = String( sHelpFile , RTL_TEXTENCODING_ASCII_US );
+ sXmlFile = rtl::OStringToOUString(sHelpFile, RTL_TEXTENCODING_ASCII_US);
}
OUString sOUHelpFile( sXmlFile );
- String fullFilePath;
DirEntry aFile( sXmlFile );
XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( rtl::OUString('0') ) ) );
@@ -349,25 +340,25 @@ bool HelpParser::Merge(
}
- ByteString sCur;
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sFilepath;
+ rtl::OString sFilepath;
if( bISO ) sFilepath = GetOutpath( rPathX , sCur , rPathY );
else sFilepath = rPathX;
if( bCreateDir )
MakeDir(sFilepath);
XMLFile* file = new XMLFile( *xmlfile );
- sFilepath.Append( sHelpFile );
+ sFilepath += sHelpFile;
hasNoError = MergeSingleFile( file , aMergeDataFile , sCur , sFilepath );
delete file;
if( !hasNoError ) return false; // Stop on error
}
- if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) )
+ if( !sUsedTempFile.isEmpty() )
{
DirEntry aTempFile( sUsedTempFile );
aTempFile.Kill();
@@ -404,9 +395,9 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
// Init temp and target file
- ByteString sTempFile;
- ByteString sTargetFile( sPath );
- ByteString sTempFileCopy;
+ rtl::OString sTempFile;
+ rtl::OString sTargetFile( sPath );
+ rtl::OString sTempFileCopy;
static const rtl::OString INPATH = Export::GetEnv("INPATH");
sTempFile = Export::getRandomName(sPath, INPATH);
@@ -432,7 +423,7 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
#endif
if( !Export::CopyFile( sTempFile , sTempFileCopy ) )
{
- cerr << "ERROR: Can not copy file from " << sTempFile.GetBuffer() << " to " << sTempFileCopy.GetBuffer() << "\n";
+ cerr << "ERROR: Can not copy file from " << sTempFile.getStr() << " to " << sTempFileCopy.getStr() << "\n";
return false;
}
}
@@ -440,11 +431,11 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
FileStat aFSTest( aTar );
if( aFSTest.GetSize() < 1 )
{
- remove( sTargetFile.GetBuffer() );
+ remove( sTargetFile.getStr() );
}
int rc;
#if defined(UNX)
- rc = rename( sTempFile.GetBuffer() , sTargetFile.GetBuffer() );
+ rc = rename( sTempFile.getStr() , sTargetFile.getStr() );
#else
rc = MoveFileEx( sTempFile.GetBuffer() , sTargetFile.GetBuffer(), MOVEFILE_REPLACE_EXISTING );
#endif
@@ -467,10 +458,10 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
aFSTest.Update( aTar );
if( aFSTest.GetSize() < 1 )
{
- remove( sTargetFile.GetBuffer() );
+ remove( sTargetFile.getStr() );
}
#if defined(UNX)
- rc = rename( sTempFileCopy.GetBuffer() , sTargetFile.GetBuffer() );
+ rc = rename( sTempFileCopy.getStr() , sTargetFile.getStr() );
#else
rc = MoveFileEx( sTempFileCopy.GetBuffer() , sTargetFile.GetBuffer() , MOVEFILE_REPLACE_EXISTING );
#endif
@@ -486,7 +477,7 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
if( rc < 0 || aFS.GetSize() < 1 )
//#endif
{
- cerr << "ERROR: helpex Can't rename file " << sTempFileCopy.GetBuffer() << " to " << sTargetFile.GetBuffer() << " rename rc=" << rc << " filesize=" << aFS.GetSize() << "\n";
+ cerr << "ERROR: helpex Can't rename file " << sTempFileCopy.getStr() << " to " << sTargetFile.getStr() << " rename rc=" << rc << " filesize=" << aFS.GetSize() << "\n";
aTmp.Kill();
aTmp2.Kill();
if( aFS.GetSize() < 1 )
@@ -502,14 +493,14 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
rtl::OString HelpParser::GetOutpath( const rtl::OString& rPathX , const rtl::OString& sCur , const rtl::OString& rPathY )
{
- ByteString testpath = rPathX;
+ rtl::OString testpath = rPathX;
static const rtl::OString sDelimiter(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
testpath = comphelper::string::stripEnd(testpath, '/');
testpath = comphelper::string::stripEnd(testpath, '\\');
testpath += sDelimiter;
testpath += sCur;
testpath += sDelimiter;
- ByteString sRelativePath( rPathY );
+ rtl::OString sRelativePath( rPathY );
sRelativePath = comphelper::string::stripStart(sRelativePath, '/');
sRelativePath = comphelper::string::stripStart(sRelativePath, '\\');
testpath += sRelativePath;
@@ -544,9 +535,8 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur ,
PFormEntrys *pEntrys = NULL;
XMLData *data = NULL;
- String sNewdata;
- ByteString sLId;
- ByteString sGId;
+ rtl::OString sLId;
+ rtl::OString sGId;
pEntrys = NULL;
@@ -566,8 +556,9 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur ,
{
rtl::OString sNewText;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur , true );
- sNewdata = String( sNewText , RTL_TEXTENCODING_UTF8 );
- if ( sNewdata.Len())
+ rtl::OUString sNewdata(
+ rtl::OStringToOUString(sNewText, RTL_TEXTENCODING_UTF8));
+ if (!sNewdata.isEmpty())
{
if( pXMLElement != NULL )
{
@@ -584,7 +575,8 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur ,
pResData->sGId.getStr(), pResData->sId.getStr(),
pResData->sResTyp.getStr());
}
- pXMLElement->ChangeLanguageTag( String( sCur , RTL_TEXTENCODING_ASCII_US) );
+ pXMLElement->ChangeLanguageTag(
+ rtl::OStringToOUString(sCur, RTL_TEXTENCODING_ASCII_US));
}
}
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index 47e3c6b..fee478f 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -48,10 +48,12 @@ LngParser::LngParser(const rtl::OString &rLngFile, sal_Bool bUTF8,
, bULF( bULFFormat )
{
pLines = new LngLineList();
- DirEntry aEntry( String( sSource, RTL_TEXTENCODING_ASCII_US ));
+ DirEntry aEntry(rtl::OStringToOUString(sSource, RTL_TEXTENCODING_ASCII_US));
if ( aEntry.Exists())
{
- SvFileStream aStream( String( sSource, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
+ SvFileStream aStream(
+ rtl::OStringToOUString(sSource, RTL_TEXTENCODING_ASCII_US),
+ STREAM_STD_READ);
if ( aStream.IsOpen())
{
rtl::OString sLine;
@@ -91,29 +93,31 @@ sal_Bool LngParser::CreateSDF(const rtl::OString &rSDFFile,
Export::InitLanguages( false );
aLanguages = Export::GetLanguages();
- SvFileStream aSDFStream( String( rSDFFile, RTL_TEXTENCODING_ASCII_US ),
- STREAM_STD_WRITE | STREAM_TRUNC );
+ SvFileStream aSDFStream(
+ rtl::OStringToOUString(rSDFFile, RTL_TEXTENCODING_ASCII_US),
+ STREAM_STD_WRITE | STREAM_TRUNC);
if ( !aSDFStream.IsOpen()) {
nError = SDF_COULD_NOT_OPEN;
}
aSDFStream.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
nError = SDF_OK;
- DirEntry aEntry( String( sSource, RTL_TEXTENCODING_ASCII_US ));
+ DirEntry aEntry(rtl::OStringToOUString(sSource, RTL_TEXTENCODING_ASCII_US));
aEntry.ToAbs();
- String sFullEntry = aEntry.GetFull();
- aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
+ rtl::OUString sFullEntry(aEntry.GetFull());
+ aEntry += DirEntry(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("..")));
aEntry += DirEntry( rRoot );
rtl::OString sPrjEntry(rtl::OUStringToOString(aEntry.GetFull(),
osl_getThreadTextEncoding()));
rtl::OString sActFileName(rtl::OUStringToOString(
- sFullEntry.Copy( sPrjEntry.getLength() + 1 ), osl_getThreadTextEncoding()));
+ sFullEntry.copy(sPrjEntry.getLength() + 1),
+ osl_getThreadTextEncoding()));
sActFileName = sActFileName.replace('/', '\\');
size_t nPos = 0;
sal_Bool bStart = true;
rtl::OString sGroup, sLine;
OStringHashMap Text;
- ByteString sID;
+ rtl::OString sID;
while( nPos < pLines->size() ) {
sLine = *(*pLines)[ nPos++ ];
@@ -142,15 +146,15 @@ void LngParser::WriteSDF(SvFileStream &aSDFStream,
sal_Bool bExport = true;
if ( bExport ) {
- ByteString sTimeStamp( Export::GetTimeStamp());
- ByteString sCur;
+ rtl::OString sTimeStamp( Export::GetTimeStamp());
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sAct = rText_inout[ sCur ];
- if ( !sAct.Len() && sCur.Len() )
- sAct = rText_inout[ ByteString("en-US") ];
+ rtl::OString sAct = rText_inout[ sCur ];
+ if ( sAct.isEmpty() && !sCur.isEmpty() )
+ sAct = rText_inout[ rtl::OString("en-US") ];
- ByteString sOutput( rPrj ); sOutput += "\t";
+ rtl::OString sOutput( rPrj ); sOutput += "\t";
if (rRoot.getLength())
sOutput += rActFileName;
sOutput += "\t0\t";
@@ -195,16 +199,16 @@ sal_Bool LngParser::Merge(
{
Export::InitLanguages( true );
SvFileStream aDestination(
- String( rDestinationFile, RTL_TEXTENCODING_ASCII_US ),
- STREAM_STD_WRITE | STREAM_TRUNC );
+ rtl::OStringToOUString(rDestinationFile, RTL_TEXTENCODING_ASCII_US),
+ STREAM_STD_WRITE | STREAM_TRUNC);
if ( !aDestination.IsOpen()) {
nError = LNG_COULD_NOT_OPEN;
}
nError = LNG_OK;
MergeDataFile aMergeDataFile( rSDFFile, sSource, sal_False );
- ByteString sTmp( Export::sLanguages );
- if( sTmp.ToUpperAscii().Equals("ALL") )
+ rtl::OString sTmp( Export::sLanguages );
+ if( sTmp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("ALL")) )
Export::SetLanguages( aMergeDataFile.GetLanguages() );
aLanguages = Export::GetLanguages();
@@ -231,7 +235,7 @@ sal_Bool LngParser::Merge(
while ( nPos < pLines->size()) {
OStringHashMap Text;
- ByteString sID( sGroup );
+ rtl::OString sID( sGroup );
sal_uLong nLastLangPos = 0;
ResData *pResData = new ResData( "", sID , sSource );
@@ -240,7 +244,7 @@ sal_Bool LngParser::Merge(
// read languages
bGroup = sal_False;
- ByteString sLanguagesDone;
+ rtl::OString sLanguagesDone;
while ( nPos < pLines->size() && !bGroup )
{
@@ -259,22 +263,22 @@ sal_Bool LngParser::Merge(
}
else if ( getTokenCount(sLine, '=') > 1 )
{
- ByteString sLang = getToken(sLine, 0, '=');
+ rtl::OString sLang = getToken(sLine, 0, '=');
sLang = comphelper::string::stripStart(sLang, ' ');
sLang = comphelper::string::stripEnd(sLang, ' ');
- ByteString sSearch( ";" );
+ rtl::OString sSearch( ";" );
sSearch += sLang;
sSearch += ";";
- if (( sLanguagesDone.Search( sSearch ) != STRING_NOTFOUND )) {
+ if (( sLanguagesDone.indexOf( sSearch ) != -1 )) {
LngLineList::iterator it = pLines->begin();
::std::advance( it, nPos );
pLines->erase( it );
}
if( bULF && pEntrys )
{
- if( sLang.Len() )
+ if( !sLang.isEmpty() )
{
rtl::OString sNewText;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sLang, sal_True );
@@ -282,7 +286,7 @@ sal_Bool LngParser::Merge(
if ( !sNewText.isEmpty()) {
rtl::OString *pLine = (*pLines)[ nPos ];
- ByteString sText1( sLang );
+ rtl::OString sText1( sLang );
sText1 += " = \"";
sText1 += sNewText;
sText1 += "\"";
@@ -303,21 +307,21 @@ sal_Bool LngParser::Merge(
else
nPos++;
}
- ByteString sCur;
+ rtl::OString sCur;
if ( nLastLangPos )
{
for(size_t n = 0; n < aLanguages.size(); ++n)
{
sCur = aLanguages[ n ];
- if( !sCur.EqualsIgnoreCaseAscii("en-US") && Text[sCur].isEmpty() && pEntrys )
+ if( !sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")) && Text[sCur].isEmpty() && pEntrys )
{
rtl::OString sNewText;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur, sal_True );
if (( !sNewText.isEmpty()) &&
- !(( sCur.Equals("x-comment") ) && ( sNewText == "-" )))
+ !(( sCur.equalsL(RTL_CONSTASCII_STRINGPARAM("x-comment"))) && ( sNewText == "-" )))
{
- ByteString sLine;
+ rtl::OString sLine;
sLine += sCur;
sLine += " = \"";
sLine += sNewText;
diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx
index 5dfd761..8ae73c9 100644
--- a/l10ntools/source/localize.cxx
+++ b/l10ntools/source/localize.cxx
@@ -26,6 +26,7 @@
*
************************************************************************/
+#include "sal/config.h"
#include "srciter.hxx"
#include "export.hxx"
@@ -36,10 +37,7 @@
#include "tools/errcode.hxx"
#include "tools/fsys.hxx"
-#ifndef L10NTOOLS_FILE_HXX
-#define L10NTOOLS_FILE_HXX
-#include <l10ntools/file.hxx>
-#endif
+#include "helper.hxx"
using namespace std;
@@ -178,38 +176,38 @@ private:
SvFileStream aSDF;
sal_uInt16 nMode;
- ByteString sLanguageRestriction;
+ rtl::OString sLanguageRestriction;
- ByteString sOutputFile;
+ rtl::OString sOutputFile;
int nFileCnt;
- const ByteString GetProjectName( sal_Bool bAbs = sal_False );
- const ByteString GetProjectRootRel();
+ const rtl::OString GetProjectName( sal_Bool bAbs = sal_False );
+ const rtl::OString GetProjectRootRel();
- sal_Bool CheckNegativeList( const ByteString &rFileName );
- sal_Bool CheckPositiveList( const ByteString &rFileName );
+ sal_Bool CheckNegativeList( const rtl::OString &rFileName );
+ sal_Bool CheckPositiveList( const rtl::OString &rFileName );
void WorkOnFile(
- const ByteString &rFileName,
- const ByteString &rExecutable,
- const ByteString &rParameter
+ const rtl::OString &rFileName,
+ const rtl::OString &rExecutable,
+ const rtl::OString &rParameter
);
void WorkOnFileType(
- const ByteString &rDirectory,
- const ByteString &rExtension,
- const ByteString &rExecutable,
- const ByteString &rParameter,
- const ByteString &rCollectMode
+ const rtl::OString &rDirectory,
+ const rtl::OString &rExtension,
+ const rtl::OString &rExecutable,
+ const rtl::OString &rParameter,
+ const rtl::OString &rCollectMode
);
void WorkOnDirectory(const rtl::OString &rDirectory);
public:
- SourceTreeLocalizer(const ByteString &rRoot, bool skip_links);
+ SourceTreeLocalizer(const rtl::OString &rRoot, bool skip_links);
~SourceTreeLocalizer();
- void SetLanguageRestriction( const ByteString& rRestrictions )
+ void SetLanguageRestriction( const rtl::OString& rRestrictions )
{ sLanguageRestriction = rRestrictions; }
int getFileCnt();
sal_Bool Extract(const rtl::OString &rDestinationFile);
@@ -217,7 +215,7 @@ public:
virtual void OnExecuteDirectory( const rtl::OUString &rDirectory );
};
-SourceTreeLocalizer::SourceTreeLocalizer(const ByteString &rRoot, bool skip_links)
+SourceTreeLocalizer::SourceTreeLocalizer(const rtl::OString &rRoot, bool skip_links)
: SourceTreeIterator(rRoot)
, nMode( LOCALIZE_NONE )
, nFileCnt( 0 )
@@ -232,7 +230,7 @@ SourceTreeLocalizer::~SourceTreeLocalizer()
}
/*****************************************************************************/
-const ByteString SourceTreeLocalizer::GetProjectName( sal_Bool bAbs )
+const rtl::OString SourceTreeLocalizer::GetProjectName( sal_Bool bAbs )
/*****************************************************************************/
{
sal_Bool bFound = sal_False;
@@ -260,44 +258,44 @@ int SourceTreeLocalizer::GetFileCnt(){
}
/*****************************************************************************/
-const ByteString SourceTreeLocalizer::GetProjectRootRel()
+const rtl::OString SourceTreeLocalizer::GetProjectRootRel()
/*****************************************************************************/
{
- ByteString sProjectRoot( GetProjectName( sal_True ));
+ rtl::OString sProjectRoot( GetProjectName( sal_True ));
DirEntry aCur;
aCur.ToAbs();
- ByteString sCur(rtl::OUStringToOString(aCur.GetFull(), RTL_TEXTENCODING_ASCII_US));
+ rtl::OString sCur(rtl::OUStringToOString(aCur.GetFull(), RTL_TEXTENCODING_ASCII_US));
- if( sCur.SearchAndReplace( sProjectRoot, "" ) == STRING_NOTFOUND )
+ if (helper::searchAndReplace(&sCur, sProjectRoot, rtl::OString()) == -1)
return "";
rtl::OString sDelimiter(rtl::OUStringToOString(
DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
- sCur.SearchAndReplaceAll( sDelimiter, "/" );
+ helper::searchAndReplaceAll(&sCur, sDelimiter, "/");
sCur = comphelper::string::stripStart(sCur, '/');
sal_Int32 nCount = comphelper::string::getTokenCount(sCur, '/');
- ByteString sProjectRootRel;
+ rtl::OString sProjectRootRel;
for (sal_Int32 i = 0; i < nCount; ++i)
{
- if ( sProjectRootRel.Len())
+ if (!sProjectRootRel.isEmpty())
sProjectRootRel += sDelimiter;
sProjectRootRel += "..";
}
- if ( sProjectRootRel.Len())
+ if (!sProjectRootRel.isEmpty())
return sProjectRootRel;
return ".";
}
-bool skipProject( ByteString sPrj )
+bool skipProject( rtl::OString sPrj )
{
int nIndex = 0;
bool bReturn = true;
- ByteString sModule( ModuleList[ nIndex ] );
- while( !sModule.Equals( "NULL" ) && bReturn ) {
- if( sPrj.Equals ( sModule ) )
+ rtl::OString sModule( ModuleList[ nIndex ] );
+ while (!sModule.equalsL(RTL_CONSTASCII_STRINGPARAM("NULL")) && bReturn) {
+ if (sPrj == sModule)
bReturn = false;
nIndex++;
sModule = ModuleList[ nIndex ];
@@ -307,11 +305,12 @@ bool skipProject( ByteString sPrj )
/*****************************************************************************/
void SourceTreeLocalizer::WorkOnFile(
- const ByteString &rFileName, const ByteString &rExecutable,
- const ByteString &rParameter )
+ const rtl::OString &rFileName, const rtl::OString &rExecutable,
+ const rtl::OString &rParameter )
/*****************************************************************************/
{
- String sFull( rFileName, RTL_TEXTENCODING_ASCII_US );
+ rtl::OUString sFull(
+ rtl::OStringToOUString(rFileName, RTL_TEXTENCODING_ASCII_US));
DirEntry aEntry( sFull );
rtl::OString sFileName(rtl::OUStringToOString(aEntry.GetName(), RTL_TEXTENCODING_ASCII_US));
@@ -320,26 +319,26 @@ void SourceTreeLocalizer::WorkOnFile(
DirEntry aOldCWD;
aPath.SetCWD();
- ByteString sPrj( GetProjectName());
- if ( sPrj.Len() && !skipProject( sPrj ) )
+ rtl::OString sPrj( GetProjectName());
+ if (!sPrj.isEmpty() && !skipProject( sPrj ) )
{
- ByteString sRoot( GetProjectRootRel());
+ rtl::OString sRoot( GetProjectRootRel());
DirEntry aTemp( Export::GetTempFile());
rtl::OString sTempFile(rtl::OUStringToOString(aTemp.GetFull(), RTL_TEXTENCODING_ASCII_US));
- ByteString sDel;
+ rtl::OString sDel;
#if defined(WNT)
- sDel=ByteString("\\");
+ sDel=rtl::OString("\\");
#else
- sDel=ByteString("/");
+ sDel=rtl::OString("/");
#endif
- ByteString sPath1( Export::GetEnv("SOLARVER") );
- ByteString sPath2( Export::GetEnv("INPATH_FOR_BUILD") );
- ByteString sPath3( "bin" );
- ByteString sExecutable( sPath1 );
+ rtl::OString sPath1( Export::GetEnv("SOLARVER") );
+ rtl::OString sPath2( Export::GetEnv("INPATH_FOR_BUILD") );
+ rtl::OString sPath3( "bin" );
+ rtl::OString sExecutable( sPath1 );
#if defined(WNT)
- sExecutable.SearchAndReplaceAll( "/", sDel );
+ sExecutable = sExecutable.replace('/', '\\');
#endif
sExecutable += sDel ;
sExecutable += sPath2 ;
@@ -349,7 +348,7 @@ void SourceTreeLocalizer::WorkOnFile(
sExecutable += rExecutable ;
- ByteString sCommand( sExecutable );
+ rtl::OString sCommand( sExecutable );
sCommand += " ";
sCommand += rParameter;
sCommand += " -p ";
@@ -360,14 +359,14 @@ void SourceTreeLocalizer::WorkOnFile(
sCommand += sFileName;
sCommand += " -o ";
sCommand += sTempFile;
- if ( sLanguageRestriction.Len()) {
+ if (!sLanguageRestriction.isEmpty()) {
sCommand += " -l ";
sCommand += sLanguageRestriction;
}
//printf("DBG: %s\n",sCommand.GetBuffer());
- if (system(sCommand.GetBuffer()) == -1)
- fprintf(stderr, "%s failed\n", sCommand.GetBuffer());
+ if (system(sCommand.getStr()) == -1)
+ fprintf(stderr, "%s failed\n", sCommand.getStr());
nFileCnt++;
SvFileStream aSDFIn( aTemp.GetFull(), STREAM_READ );
@@ -388,7 +387,7 @@ void SourceTreeLocalizer::WorkOnFile(
}
/*****************************************************************************/
-sal_Bool SourceTreeLocalizer::CheckNegativeList( const ByteString &rFileName )
+sal_Bool SourceTreeLocalizer::CheckNegativeList( const rtl::OString &rFileName )
/*****************************************************************************/
{
sal_uLong nIndex = 0;
@@ -397,17 +396,19 @@ sal_Bool SourceTreeLocalizer::CheckNegativeList( const ByteString &rFileName )
rtl::OString sDelimiter(rtl::OUStringToOString(
DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
- ByteString sFileName( rFileName );
- sFileName.ToLowerAscii();
+ rtl::OString sFileName(rFileName.toAsciiLowerCase());
- ByteString sNegative( NegativeList[ nIndex ] );
- while( !sNegative.Equals( "NULL" ) && bReturn ) {
- sNegative.SearchAndReplaceAll( "\\", sDelimiter );
- sNegative.SearchAndReplaceAll( "/", sDelimiter );
- sNegative.ToLowerAscii();
+ rtl::OString sNegative( NegativeList[ nIndex ] );
+ while (!sNegative.equalsL(RTL_CONSTASCII_STRINGPARAM("NULL")) && bReturn) {
+ helper::searchAndReplaceAll(&sNegative, "\\", sDelimiter);
+ helper::searchAndReplaceAll(&sNegative, "/", sDelimiter);
+ sNegative = sNegative.toAsciiLowerCase();
- if( sFileName.Search( sNegative ) == sFileName.Len() - sNegative.Len())
- bReturn = sal_False;
+ if (sFileName.indexOf(sNegative)
+ == sFileName.getLength() - sNegative.getLength())
+ {
+ bReturn = false;
+ }
nIndex++;
sNegative = NegativeList[ nIndex ];
@@ -417,7 +418,7 @@ sal_Bool SourceTreeLocalizer::CheckNegativeList( const ByteString &rFileName )
}
/*****************************************************************************/
-sal_Bool SourceTreeLocalizer::CheckPositiveList( const ByteString &rFileName )
+sal_Bool SourceTreeLocalizer::CheckPositiveList( const rtl::OString &rFileName )
/*****************************************************************************/
{
sal_uLong nIndex = 0;
@@ -426,17 +427,19 @@ sal_Bool SourceTreeLocalizer::CheckPositiveList( const ByteString &rFileName )
rtl::OString sDelimiter(rtl::OUStringToOString(
DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
- ByteString sFileName( rFileName );
- sFileName.ToLowerAscii();
+ rtl::OString sFileName(rFileName.toAsciiLowerCase());
- ByteString sNegative( PositiveList[ nIndex ] );
- while( !sNegative.Equals( "NULL" ) && !bReturn ) {
- sNegative.SearchAndReplaceAll( "\\", sDelimiter );
- sNegative.SearchAndReplaceAll( "/", sDelimiter );
- sNegative.ToLowerAscii();
+ rtl::OString sNegative( PositiveList[ nIndex ] );
+ while (!sNegative.equalsL(RTL_CONSTASCII_STRINGPARAM("NULL")) && !bReturn) {
+ helper::searchAndReplaceAll(&sNegative, "\\", sDelimiter);
+ helper::searchAndReplaceAll(&sNegative, "/", sDelimiter);
+ sNegative = sNegative.toAsciiLowerCase();
- if( sFileName.Search( sNegative ) == sFileName.Len() - sNegative.Len())
- bReturn = sal_True;
+ if (sFileName.indexOf(sNegative)
+ == sFileName.getLength() - sNegative.getLength())
+ {
+ bReturn = true;
+ }
nIndex++;
sNegative = PositiveList[ nIndex ];
@@ -447,19 +450,19 @@ sal_Bool SourceTreeLocalizer::CheckPositiveList( const ByteString &rFileName )
/*****************************************************************************/
void SourceTreeLocalizer::WorkOnFileType(
- const ByteString &rDirectory, const ByteString &rExtension,
- const ByteString &rExecutable, const ByteString &rParameter,
- const ByteString &rCollectMode
+ const rtl::OString &rDirectory, const rtl::OString &rExtension,
+ const rtl::OString &rExecutable, const rtl::OString &rParameter,
+ const rtl::OString &rCollectMode
)
/*****************************************************************************/
{
- String sWild( rDirectory, RTL_TEXTENCODING_ASCII_US );
+ rtl::OUString sWild(
+ rtl::OStringToOUString(rDirectory, RTL_TEXTENCODING_ASCII_US));
sWild += DirEntry::GetAccessDelimiter();
- sWild += String::CreateFromAscii( "*." );
- sWild += String( rExtension, RTL_TEXTENCODING_ASCII_US );
+ sWild += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("*."));
+ sWild += rtl::OStringToOUString(rExtension, RTL_TEXTENCODING_ASCII_US);
- DirEntry aEntry( sWild );
- Dir aDir( sWild, FSYS_KIND_FILE );
+ Dir aDir(DirEntry(sWild), FSYS_KIND_FILE);
for ( sal_uInt16 i = 0; i < aDir.Count(); i++ )
{
@@ -468,9 +471,9 @@ void SourceTreeLocalizer::WorkOnFileType(
sal_Bool bAllowed = sal_True;
- if ( rCollectMode.Equals( "negative" ))
+ if (rCollectMode.equalsL(RTL_CONSTASCII_STRINGPARAM("negative")))
bAllowed = CheckNegativeList( sFile );
- else if ( rCollectMode.Equals( "positive" ))
+ else if (rCollectMode.equalsL(RTL_CONSTASCII_STRINGPARAM("positive")))
bAllowed = CheckPositiveList( sFile );
if ( bAllowed )
@@ -482,12 +485,12 @@ void SourceTreeLocalizer::WorkOnDirectory(const rtl::OString &rDirectory)
{
//printf("Working on Directory %s\n",rDirectory.getStr());
sal_uLong nIndex = 0;
- ByteString sExtension( ExeTable[ nIndex ][ 0 ] );
- ByteString sExecutable( ExeTable[ nIndex ][ 1 ] );
- ByteString sParameter( ExeTable[ nIndex ][ 2 ] );
- ByteString sCollectMode( ExeTable[ nIndex ][ 3 ] );
+ rtl::OString sExtension( ExeTable[ nIndex ][ 0 ] );
+ rtl::OString sExecutable( ExeTable[ nIndex ][ 1 ] );
+ rtl::OString sParameter( ExeTable[ nIndex ][ 2 ] );
+ rtl::OString sCollectMode( ExeTable[ nIndex ][ 3 ] );
- while( !sExtension.Equals( "NULL" )) {
+ while (!sExtension.equalsL(RTL_CONSTASCII_STRINGPARAM("NULL"))) {
WorkOnFileType(
rDirectory,
sExtension,
@@ -573,7 +576,7 @@ int _cdecl main( int argc, char *argv[] )
#endif
/*****************************************************************************/
{
- String sTempBase( String::CreateFromAscii( "loc" ));
+ rtl::OUString sTempBase(RTL_CONSTASCII_USTRINGPARAM("loc"));
DirEntry::SetTempNameBase( sTempBase );
bool bSkipLinks = false;
@@ -591,14 +594,14 @@ int _cdecl main( int argc, char *argv[] )
DirEntry aEntry(rtl::OStringToOUString(sFileName, RTL_TEXTENCODING_ASCII_US));
aEntry.ToAbs();
- String sFullEntry = aEntry.GetFull();
+ rtl::OUString sFullEntry(aEntry.GetFull());
rtl::OString sFileABS(rtl::OUStringToOString(aEntry.GetFull(), osl_getThreadTextEncoding()));
sFileName = sFileABS;
string pwd;
Export::getCurrentDir( pwd );
cout << "Localizing directory " << pwd << "\n";
- SourceTreeLocalizer aIter( ByteString( pwd.c_str() ) , bSkipLinks );
+ SourceTreeLocalizer aIter( rtl::OString( pwd.c_str() ) , bSkipLinks );
aIter.SetLanguageRestriction( sLanguages );
aIter.Extract( sFileName );
printf("\n%d files found!\n",aIter.GetFileCnt());
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index 9f02125..75b0d55 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -47,8 +47,6 @@ namespace
};
}
-extern void ConvertHalfwitdhToFullwidth( String& rString );
-
//
// class PFormEntrys
//
@@ -157,15 +155,8 @@ PFormEntrys* MergeData::GetPFObject( const rtl::OString& rPFO )
sal_Bool MergeData::operator==( ResData *pData )
{
- ByteString sResTyp_upper( pData->sResTyp );
- sResTyp_upper.ToUpperAscii();
- ByteString sTyp_upper( sTyp );
- sTyp_upper.ToUpperAscii();
-
- return (( pData->sId == sLID ) &&
- ( pData->sGId == sGID ) &&
- ( sResTyp_upper == sTyp_upper )
- );
+ return pData->sId == sLID && pData->sGId == sGID
+ && pData->sResTyp.equalsIgnoreAsciiCase(sTyp);
}
//
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 7b4fead..50096c7 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -165,14 +165,11 @@ int XMLParentNode::RemoveChild( XMLElement *pRefElement )
XMLChildNode *pChild = (*pChildList)[ i ];
if ( pChild->GetNodeType() == XML_NODE_TYPE_ELEMENT ){
a = static_cast<XMLElement* >(pChild);
- ByteString elemid( a->GetId() );
- elemid.ToLowerAscii();
- ByteString elemLID( a->GetLanguageId() );
- elemLID.ToLowerAscii();
- ByteString pRefLID( pRefElement->GetLanguageId() );
- pRefLID.ToLowerAscii();
- if ( elemid.Equals(pRefElement->GetId())
- && elemLID.Equals( pRefLID ) )
+ rtl::OString elemid(a->GetId().toAsciiLowerCase());
+ rtl::OString elemLID(a->GetLanguageId().toAsciiLowerCase());
+ rtl::OString pRefLID(
+ pRefElement->GetLanguageId().toAsciiLowerCase());
+ if (elemid == pRefElement->GetId() && elemLID == pRefLID)
{
if( pRefElement->ToOString().compareTo( a->ToOString() )==0 ){
XMLChildNodeList::iterator it = pChildList->begin();
@@ -402,7 +399,7 @@ void XMLFile::Print( XMLNode *pCur, sal_uInt16 nLevel )
break;
case XML_NODE_TYPE_DATA: {
XMLData *pData = ( XMLData * ) pCur;
- String sData = pData->GetData();
+ rtl::OUString sData = pData->GetData();
fprintf( stdout, "%s", rtl::OUStringToOString(sData, RTL_TEXTENCODING_UTF8).getStr());
}
break;
@@ -468,17 +465,17 @@ void XMLFile::Extract( XMLFile *pCur )
/*****************************************************************************/
void XMLFile::InsertL10NElement( XMLElement* pElement ){
/*****************************************************************************/
- ByteString tmpStr,id,oldref,language("");
+ rtl::OString tmpStr,id,oldref,language("");
LangHashMap* elem;
if( pElement->GetAttributeList() != NULL ){
for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ )
{
tmpStr=rtl::OUStringToOString((*pElement->GetAttributeList())[ j ]->GetName(), RTL_TEXTENCODING_UTF8);
- if( tmpStr.CompareTo(ID)==COMPARE_EQUAL ){ // Get the "id" Attribute
+ if (tmpStr == ID) { // Get the "id" Attribute
id = rtl::OUStringToOString((*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8);
}
- if( tmpStr.CompareTo( XML_LANG ) == COMPARE_EQUAL ){ // Get the "xml-lang" Attribute
+ if (tmpStr == XML_LANG) { // Get the "xml-lang" Attribute
language = rtl::OUStringToOString((*pElement->GetAttributeList())[j]->GetValue(),RTL_TEXTENCODING_UTF8);
}
@@ -500,7 +497,7 @@ void XMLFile::InsertL10NElement( XMLElement* pElement ){
elem=pos->second;
if ( (*elem)[ language ] )
{
- fprintf(stdout,"Error: Duplicated entry. ID = %s LANG = %s in File %s\n", id.GetBuffer(), language.GetBuffer(), rtl::OUStringToOString(sFullName, RTL_TEXTENCODING_ASCII_US).getStr() );
+ fprintf(stdout,"Error: Duplicated entry. ID = %s LANG = %s in File %s\n", id.getStr(), language.getStr(), rtl::OUStringToOString(sFullName, RTL_TEXTENCODING_ASCII_US).getStr() );
exit( -1 );
}
(*elem)[ language ]=pElement;
@@ -557,8 +554,8 @@ XMLFile& XMLFile::operator=(const XMLFile& obj){
void XMLFile::SearchL10NElements( XMLParentNode *pCur , int pos)
/*****************************************************************************/
{
- static const ByteString LOCALIZE("localize");
- static const ByteString THEID("id");
+ static const rtl::OString LOCALIZE("localize");
+ static const rtl::OString THEID("id");
bool bInsert = true;
if ( !pCur )
SearchL10NElements( this );
@@ -577,27 +574,27 @@ void XMLFile::SearchL10NElements( XMLParentNode *pCur , int pos)
case XML_NODE_TYPE_ELEMENT: {
XMLElement *pElement = ( XMLElement * ) pCur;
rtl::OString sName(rtl::OUStringToOString(pElement->GetName(), RTL_TEXTENCODING_ASCII_US).toAsciiLowerCase());
- ByteString language,tmpStrVal,oldref;
+ rtl::OString language,tmpStrVal,oldref;
if ( pElement->GetAttributeList())
{
for ( size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; ++j )
{
- const ByteString tmpStr = rtl::OUStringToOString((*pElement->GetAttributeList())[j]->GetName(), RTL_TEXTENCODING_UTF8);
- if( tmpStr.CompareTo(THEID)==COMPARE_EQUAL ){ // Get the "id" Attribute
+ const rtl::OString tmpStr = rtl::OUStringToOString((*pElement->GetAttributeList())[j]->GetName(), RTL_TEXTENCODING_UTF8);
+ if (tmpStr == THEID) { // Get the "id" Attribute
tmpStrVal=rtl::OUStringToOString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
}
- if( tmpStr.CompareTo(LOCALIZE)==COMPARE_EQUAL ){ // Get the "localize" Attribute
+ if (tmpStr == LOCALIZE) { // Get the "localize" Attribute
bInsert=false;
}
- if( tmpStr.CompareTo(XML_LANG)==COMPARE_EQUAL ){ // Get the "xml-lang" Attribute
+ if (tmpStr == XML_LANG) { // Get the "xml-lang" Attribute
language=rtl::OUStringToOString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
}
- if( tmpStr.CompareTo(OLDREF)==COMPARE_EQUAL ){ // Get the "oldref" Attribute
+ if (tmpStr == OLDREF) { // Get the "oldref" Attribute
oldref=rtl::OUStringToOString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
}
}
pElement->SetLanguageId ( language );
- pElement->SetId ( tmpStrVal.GetBuffer() );
+ pElement->SetId(tmpStrVal);
pElement->SetOldRef ( oldref );
pElement->SetPos( pos );
}
@@ -628,7 +625,7 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur )
/*****************************************************************************/
{
static bool bStatusExport = true;
- const ByteString LOCALIZE("localize");
+ const rtl::OString LOCALIZE("localize");
const rtl::OString STATUS(RTL_CONSTASCII_STRINGPARAM("status"));
const rtl::OString PUBLISH(RTL_CONSTASCII_STRINGPARAM("PUBLISH"));
const rtl::OString DEPRECATED(RTL_CONSTASCII_STRINGPARAM("DEPRECATED"));
@@ -834,7 +831,7 @@ OUString XMLElement::ToOUString(){
OUStringBuffer* buffer = new OUStringBuffer();
Print(this,*buffer,true);
OUString result=buffer->makeStringAndClear();
- String xy(result.getStr());
+ rtl::OUString xy(result.getStr());
result=OUString(xy);
delete buffer;
return result;
@@ -898,7 +895,7 @@ void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement
break;
case XML_NODE_TYPE_DATA: {
XMLData *pData = ( XMLData * ) pCur;
- String sData = pData->GetData();
+ rtl::OUString sData = pData->GetData();
buffer.append( sData );
}
break;
@@ -1083,7 +1080,7 @@ void SimpleXMLParser::StartElement(
const XML_Char *name, const XML_Char **atts )
/*****************************************************************************/
{
- String sElementName = String( XML_CHAR_TO_OUSTRING( name ));
+ rtl::OUString sElementName = rtl::OUString( XML_CHAR_TO_OUSTRING( name ));
XMLElement *pElement = new XMLElement( sElementName, ( XMLParentNode * ) pCurNode );
pCurNode = pElement;
pCurData = NULL;
@@ -1091,8 +1088,8 @@ void SimpleXMLParser::StartElement(
int i = 0;
while( atts[i] ) {
pElement->AddAttribute(
- String( XML_CHAR_TO_OUSTRING( atts[ i ] )),
- String( XML_CHAR_TO_OUSTRING( atts[ i + 1 ] )));
+ rtl::OUString( XML_CHAR_TO_OUSTRING( atts[ i ] )),
+ rtl::OUString( XML_CHAR_TO_OUSTRING( atts[ i + 1 ] )));
i += 2;
}
}
@@ -1133,7 +1130,7 @@ void SimpleXMLParser::Comment(
/*****************************************************************************/
{
pCurData = NULL;
- new XMLComment( String( XML_CHAR_TO_OUSTRING( data )), pCurNode );
+ new XMLComment( rtl::OUString( XML_CHAR_TO_OUSTRING( data )), pCurNode );
}
/*****************************************************************************/
@@ -1143,7 +1140,7 @@ void SimpleXMLParser::Default(
{
pCurData = NULL;
new XMLDefault(
- String( XML_CHAR_N_TO_OUSTRING( s, len )), pCurNode );
+ rtl::OUString( XML_CHAR_N_TO_OUSTRING( s, len )), pCurNode );
}
/*****************************************************************************/
@@ -1153,7 +1150,8 @@ XMLFile *SimpleXMLParser::Execute( const rtl::OUString &rFullFileName , const rt
aErrorInformation.eCode = XML_ERROR_NONE;
aErrorInformation.nLine = 0;
aErrorInformation.nColumn = 0;
- aErrorInformation.sMessage = String::CreateFromAscii( "ERROR: Unable to open file " );
+ aErrorInformation.sMessage = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("ERROR: Unable to open file "));
aErrorInformation.sMessage += rFileName;
SvFileStream aStream( rFileName, STREAM_STD_READ );
@@ -1179,7 +1177,7 @@ XMLFile *SimpleXMLParser::Execute( SvMemoryStream *pStream )
/*****************************************************************************/
{
if ( !pXMLFile )
- pXMLFile = new XMLFile( String());
+ pXMLFile = new XMLFile(rtl::OUString());
pCurNode = pXMLFile;
pCurData = NULL;
@@ -1191,12 +1189,15 @@ XMLFile *SimpleXMLParser::Execute( SvMemoryStream *pStream )
aErrorInformation.nLine = 0;
aErrorInformation.nColumn = 0;
if ( !pXMLFile->GetName().isEmpty()) {
- aErrorInformation.sMessage = String::CreateFromAscii( "File " );
+ aErrorInformation.sMessage = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("File "));
aErrorInformation.sMessage += pXMLFile->GetName();
- aErrorInformation.sMessage += String::CreateFromAscii( " parsed successfully" );
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(" parsed successfully"));
}
else
- aErrorInformation.sMessage = String::CreateFromAscii( "XML-File parsed successfully" );
+ aErrorInformation.sMessage = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("XML-File parsed successfully"));
if ( !XML_Parse(
aParser, ( char * ) pStream->GetData() + nPos, pStream->Tell() - nPos, sal_True ))
@@ -1205,44 +1206,115 @@ XMLFile *SimpleXMLParser::Execute( SvMemoryStream *pStream )
aErrorInformation.nLine = XML_GetErrorLineNumber( aParser );
aErrorInformation.nColumn = XML_GetErrorColumnNumber( aParser );
- aErrorInformation.sMessage = String::CreateFromAscii( "ERROR: " );
+ aErrorInformation.sMessage = rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("ERROR: "));
if ( !pXMLFile->GetName().isEmpty())
aErrorInformation.sMessage += pXMLFile->GetName();
else
- aErrorInformation.sMessage += String::CreateFromAscii( "XML-File" );
- aErrorInformation.sMessage += String::CreateFromAscii( " (" );
- aErrorInformation.sMessage += String::CreateFromInt64( aErrorInformation.nLine );
- aErrorInformation.sMessage += String::CreateFromAscii( "," );
- aErrorInformation.sMessage += String::CreateFromInt64( aErrorInformation.nColumn );
- aErrorInformation.sMessage += String::CreateFromAscii( "): " );
-
- switch( aErrorInformation.eCode ) {
- case XML_ERROR_NO_MEMORY: aErrorInformation.sMessage += String::CreateFromAscii( "No memory" ); break;
- case XML_ERROR_SYNTAX: aErrorInformation.sMessage += String::CreateFromAscii( "Syntax" ); break;
- case XML_ERROR_NO_ELEMENTS: aErrorInformation.sMessage += String::CreateFromAscii( "No elements" ); break;
- case XML_ERROR_INVALID_TOKEN: aErrorInformation.sMessage += String::CreateFromAscii( "Invalid token" ); break;
- case XML_ERROR_UNCLOSED_TOKEN: aErrorInformation.sMessage += String::CreateFromAscii( "Unclosed token" ); break;
- case XML_ERROR_PARTIAL_CHAR: aErrorInformation.sMessage += String::CreateFromAscii( "Partial char" ); break;
- case XML_ERROR_TAG_MISMATCH: aErrorInformation.sMessage += String::CreateFromAscii( "Tag mismatch" ); break;
- case XML_ERROR_DUPLICATE_ATTRIBUTE: aErrorInformation.sMessage += String::CreateFromAscii( "Dublicat attribute" ); break;
- case XML_ERROR_JUNK_AFTER_DOC_ELEMENT: aErrorInformation.sMessage += String::CreateFromAscii( "Junk after doc element" ); break;
- case XML_ERROR_PARAM_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Param entity ref" ); break;
- case XML_ERROR_UNDEFINED_ENTITY: aErrorInformation.sMessage += String::CreateFromAscii( "Undefined entity" ); break;
- case XML_ERROR_RECURSIVE_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Recursive entity ref" ); break;
- case XML_ERROR_ASYNC_ENTITY: aErrorInformation.sMessage += String::CreateFromAscii( "Async_entity" ); break;
- case XML_ERROR_BAD_CHAR_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Bad char ref" ); break;
- case XML_ERROR_BINARY_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Binary entity" ); break;
- case XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: aErrorInformation.sMessage += String::CreateFromAscii( "Attribute external entity ref" ); break;
- case XML_ERROR_MISPLACED_XML_PI: aErrorInformation.sMessage += String::CreateFromAscii( "Misplaced xml pi" ); break;
- case XML_ERROR_UNKNOWN_ENCODING: aErrorInformation.sMessage += String::CreateFromAscii( "Unknown encoding" ); break;
- case XML_ERROR_INCORRECT_ENCODING: aErrorInformation.sMessage += String::CreateFromAscii( "Incorrect encoding" ); break;
- case XML_ERROR_UNCLOSED_CDATA_SECTION: aErrorInformation.sMessage += String::CreateFromAscii( "Unclosed cdata section" ); break;
- case XML_ERROR_EXTERNAL_ENTITY_HANDLING: aErrorInformation.sMessage += String::CreateFromAscii( "External entity handling" ); break;
- case XML_ERROR_NOT_STANDALONE: aErrorInformation.sMessage += String::CreateFromAscii( "Not standalone" ); break;
- case XML_ERROR_NONE: break;
- default:
- break;
-
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("XML-File ("));
+ aErrorInformation.sMessage += rtl::OUString::valueOf(
+ sal::static_int_cast< sal_Int64 >(aErrorInformation.nLine));
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM(","));
+ aErrorInformation.sMessage += rtl::OUString::valueOf(
+ sal::static_int_cast< sal_Int64 >(aErrorInformation.nColumn));
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("): "));
+
+ switch (aErrorInformation.eCode) {
+ case XML_ERROR_NO_MEMORY:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("No memory"));
+ break;
+ case XML_ERROR_SYNTAX:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Syntax"));
+ break;
+ case XML_ERROR_NO_ELEMENTS:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("No elements"));
+ break;
+ case XML_ERROR_INVALID_TOKEN:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Invalid token"));
+ break;
+ case XML_ERROR_UNCLOSED_TOKEN:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Unclosed token"));
+ break;
+ case XML_ERROR_PARTIAL_CHAR:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Partial char"));
+ break;
+ case XML_ERROR_TAG_MISMATCH:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Tag mismatch"));
+ break;
+ case XML_ERROR_DUPLICATE_ATTRIBUTE:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Dublicat attribute"));
+ break;
+ case XML_ERROR_JUNK_AFTER_DOC_ELEMENT:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Junk after doc element"));
+ break;
+ case XML_ERROR_PARAM_ENTITY_REF:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Param entity ref"));
+ break;
+ case XML_ERROR_UNDEFINED_ENTITY:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Undefined entity"));
+ break;
+ case XML_ERROR_RECURSIVE_ENTITY_REF:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Recursive entity ref"));
+ break;
+ case XML_ERROR_ASYNC_ENTITY:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Async_entity"));
+ break;
+ case XML_ERROR_BAD_CHAR_REF:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Bad char ref"));
+ break;
+ case XML_ERROR_BINARY_ENTITY_REF:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Binary entity"));
+ break;
+ case XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Attribute external entity ref"));
+ break;
+ case XML_ERROR_MISPLACED_XML_PI:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Misplaced xml pi"));
+ break;
+ case XML_ERROR_UNKNOWN_ENCODING:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Unknown encoding"));
+ break;
+ case XML_ERROR_INCORRECT_ENCODING:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Incorrect encoding"));
+ break;
+ case XML_ERROR_UNCLOSED_CDATA_SECTION:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Unclosed cdata section"));
+ break;
+ case XML_ERROR_EXTERNAL_ENTITY_HANDLING:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("External entity handling"));
+ break;
+ case XML_ERROR_NOT_STANDALONE:
+ aErrorInformation.sMessage += rtl::OUString(
+ RTL_CONSTASCII_USTRINGPARAM("Not standalone"));
+ break;
+ case XML_ERROR_NONE:
+ break;
+ default:
+ break;
}
delete pXMLFile;
pXMLFile = NULL;
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index a3d605d..b8d40c4 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -26,9 +26,10 @@
*
************************************************************************/
+#include "sal/config.h"
+
#include <comphelper/string.hxx>
#include <stdio.h>
-#include <tools/string.hxx>
#include <tools/fsys.hxx>
// local includes
@@ -62,15 +63,15 @@ sal_Bool bErrorLog;
sal_Bool bUTF8;
sal_Bool bDisplayName;
sal_Bool bExtensionDescription;
-ByteString sPrj;
-ByteString sPrjRoot;
-ByteString sInputFileName;
-ByteString sActFileName;
-ByteString sOutputFile;
-ByteString sMergeSrc;
-ByteString sLangAttribute;
-ByteString sResourceType;
-String sUsedTempFile;
+rtl::OString sPrj;
+rtl::OString sPrjRoot;
+rtl::OString sInputFileName;
+rtl::OString sActFileName;
+rtl::OString sOutputFile;
+rtl::OString sMergeSrc;
+rtl::OString sLangAttribute;
+rtl::OString sResourceType;
+rtl::OUString sUsedTempFile;
XRMResParser *pParser = NULL;
extern "C" {
@@ -96,26 +97,26 @@ extern char *GetOutputFile( int argc, char* argv[])
// parse command line
for( int i = 1; i < argc; i++ ) {
- if ( ByteString( argv[ i ] ).ToUpperAscii() == "-I" ) {
+ if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-I" ) {
nState = STATE_INPUT; // next token specifies source file
}
- else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-O" ) {
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-O" ) {
nState = STATE_OUTPUT; // next token specifies the dest file
}
- else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-P" ) {
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-P" ) {
nState = STATE_PRJ; // next token specifies the cur. project
}
- else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-R" ) {
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-R" ) {
nState = STATE_ROOT; // next token specifies path to project root
}
- else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-M" ) {
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-M" ) {
nState = STATE_MERGESRC; // next token specifies the merge database
}
- else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-E" ) {
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-E" ) {
nState = STATE_ERRORLOG;
bErrorLog = sal_False;
}
- else if ( ByteString( argv[ i ] ).ToUpperAscii() == "-L" ) {
+ else if ( rtl::OString( argv[ i ] ).toAsciiUpperCase() == "-L" ) {
nState = STATE_LANGUAGES;
}
else {
@@ -133,20 +134,20 @@ extern char *GetOutputFile( int argc, char* argv[])
}
break;
case STATE_PRJ: {
- sPrj = ByteString( argv[ i ]);
+ sPrj = rtl::OString( argv[ i ]);
}
break;
case STATE_ROOT: {
- sPrjRoot = ByteString( argv[ i ]); // path to project root
+ sPrjRoot = rtl::OString( argv[ i ]); // path to project root
}
break;
case STATE_MERGESRC: {
- sMergeSrc = ByteString( argv[ i ]);
+ sMergeSrc = rtl::OString( argv[ i ]);
bMergeMode = sal_True; // activate merge mode, cause merge database found
}
break;
case STATE_LANGUAGES: {
- Export::sLanguages = ByteString( argv[ i ]);
+ Export::sLanguages = rtl::OString( argv[ i ]);
}
break;
}
@@ -156,8 +157,8 @@ extern char *GetOutputFile( int argc, char* argv[])
if ( bInput ) {
// command line is valid
bEnableExport = sal_True;
- char *pReturn = new char[ sOutputFile.Len() + 1 ];
- strcpy( pReturn, sOutputFile.GetBuffer()); // #100211# - checked
+ char *pReturn = new char[ sOutputFile.getLength() + 1 ];
+ strcpy( pReturn, sOutputFile.getStr()); // #100211# - checked
return pReturn;
}
@@ -165,7 +166,7 @@ extern char *GetOutputFile( int argc, char* argv[])
return NULL;
}
void removeTempFile(){
- if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
+ if (!sUsedTempFile.isEmpty()) {
DirEntry aTempFile( sUsedTempFile );
aTempFile.Kill();
}
@@ -175,13 +176,13 @@ int InitXrmExport( char *pOutput , char* pFilename)
/*****************************************************************************/
{
// instanciate Export
- ByteString sOutput( pOutput );
- ByteString sFilename( pFilename );
+ rtl::OString sOutput( pOutput );
+ rtl::OString sFilename( pFilename );
Export::InitLanguages( false );
if ( bMergeMode )
pParser = new XRMResMerge( sMergeSrc, sOutputFile, sFilename );
- else if ( sOutputFile.Len()) {
+ else if (!sOutputFile.isEmpty()) {
pParser = new XRMResExport( sOutputFile, sPrj, sActFileName );
}
@@ -197,7 +198,7 @@ int EndXrmExport()
}
extern const char* getFilename()
{
- return sInputFileName.GetBuffer();
+ return sInputFileName.getStr();
}
/*****************************************************************************/
extern FILE *GetXrmFile()
@@ -205,31 +206,31 @@ extern FILE *GetXrmFile()
{
FILE *pFile = 0;
// look for valid filename
- if ( sInputFileName.Len()) {
+ if (!sInputFileName.isEmpty()) {
if( Export::fileHasUTF8ByteOrderMarker( sInputFileName ) ){
DirEntry aTempFile = Export::GetTempFile();
- DirEntry aSourceFile( String( sInputFileName , RTL_TEXTENCODING_ASCII_US ) );
+ DirEntry aSourceFile( rtl::OStringToOUString( sInputFileName , RTL_TEXTENCODING_ASCII_US ) );
aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
- String sTempFile = aTempFile.GetFull();
+ rtl::OUString sTempFile = aTempFile.GetFull();
Export::RemoveUTF8ByteOrderMarkerFromFile(rtl::OUStringToOString(sTempFile , RTL_TEXTENCODING_ASCII_US) );
pFile = fopen(rtl::OUStringToOString(sTempFile , RTL_TEXTENCODING_ASCII_US).getStr(), "r");
sUsedTempFile = sTempFile;
}else{
// able to open file?
- pFile = fopen( sInputFileName.GetBuffer(), "r" );
- sUsedTempFile = String::CreateFromAscii("");
+ pFile = fopen(sInputFileName.getStr(), "r");
+ sUsedTempFile = rtl::OUString();
}
if ( !pFile ){
fprintf( stderr, "Error: Could not open file %s\n",
- sInputFileName.GetBuffer());
+ sInputFileName.getStr());
}
else {
// this is a valid file which can be opened, so
// create path to project root
- DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
+ DirEntry aEntry( rtl::OStringToOUString( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
aEntry.ToAbs();
rtl::OString sFullEntry(rtl::OUStringToOString(aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US));
- aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
+ aEntry += DirEntry(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("..")));
aEntry += DirEntry( sPrjRoot );
rtl::OString sPrjEntry(rtl::OUStringToOString(aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US));
@@ -238,7 +239,7 @@ extern FILE *GetXrmFile()
sActFileName = sFullEntry.copy(sPrjEntry.getLength() + 1);
- sActFileName.SearchAndReplaceAll( "/", "\\" );
+ sActFileName = sActFileName.replace('/', '\\');
return pFile;
}
@@ -299,7 +300,7 @@ XRMResParser::~XRMResParser()
int XRMResParser::Execute( int nToken, char * pToken )
/*****************************************************************************/
{
- ByteString rToken( pToken );
+ rtl::OString rToken( pToken );
switch ( nToken ) {
case XRM_TEXT_START:{
@@ -316,14 +317,14 @@ int XRMResParser::Execute( int nToken, char * pToken )
case XRM_TEXT_END: {
sCurrentCloseTag = rToken;
- sResourceType = ByteString ( "readmeitem" );
- sLangAttribute = ByteString ( "xml:lang" );
+ sResourceType = rtl::OString ( "readmeitem" );
+ sLangAttribute = rtl::OString ( "xml:lang" );
WorkOnText( sCurrentOpenTag, sCurrentText );
Output( sCurrentText );
EndOfText( sCurrentOpenTag, sCurrentCloseTag );
bText = sal_False;
- rToken = ByteString("");
- sCurrentText = ByteString("");
+ rToken = rtl::OString("");
+ sCurrentText = rtl::OString("");
}
break;
@@ -339,7 +340,7 @@ int XRMResParser::Execute( int nToken, char * pToken )
case DESC_TEXT_START:{
if (bDisplayName) {
- sLID = ByteString("dispname");
+ sLID = rtl::OString("dispname");
bText = sal_True;
sCurrentText = "";
sCurrentOpenTag = rToken;
@@ -351,14 +352,14 @@ int XRMResParser::Execute( int nToken, char * pToken )
case DESC_TEXT_END: {
if (bDisplayName) {
sCurrentCloseTag = rToken;
- sResourceType = ByteString ( "description" );
- sLangAttribute = ByteString ( "lang" );
+ sResourceType = rtl::OString ( "description" );
+ sLangAttribute = rtl::OString ( "lang" );
WorkOnText( sCurrentOpenTag, sCurrentText );
Output( sCurrentText );
EndOfText( sCurrentOpenTag, sCurrentCloseTag );
bText = sal_False;
- rToken = ByteString("");
- sCurrentText = ByteString("");
+ rToken = rtl::OString("");
+ sCurrentText = rtl::OString("");
}
}
break;
@@ -375,17 +376,17 @@ int XRMResParser::Execute( int nToken, char * pToken )
case DESC_EXTENSION_DESCRIPTION_SRC: {
if (bExtensionDescription) {
- sLID = ByteString("extdesc");
- sResourceType = ByteString ( "description" );
- sLangAttribute = ByteString ( "lang" );
+ sLID = rtl::OString("extdesc");
+ sResourceType = rtl::OString ( "description" );
+ sLangAttribute = rtl::OString ( "lang" );
sCurrentOpenTag = rToken;
- sCurrentText = ByteString("");
+ sCurrentText = rtl::OString("");
Output( rToken );
WorkOnDesc( sCurrentOpenTag, sCurrentText );
sCurrentCloseTag = rToken;
Output( sCurrentText );
- rToken = ByteString("");
- sCurrentText = ByteString("");
+ rToken = rtl::OString("");
+ sCurrentText = rtl::OString("");
}
}
break;
@@ -408,18 +409,18 @@ int XRMResParser::Execute( int nToken, char * pToken )
rtl::OString XRMResParser::GetAttribute( const rtl::OString &rToken, const rtl::OString &rAttribute )
/*****************************************************************************/
{
- ByteString sTmp( rToken );
- sTmp.SearchAndReplaceAll( "\t", " " );
+ rtl::OString sTmp( rToken );
+ sTmp = sTmp.replace('\t', ' ');
- ByteString sSearch( " " );
+ rtl::OString sSearch( " " );
sSearch += rAttribute;
sSearch += "=";
- sal_uInt16 nPos = sTmp.Search( sSearch );
+ sal_Int32 nPos = sTmp.indexOf( sSearch );
- if ( nPos != STRING_NOTFOUND )
+ if ( nPos != -1 )
{
- sTmp = sTmp.Copy( nPos );
- ByteString sId = comphelper::string::getToken(sTmp, 1, '\"');
+ sTmp = sTmp.copy( nPos );
+ rtl::OString sId = comphelper::string::getToken(sTmp, 1, '\"');
return sId;
}
return "";
@@ -468,12 +469,12 @@ XRMResOutputParser::XRMResOutputParser ( const rtl::OString &rOutputFile )
aLanguages = Export::GetLanguages();
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( "Unable to open output file: " );
+ rtl::OString sError( "Unable to open output file: " );
sError += rOutputFile;
Error( sError );
delete pOutputStream;
@@ -524,14 +525,14 @@ void XRMResExport::WorkOnDesc(
)
/*****************************************************************************/
{
- DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
+ DirEntry aEntry( rtl::OStringToOUString( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
aEntry.ToAbs();
- ByteString sDescFileName(rtl::OUStringToOString(aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US));
- sDescFileName.SearchAndReplaceAll( "description.xml", "" );
+ rtl::OString sDescFileName(rtl::OUStringToOString(aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US));
+ helper::searchAndReplaceAll(&sDescFileName, "description.xml", "");
sDescFileName += GetAttribute( rOpenTag, "xlink:href" );
int size;
char * memblock;
- ifstream file (sDescFileName.GetBuffer(), ios::in|ios::binary|ios::ate);
+ ifstream file (sDescFileName.getStr(), ios::in|ios::binary|ios::ate);
if (file.is_open()) {
size = static_cast<int>(file.tellg());
memblock = new char [size+1];
@@ -539,7 +540,7 @@ void XRMResExport::WorkOnDesc(
file.read (memblock, size);
file.close();
memblock[size] = '\0';
- rText = ByteString(memblock);
+ rText = rtl::OString(memblock);
helper::searchAndReplaceAll(&rText, "\n", "\\n");
delete[] memblock;
}
@@ -554,11 +555,11 @@ void XRMResExport::WorkOnText(
)
/*****************************************************************************/
{
- ByteString sLang( GetAttribute( rOpenTag, sLangAttribute ));
+ rtl::OString sLang( GetAttribute( rOpenTag, sLangAttribute ));
if ( !pResData )
{
- ByteString sPlatform( "" );
+ rtl::OString sPlatform( "" );
pResData = new ResData( sPlatform, GetGID() );
pResData->sId = GetLID();
}
@@ -577,8 +578,8 @@ void XRMResExport::EndOfText(
{
if ( pResData && pOutputStream )
{
- ByteString sTimeStamp( Export::GetTimeStamp());
- ByteString sCur;
+ rtl::OString sTimeStamp( Export::GetTimeStamp());
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ )
{
sCur = aLanguages[ n ];
@@ -586,7 +587,7 @@ void XRMResExport::EndOfText(
rtl::OString sAct = pResData->sText[ sCur ];
sAct = comphelper::string::remove(sAct, 0x0A);
- ByteString sOutput( sPrj ); sOutput += "\t";
+ rtl::OString sOutput( sPrj ); sOutput += "\t";
sOutput += sPath;
sOutput += "\t0\t";
sOutput += sResourceType;
@@ -604,8 +605,7 @@ void XRMResExport::EndOfText(
sOutput += "\t\t\t\t";
sOutput += sTimeStamp;
- sal_Char cSearch = 0x00;
- sOutput.SearchAndReplaceAll( cSearch, '_' );
+ sOutput = sOutput.replace('\0', '_');
if( sAct.getLength() > 1 )
pOutputStream->WriteLine( sOutput );
}
@@ -659,49 +659,51 @@ void XRMResMerge::WorkOnDesc(
if ( pMergeDataFile && pResData ) {
PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
if ( pEntrys ) {
- ByteString sCur;
- ByteString sDescFilename = GetAttribute ( rOpenTag, "xlink:href" );
+ rtl::OString sCur;
+ rtl::OString sDescFilename = GetAttribute ( rOpenTag, "xlink:href" );
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
rtl::OString sContent;
- if ( !sCur.EqualsIgnoreCaseAscii("en-US") &&
+ if ( !sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")) &&
( pEntrys->GetText(
sContent, STRING_TYP_TEXT, sCur, sal_True )) &&
( sContent != "-" ) && !sContent.isEmpty())
{
- ByteString sText( sContent );
- ByteString sAdditionalLine( "\n " );
+ rtl::OString sText( sContent );
+ rtl::OString sAdditionalLine( "\n " );
sAdditionalLine += rOpenTag;
- ByteString sSearch = sLangAttribute;
+ rtl::OString sSearch = sLangAttribute;
sSearch += "=\"";
- ByteString sReplace( sSearch );
+ rtl::OString sReplace( sSearch );
sSearch += GetAttribute( rOpenTag, sLangAttribute );
sReplace += sCur;
- sAdditionalLine.SearchAndReplace( sSearch, sReplace );
+ helper::searchAndReplace(
+ &sAdditionalLine, sSearch, sReplace);
- sSearch = ByteString("xlink:href=\"");
+ sSearch = rtl::OString("xlink:href=\"");
sReplace = sSearch;
- ByteString sLocDescFilename = sDescFilename;
- sLocDescFilename.SearchAndReplace( "en-US", sCur );
+ rtl::OString sLocDescFilename = sDescFilename;
+ helper::searchAndReplace(&sLocDescFilename, "en-US", sCur);
sSearch += sDescFilename;
sReplace += sLocDescFilename;
- sAdditionalLine.SearchAndReplace( sSearch, sReplace );
+ helper::searchAndReplace(
+ &sAdditionalLine, sSearch, sReplace);
Output( sAdditionalLine );
- DirEntry aEntry( String( sOutputFile, RTL_TEXTENCODING_ASCII_US ));
+ DirEntry aEntry( rtl::OStringToOUString( sOutputFile, RTL_TEXTENCODING_ASCII_US ));
aEntry.ToAbs();
- ByteString sOutputDescFile(rtl::OUStringToOString(aEntry.GetPath().GetFull(), RTL_TEXTENCODING_ASCII_US));
+ rtl::OString sOutputDescFile(rtl::OUStringToOString(aEntry.GetPath().GetFull(), RTL_TEXTENCODING_ASCII_US));
rtl::OString sDel(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
sOutputDescFile += sDel;
sOutputDescFile += sLocDescFilename;
- sText.SearchAndReplaceAll( "\\n", "\n" );
- ofstream file ( sOutputDescFile.GetBuffer() );
+ helper::searchAndReplaceAll(&sText, "\\n", "\n");
+ ofstream file(sOutputDescFile.getStr());
if (file.is_open()) {
- file << sText.GetBuffer();
+ file << sText.getStr();
file.close();
}
}
@@ -719,11 +721,11 @@ void XRMResMerge::WorkOnText(
)
/*****************************************************************************/
{
- ByteString sLang( GetAttribute( rOpenTag, sLangAttribute ));
+ rtl::OString sLang( GetAttribute( rOpenTag, sLangAttribute ));
if ( pMergeDataFile ) {
if ( !pResData ) {
- ByteString sPlatform( "" );
+ rtl::OString sPlatform( "" );
pResData = new ResData( sPlatform, GetLID() , sFilename );
pResData->sId = GetLID();
pResData->sResTyp = sResourceType;
@@ -766,26 +768,27 @@ void XRMResMerge::EndOfText(
if ( pMergeDataFile && pResData ) {
PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
if ( pEntrys ) {
- ByteString sCur;
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
rtl::OString sContent;
- if ( !sCur.EqualsIgnoreCaseAscii("en-US") &&
+ if (!sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")) &&
( pEntrys->GetText(
sContent, STRING_TYP_TEXT, sCur, sal_True )) &&
( sContent != "-" ) && !sContent.isEmpty())
{
- ByteString sText( sContent );
- ByteString sAdditionalLine( "\n " );
+ rtl::OString sText( sContent );
+ rtl::OString sAdditionalLine( "\n " );
sAdditionalLine += rOpenTag;
- ByteString sSearch = sLangAttribute;
+ rtl::OString sSearch = sLangAttribute;
sSearch += "=\"";
- ByteString sReplace( sSearch );
+ rtl::OString sReplace( sSearch );
sSearch += GetAttribute( rOpenTag, sLangAttribute );
sReplace += sCur;
- sAdditionalLine.SearchAndReplace( sSearch, sReplace );
+ helper::searchAndReplace(
+ &sAdditionalLine, sSearch, sReplace);
sAdditionalLine += sText;
sAdditionalLine += rCloseTag;
More information about the Libreoffice-commits
mailing list