summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2012-02-02 09:11:38 +0100
committerStephan Bergmann <sbergman@redhat.com>2012-02-02 09:22:07 +0100
commite521a240601c6a2b9f9448db73c09181fed2247d (patch)
treea878cdcf1b551491edc64551c2fd24888906b123 /l10ntools
parent54d278ae5feea82d105e4bd11d554ad5fcb41099 (diff)
Reduced tools/string usage
plus some preliminary cfgex clean up.
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/inc/cfgmerge.hxx29
-rw-r--r--l10ntools/inc/export.hxx79
-rw-r--r--l10ntools/inc/gsicheck.hxx47
-rw-r--r--l10ntools/inc/helpmerge.hxx20
-rw-r--r--l10ntools/inc/lngmerge.hxx4
-rw-r--r--l10ntools/inc/xmlparse.hxx53
-rw-r--r--l10ntools/source/cfglex.l100
-rw-r--r--l10ntools/source/cfgmerge.cxx546
-rw-r--r--l10ntools/source/export.cxx247
-rw-r--r--l10ntools/source/export2.cxx89
-rw-r--r--l10ntools/source/gsicheck.cxx152
-rw-r--r--l10ntools/source/helper.hxx70
-rw-r--r--l10ntools/source/helpex.cxx2
-rw-r--r--l10ntools/source/helpmerge.cxx42
-rw-r--r--l10ntools/source/lngmerge.cxx16
-rw-r--r--l10ntools/source/merge.cxx14
-rw-r--r--l10ntools/source/xmlparse.cxx72
-rw-r--r--l10ntools/source/xrmmerge.cxx12
18 files changed, 760 insertions, 834 deletions
diff --git a/l10ntools/inc/cfgmerge.hxx b/l10ntools/inc/cfgmerge.hxx
index d85271536660..bd0627e876f0 100644
--- a/l10ntools/inc/cfgmerge.hxx
+++ b/l10ntools/inc/cfgmerge.hxx
@@ -29,11 +29,10 @@
#ifndef _CFG_MERGE_HXX
#define _CFG_MERGE_HXX
-#include <tools/string.hxx>
#include <boost/unordered_map.hpp>
#include <vector>
-typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> ByteStringHashMap;
+typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> OStringHashMap;
//
@@ -54,7 +53,7 @@ private:
rtl::OString sTextTag;
rtl::OString sEndTextTag;
- ByteStringHashMap sText;
+ OStringHashMap sText;
public:
CfgStackData(const rtl::OString &rTag, const rtl::OString &rId)
: sTagType( rTag ), sIdentifier( rId )
@@ -106,7 +105,7 @@ class CfgParser
protected:
rtl::OString sCurrentResTyp;
rtl::OString sCurrentIsoLang;
- ByteString sCurrentText;
+ rtl::OString sCurrentText;
rtl::OString sLastWhitespace;
@@ -116,7 +115,7 @@ protected:
sal_Bool bLocalize;
virtual void WorkOnText(
- ByteString &rText,
+ rtl::OString &rText,
const rtl::OString &rLangIndex )=0;
virtual void WorkOnRessourceEnd()=0;
@@ -129,9 +128,9 @@ private:
int ExecuteAnalyzedToken( int nToken, char *pToken );
std::vector<rtl::OString> aLanguages;
void AddText(
- ByteString &rText,
- const ByteString &rIsoLang,
- const ByteString &rResTyp );
+ rtl::OString &rText,
+ const rtl::OString &rIsoLang,
+ const rtl::OString &rResTyp );
sal_Bool IsTokenClosed(const rtl::OString &rToken);
@@ -162,12 +161,12 @@ public:
class CfgExport : public CfgOutputParser
{
private:
- ByteString sPrj;
- ByteString sPath;
+ rtl::OString sPrj;
+ rtl::OString sPath;
std::vector<rtl::OString> aLanguages;
protected:
virtual void WorkOnText(
- ByteString &rText,
+ rtl::OString &rText,
const rtl::OString &rIsoLang
);
@@ -175,9 +174,9 @@ protected:
void Output(const rtl::OString& rOutput);
public:
CfgExport(
- const ByteString &rOutputFile,
- const ByteString &rProject,
- const ByteString &rFilePath
+ const rtl::OString &rOutputFile,
+ const rtl::OString &rProject,
+ const rtl::OString &rFilePath
);
~CfgExport();
};
@@ -197,7 +196,7 @@ private:
sal_Bool bEnglish;
protected:
- virtual void WorkOnText(ByteString &rText, const rtl::OString &rLangIndex);
+ virtual void WorkOnText(rtl::OString &rText, const rtl::OString &rLangIndex);
void WorkOnRessourceEnd();
diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index e0fcf058fe1e..d8e3c963aa3e 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -29,6 +29,8 @@
#ifndef _EXPORT_HXX
#define _EXPORT_HXX
+#include "sal/config.h"
+
#include <comphelper/string.hxx>
#ifndef L10NTOOLS_DIRECTORY_HXX
@@ -36,7 +38,6 @@
#include <l10ntools/directory.hxx>
#endif
-#include <tools/string.hxx>
#include <tools/stream.hxx>
#include <tools/fsys.hxx>
#include <osl/file.hxx>
@@ -58,13 +59,12 @@
class PFormEntrys;
class MergeData;
-typedef std::set<rtl::OString> ByteStringSet;
typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash>
- ByteStringHashMap;
+ OStringHashMap;
typedef boost::unordered_map<rtl::OString, bool, rtl::OStringHash>
- ByteStringBoolHashMap;
+ OStringBoolHashMap;
typedef boost::unordered_map<rtl::OString, PFormEntrys*, rtl::OStringHash>
PFormEntrysHashMap;
@@ -75,7 +75,7 @@ typedef boost::unordered_map<rtl::OString, MergeData*, rtl::OStringHash>
#define SOURCE_LANGUAGE rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))
#define LIST_REFID "LIST_REFID"
-typedef ByteStringHashMap ExportListEntry;
+typedef OStringHashMap ExportListEntry;
typedef ::std::vector< ExportListEntry* > ExportListBase;
//
@@ -145,16 +145,16 @@ public:
rtl::OString sHelpId;
rtl::OString sFilename;
- ByteStringHashMap sText;
+ OStringHashMap sText;
sal_uInt16 nTextRefId;
- ByteStringHashMap sHelpText;
+ OStringHashMap sHelpText;
sal_uInt16 nHelpTextRefId;
- ByteStringHashMap sQuickHelpText;
+ OStringHashMap sQuickHelpText;
sal_uInt16 nQuickHelpTextRefId;
- ByteStringHashMap sTitle;
+ OStringHashMap sTitle;
sal_uInt16 nTitleRefId;
rtl::OString sTextTyp;
@@ -267,7 +267,7 @@ private:
ResStack aResStack; // stack for parsing recursive
- ByteString sActPForm; // hold cur. system
+ rtl::OString sActPForm; // hold cur. system
sal_Bool bDefine; // cur. res. in a define?
sal_Bool bNextMustBeDefineEOL; // define but no \ at lineend
@@ -277,18 +277,18 @@ private:
sal_uLong nListIndex;
sal_uLong nListLevel;
bool bSkipFile;
- ByteString sProject;
- ByteString sRoot;
+ rtl::OString sProject;
+ rtl::OString sRoot;
sal_Bool bEnableExport;
sal_Bool bMergeMode;
- ByteString sMergeSrc;
- ByteString sLastListLine;
+ rtl::OString sMergeSrc;
+ rtl::OString sLastListLine;
sal_Bool bError; // any errors while export?
sal_Bool bReadOver;
sal_Bool bDontWriteOutput;
- ByteString sLastTextTyp;
+ rtl::OString sLastTextTyp;
static bool isInitialized;
- ByteString sFilename;
+ rtl::OString sFilename;
public:
@@ -296,8 +296,6 @@ public:
static rtl::OString sLanguages; // public ?
static rtl::OString sForcedLanguages; // public ?
-
- static bool skipProject( ByteString sPrj ) ;
static void InitLanguages( bool bMergeMode = false );
static void InitForcedLanguages( bool bMergeMode = false );
static std::vector<rtl::OString> GetLanguages();
@@ -308,10 +306,10 @@ public:
static bool hasUTF8ByteOrderMarker( const rtl::OString &rString );
static void RemoveUTF8ByteOrderMarkerFromFile(const rtl::OString &rFilename);
static bool fileHasUTF8ByteOrderMarker(const rtl::OString &rString);
- static void QuotHTML( ByteString &rString );
+ static rtl::OString QuoteHTML( rtl::OString const &rString );
static bool CopyFile(const rtl::OString& rSource , const rtl::OString& rDest);
- static void UnquotHTML( ByteString &rString );
+ static rtl::OString UnquoteHTML( rtl::OString const &rString );
static const char* GetEnv( const char *pVar );
@@ -323,14 +321,14 @@ public:
static void getCurrentDir( std::string& dir );
static rtl::OString GetTimeStamp();
- static sal_Bool ConvertLineEnds( ByteString sSource, ByteString sDestination );
- static ByteString GetNativeFile( ByteString sSource );
+ static sal_Bool ConvertLineEnds( rtl::OString const & sSource, rtl::OString const & sDestination );
+ static rtl::OString GetNativeFile( rtl::OString const & sSource );
static DirEntry GetTempFile();
static void DumpExportList(const rtl::OString& rListName,
ExportList& aList);
static void DumpMap(const rtl::OString& rMapName,
- ByteStringHashMap& aMap);
+ OStringHashMap& aMap);
private:
static std::vector<rtl::OString> aLanguages;
@@ -340,7 +338,7 @@ private:
sal_Bool WriteExportList( ResData *pResData, ExportList *pExportList,
const rtl::OString &rTyp, sal_Bool bCreateNew = sal_False );
- ByteString MergePairedList( ByteString& sLine , ByteString& sText );
+ rtl::OString MergePairedList( rtl::OString const & sLine , rtl::OString const & sText );
rtl::OString FullId(); // creates cur. GID
@@ -349,19 +347,19 @@ private:
rtl::OString StripList(const rtl::OString& rText);
void InsertListEntry(const rtl::OString &rText, const rtl::OString &rLine);
- void CleanValue( ByteString &rValue );
+ void CleanValue( rtl::OString &rValue );
rtl::OString GetText(const rtl::OString &rSource, int nToken);
- sal_Bool PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
+ sal_Bool PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
rtl::OString &rLangIndex, ResData *pResData);
void MergeRest( ResData *pResData, sal_uInt16 nMode = MERGE_MODE_NORMAL );
- void ConvertMergeContent( ByteString &rText );
+ void ConvertMergeContent( rtl::OString &rText );
void WriteToMerged(const rtl::OString &rText , bool bSDFContent);
void SetChildWithText();
- void CutComment( ByteString &rText );
+ void CutComment( rtl::OString &rText );
public:
Export(const rtl::OString &rOutput, sal_Bool bWrite,
@@ -386,20 +384,21 @@ public:
* Purpose: holds information of data to merge (one pform)
******************************************************************************/
-class PFormEntrys : public ByteString
+class PFormEntrys
{
friend class MergeDataFile;
private:
- ByteString sHelpText; // empty string
- ByteStringHashMap sText;
- ByteStringBoolHashMap bTextFirst;
- ByteStringHashMap sQuickHelpText;
- ByteStringBoolHashMap bQuickHelpTextFirst;
- ByteStringHashMap sTitle;
- ByteStringBoolHashMap bTitleFirst;
+ rtl::OString data_; //TODO
+ rtl::OString sHelpText; // empty string
+ OStringHashMap sText;
+ OStringBoolHashMap bTextFirst;
+ OStringHashMap sQuickHelpText;
+ OStringBoolHashMap bQuickHelpTextFirst;
+ OStringHashMap sTitle;
+ OStringBoolHashMap bTitleFirst;
public:
- PFormEntrys( const ByteString &rPForm ) : ByteString( rPForm ) {};
+ PFormEntrys( const rtl::OString &rPForm ) : data_( rPForm ) {};
rtl::OString Dump();
void InsertEntry(const rtl::OString &rId, const rtl::OString &rText,
const rtl::OString &rQuickHelpText, const rtl::OString &rTitle)
@@ -412,8 +411,8 @@ public:
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 );
+ sal_Bool GetText( rtl::OString &rReturn, sal_uInt16 nTyp, const rtl::OString &nLangIndex, sal_Bool bDel = sal_False );
+ sal_Bool GetTransex3Text( rtl::OString &rReturn, sal_uInt16 nTyp, const rtl::OString &nLangIndex, sal_Bool bDel = sal_False );
};
@@ -461,7 +460,7 @@ class MergeDataFile
{
private:
sal_Bool bErrorLog;
- ByteString sErrorLog;
+ rtl::OString sErrorLog;
SvFileStream aErrLog;
MergeDataHashMap aMap;
std::set<rtl::OString> aLanguageSet;
diff --git a/l10ntools/inc/gsicheck.hxx b/l10ntools/inc/gsicheck.hxx
index 2915c693ddad..3a6fc547d670 100644
--- a/l10ntools/inc/gsicheck.hxx
+++ b/l10ntools/inc/gsicheck.hxx
@@ -37,20 +37,19 @@
//
enum LineFormat { FORMAT_SDF, FORMAT_UNKNOWN };
-class GSILine : public ByteString
+class GSILine
{
private:
-
ParserMessageList aMessages;
LineFormat aFormat;
sal_uLong nLineNumber;
- ByteString aUniqId;
- ByteString aLineType;
- ByteString aLangId;
- ByteString aText;
- ByteString aQuickHelpText;
- ByteString aTitle;
+ rtl::OString aUniqId;
+ rtl::OString aLineType;
+ rtl::OString aLangId;
+ rtl::OString aText;
+ rtl::OString aQuickHelpText;
+ rtl::OString aTitle;
sal_Bool bOK;
sal_Bool bFixed;
@@ -58,22 +57,24 @@ private:
void ReassembleLine();
public:
- GSILine( const ByteString &rLine, sal_uLong nLine );
+ rtl::OString data_;
+
+ GSILine( const rtl::OString &rLine, sal_uLong nLine );
LineFormat GetLineFormat() const { return aFormat; }
sal_uLong GetLineNumber() const { return nLineNumber; }
- ByteString const GetUniqId() const { return aUniqId; }
- ByteString const GetLineType() const { return aLineType; }
- ByteString const GetLanguageId() const { return aLangId; }
- ByteString const GetText() const { return aText; }
- String const GetUText() const { return String( aText, RTL_TEXTENCODING_UTF8 ); }
- ByteString const GetQuickHelpText() const { return aQuickHelpText; }
- ByteString const GetTitle() const { return aTitle; }
+ rtl::OString const GetUniqId() const { return aUniqId; }
+ rtl::OString const GetLineType() const { return aLineType; }
+ rtl::OString const GetLanguageId() const { return aLangId; }
+ rtl::OString const GetText() const { return aText; }
+ rtl::OUString const GetUText() const { return rtl::OStringToOUString( aText, RTL_TEXTENCODING_UTF8 ); }
+ rtl::OString const GetQuickHelpText() const { return aQuickHelpText; }
+ rtl::OString const GetTitle() const { return aTitle; }
void SetUText( String &aNew ) { aText = rtl::OUStringToOString(aNew, RTL_TEXTENCODING_UTF8); ReassembleLine(); }
- void SetText( ByteString &aNew ) { aText = aNew; ReassembleLine(); }
- void SetQuickHelpText( ByteString &aNew ) { aQuickHelpText = aNew; ReassembleLine(); }
- void SetTitle( ByteString &aNew ) { aTitle = aNew; ReassembleLine(); }
+ void SetText( rtl::OString const &aNew ) { aText = aNew; ReassembleLine(); }
+ void SetQuickHelpText( rtl::OString const &aNew ) { aQuickHelpText = aNew; ReassembleLine(); }
+ void SetTitle( rtl::OString const &aNew ) { aTitle = aNew; ReassembleLine(); }
ParserMessageList* GetMessageList() { return &aMessages; };
sal_Bool HasMessages(){ return ( aMessages.size() > 0 ); };
@@ -99,7 +100,7 @@ private:
GSIBlock_Impl maList;
GSILine *pSourceLine;
GSILine *pReferenceLine;
- void PrintList( ParserMessageList *pList, ByteString aPrefix, GSILine *pLine );
+ void PrintList( ParserMessageList *pList, rtl::OString const & aPrefix, GSILine *pLine );
sal_Bool bPrintContext;
sal_Bool bCheckSourceLang;
sal_Bool bCheckTranslationLang;
@@ -108,15 +109,15 @@ private:
sal_Bool bHasBlockError;
- sal_Bool IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, ByteString &aErrorMsg, sal_Bool &bHasBeenFixed, ByteString &aFixed ) const;
+ sal_Bool IsUTF8( const rtl::OString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, rtl::OString &aErrorMsg, sal_Bool &bHasBeenFixed, rtl::OString &aFixed ) const;
sal_Bool TestUTF8( GSILine* pTestee, sal_Bool bFixTags );
sal_Bool HasSuspiciousChars( GSILine* pTestee, GSILine* pSource );
public:
GSIBlock( sal_Bool PbPrintContext, sal_Bool bSource, sal_Bool bTrans, sal_Bool bRef, sal_Bool bAllowSusp );
~GSIBlock();
- void PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() );
- void PrintError( ByteString aMsg, ByteString aPrefix, ByteString aContext, sal_uLong nLine, ByteString aUniqueId = ByteString() );
+ void PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix, rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId = rtl::OString() );
+ void PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix, rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId = rtl::OString() );
void InsertLine( GSILine* pLine, const rtl::OString &rSourceLang);
void SetReferenceLine( GSILine* pLine );
sal_Bool CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sal_Bool bFixTags );
diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx
index 3e8383ac1da0..6a347464cb62 100644
--- a/l10ntools/inc/helpmerge.hxx
+++ b/l10ntools/inc/helpmerge.hxx
@@ -39,43 +39,43 @@
class HelpParser
{
private:
- ByteString sHelpFile;
+ rtl::OString sHelpFile;
bool bUTF8;
bool bHasInputList;
#if OSL_DEBUG_LEVEL > 2
/// Debugmethod, prints the content of the map to stdout
- static void Dump(LangHashMap* rElem_in , const ByteString sKey_in);
+ static void Dump(LangHashMap* rElem_in , const rtl::OString & sKey_in);
/// Debugmethod, prints the content of the map to stdout
static void Dump(XMLHashMap* rElem_in);
#endif
public:
- HelpParser( const ByteString &rHelpFile, bool bUTF8 , bool bHasInputList );
+ HelpParser( const rtl::OString &rHelpFile, bool bUTF8 , bool bHasInputList );
~HelpParser(){};
/// Method creates/append a SDF file with the content of a parsed XML file
/// @PRECOND rHelpFile is valid
- static bool CreateSDF( const ByteString &rSDFFile_in, const ByteString &rPrj_in, const ByteString &rRoot_in,
- const ByteString &sHelpFile, XMLFile *pXmlFile, const ByteString &rGsi1 );
+ static bool 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 );
static void parse_languages( std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile );
/// Method merges the String from the SDFfile into XMLfile. Both Strings must
/// point to existing files.
- bool Merge( const ByteString &rSDFFile_in, const ByteString &rDestinationFile_in ,
+ bool Merge( const rtl::OString &rSDFFile_in, const rtl::OString &rDestinationFile_in ,
const rtl::OString& sLanguage , MergeDataFile& aMergeDataFile );
- bool Merge( const ByteString &rSDFFile, const ByteString &rPathX , const ByteString &rPathY , bool bISO
+ bool Merge( const rtl::OString &rSDFFile, const rtl::OString &rPathX , const rtl::OString &rPathY , bool bISO
, const std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir );
private:
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 );
+ rtl::OString GetOutpath( const rtl::OString& rPathX , const rtl::OString& sCur , const rtl::OString& rPathY );
+ bool MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const rtl::OString& sLanguage , rtl::OString const & sPath );
- void ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile );
+ void ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile );
void MakeDir(const rtl::OString& rPath);
};
diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx
index 2a4a0d31db1f..d6a0ebd4e2cf 100644
--- a/l10ntools/inc/lngmerge.hxx
+++ b/l10ntools/inc/lngmerge.hxx
@@ -55,8 +55,8 @@ private:
bool isNextGroup(rtl::OString &sGroup_out, rtl::OString &sLine_in);
void ReadLine(const rtl::OString &rLine_in,
- ByteStringHashMap &rText_inout);
- void WriteSDF(SvFileStream &aSDFStream, ByteStringHashMap &rText_inout,
+ OStringHashMap &rText_inout);
+ void WriteSDF(SvFileStream &aSDFStream, OStringHashMap &rText_inout,
const rtl::OString &rPrj, const rtl::OString &rRoot,
const rtl::OString &rActFileName, const rtl::OString &rID);
public:
diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx
index c6fe74055080..3b3e4baa9108 100644
--- a/l10ntools/inc/xmlparse.hxx
+++ b/l10ntools/inc/xmlparse.hxx
@@ -64,30 +64,31 @@ using namespace std;
/** Holds data of Attributes
*/
-class XMLAttribute : public String
+class XMLAttribute
{
private:
- String sValue;
+ rtl::OUString sName;
+ rtl::OUString sValue;
public:
/// creates an attribute
XMLAttribute(
- const String &rName, // attributes name
- const String &rValue // attributes data
+ const rtl::OUString &rName, // attributes name
+ const rtl::OUString &rValue // attributes data
)
- : String( rName ), sValue( rValue ) {}
+ : sName( rName ), sValue( rValue ) {}
- /// getting value of an attribue
- const String &GetValue() { return sValue; }
+ rtl::OUString GetName() const { return sName; }
+ rtl::OUString GetValue() const { return sValue; }
- void setValue(const String &rValue){sValue=rValue;}
+ void setValue(const rtl::OUString &rValue){sValue=rValue;}
/// returns true if two attributes are equal and have the same value
sal_Bool IsEqual(
const XMLAttribute &rAttribute // the attribute which has to be equal
)
{
- return (( rAttribute == *this ) && ( rAttribute.sValue == sValue ));
+ return (( rAttribute.sName == sName ) && ( rAttribute.sValue == sValue ));
}
};
@@ -172,7 +173,6 @@ public:
XMLChildNode *pChild , size_t pos /// the new child
);
- virtual int GetPosition( ByteString id );
int RemoveChild( XMLElement *pRefElement );
void RemoveAndDeleteAllChildren();
@@ -204,18 +204,17 @@ class XMLFile : public XMLParentNode
{
public:
XMLFile(
- const String &rFileName // the file name, empty if created from memory stream
+ const rtl::OUString &rFileName // the file name, empty if created from memory stream
);
XMLFile( const XMLFile& obj ) ;
~XMLFile();
- ByteString* GetGroupID(std::deque<rtl::OString> &groupid);
void Print( XMLNode *pCur = NULL, sal_uInt16 nLevel = 0 );
virtual void SearchL10NElements( XMLParentNode *pCur, int pos = 0 );
void Extract( XMLFile *pCur = NULL );
XMLHashMap* GetStrings(){return XMLStrings;}
- sal_Bool Write( ByteString &rFilename );
+ sal_Bool Write( rtl::OString const &rFilename );
sal_Bool Write( ofstream &rStream , XMLNode *pCur = NULL );
bool CheckExportStatus( XMLParentNode *pCur = NULL );// , int pos = 0 );
@@ -277,7 +276,7 @@ class XMLElement : public XMLParentNode
private:
String sElementName;
XMLAttributeList *pAttributes;
- ByteString project,
+ rtl::OString project,
filename,
id,
sOldRef,
@@ -332,23 +331,23 @@ public:
/// returns a attribute
XMLAttribute *GetAttribute(
- const String &rName // the attribute name
+ const rtl::OUString &rName // the attribute name
);
- void SetProject ( ByteString prj ){ project = prj; }
- void SetFileName ( ByteString fn ){ filename = fn; }
- void SetId ( ByteString theId ){ id = theId; }
- void SetResourceType ( ByteString rt ){ resourceType = rt; }
- void SetLanguageId ( ByteString lid ){ languageId = lid; }
+ void SetProject ( rtl::OString const & prj ){ project = prj; }
+ void SetFileName ( rtl::OString const & fn ){ filename = fn; }
+ void SetId ( rtl::OString const & theId ){ id = theId; }
+ void SetResourceType ( rtl::OString const & rt ){ resourceType = rt; }
+ void SetLanguageId ( rtl::OString const & lid ){ languageId = lid; }
void SetPos ( int nPos_in ){ nPos = nPos_in; }
- void SetOldRef ( ByteString sOldRef_in ){ sOldRef = sOldRef_in; }
+ void SetOldRef ( rtl::OString const & sOldRef_in ){ sOldRef = sOldRef_in; }
virtual int GetPos() { return nPos; }
- ByteString GetProject() { return project; }
- ByteString GetFileName() { return filename; }
- ByteString GetId() { return id; }
- ByteString GetOldref() { return sOldRef; }
- ByteString GetResourceType(){ return resourceType; }
- ByteString GetLanguageId() { return languageId; }
+ rtl::OString GetProject() { return project; }
+ rtl::OString GetFileName() { return filename; }
+ rtl::OString GetId() { return id; }
+ rtl::OString GetOldref() { return sOldRef; }
+ rtl::OString GetResourceType(){ return resourceType; }
+ rtl::OString GetLanguageId() { return languageId; }
};
diff --git a/l10ntools/source/cfglex.l b/l10ntools/source/cfglex.l
index 94648a6a35f7..f1daee6711fa 100644
--- a/l10ntools/source/cfglex.l
+++ b/l10ntools/source/cfglex.l
@@ -34,18 +34,8 @@ int yycolumn = 1;
#define YY_USER_ACTION yycolumn += yyleng;
/* external functions (C++ code, declared as extren "C" */
-extern int WorkOnTokenSet( int, char* );
-extern int InitCfgExport( char * , char *);
-extern int EndCfgExport();
-extern int GetError();
-extern int SetError();
-extern char *GetOutputFile( int argc, char* argv[]);
-extern FILE *GetCfgFile();
-extern int isQuiet();
-extern void removeTempFile();
-extern char* getFilename();
-/* forwards */
-void YYWarning();
+extern void workOnTokenSet( int, char* );
+extern FILE * init(int, char **);
int bText=0;
%}
@@ -58,28 +48,28 @@ int bText=0;
\<[^\>]*"xml:lang="\""x-no-translate"\"[^\<]*\/\> {
bText = 0;
- WorkOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
+ workOnTokenSet( CFG_TOKEN_NO_TRANSLATE, yytext );
}
\<.*\/\> {
bText = 0;
- WorkOnTokenSet( ANYTOKEN, yytext );
+ workOnTokenSet( ANYTOKEN, yytext );
}
\<[^\>]*"xml:lang="\".*\"[^\<]*\> {
bText = 1;
- WorkOnTokenSet( CFG_TEXT_START, yytext );
+ workOnTokenSet( CFG_TEXT_START, yytext );
}
\<[^\/\!][^\>]*\> {
bText = 0;
- WorkOnTokenSet( CFG_TAG, yytext );
+ workOnTokenSet( CFG_TAG, yytext );
}
"<!"DOCTYPE[^\>]*\> {
bText = 0;
- WorkOnTokenSet( CFG_TAG, yytext );
+ workOnTokenSet( CFG_TAG, yytext );
}
@@ -89,8 +79,8 @@ int bText=0;
pChar[1] = 0x00;
pChar[0] = c3;
- WorkOnTokenSet( COMMEND, yytext );
- WorkOnTokenSet( COMMEND, pChar );
+ workOnTokenSet( COMMEND, yytext );
+ workOnTokenSet( COMMEND, pChar );
for(;;) {
if ( c3 == EOF )
@@ -101,29 +91,29 @@ int bText=0;
c2 = c3;
c3 = input();
pChar[0] = c3;
- WorkOnTokenSet( COMMEND, pChar );
+ workOnTokenSet( COMMEND, pChar );
}
}
\<\/[^\>]*\> {
bText = 0;
- WorkOnTokenSet( CFG_CLOSETAG, yytext );
+ workOnTokenSet( CFG_CLOSETAG, yytext );
}
\<[^\>\!]*\> {
bText = 0;
if ( yytext[ 1 ] == '!' && yytext[ 2 ] == '-' && yytext[ 3 ] == '-' )
- WorkOnTokenSet( COMMEND, yytext );
+ workOnTokenSet( COMMEND, yytext );
else
- WorkOnTokenSet( CFG_UNKNOWNTAG, yytext );
+ workOnTokenSet( CFG_UNKNOWNTAG, yytext );
}
.|\n {
yycolumn = 1;
if ( bText == 1 )
- WorkOnTokenSet( CFG_TEXTCHAR, yytext );
+ workOnTokenSet( CFG_TEXTCHAR, yytext );
else
- WorkOnTokenSet( UNKNOWNCHAR, yytext );
+ workOnTokenSet( UNKNOWNCHAR, yytext );
}
@@ -156,63 +146,15 @@ void yyerror ( const char *s )
/* write error to stderr */
fprintf( stderr,
"Error: \"%s\" in line %d, column %d: \"%s\"\n", s, yylineno, yycolumn, yytext );
- SetError();
+ exit(EXIT_FAILURE);
}
-/*****************************************************************************/
int
-#ifdef WNT
+#if defined WNT
_cdecl
#endif
-main( int argc, char* argv[])
-/*****************************************************************************/
-{
- /* error level */
- int nRetValue = 0;
- char *pOutput;
- FILE *pFile;
-
- pOutput = GetOutputFile( argc, argv );
-
- if ( !pOutput ) {
- fprintf( stdout, "Syntax: CFGEX[-p Prj][-r PrjRoot]-i FileIn [-o FileOut][-m DataBase][-e][-b][-u][-f][-d DoneFile][-g[:dtd] ][-L l1,l2,...]\n" );
- fprintf( stdout, " Prj: Project\n" );
- fprintf( stdout, " PrjRoot: Path to project root (..\\.. etc.)\n" );
- fprintf( stdout, " FileIn: Source files (*.src)\n" );
- fprintf( stdout, " FileOut: Destination file (*.*)\n" );
- fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
- fprintf( stdout, " -e: Disable writing errorlog\n" );
- fprintf( stdout, " -b: Break when Token \"HelpText\" found in source\n" );
- fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
- fprintf( stdout, " -f: force extraction and merge even if only one language is existent\n" );
- fprintf( stdout, " -g[:dtd]: enables generation of properties (dtds if :dtd is set) - in this case FileOut is the output path\n" );
- fprintf( stdout, " -d: enables generation of *.don if work is done\n" );
- fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
- fprintf( stdout, " f1, f2,... are also elements of (de,en-US...)\n" );
- return 1;
- }
-
- pFile = GetCfgFile();
- InitCfgExport( pOutput , getFilename() );
- if ( !pFile )
- return 1;
-
- yyin = pFile;
-
- /* create global instance of class CfgExport */
- //InitCfgExport( pOutput );
-
- /* start parser */
- yylex();
-
- /* get error info. and end export */
- nRetValue = GetError();
- EndCfgExport();
-
-
- removeTempFile();
-/* return error level */
- return nRetValue;
+main(int argc, char ** argv) {
+ yyin = init(argc, argv);
+ yylex();
+ return EXIT_SUCCESS;
}
-
-
diff --git a/l10ntools/source/cfgmerge.cxx b/l10ntools/source/cfgmerge.cxx
index 13cf715ba1f7..fded669b8f00 100644
--- a/l10ntools/source/cfgmerge.cxx
+++ b/l10ntools/source/cfgmerge.cxx
@@ -26,256 +26,216 @@
*
************************************************************************/
-#include <stdio.h>
+#include "sal/config.h"
+
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+
+#include "boost/scoped_ptr.hpp"
+#include "osl/process.h"
+#include "rtl/uri.hxx"
+
#include <comphelper/string.hxx>
-#include <tools/string.hxx>
-#include <tools/fsys.hxx>
-// local includes
+#include "helper.hxx"
#include "export.hxx"
#include "cfgmerge.hxx"
#include "tokens.h"
using comphelper::string::getToken;
-extern "C" { int yyerror(const char *); }
-extern "C" { int YYWarning(const char *); }
-
-// defines to parse command line
-#define STATE_NON 0x0001
-#define STATE_INPUT 0x0002
-#define STATE_OUTPUT 0x0003
-#define STATE_PRJ 0x0004
-#define STATE_ROOT 0x0005
-#define STATE_MERGESRC 0x0006
-#define STATE_ERRORLOG 0x0007
-#define STATE_UTF8 0x0008
-#define STATE_LANGUAGES 0X0009
-#define STATE_FORCE 0x000B
-
-// set of global variables
-sal_Bool bEnableExport;
-sal_Bool bMergeMode;
-sal_Bool bErrorLog;
-sal_Bool bForce;
-sal_Bool bUTF8;
-ByteString sPrj;
-ByteString sPrjRoot;
-ByteString sInputFileName;
-ByteString sActFileName;
-rtl::OString sFullEntry;
-rtl::OString sOutputFile;
-rtl::OString sMergeSrc;
-String sUsedTempFile;
-
-CfgParser *pParser;
-
-extern "C" {
-// the whole interface to lexer is in this extern "C" section
-
-/*****************************************************************************/
-extern char *GetOutputFile( int argc, char* argv[])
-/*****************************************************************************/
-{
- bEnableExport = sal_False;
- bMergeMode = sal_False;
- bErrorLog = sal_True;
- bForce = sal_False;
- bUTF8 = sal_True;
- sPrj = "";
- sPrjRoot = "";
- sInputFileName = "";
- sActFileName = "";
-
- sal_uInt16 nState = STATE_NON;
- sal_Bool bInput = sal_False;
-
- // parse command line
- for( int i = 1; i < argc; i++ ) {
- ByteString sSwitch( argv[ i ] );
- sSwitch.ToUpperAscii();
-
- if ( sSwitch == "-I" ) {
- nState = STATE_INPUT; // next token specifies source file
- }
- else if ( sSwitch == "-O" ) {
- nState = STATE_OUTPUT; // next token specifies the dest file
- }
- else if ( sSwitch == "-P" ) {
- nState = STATE_PRJ; // next token specifies the cur. project
- }
- else if ( sSwitch == "-R" ) {
- nState = STATE_ROOT; // next token specifies path to project root
- }
- else if ( sSwitch == "-M" ) {
- nState = STATE_MERGESRC; // next token specifies the merge database
- }
- else if ( sSwitch == "-E" ) {
- nState = STATE_ERRORLOG;
- bErrorLog = sal_False;
- }
- else if ( sSwitch == "-F" ) {
- nState = STATE_FORCE;
- bForce = sal_True;
- }
- else if ( sSwitch == "-L" ) {
- nState = STATE_LANGUAGES;
- }
- else {
- switch ( nState ) {
- case STATE_NON: {
- return NULL; // no valid command line
- }
- case STATE_INPUT: {
- sInputFileName = argv[ i ];
- bInput = sal_True; // source file found
- }
+extern "C" { int yyerror(char const *); }
+
+namespace {
+
+namespace global {
+
+bool mergeMode = false;
+bool errorLog = true;
+char const * prj = 0;
+char const * prjRoot = 0;
+char const * inputPathname = 0;
+char const * outputPathname = 0;
+char const * mergeSrc;
+boost::scoped_ptr< CfgParser > parser;
+
+}
+
+void badArguments() {
+}
+
+void handleArguments(int argc, char ** argv) {
+ enum State {
+ STATE_NONE, STATE_INPUT, STATE_OUTPUT, STATE_PRJ, STATE_ROOT,
+ STATE_MERGESRC, STATE_LANGUAGES };
+ State state = STATE_NONE;
+ for (int i = 1; i < argc; ++i) {
+ if (std::strcmp(argv[i], "-i") == 0) {
+ state = STATE_INPUT;
+ } else if (std::strcmp(argv[i], "-o") == 0) {
+ state = STATE_OUTPUT;
+ } else if (std::strcmp(argv[i], "-p") == 0) {
+ state = STATE_PRJ;
+ } else if (std::strcmp(argv[i], "-r") == 0) {
+ state = STATE_ROOT;
+ } else if (std::strcmp(argv[i], "-m") == 0) {
+ state = STATE_MERGESRC;
+ } else if (std::strcmp(argv[i], "-e") == 0) {
+ state = STATE_NONE;
+ global::errorLog = false;
+ } else if (std::strcmp(argv[i], "-l") == 0) {
+ state = STATE_LANGUAGES;
+ } else {
+ switch (state) {
+ default:
+ global::inputPathname = 0; // no valid command line
+ goto done;
+ case STATE_INPUT:
+ global::inputPathname = argv[i];
break;
- case STATE_OUTPUT: {
- sOutputFile = argv[ i ]; // the dest. file
- }
+ case STATE_OUTPUT:
+ global::outputPathname = argv[i];
break;
- case STATE_PRJ: {
- sPrj = ByteString( argv[ i ]);
-// sPrj.ToLowerAscii(); // the project
- }
+ case STATE_PRJ:
+ global::prj = argv[i];
break;
- case STATE_ROOT: {
- sPrjRoot = ByteString( argv[ i ]); // path to project root
- }
+ case STATE_ROOT:
+ global::prjRoot = argv[i];
break;
- case STATE_MERGESRC: {
- sMergeSrc = rtl::OString(argv[i]);
- bMergeMode = sal_True; // activate merge mode, cause merge database found
- }
+ case STATE_MERGESRC:
+ global::mergeSrc = argv[i];
+ global::mergeMode = true;
break;
- case STATE_LANGUAGES: {
- Export::sLanguages = ByteString( argv[ i ]);
- }
+ case STATE_LANGUAGES:
+ Export::sLanguages = argv[i];
break;
}
+ state = STATE_NONE;
}
}
-
- if ( bInput ) {
- // command line is valid
- bEnableExport = sal_True;
- char *pReturn = new char[ sOutputFile.getLength() + 1 ];
- strcpy( pReturn, sOutputFile.getStr()); // #100211# - checked
- return pReturn;
+done:
+ if (global::inputPathname == 0 || global::outputPathname == 0) {
+ std::fprintf(
+ stderr,
+ ("Syntax: cfgex [-p Prj] [-r PrjRoot] -i FileIn -o FileOut"
+ " [-m DataBase] [-e] [-l l1,l2,...]\n"
+ " Prj: Project\n"
+ " PrjRoot: Path to project root (../.. etc.)\n"
+ " FileIn: Source files (*.src)\n"
+ " FileOut: Destination file (*.*)\n"
+ " DataBase: Mergedata (*.sdf)\n"
+ " -e: Disable writing errorlog\n"
+ " -l: Restrict the handled languages; l1, l2, ... are elements of"
+ " (de, en-US, ...)\n"));
+ std::exit(EXIT_FAILURE);
}
-
- // command line is not valid
- return NULL;
-}
-
-int InitCfgExport( char *pOutput , char* pFilename )
-{
- // instanciate Export
- rtl::OString sOutput( pOutput );
- ByteString sFilename( pFilename );
Export::InitLanguages();
+}
- if ( bMergeMode )
- pParser = new CfgMerge( sMergeSrc, sOutputFile, sFilename );
- else if ( sOutputFile.getLength())
- pParser = new CfgExport( sOutputFile, sPrj, sActFileName );
-
- return 1;
}
-/*****************************************************************************/
-int EndCfgExport()
-/*****************************************************************************/
-{
- delete pParser;
+extern "C" {
- return 1;
-}
+FILE * init(int argc, char ** argv) {
+ handleArguments(argc, argv);
-void removeTempFile(){
- if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
- DirEntry aTempFile( sUsedTempFile );
- aTempFile.Kill();
+ FILE * pFile = std::fopen(global::inputPathname, "r");
+ if (pFile == 0) {
+ std::fprintf(
+ stderr, "Error: Cannot open file \"%s\"\n",
+ global::inputPathname);
+ std::exit(EXIT_FAILURE);
}
-}
-extern const char* getFilename()
-{
- return sInputFileName.GetBuffer();
-}
-/*****************************************************************************/
-extern FILE *GetCfgFile()
-/*****************************************************************************/
-{
- FILE *pFile = 0;
- // look for valid filename
- if ( sInputFileName.Len()) {
- if( Export::fileHasUTF8ByteOrderMarker( sInputFileName ) ){
- DirEntry aTempFile = Export::GetTempFile();
- DirEntry aSourceFile( String( sInputFileName , RTL_TEXTENCODING_ASCII_US ) );
- aSourceFile.CopyTo( aTempFile , FSYS_ACTION_COPYFILE );
- String 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("");
+
+ // Skip UTF-8 BOM:
+ unsigned char buf[3];
+ if (std::fread(buf, 1, 3, pFile) != 3 ||
+ buf[0] != 0xEF || buf[1] != 0xBB || buf[2] != 0xBF)
+ {
+ std::rewind(pFile);
+ }
+
+ if (global::mergeMode) {
+ global::parser.reset(
+ new CfgMerge(
+ global::mergeSrc, global::outputPathname,
+ global::inputPathname));
+ } else {
+ rtl::OUString cwd;
+ if (osl_getProcessWorkingDir(&cwd.pData) != osl_Process_E_None) {
+ std::fprintf(stderr, "Error: Cannot determine cwd\n");
+ std::exit(EXIT_FAILURE);
+ }
+ rtl::OUString full;
+ if (!rtl_convertStringToUString(
+ &full.pData, global::inputPathname,
+ rtl_str_getLength(global::inputPathname),
+ osl_getThreadTextEncoding(),
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
+ | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
+ | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
+ {
+ std::fprintf(
+ stderr, "Error: Cannot convert input pathname to UTF-16\n");
+ std::exit(EXIT_FAILURE);
+ }
+ if (osl::FileBase::getAbsoluteFileURL(cwd, full, full)
+ != osl::FileBase::E_None)
+ {
+ std::fprintf(
+ stderr,
+ "Error: Cannot convert input pathname to absolute URL\n");
+ std::exit(EXIT_FAILURE);
+ }
+ if (global::prjRoot == 0) {
+ std::fprintf(stderr, "Error: No project root argument\n");
+ std::exit(EXIT_FAILURE);
+ }
+ rtl::OUString base;
+ if (!rtl_convertStringToUString(
+ &base.pData, global::prjRoot,
+ rtl_str_getLength(global::prjRoot),
+ osl_getThreadTextEncoding(),
+ (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR
+ | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR
+ | RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
+ {
+ std::fprintf(
+ stderr, "Error: Cannot convert project root to UTF-16\n");
+ std::exit(EXIT_FAILURE);
}
- if ( !pFile ){
- fprintf( stderr, "Error: Could not open file %s\n",
- sInputFileName.GetBuffer());
- exit( -13 );
+ base = rtl::Uri::convertRelToAbs(full, base);
+ if (full.getLength() <= base.getLength() || base.isEmpty()
+ || base[base.getLength() - 1] != '/'
+ || full[base.getLength() - 1] != '/')
+ {
+ std::fprintf(
+ stderr, "Error: Cannot extract suffix from input pathname\n");
+ std::exit(EXIT_FAILURE);
}
- else {
- // this is a valid file which can be opened, so
- // create path to project root
- DirEntry aEntry( String( sInputFileName, RTL_TEXTENCODING_ASCII_US ));
- aEntry.ToAbs();
- sFullEntry = rtl::OUStringToOString(aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US);
- aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
- aEntry += DirEntry( sPrjRoot );
- rtl::OString sPrjEntry(rtl::OUStringToOString(aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US));
-
- // create file name, beginnig with project root
- // (e.g.: source\ui\src\menue.src)
-// printf("sFullEntry = %s\n",sFullEntry.getStr());
- sActFileName = sFullEntry.copy(sPrjEntry.getLength() + 1);
-// printf("sActFileName = %s\n",sActFileName.GetBuffer());
-
- sActFileName.SearchAndReplaceAll( "/", "\\" );
-
- return pFile;
+ full = full.copy(base.getLength()).replace('/', '\\');
+ rtl::OString suffix;
+ if (!full.convertToString(
+ &suffix, osl_getThreadTextEncoding(),
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
+ | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
+ {
+ std::fprintf(
+ stderr, "Error: Cannot convert suffix from UTF-16\n");
+ std::exit(EXIT_FAILURE);
}
+ global::parser.reset(
+ new CfgExport(global::outputPathname, global::prj, suffix));
}
- // this means the file could not be opened
- return NULL;
-}
-/*****************************************************************************/
-int WorkOnTokenSet( int nTyp, char *pTokenText )
-/*****************************************************************************/
-{
- pParser->Execute( nTyp, pTokenText );
-
- return 1;
+ return pFile;
}
-
-/*****************************************************************************/
-int SetError()
-/*****************************************************************************/
-{
- return 1;
+void workOnTokenSet(int nTyp, char * pTokenText) {
+ global::parser->Execute( nTyp, pTokenText );
}
-/*****************************************************************************/
-int GetError()
-/*****************************************************************************/
-{
- return 0;
-}
}
//
@@ -356,19 +316,19 @@ sal_Bool CfgParser::IsTokenClosed(const rtl::OString &rToken)
/*****************************************************************************/
void CfgParser::AddText(
- ByteString &rText,
- const ByteString &rIsoLang,
- const ByteString &rResTyp
+ rtl::OString &rText,
+ const rtl::OString &rIsoLang,
+ const rtl::OString &rResTyp
)
/*****************************************************************************/
{
- sal_uInt16 nTextLen = 0;
- while ( rText.Len() != nTextLen ) {
- nTextLen = rText.Len();
- rText.SearchAndReplaceAll( "\n", " " );
- rText.SearchAndReplaceAll( "\r", " " );
- rText.SearchAndReplaceAll( "\t", " " );
- rText.SearchAndReplaceAll( " ", " " );
+ sal_Int32 nTextLen = 0;
+ while ( rText.getLength() != nTextLen ) {
+ nTextLen = rText.getLength();
+ rText = rText.replace( '\n', ' ' );
+ rText = rText.replace( '\r', ' ' );
+ rText = rText.replace( '\t', ' ' );
+ while (helper::searchAndReplace(&rText, " ", " ") != -1) {}
}
pStackData->sResTyp = rResTyp;
WorkOnText( rText, rIsoLang );
@@ -380,13 +340,13 @@ void CfgParser::AddText(
int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
/*****************************************************************************/
{
- ByteString sToken( pToken );
+ rtl::OString sToken( pToken );
if ( sToken == " " || sToken == "\t" )
sLastWhitespace += sToken;
rtl::OString sTokenName;
- ByteString sTokenId;
+ rtl::OString sTokenId;
sal_Bool bOutput = sal_True;
@@ -404,7 +364,7 @@ int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
sTokenName = getToken(getToken(getToken(sToken, 1, '<'), 0, '>'), 0, ' ');
if ( !IsTokenClosed( sToken )) {
- ByteString sSearch;
+ rtl::OString sSearch;
switch ( nToken ) {
case CFG_TOKEN_PACKAGE:
sSearch = "package-id=";
@@ -428,15 +388,15 @@ int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
case CFG_TEXT_START: {
if ( sCurrentResTyp != sTokenName ) {
WorkOnRessourceEnd();
- ByteString sCur;
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- pStackData->sText[ sCur ] = ByteString("");
+ pStackData->sText[ sCur ] = rtl::OString();
}
}
sCurrentResTyp = sTokenName;
- ByteString sTemp = sToken.Copy( sToken.Search( "xml:lang=" ));
+ rtl::OString sTemp = sToken.copy( sToken.indexOf( "xml:lang=" ));
sCurrentIsoLang = getToken(getToken(sTemp, 1, '\"'), 0, '\"');
if ( sCurrentIsoLang == NO_TRANSLATE_ISO )
@@ -448,27 +408,26 @@ int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
}
break;
}
- if ( sSearch.Len())
+ if ( !sSearch.isEmpty())
{
- rtl::OString sTemp = sToken.Copy( sToken.Search( sSearch ));
+ rtl::OString sTemp = sToken.copy( sToken.indexOf( sSearch ));
sTokenId = getToken(getToken(sTemp, 1, '\"'), 0, '\"');
}
pStackData = aStack.Push( sTokenName, sTokenId );
if ( sSearch == "cfg:name=" ) {
- ByteString sTemp( sToken );
- sTemp.ToUpperAscii();
- bLocalize = (( sTemp.Search( "CFG:TYPE=\"STRING\"" ) != STRING_NOTFOUND ) &&
- ( sTemp.Search( "CFG:LOCALIZED=\"sal_True\"" ) != STRING_NOTFOUND ));
+ rtl::OString sTemp( sToken.toAsciiUpperCase() );
+ bLocalize = (( sTemp.indexOf( "CFG:TYPE=\"STRING\"" ) != -1 ) &&
+ ( sTemp.indexOf( "CFG:LOCALIZED=\"sal_True\"" ) != -1 ));
}
}
else if ( sTokenName == "label" ) {
if ( sCurrentResTyp != sTokenName ) {
WorkOnRessourceEnd();
- ByteString sCur;
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- pStackData->sText[ sCur ] = ByteString("");
+ pStackData->sText[ sCur ] = rtl::OString();
}
}
sCurrentResTyp = sTokenName;
@@ -479,20 +438,20 @@ int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
sTokenName = getToken(getToken(getToken(sToken, 1, '/'), 0, '>'), 0, ' ');
if ( aStack.GetStackData() && ( aStack.GetStackData()->GetTagType() == sTokenName ))
{
- if (!sCurrentText.Len())
+ if (sCurrentText.isEmpty())
WorkOnRessourceEnd();
aStack.Pop();
pStackData = aStack.GetStackData();
}
else
{
- ByteString sError( "Misplaced close tag: " );
- ByteString sInFile(" in file ");
+ rtl::OString sError( "Misplaced close tag: " );
+ rtl::OString sInFile(" in file ");
sError += sToken;
sError += sInFile;
- sError += sFullEntry;
+ sError += global::inputPathname;
Error( sError );
- exit ( 13 );
+ std::exit(EXIT_FAILURE);
}
break;
@@ -506,11 +465,11 @@ int CfgParser::ExecuteAnalyzedToken( int nToken, char *pToken )
break;
}
- if ( sCurrentText.Len() && nToken != CFG_TEXTCHAR )
+ if ( !sCurrentText.isEmpty() && nToken != CFG_TEXTCHAR )
{
AddText( sCurrentText, sCurrentIsoLang, sCurrentResTyp );
Output( sCurrentText );
- sCurrentText = "";
+ sCurrentText = rtl::OString();
pStackData->sEndTextTag = sToken;
}
@@ -531,21 +490,21 @@ void CfgExport::Output(const rtl::OString&)
int CfgParser::Execute( int nToken, char * pToken )
/*****************************************************************************/
{
- ByteString sToken( pToken );
+ rtl::OString sToken( pToken );
switch ( nToken ) {
case CFG_TAG:
- if ( sToken.Search( "package-id=" ) != STRING_NOTFOUND )
+ if ( sToken.indexOf( "package-id=" ) != -1 )
return ExecuteAnalyzedToken( CFG_TOKEN_PACKAGE, pToken );
- else if ( sToken.Search( "component-id=" ) != STRING_NOTFOUND )
+ else if ( sToken.indexOf( "component-id=" ) != -1 )
return ExecuteAnalyzedToken( CFG_TOKEN_COMPONENT, pToken );
- else if ( sToken.Search( "template-id=" ) != STRING_NOTFOUND )
+ else if ( sToken.indexOf( "template-id=" ) != -1 )
return ExecuteAnalyzedToken( CFG_TOKEN_TEMPLATE, pToken );
- else if ( sToken.Search( "cfg:name=" ) != STRING_NOTFOUND )
+ else if ( sToken.indexOf( "cfg:name=" ) != -1 )
return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, pToken );
- else if ( sToken.Search( "oor:name=" ) != STRING_NOTFOUND )
+ else if ( sToken.indexOf( "oor:name=" ) != -1 )
return ExecuteAnalyzedToken( CFG_TOKEN_OORNAME, pToken );
- else if ( sToken.Search( "oor:value=" ) != STRING_NOTFOUND )
+ else if ( sToken.indexOf( "oor:value=" ) != -1 )
return ExecuteAnalyzedToken( CFG_TOKEN_OORVALUE, pToken );
break;
}
@@ -577,7 +536,7 @@ CfgOutputParser::CfgOutputParser(const rtl::OString &rOutputFile)
Error(sError.makeStringAndClear());
delete pOutputStream;
pOutputStream = NULL;
- exit( -13 );
+ std::exit(EXIT_FAILURE);
}
}
@@ -597,9 +556,9 @@ CfgOutputParser::~CfgOutputParser()
/*****************************************************************************/
CfgExport::CfgExport(
- const ByteString &rOutputFile,
- const ByteString &rProject,
- const ByteString &rFilePath
+ const rtl::OString &rOutputFile,
+ const rtl::OString &rProject,
+ const rtl::OString &rFilePath
)
/*****************************************************************************/
: CfgOutputParser( rOutputFile ),
@@ -621,15 +580,11 @@ void CfgExport::WorkOnRessourceEnd()
/*****************************************************************************/
{
if ( pOutputStream && bLocalize ) {
- if (( pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))].getLength()
- ) ||
- ( bForce &&
- ( pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("de"))].getLength() ||
- pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))].getLength() )))
+ if ( pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))].getLength() )
{
- ByteString sFallback = pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))];
- ByteString sLocalId = pStackData->sIdentifier;
- ByteString sGroupId;
+ rtl::OString sFallback = pStackData->sText[rtl::OString(RTL_CONSTASCII_STRINGPARAM("en-US"))];
+ rtl::OString sLocalId = pStackData->sIdentifier;
+ rtl::OString sGroupId;
if ( aStack.size() == 1 ) {
sGroupId = sLocalId;
sLocalId = "";
@@ -638,19 +593,19 @@ void CfgExport::WorkOnRessourceEnd()
sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
}
- ByteString sTimeStamp( Export::GetTimeStamp());
+ rtl::OString sTimeStamp( Export::GetTimeStamp());
for (size_t n = 0; n < aLanguages.size(); n++)
{
- ByteString sCur = aLanguages[ n ];
+ rtl::OString sCur = aLanguages[ n ];
- ByteString sText = pStackData->sText[ sCur ];
- if ( !sText.Len())
+ rtl::OString sText = pStackData->sText[ sCur ];
+ if ( sText.isEmpty())
sText = sFallback;
- Export::UnquotHTML( sText );
+ sText = Export::UnquoteHTML( sText );
- ByteString sOutput( sPrj ); sOutput += "\t";
+ rtl::OString sOutput( sPrj ); sOutput += "\t";
sOutput += sPath;
sOutput += "\t0\t";
sOutput += pStackData->sResTyp; sOutput += "\t";
@@ -669,11 +624,11 @@ void CfgExport::WorkOnRessourceEnd()
}
void CfgExport::WorkOnText(
- ByteString &rText,
+ rtl::OString &rText,
const rtl::OString &rIsoLang
)
{
- if( rIsoLang.getLength() ) Export::UnquotHTML( rText );
+ if( rIsoLang.getLength() ) rText = Export::UnquoteHTML( rText );
}
@@ -693,7 +648,7 @@ CfgMerge::CfgMerge(
if (rMergeSource.getLength())
{
pMergeDataFile = new MergeDataFile(
- rMergeSource, sInputFileName, bErrorLog, true );
+ rMergeSource, global::inputPathname, global::errorLog, true );
if (Export::sLanguages.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("ALL")))
{
Export::SetLanguages( pMergeDataFile->GetLanguages() );
@@ -713,22 +668,22 @@ CfgMerge::~CfgMerge()
delete pResData;
}
-void CfgMerge::WorkOnText(ByteString &rText, const rtl::OString& rLangIndex)
+void CfgMerge::WorkOnText(rtl::OString &rText, const rtl::OString& rLangIndex)
{
if ( pMergeDataFile && bLocalize ) {
if ( !pResData ) {
- ByteString sLocalId = pStackData->sIdentifier;
- ByteString sGroupId;
+ rtl::OString sLocalId = pStackData->sIdentifier;
+ rtl::OString sGroupId;
if ( aStack.size() == 1 ) {
sGroupId = sLocalId;
- sLocalId = "";
+ sLocalId = rtl::OString();
}
else {
sGroupId = aStack.GetAccessPath( aStack.size() - 2 );
}
- ByteString sPlatform( "" );
+ rtl::OString sPlatform;
pResData = new ResData( sPlatform, sGroupId , sFilename );
pResData->sId = sLocalId;
@@ -740,13 +695,13 @@ void CfgMerge::WorkOnText(ByteString &rText, const rtl::OString& rLangIndex)
PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
if ( pEntrys ) {
- ByteString sContent;
+ rtl::OString sContent;
pEntrys->GetText( sContent, STRING_TYP_TEXT, rLangIndex );
if ( Export::isAllowed( rLangIndex ) &&
- ( sContent != "-" ) && ( sContent.Len()))
+ ( sContent != "-" ) && !sContent.isEmpty())
{
- Export::QuotHTML( rText );
+ rText = Export::QuoteHTML( rText );
}
}
}
@@ -763,41 +718,40 @@ void CfgMerge::WorkOnRessourceEnd()
/*****************************************************************************/
{
- if ( pMergeDataFile && pResData && bLocalize && (( bEnglish ) || bForce )) {
+ if ( pMergeDataFile && pResData && bLocalize && bEnglish ) {
PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrysCaseSensitive( pResData );
if ( pEntrys ) {
- ByteString sCur;
+ rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sContent;
+ rtl::OString sContent;
pEntrys->GetText( sContent, STRING_TYP_TEXT, sCur , sal_True );
if (
- ( !sCur.EqualsIgnoreCaseAscii("en-US") ) &&
+ ( !sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")) ) &&
- ( sContent != "-" ) && ( sContent.Len()))
+ ( sContent != "-" ) && !sContent.isEmpty())
{
- ByteString sText = sContent;
- Export::QuotHTML( sText );
+ rtl::OString sText = Export::QuoteHTML( sContent);
- ByteString sAdditionalLine( "\t" );
+ rtl::OString sAdditionalLine( "\t" );
- ByteString sTextTag = pStackData->sTextTag;
- ByteString sTemp = sTextTag.Copy( sTextTag.Search( "xml:lang=" ));
+ rtl::OString sTextTag = pStackData->sTextTag;
+ rtl::OString sTemp = sTextTag.copy( sTextTag.indexOf( "xml:lang=" ));
- ByteString sSearch = getToken(sTemp, 0, '\"');
+ rtl::OString sSearch = getToken(sTemp, 0, '\"');
sSearch += "\"";
sSearch += getToken(sTemp, 1, '\"');
sSearch += "\"";
- ByteString sReplace = getToken(sTemp, 0, '\"');
+ rtl::OString sReplace = getToken(sTemp, 0, '\"');
sReplace += "\"";
sReplace += sCur;
sReplace += "\"";
- sTextTag.SearchAndReplace( sSearch, sReplace );
+ helper::searchAndReplace(&sTextTag, sSearch, sReplace);
sAdditionalLine += sTextTag;
sAdditionalLine += sText;
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index 8909a1eed945..eacba7843adf 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -30,6 +30,7 @@
#include <stdlib.h>
#include <tools/fsys.hxx>
#include "export.hxx"
+#include "helper.hxx"
#include "tokens.h"
#include <iostream>
#include <vector>
@@ -514,8 +515,8 @@ int Export::Execute( int nToken, const char * pToken )
/*****************************************************************************/
{
- ByteString sToken( pToken );
- ByteString sOrig( sToken );
+ rtl::OString sToken( pToken );
+ rtl::OString sOrig( sToken );
sal_Bool bWriteToMerged = bMergeMode;
if ( nToken == CONDITION )
@@ -594,18 +595,18 @@ int Export::Execute( int nToken, const char * pToken )
sal_uInt16 nClose = 0;
sal_Bool bReadOver1 = sal_False;
sal_uInt16 i = 0;
- for ( i = 0; i < sToken.Len(); i++ ) {
- if ( sToken.GetChar( i ) == '\"' )
+ for ( i = 0; i < sToken.getLength(); i++ ) {
+ if ( sToken[i] == '"' )
bReadOver1 = !bReadOver1;
- if ( !bReadOver1 && ( sToken.GetChar( i ) == '{' ))
+ if ( !bReadOver1 && ( sToken[i] == '{' ))
nOpen++;
}
bReadOver1 = sal_False;
- for ( i = 0; i < sToken.Len(); i++ ) {
- if ( sToken.GetChar( i ) == '\"' )
+ for ( i = 0; i < sToken.getLength(); i++ ) {
+ if ( sToken[i] == '"' )
bReadOver1 = !bReadOver1;
- if ( !bReadOver1 && ( sToken.GetChar( i ) == '}' ))
+ if ( !bReadOver1 && ( sToken[i] == '}' ))
nClose++;
}
@@ -615,10 +616,10 @@ int Export::Execute( int nToken, const char * pToken )
switch ( nToken ) {
case NORMDEFINE:
- while( sToken.SearchAndReplace( "\r", " " ) != STRING_NOTFOUND ) {};
- while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
- while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {};
- if( sToken.EqualsIgnoreCaseAscii( "#define NO_LOCALIZE_EXPORT" ) ){
+ while( helper::searchAndReplace(&sToken, "\r", " " ) != -1 ) {};
+ while( helper::searchAndReplace(&sToken, "\t", " " ) != -1 ) {};
+ while( helper::searchAndReplace(&sToken, " ", " " ) != -1 ) {};
+ if( sToken.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("#define NO_LOCALIZE_EXPORT")) ){
bSkipFile = true;
return 0;
}
@@ -650,13 +651,13 @@ int Export::Execute( int nToken, const char * pToken )
sToken = comphelper::string::remove(sToken, '\n');
sToken = comphelper::string::remove(sToken, '\r');
sToken = comphelper::string::remove(sToken, '{');
- while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
+ while( helper::searchAndReplace(&sToken, "\t", " " ) != -1 ) {};
sToken = comphelper::string::stripEnd(sToken, ' ');
rtl::OString sTLower = getToken(sToken, 0, ' ').toAsciiLowerCase();
pResData->sResTyp = sTLower;
- ByteString sId( sToken.Copy( pResData->sResTyp.getLength() + 1 ));
+ rtl::OString sId( sToken.copy( pResData->sResTyp.getLength() + 1 ));
ByteString sCondition;
- if ( sId.Search( "#" ) != STRING_NOTFOUND )
+ if ( sId.indexOf( '#' ) != -1 )
{
// between ResTyp, Id and paranthes is a precomp. condition
sCondition = "#";
@@ -692,7 +693,8 @@ int Export::Execute( int nToken, const char * pToken )
sToken = comphelper::string::remove(sToken, '\t');
sToken = comphelper::string::remove(sToken, ' ');
sToken = comphelper::string::remove(sToken, '\\');
- pResData->sResTyp = sToken.ToLowerAscii();
+ sToken = sToken.toAsciiLowerCase();
+ pResData->sResTyp = sToken;
}
break;
case LEVELUP: {
@@ -753,7 +755,7 @@ int Export::Execute( int nToken, const char * pToken )
rtl::OString sKey = getToken(sToken, 0, '=');
sKey = comphelper::string::remove(sKey, ' ');
sKey = comphelper::string::remove(sKey, '\t');
- ByteString sValue = getToken(sToken, 1, '=');
+ rtl::OString sValue = getToken(sToken, 1, '=');
CleanValue( sValue );
sKey = sKey.toAsciiUpperCase();
if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("IDENTIFIER")))
@@ -790,7 +792,7 @@ int Export::Execute( int nToken, const char * pToken )
nListIndex = 0;
nListLevel = 0;
}
- if ( (sToken.Search( "{" ) != STRING_NOTFOUND) &&
+ if ( (sToken.indexOf( '{' ) != -1) &&
( getTokenCount(sToken, '{') > getTokenCount(sToken, '}') ))
{
Parse( LEVELUP, "" );
@@ -808,7 +810,7 @@ int Export::Execute( int nToken, const char * pToken )
rtl::OString sKey = sTmpToken.Copy( 0 , nPos );
sKey = comphelper::string::remove(sKey, ' ');
sKey = comphelper::string::remove(sKey, '\t');
- ByteString sValue = getToken(sToken, 1, '=');
+ rtl::OString sValue = getToken(sToken, 1, '=');
CleanValue( sValue );
sKey = sKey.toAsciiUpperCase();
if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("STRINGLIST")))
@@ -871,7 +873,7 @@ int Export::Execute( int nToken, const char * pToken )
else if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("UIENTRIES")))
nList = LIST_UIENTRIES;
if ( nList ) {
- ByteString sLang = getToken(getToken(sToken, 1, '['), 0, ']');
+ rtl::OString sLang = getToken(getToken(sToken, 1, '['), 0, ']');
CleanValue( sLang );
m_sListLang = sLang;
nListIndex = 0;
@@ -911,7 +913,7 @@ int Export::Execute( int nToken, const char * pToken )
sKey = comphelper::string::remove(sKey, ' ');
sKey = comphelper::string::remove(sKey, '\t');
ByteString sText( GetText( sToken, nToken ));
- ByteString sLang;
+ rtl::OString sLang;
if ( getToken(sToken, 0, '=').indexOf('[') != -1 )
{
sLang = getToken(getToken(getToken(sToken, 0, '='), 1, '['), 0, ']');
@@ -919,7 +921,7 @@ int Export::Execute( int nToken, const char * pToken )
}
rtl::OString sLangIndex = sLang;
ByteString sOrigKey = sKey;
- if ( sText.Len() && sLang.Len() )
+ if ( sText.Len() && !sLang.isEmpty() )
{
sKey = sKey.toAsciiUpperCase();
if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("TEXT")) ||
@@ -1045,9 +1047,9 @@ int Export::Execute( int nToken, const char * pToken )
break;
case CONDITION: {
bDontWriteOutput = sal_False;
- while( sToken.SearchAndReplace( "\r", " " ) != STRING_NOTFOUND ) {};
- while( sToken.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
- while( sToken.SearchAndReplace( " ", " " ) != STRING_NOTFOUND ) {};
+ while( helper::searchAndReplace(&sToken, "\r", " " ) != -1 ) {};
+ while( helper::searchAndReplace(&sToken, "\t", " " ) != -1 ) {};
+ while( helper::searchAndReplace(&sToken, " ", " " ) != -1 ) {};
ByteString sCondition = getToken(sToken, 0, ' ');
if ( sCondition == "#ifndef" ) {
sActPForm = "!defined ";
@@ -1058,12 +1060,12 @@ int Export::Execute( int nToken, const char * pToken )
sActPForm += ByteString(getToken(sToken, 1, ' '));
}
else if ( sCondition == "#if" ) {
- sActPForm = sToken.Copy( 4 );
- while ( sActPForm.SearchAndReplace( "||", "\\or" ) != STRING_NOTFOUND ) {};
+ sActPForm = sToken.copy( 4 );
+ while ( helper::searchAndReplace(&sActPForm, "||", "\\or" ) != -1 ) {};
}
else if ( sCondition == "#elif" ) {
- sActPForm = sToken.Copy( 6 );
- while ( sActPForm.SearchAndReplace( "||", "\\or" ) != STRING_NOTFOUND ) {};
+ sActPForm = sToken.copy( 6 );
+ while ( helper::searchAndReplace(&sActPForm, "||", "\\or" ) != -1 ) {};
}
else if ( sCondition == "#else" ) {
sActPForm = sCondition;
@@ -1090,7 +1092,7 @@ int Export::Execute( int nToken, const char * pToken )
break;
case PRAGMA : {
bDontWriteOutput = sal_False;
- fprintf(stderr, "ERROR: archaic PRAGMA %s\n", sToken.GetBuffer());
+ fprintf(stderr, "ERROR: archaic PRAGMA %s\n", sToken.getStr());
exit(-1);
}
break;
@@ -1101,10 +1103,10 @@ int Export::Execute( int nToken, const char * pToken )
if ( bWriteToMerged ) {
// the current token must be written to dest. without merging
- if( bDefine && sOrig.Len() > 2 ){
- for( sal_uInt16 n = 0 ; n < sOrig.Len() ; n++ ){
- if( sOrig.GetChar( n ) == '\n' && sOrig.GetChar( n-1 ) != '\\'){
- sOrig.Insert('\\' , n++ );
+ if( bDefine && sOrig.getLength() > 2 ){
+ for( sal_uInt16 n = 0 ; n < sOrig.getLength() ; n++ ){
+ if( sOrig[n] == '\n' && sOrig[n-1] != '\\'){
+ sOrig = sOrig.replaceAt(n++, 0, "\\");
}
}
}
@@ -1119,10 +1121,10 @@ int Export::Execute( int nToken, const char * pToken )
}
/*****************************************************************************/
-void Export::CutComment( ByteString &rText )
+void Export::CutComment( rtl::OString &rText )
/*****************************************************************************/
{
- if ( rText.Search( "//" ) != STRING_NOTFOUND ) {
+ if ( rText.indexOf( "//" ) != -1 ) {
ByteString sWork( rText );
sWork.SearchAndReplaceAll( "\\\"", "XX" );
sal_uInt16 i = 0;
@@ -1136,7 +1138,7 @@ void Export::CutComment( ByteString &rText )
( !bInner ) &&
( sWork.GetChar( i + 1 ) == '/' ))
{
- rText.Erase( i );
+ rText = rText.copy(0, i);
return;
}
i++;
@@ -1222,7 +1224,7 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
if ( bEnableExport ) {
ByteString sOutput( sProject ); sOutput += "\t";
- if ( sRoot.Len())
+ if ( !sRoot.isEmpty())
sOutput += sActFileName;
sOutput += "\t0\t";
sOutput += pResData->sResTyp; sOutput += "\t";
@@ -1359,7 +1361,7 @@ sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList,
rtl::OStringBuffer sOutput(sProject);
sOutput.append('\t');
- if ( sRoot.Len())
+ if ( !sRoot.isEmpty())
sOutput.append(sActFileName);
sOutput.append("\t0\t");
sOutput.append(rTyp).append('\t');
@@ -1484,23 +1486,23 @@ void Export::InsertListEntry(const rtl::OString &rText, const rtl::OString &rLin
}
/*****************************************************************************/
-void Export::CleanValue( ByteString &rValue )
+void Export::CleanValue( rtl::OString &rValue )
/*****************************************************************************/
{
- while ( rValue.Len()) {
- if (( rValue.GetChar( 0 ) == ' ' ) || ( rValue.GetChar( 0 ) == '\t' ))
- rValue = rValue.Copy( 1 );
+ while ( !rValue.isEmpty()) {
+ if (( rValue[0] == ' ' ) || ( rValue[0] == '\t' ))
+ rValue = rValue.copy( 1 );
else
break;
}
- if ( rValue.Len()) {
- for ( sal_uInt16 i = rValue.Len() - 1; i > 0; i-- ) {
- if (( rValue.GetChar( i ) == ' ' ) || ( rValue.GetChar( i ) == '\t' ) ||
- ( rValue.GetChar( i ) == '\n' ) || ( rValue.GetChar( i ) == ';' ) ||
- ( rValue.GetChar( i ) == '{' ) || ( rValue.GetChar( i ) == '\\' ) ||
- ( rValue.GetChar( i ) == '\r' ))
- rValue.Erase( i );
+ if ( !rValue.isEmpty()) {
+ for ( sal_Int32 i = rValue.getLength() - 1; i > 0; i-- ) {
+ if (( rValue[i] == ' ' ) || ( rValue[i] == '\t' ) ||
+ ( rValue[i] == '\n' ) || ( rValue[i] == ';' ) ||
+ ( rValue[i] == '{' ) || ( rValue[i] == '\\' ) ||
+ ( rValue[i] == '\r' ))
+ rValue = rValue.copy(0, i);
else
break;
}
@@ -1519,19 +1521,19 @@ rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
case TEXTLINE:
case LONGTEXTLINE:
{
- ByteString sTmp(rSource.copy(rSource.indexOf("=")));
+ rtl::OString sTmp(rSource.copy(rSource.indexOf("=")));
CleanValue( sTmp );
sTmp = comphelper::string::remove(sTmp, '\n');
sTmp = comphelper::string::remove(sTmp, '\r');
- while ( sTmp.SearchAndReplace( "\\\\\"", "-=<[BSlashBSlashHKom]>=-\"" )
- != STRING_NOTFOUND ) {}
- while ( sTmp.SearchAndReplace( "\\\"", "-=<[Hochkomma]>=-" )
- != STRING_NOTFOUND ) {}
- while ( sTmp.SearchAndReplace( "\\", "-=<[0x7F]>=-" )
- != STRING_NOTFOUND ) {}
- while ( sTmp.SearchAndReplace( "\\0x7F", "-=<[0x7F]>=-" )
- != STRING_NOTFOUND ) {}
+ while ( helper::searchAndReplace(&sTmp, "\\\\\"", "-=<[BSlashBSlashHKom]>=-\"" )
+ != -1 ) {}
+ while ( helper::searchAndReplace(&sTmp, "\\\"", "-=<[Hochkomma]>=-" )
+ != -1 ) {}
+ while ( helper::searchAndReplace(&sTmp, "\\", "-=<[0x7F]>=-" )
+ != -1 ) {}
+ while ( helper::searchAndReplace(&sTmp, "\\0x7F", "-=<[0x7F]>=-" )
+ != -1 ) {}
sal_uInt16 nStart = 0;
sal_uInt16 nState = TXT_STATE_MACRO;
@@ -1638,21 +1640,20 @@ void Export::WriteToMerged(const rtl::OString &rText , bool bSDFContent)
}
/*****************************************************************************/
-void Export::ConvertMergeContent( ByteString &rText )
+void Export::ConvertMergeContent( rtl::OString &rText )
/*****************************************************************************/
{
- sal_Bool bNoOpen = ( rText.Search( "\\\"" ) != 0 );
- ByteString sClose( rText.Copy( rText.Len() - 2 ));
- sal_Bool bNoClose = ( sClose != "\\\"" );
+ sal_Bool bNoOpen = ( rText.indexOf( "\\\"" ) != 0 );
+ sal_Bool bNoClose = !helper::endsWith(rText, "\\\"");
rtl::OStringBuffer sNew;
- for ( sal_uInt16 i = 0; i < rText.Len(); i++ )
+ for ( sal_Int32 i = 0; i < rText.getLength(); i++ )
{
- rtl::OString sChar( rText.GetChar( i ));
+ rtl::OString sChar( rText[i]);
if (sChar.equalsL(RTL_CONSTASCII_STRINGPARAM("\\")))
{
- if (( i + 1 ) < rText.Len())
+ if (( i + 1 ) < rText.getLength())
{
- sal_Char cNext = rText.GetChar(i + 1);
+ sal_Char cNext = rText[i + 1];
if ( cNext == '\"' )
{
sChar = rtl::OString('\"');
@@ -1705,12 +1706,12 @@ void Export::ConvertMergeContent( ByteString &rText )
rText += "\"";
}
-sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
+sal_Bool Export::PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
rtl::OString &rLangIndex, ResData *pResData)
{
// position to merge in:
- sal_uInt16 nStart = 0;
- sal_uInt16 nEnd = 0;
+ sal_Int32 nStart = 0;
+ sal_Int32 nEnd = 0;
ByteString sOldId = pResData->sId;
ByteString sOldGId = pResData->sGId;
ByteString sOldTyp = pResData->sResTyp;
@@ -1763,15 +1764,15 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
rText = (*pCurEntry)[ SOURCE_LANGUAGE ];
}
- nStart = rText.Search( "\"" );
- if ( nStart == STRING_NOTFOUND ) {
+ nStart = rText.indexOf( '"' );
+ if ( nStart == -1 ) {
rText = sOrigText;
return sal_False;
}
sal_Bool bFound = sal_False;
- for ( nEnd = nStart + 1; nEnd < rText.Len() && !bFound; nEnd++ ) {
- if ( rText.GetChar( nEnd ) == '\"' )
+ for ( nEnd = nStart + 1; nEnd < rText.getLength() && !bFound; nEnd++ ) {
+ if ( rText[nEnd] == '\"' )
bFound = sal_True;
}
if ( !bFound ) {
@@ -1781,8 +1782,8 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
nEnd --;
sLastListLine = rText;
- if (( sLastListLine.Search( ">" ) != STRING_NOTFOUND ) &&
- ( sLastListLine.Search( "<" ) == STRING_NOTFOUND ))
+ if (( sLastListLine.indexOf( '>' ) != -1 ) &&
+ ( sLastListLine.indexOf( '<' ) == -1 ))
{
ByteString sTmp = sLastListLine;
sLastListLine = "<";
@@ -1805,16 +1806,16 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
case STRING_TYP_QUICKHELPTEXT :
case STRING_TYP_TITLE :
{
- nStart = rText.Search( "=" );
- if ( nStart == STRING_NOTFOUND ) {
+ nStart = rText.indexOf( "=" );
+ if ( nStart == -1 ) {
rText = sOrigText;
return sal_False;
}
nStart++;
sal_Bool bFound = sal_False;
- while(( nStart < rText.Len()) && !bFound ) {
- if (( rText.GetChar( nStart ) != ' ' ) && ( rText.GetChar( nStart ) != '\t' ))
+ while(( nStart < rText.getLength()) && !bFound ) {
+ if (( rText[nStart] != ' ' ) && ( rText[nStart] != '\t' ))
bFound = sal_True;
else
nStart ++;
@@ -1827,13 +1828,13 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
}
// position to end mergeing in
- nEnd = rText.Len() - 1;
+ nEnd = rText.getLength() - 1;
bFound = sal_False;
while (( nEnd > nStart ) && !bFound ) {
- if (( rText.GetChar( nEnd ) != ' ' ) && ( rText.GetChar( nEnd ) != '\t' ) &&
- ( rText.GetChar( nEnd ) != '\n' ) && ( rText.GetChar( nEnd ) != ';' ) &&
- ( rText.GetChar( nEnd ) != '{' ) && ( rText.GetChar( nEnd ) != '\\' ))
+ if (( rText[nEnd] != ' ' ) && ( rText[nEnd] != '\t' ) &&
+ ( rText[nEnd] != '\n' ) && ( rText[nEnd] != ';' ) &&
+ ( rText[nEnd] != '{' ) && ( rText[nEnd] != '\\' ))
{
bFound = sal_True;
}
@@ -1866,9 +1867,9 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
return sal_False; // no data found
}
- ByteString sContent;
+ rtl::OString sContent;
pEntrys->GetTransex3Text(sContent, nTyp, rLangIndex);
- if (!sContent.Len() && (!Export::isSourceLanguage(rLangIndex)))
+ if (sContent.isEmpty() && (!Export::isSourceLanguage(rLangIndex)))
{
rText = sOrigText;
return sal_False; // no data found
@@ -1877,8 +1878,8 @@ sal_Bool Export::PrepareTextToMerge(ByteString &rText, sal_uInt16 nTyp,
if (Export::isSourceLanguage(rLangIndex))
return sal_False;
- ByteString sPostFix( rText.Copy( ++nEnd ));
- rText.Erase( nStart );
+ ByteString sPostFix( rText.copy( ++nEnd ));
+ rText = rText.copy(0, nStart);
ConvertMergeContent( sContent );
@@ -1920,9 +1921,9 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sText;
+ rtl::OString sText;
sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TEXT, sCur , sal_True );
- if ( bText && sText.Len() && sText != "-" ) {
+ if ( bText && !sText.isEmpty() && sText != "-" ) {
ByteString sOutput;
if ( bNextMustBeDefineEOL) {
if ( bFirst )
@@ -1972,9 +1973,9 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sText;
+ rtl::OString sText;
sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_QUICKHELPTEXT, sCur, sal_True );
- if ( bText && sText.Len() && sText != "-" ) {
+ if ( bText && !sText.isEmpty() && sText != "-" ) {
ByteString sOutput;
if ( bNextMustBeDefineEOL) {
if ( bFirst )
@@ -2018,9 +2019,9 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sText;
+ rtl::OString sText;
sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TITLE, sCur, sal_True );
- if ( bText && sText.Len() && sText != "-" ) {
+ if ( bText && !sText.isEmpty() && sText != "-" ) {
ByteString sOutput;
if ( bNextMustBeDefineEOL) {
if ( bFirst )
@@ -2098,13 +2099,13 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
nMaxIndex = pList->GetSourceLanguageListEntryCount();
pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
while( pEntrys && ( nLIndex < nMaxIndex )) {
- ByteString sText;
+ rtl::OString sText;
sal_Bool bText;
bText = pEntrys->GetTransex3Text( sText, STRING_TYP_TEXT, sCur, sal_True );
if( !bText )
bText = pEntrys->GetTransex3Text( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , sal_False );
- if ( bText && sText.Len())
+ if ( bText && !sText.isEmpty())
{
if ( nIdx == 1 )
{
@@ -2148,31 +2149,31 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
}
WriteToMerged(sHead.makeStringAndClear() , true);
}
- ByteString sLine;
+ rtl::OString sLine;
if ( pList && (*pList)[ nLIndex ] )
sLine = ( *(*pList)[ nLIndex ])[ SOURCE_LANGUAGE ];
- if ( !sLine.Len())
+ if ( sLine.isEmpty())
sLine = sLastListLine;
- if ( sLastListLine.Search( "<" ) != STRING_NOTFOUND ) {
+ if ( sLastListLine.indexOf( '<' ) != -1 ) {
if (( nT != LIST_UIENTRIES ) &&
- (( sLine.Search( "{" ) == STRING_NOTFOUND ) ||
- ( sLine.Search( "{" ) >= sLine.Search( "\"" ))) &&
- (( sLine.Search( "<" ) == STRING_NOTFOUND ) ||
- ( sLine.Search( "<" ) >= sLine.Search( "\"" ))))
+ (( sLine.indexOf( '{' ) == -1 ) ||
+ ( sLine.indexOf( '{' ) >= sLine.indexOf( '"' ))) &&
+ (( sLine.indexOf( '<' ) == -1 ) ||
+ ( sLine.indexOf( '<' ) >= sLine.indexOf( '"' ))))
{
- sLine.SearchAndReplace( "\"", "< \"" );
+ helper::searchAndReplace(&sLine, "\"", "< \"" );
}
}
- sal_uInt16 nStart, nEnd;
- nStart = sLine.Search( "\"" );
+ sal_Int32 nStart, nEnd;
+ nStart = sLine.indexOf( '"' );
ByteString sPostFix;
if( !bPairedList ){
- nEnd = sLine.SearchBackward( '\"' );
- sPostFix = ByteString( sLine.Copy( ++nEnd ));
- sLine.Erase( nStart );
+ nEnd = sLine.lastIndexOf( '"' );
+ sPostFix = sLine.copy( ++nEnd );
+ sLine = sLine.copy(0, nStart);
}
@@ -2251,20 +2252,20 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
sal_uLong nMaxIndex = 0;
if ( pList )
nMaxIndex = pList->GetSourceLanguageListEntryCount();
- ByteString sLine;
+ rtl::OString sLine;
if ( pList && (*pList)[ nListIndex ] )
sLine = ( *(*pList)[ nListIndex ])[ SOURCE_LANGUAGE ];
- if ( !sLine.Len())
+ if ( sLine.isEmpty())
sLine = sLastListLine;
- if ( sLastListLine.Search( "<" ) != STRING_NOTFOUND ) {
+ if ( sLastListLine.indexOf( '<' ) != -1 ) {
if (( nList != LIST_UIENTRIES ) &&
- (( sLine.Search( "{" ) == STRING_NOTFOUND ) ||
- ( sLine.Search( "{" ) >= sLine.Search( "\"" ))) &&
- (( sLine.Search( "<" ) == STRING_NOTFOUND ) ||
- ( sLine.Search( "<" ) >= sLine.Search( "\"" ))))
+ (( sLine.indexOf( '{' ) == -1 ) ||
+ ( sLine.indexOf( '{' ) >= sLine.indexOf( '"' ))) &&
+ (( sLine.indexOf( '<' ) == -1 ) ||
+ ( sLine.indexOf( '<' ) >= sLine.indexOf( '"' ))))
{
- sLine.SearchAndReplace( "\"", "< \"" );
+ helper::searchAndReplace(&sLine, "\"", "< \"" );
}
}
@@ -2279,7 +2280,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
nListIndex++;
if ( pList && (*pList)[ nListIndex ])
sLine = ( *(*pList)[ nListIndex ])[ SOURCE_LANGUAGE ];
- if ( !sLine.Len())
+ if ( sLine.isEmpty())
sLine = sLastListLine;
sLine += " ;";
}
@@ -2289,12 +2290,12 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
pParseQueue->bMflag = false;
}
-ByteString Export::MergePairedList( ByteString& sLine , ByteString& sText ){
+rtl::OString Export::MergePairedList( rtl::OString const & sLine , rtl::OString const & sText ){
// < "xy" ; IDENTIFIER ; >
- ByteString sPre = sLine.Copy( 0 , sLine.Search('\"') );
- ByteString sPost = sLine.Copy( sLine.SearchBackward('\"') + 1 , sLine.Len() );
- sPre.Append( sText );
- sPre.Append( sPost );
+ rtl::OString sPre = sLine.copy( 0 , sLine.indexOf('"') );
+ rtl::OString sPost = sLine.copy( sLine.lastIndexOf('"') + 1 );
+ sPre += sText;
+ sPre += sPost;
return sPre;
}
diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index 1c0af7d44506..ee4cb0954881 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -106,13 +106,13 @@ void Export::DumpExportList(const rtl::OString& rListName, ExportList& aList)
}
void Export::DumpMap(const rtl::OString& rMapName,
- ByteStringHashMap& aMap)
+ OStringHashMap& aMap)
{
if( rMapName.getLength() )
printf("MapName %s\n", rMapName.getStr());
if( aMap.size() < 1 )
return;
- for(ByteStringHashMap::const_iterator idbg = aMap.begin(); idbg != aMap.end(); ++idbg)
+ for(OStringHashMap::const_iterator idbg = aMap.begin(); idbg != aMap.end(); ++idbg)
{
ByteString a( idbg->first );
ByteString b( idbg->second );
@@ -143,24 +143,24 @@ std::vector<rtl::OString> Export::aLanguages = std::vector<rtl::OString>()
std::vector<rtl::OString> Export::aForcedLanguages = std::vector<rtl::OString>();
/*****************************************************************************/
-void Export::QuotHTML( ByteString &rString )
+rtl::OString Export::QuoteHTML( rtl::OString const &rString )
/*****************************************************************************/
{
rtl::OStringBuffer sReturn;
- for ( sal_uInt16 i = 0; i < rString.Len(); i++ ) {
- ByteString sTemp = rString.Copy( i );
- if ( sTemp.Search( "<Arg n=" ) == 0 ) {
- while ( i < rString.Len() && rString.GetChar( i ) != '>' ) {
- sReturn.append(rString.GetChar(i));
+ for ( sal_Int32 i = 0; i < rString.getLength(); i++ ) {
+ rtl::OString sTemp = rString.copy( i );
+ if ( sTemp.match( "<Arg n=" ) ) {
+ while ( i < rString.getLength() && rString[i] != '>' ) {
+ sReturn.append(rString[i]);
i++;
}
- if ( rString.GetChar( i ) == '>' ) {
+ if ( rString[i] == '>' ) {
sReturn.append('>');
i++;
}
}
- if ( i < rString.Len()) {
- switch ( rString.GetChar( i )) {
+ if ( i < rString.getLength()) {
+ switch ( rString[i]) {
case '<':
sReturn.append("&lt;");
break;
@@ -178,20 +178,20 @@ void Export::QuotHTML( ByteString &rString )
break;
case '&':
- if ((( i + 4 ) < rString.Len()) &&
- ( rString.Copy( i, 5 ) == "&amp;" ))
- sReturn.append(rString.GetChar(i));
+ if ((( i + 4 ) < rString.getLength()) &&
+ ( rString.copy( i, 5 ) == "&amp;" ))
+ sReturn.append(rString[i]);
else
sReturn.append("&amp;");
break;
default:
- sReturn.append(rString.GetChar(i));
+ sReturn.append(rString[i]);
break;
}
}
}
- rString = sReturn.makeStringAndClear();
+ return sReturn.makeStringAndClear();
}
void Export::RemoveUTF8ByteOrderMarker( rtl::OString &rString )
@@ -298,45 +298,32 @@ bool Export::CopyFile(const rtl::OString& rSource, const rtl::OString& rDest)
}
/*****************************************************************************/
-void Export::UnquotHTML( ByteString &rString )
+rtl::OString Export::UnquoteHTML( rtl::OString const &rString )
/*****************************************************************************/
{
rtl::OStringBuffer sReturn;
-
- while ( rString.Len())
- {
- if ( rString.Copy( 0, 5 ) == "&amp;" )
- {
+ for (sal_Int32 i = 0; i != rString.getLength();) {
+ if (rString.match("&amp;", i)) {
sReturn.append('&');
- rString.Erase( 0, 5 );
- }
- else if ( rString.Copy( 0, 4 ) == "&lt;" )
- {
+ i += RTL_CONSTASCII_LENGTH("&amp;");
+ } else if (rString.match("&lt;", i)) {
sReturn.append('<');
- rString.Erase( 0, 4 );
- }
- else if ( rString.Copy( 0, 4 ) == "&gt;" )
- {
+ i += RTL_CONSTASCII_LENGTH("&lt;");
+ } else if (rString.match("&gt;", i)) {
sReturn.append('>');
- rString.Erase( 0, 4 );
- }
- else if ( rString.Copy( 0, 6 ) == "&quot;" )
- {
- sReturn.append('\"');;
- rString.Erase( 0, 6 );
- }
- else if ( rString.Copy( 0, 6 ) == "&apos;" )
- {
+ i += RTL_CONSTASCII_LENGTH("&gt;");
+ } else if (rString.match("&quot;", i)) {
+ sReturn.append('"');
+ i += RTL_CONSTASCII_LENGTH("&quot;");
+ } else if (rString.match("&apos;", i)) {
sReturn.append('\'');
- rString.Erase( 0, 6 );
- }
- else
- {
- sReturn.append(rString.GetChar(0));
- rString.Erase( 0, 1 );
+ i += RTL_CONSTASCII_LENGTH("&apos;");
+ } else {
+ sReturn.append(rString[i]);
+ ++i;
}
}
- rString = sReturn.makeStringAndClear();
+ return sReturn.makeStringAndClear();
}
bool Export::isSourceLanguage(const rtl::OString &rLanguage)
@@ -357,7 +344,7 @@ void Export::InitLanguages( bool bMergeMode ){
if( !isInitialized )
{
ByteString sTmp;
- ByteStringBoolHashMap aEnvLangs;
+ OStringBoolHashMap aEnvLangs;
sal_Int32 nIndex = 0;
do
@@ -380,7 +367,7 @@ void Export::InitLanguages( bool bMergeMode ){
void Export::InitForcedLanguages( bool bMergeMode ){
/*****************************************************************************/
ByteString sTmp;
- ByteStringBoolHashMap aEnvLangs;
+ OStringBoolHashMap aEnvLangs;
sal_Int32 nIndex = 0;
do
@@ -409,7 +396,7 @@ rtl::OString Export::GetTimeStamp()
/*****************************************************************************/
sal_Bool Export::ConvertLineEnds(
- ByteString sSource, ByteString sDestination )
+ rtl::OString const & sSource, rtl::OString const & sDestination )
/*****************************************************************************/
{
String sSourceFile( sSource, RTL_TEXTENCODING_ASCII_US );
@@ -445,7 +432,7 @@ sal_Bool Export::ConvertLineEnds(
}
/*****************************************************************************/
-ByteString Export::GetNativeFile( ByteString sSource )
+rtl::OString Export::GetNativeFile( rtl::OString const & sSource )
/*****************************************************************************/
{
DirEntry aTemp( GetTempFile());
@@ -455,7 +442,7 @@ ByteString Export::GetNativeFile( ByteString sSource )
if ( ConvertLineEnds( sSource, sReturn ))
return sReturn;
- return "";
+ return rtl::OString();
}
const char* Export::GetEnv( const char *pVar )
diff --git a/l10ntools/source/gsicheck.cxx b/l10ntools/source/gsicheck.cxx
index 8d5544f822e4..15ae5c557f23 100644
--- a/l10ntools/source/gsicheck.cxx
+++ b/l10ntools/source/gsicheck.cxx
@@ -32,6 +32,7 @@
#include <rtl/strbuf.hxx>
#include <comphelper/string.hxx>
+#include "helper.hxx"
#include "tagtest.hxx"
#include "gsicheck.hxx"
@@ -41,23 +42,23 @@ using comphelper::string::getTokenCount;
#define MAX_GID_LID_LEN 250
/*****************************************************************************/
-void PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix,
- ByteString aContext, sal_Bool bPrintContext, sal_uLong nLine, ByteString aUniqueId = ByteString() )
+void PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix,
+ rtl::OString const & aContext, sal_Bool bPrintContext, sal_uLong nLine, rtl::OString aUniqueId = rtl::OString() )
/*****************************************************************************/
{
- fprintf( stdout, "%s %s, Line %lu", aType.GetBuffer(), aPrefix.GetBuffer(), nLine );
- if ( aUniqueId.Len() )
- fprintf( stdout, ", UniqueID %s", aUniqueId.GetBuffer() );
- fprintf( stdout, ": %s", aMsg.GetBuffer() );
+ fprintf( stdout, "%s %s, Line %lu", aType.getStr(), aPrefix.getStr(), nLine );
+ if ( !aUniqueId.isEmpty() )
+ fprintf( stdout, ", UniqueID %s", aUniqueId.getStr() );
+ fprintf( stdout, ": %s", aMsg.getStr() );
if ( bPrintContext )
- fprintf( stdout, " \"%s\"", aContext.GetBuffer() );
+ fprintf( stdout, " \"%s\"", aContext.getStr() );
fprintf( stdout, "\n" );
}
/*****************************************************************************/
-void PrintError( ByteString aMsg, ByteString aPrefix,
- ByteString aContext, sal_Bool bPrintContext, sal_uLong nLine, ByteString aUniqueId = ByteString() )
+void PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix,
+ rtl::OString const & aContext, sal_Bool bPrintContext, sal_uLong nLine, rtl::OString const & aUniqueId = rtl::OString() )
/*****************************************************************************/
{
PrintMessage( "Error:", aMsg, aPrefix, aContext, bPrintContext, nLine, aUniqueId );
@@ -139,18 +140,29 @@ void LazySvFileStream::LazyOpen()
//
/*****************************************************************************/
-GSILine::GSILine( const ByteString &rLine, sal_uLong nLine )
+GSILine::GSILine( const rtl::OString &rLine, sal_uLong nLine )
/*****************************************************************************/
- : ByteString( rLine )
- , nLineNumber( nLine )
+ : nLineNumber( nLine )
, bOK( sal_True )
, bFixed ( sal_False )
+ , data_( rLine )
{
if ( getTokenCount(rLine, '\t') == 15 )
{
aFormat = FORMAT_SDF;
aUniqId = getToken(rLine, 0, '\t');
- aUniqId.Append("/").Append( getToken(rLine, 1, '\t') ).Append("/").Append( getToken(rLine, 3, '\t') ).Append("/").Append( getToken(rLine, 4, '\t') ).Append("/").Append( getToken(rLine, 5, '\t') ).Append("/").Append( getToken(rLine, 6, '\t') ).Append("/").Append( getToken(rLine, 7, '\t') );
+ aUniqId += "/";
+ aUniqId += getToken(rLine, 1, '\t');
+ aUniqId += "/";
+ aUniqId += getToken(rLine, 3, '\t');
+ aUniqId += "/";
+ aUniqId += getToken(rLine, 4, '\t');
+ aUniqId += "/";
+ aUniqId += getToken(rLine, 5, '\t');
+ aUniqId += "/";
+ aUniqId += getToken(rLine, 6, '\t');
+ aUniqId += "/";
+ aUniqId += getToken(rLine, 7, '\t');
aLineType = "";
aLangId = getToken(rLine, 9, '\t');
aText = getToken(rLine, 10, '\t');
@@ -201,12 +213,12 @@ void GSILine::ReassembleLine()
sal_uInt16 i;
for ( i = 0 ; i < 10 ; i++ )
{
- aReassemble.Append( GetToken( i, '\t' ) );
+ aReassemble.Append( helper::getToken( data_, i, '\t' ) );
aReassemble.Append( "\t" );
}
aReassemble.Append( aText );
aReassemble.Append( "\t" );
- aReassemble.Append( GetToken( 11, '\t' ) ); // should be empty but there are some places in sc. Not reflected to sources!!
+ aReassemble.Append( helper::getToken( data_, 11, '\t' ) ); // should be empty but there are some places in sc. Not reflected to sources!!
aReassemble.Append( "\t" );
aReassemble.Append( aQuickHelpText );
aReassemble.Append( "\t" );
@@ -214,7 +226,7 @@ void GSILine::ReassembleLine()
for ( i = 14 ; i < 15 ; i++ )
{
aReassemble.Append( "\t" );
- aReassemble.Append( GetToken( i, '\t' ) );
+ aReassemble.Append( helper::getToken( data_, i, '\t' ) );
}
*(ByteString*)this = aReassemble;
}
@@ -253,7 +265,7 @@ GSIBlock::~GSIBlock()
void GSIBlock::InsertLine( GSILine* pLine, const rtl::OString &rSourceLang)
{
- if ( pLine->GetLanguageId().Equals( rSourceLang ) )
+ if ( pLine->GetLanguageId() == rSourceLang )
{
if ( pSourceLine )
{
@@ -273,7 +285,7 @@ void GSIBlock::InsertLine( GSILine* pLine, const rtl::OString &rSourceLang)
{
for ( size_t nPos = 0, n = maList.size(); nPos < n; ++nPos )
{
- if ( maList[ nPos ]->GetLanguageId().Equals( pLine->GetLanguageId() ) )
+ if ( maList[ nPos ]->GetLanguageId() == pLine->GetLanguageId() )
{
PrintError( "Translation Language entry double. Checking both.", "File format", "", pLine->GetLineNumber(), pLine->GetUniqId() );
bHasBlockError = sal_True;
@@ -294,23 +306,23 @@ void GSIBlock::SetReferenceLine( GSILine* pLine )
}
/*****************************************************************************/
-void GSIBlock::PrintMessage( ByteString aType, ByteString aMsg, ByteString aPrefix,
- ByteString aContext, sal_uLong nLine, ByteString aUniqueId )
+void GSIBlock::PrintMessage( rtl::OString const & aType, rtl::OString const & aMsg, rtl::OString const & aPrefix,
+ rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId )
/*****************************************************************************/
{
::PrintMessage( aType, aMsg, aPrefix, aContext, bPrintContext, nLine, aUniqueId );
}
/*****************************************************************************/
-void GSIBlock::PrintError( ByteString aMsg, ByteString aPrefix,
- ByteString aContext, sal_uLong nLine, ByteString aUniqueId )
+void GSIBlock::PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix,
+ rtl::OString const & aContext, sal_uLong nLine, rtl::OString const & aUniqueId )
/*****************************************************************************/
{
PrintMessage( "Error:", aMsg, aPrefix, aContext, nLine, aUniqueId );
}
/*****************************************************************************/
-void GSIBlock::PrintList( ParserMessageList *pList, ByteString aPrefix,
+void GSIBlock::PrintList( ParserMessageList *pList, rtl::OString const & aPrefix,
GSILine *pLine )
/*****************************************************************************/
{
@@ -321,9 +333,9 @@ void GSIBlock::PrintList( ParserMessageList *pList, ByteString aPrefix,
if ( bPrintContext )
{
if ( pMsg->GetTagBegin() == STRING_NOTFOUND )
- aContext = pLine->GetText().Copy( 0, 300 );
+ aContext = pLine->GetText().copy( 0, 300 );
else
- aContext = pLine->Copy( pMsg->GetTagBegin()-150, 300 );
+ aContext = pLine->data_.copy( pMsg->GetTagBegin()-150, 300 );
aContext = comphelper::string::stripEnd(aContext, ' ');
aContext = comphelper::string::stripStart(aContext, ' ');
}
@@ -333,15 +345,15 @@ void GSIBlock::PrintList( ParserMessageList *pList, ByteString aPrefix,
}
/*****************************************************************************/
-sal_Bool GSIBlock::IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, ByteString &aErrorMsg, sal_Bool &bHasBeenFixed, ByteString &aFixed ) const
+sal_Bool GSIBlock::IsUTF8( const rtl::OString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, rtl::OString &aErrorMsg, sal_Bool &bHasBeenFixed, rtl::OString &aFixed ) const
/*****************************************************************************/
{
String aUTF8Tester(rtl::OStringToOUString(aTestee, RTL_TEXTENCODING_UTF8));
if ( STRING_MATCH != (nErrorPos = ByteString(rtl::OUStringToOString(aUTF8Tester, RTL_TEXTENCODING_UTF8)).Match( aTestee )) )
{
- aUTF8Tester = String( aTestee.GetBuffer(), nErrorPos, RTL_TEXTENCODING_UTF8 );
+ aUTF8Tester = String( aTestee.getStr(), nErrorPos, RTL_TEXTENCODING_UTF8 );
nErrorPos = aUTF8Tester.Len();
- aErrorMsg = ByteString( "UTF8 Encoding seems to be broken" );
+ aErrorMsg = "UTF8 Encoding seems to be broken";
return sal_False;
}
@@ -349,14 +361,14 @@ sal_Bool GSIBlock::IsUTF8( const ByteString &aTestee, sal_Bool bFixTags, sal_uIn
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f" ).GetBuffer() );
if ( nErrorPos != STRING_NOTFOUND )
{
- aErrorMsg = ByteString( "String contains illegal character" );
+ aErrorMsg = "String contains illegal character";
return sal_False;
}
if ( bFixTags )
{
bHasBeenFixed = sal_False;
- aFixed.Erase();
+ aFixed = rtl::OString();
}
return sal_True;
@@ -367,13 +379,13 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
/*****************************************************************************/
{
sal_uInt16 nErrorPos = 0;
- ByteString aErrorMsg;
+ rtl::OString aErrorMsg;
sal_Bool bError = sal_False;
- ByteString aFixed;
+ rtl::OString aFixed;
sal_Bool bHasBeenFixed = sal_False;
if ( !IsUTF8( pTestee->GetText(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) )
{
- ByteString aContext( pTestee->GetText().Copy( nErrorPos, 20 ) );
+ ByteString aContext( pTestee->GetText().copy( nErrorPos, 20 ) );
PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in Text at Position "))
.append(static_cast<sal_Int32>(nErrorPos)).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
@@ -386,7 +398,7 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
}
if ( !IsUTF8( pTestee->GetQuickHelpText(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) )
{
- ByteString aContext( pTestee->GetQuickHelpText().Copy( nErrorPos, 20 ) );
+ rtl::OString aContext( pTestee->GetQuickHelpText().copy( nErrorPos, 20 ) );
PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in QuickHelpText at Position "))
.append(static_cast<sal_Int32>(nErrorPos)).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
@@ -399,7 +411,7 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
}
if ( !IsUTF8( pTestee->GetTitle(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) )
{
- ByteString aContext( pTestee->GetTitle().Copy( nErrorPos, 20 ) );
+ rtl::OString aContext( pTestee->GetTitle().copy( nErrorPos, 20 ) );
PrintError(rtl::OStringBuffer(aErrorMsg).append(RTL_CONSTASCII_STRINGPARAM(" in Title at Position "))
.append(static_cast<sal_Int32>(nErrorPos)).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
@@ -420,13 +432,13 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
sal_Bool GSIBlock::HasSuspiciousChars( GSILine* pTestee, GSILine* pSource )
/*****************************************************************************/
{
- sal_uInt16 nPos = 0;
- if ( !bAllowSuspicious && ( nPos = pTestee->GetText().Search("??")) != STRING_NOTFOUND )
- if ( pSource->GetText().Search("??") == STRING_NOTFOUND )
+ sal_Int32 nPos = 0;
+ if ( !bAllowSuspicious && ( nPos = pTestee->GetText().indexOf("??")) != -1 )
+ if ( pSource->GetText().indexOf("??") == -1 )
{
String aUTF8Tester = String( pTestee->GetText(), 0, nPos, RTL_TEXTENCODING_UTF8 );
sal_uInt16 nErrorPos = aUTF8Tester.Len();
- ByteString aContext( pTestee->GetText().Copy( nPos, 20 ) );
+ rtl::OString aContext( pTestee->GetText().copy( nPos, 20 ) );
PrintError(rtl::OStringBuffer(RTL_CONSTASCII_STRINGPARAM("Found double questionmark in translation only. Looks like an encoding problem at Position "))
.append(static_cast<sal_Int32>(nErrorPos)).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
@@ -480,11 +492,11 @@ sal_Bool GSIBlock::CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sa
}
else
{
- if ( pSourceLine && !pSourceLine->Equals( *pReferenceLine ) )
+ if ( pSourceLine && pSourceLine->data_ != pReferenceLine->data_ )
{
- xub_StrLen nPos = pSourceLine->Match( *pReferenceLine );
- ByteString aContext( pReferenceLine->Copy( nPos - 5, 15) );
- aContext.Append( "\" --> \"" ).Append( pSourceLine->Copy( nPos - 5, 15) );
+ xub_StrLen nPos = ByteString(pSourceLine->data_).Match( pReferenceLine->data_ );
+ ByteString aContext( pReferenceLine->data_.copy( nPos - 5, 15) );
+ aContext.Append( "\" --> \"" ).Append( pSourceLine->data_.copy( nPos - 5, 15) );
PrintError( "Source Language Entry has changed.", "File format", aContext, pSourceLine->GetLineNumber(), pSourceLine->GetUniqId() );
pSourceLine->NotOK();
bHasError = sal_True;
@@ -529,14 +541,14 @@ void GSIBlock::WriteError( LazySvFileStream &aErrOut, sal_Bool bRequireSourceLin
{
bHasError = sal_True;
aErrOut.LazyOpen();
- aErrOut.WriteLine( *pItem );
+ aErrOut.WriteLine( pItem->data_ );
}
}
if ( pSourceLine && ( bHasError || !pSourceLine->IsOK() ) && !( !bHasError && bCheckTranslationLang ) )
{
aErrOut.LazyOpen();
- aErrOut.WriteLine( *pSourceLine );
+ aErrOut.WriteLine( pSourceLine->data_ );
}
}
@@ -553,14 +565,14 @@ void GSIBlock::WriteCorrect( LazySvFileStream &aOkOut, sal_Bool bRequireSourceLi
{
bHasOK = sal_True;
aOkOut.LazyOpen();
- aOkOut.WriteLine( *pItem );
+ aOkOut.WriteLine( pItem->data_ );
}
}
if ( ( pSourceLine && pSourceLine->IsOK() && ( !maList.empty() || !bCheckTranslationLang ) ) || ( bHasOK && bCheckTranslationLang ) )
{
aOkOut.LazyOpen();
- aOkOut.WriteLine( *pSourceLine );
+ aOkOut.WriteLine( pSourceLine->data_ );
}
}
@@ -577,14 +589,14 @@ void GSIBlock::WriteFixed( LazySvFileStream &aFixOut )
{
bHasFixes = sal_True;
aFixOut.LazyOpen();
- aFixOut.WriteLine( *pItem );
+ aFixOut.WriteLine( pItem->data_ );
}
}
if ( pSourceLine && ( bHasFixes || pSourceLine->IsFixed() ) )
{
aFixOut.LazyOpen();
- aFixOut.WriteLine( *pSourceLine );
+ aFixOut.WriteLine( pSourceLine->data_ );
}
}
@@ -654,7 +666,7 @@ int _cdecl main( int argc, char *argv[] )
String aCorrectFilename;
String aFixedFilename;
sal_Bool bFileHasError = sal_False;
- ByteString aSourceLang( "en-US" ); // English is default
+ rtl::OString aSourceLang( "en-US" ); // English is default
ByteString aFilename;
ByteString aReferenceFilename;
sal_Bool bReferenceFile = sal_False;
@@ -734,9 +746,9 @@ int _cdecl main( int argc, char *argv[] )
{
if ( (i+1) < argc )
{
- aSourceLang = ByteString( argv[ i+1 ] );
- if ( aSourceLang.EqualsIgnoreCaseAscii( "none" ) )
- aSourceLang.Erase();
+ aSourceLang = argv[ i+1 ];
+ if ( aSourceLang.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("none")) )
+ aSourceLang = rtl::OString();
i++;
}
else
@@ -795,9 +807,9 @@ int _cdecl main( int argc, char *argv[] )
exit ( 0 );
}
- if ( aSourceLang.Len() && !LanguageOK( aSourceLang ) )
+ if ( !aSourceLang.isEmpty() && !LanguageOK( aSourceLang ) )
{
- fprintf( stderr, "\nERROR: The Language '%s' is invalid!\n\n", aSourceLang.GetBuffer() );
+ fprintf( stderr, "\nERROR: The Language '%s' is invalid!\n\n", aSourceLang.getStr() );
Help();
exit ( 1 );
}
@@ -887,7 +899,7 @@ int _cdecl main( int argc, char *argv[] )
rtl::OString sGSILine;
GSILine* pGSILine = NULL;
- ByteString aOldId("No Valid ID"); // just set to something which can never be an ID
+ rtl::OString aOldId("No Valid ID"); // just set to something which can never be an ID
GSIBlock *pBlock = NULL;
sal_uLong nLine = 0;
@@ -899,40 +911,40 @@ int _cdecl main( int argc, char *argv[] )
sal_Bool bDelete = sal_True;
- if ( pGSILine->Len() )
+ if ( !pGSILine->data_.isEmpty() )
{
if ( FORMAT_UNKNOWN == pGSILine->GetLineFormat() )
{
- PrintError( "Format of line is unknown. Ignoring!", "Line format", pGSILine->Copy( 0,40 ), bPrintContext, pGSILine->GetLineNumber() );
+ PrintError( "Format of line is unknown. Ignoring!", "Line format", pGSILine->data_.copy( 0,40 ), bPrintContext, pGSILine->GetLineNumber() );
pGSILine->NotOK();
if ( bWriteError )
{
bFileHasError = sal_True;
aErrOut.LazyOpen();
- aErrOut.WriteLine( *pGSILine );
+ aErrOut.WriteLine( pGSILine->data_ );
}
}
- else if ( pGSILine->GetLineType().EqualsIgnoreCaseAscii("res-comment") )
+ else if ( pGSILine->GetLineType().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("res-comment")) )
{ // ignore comment lines, but write them to Correct Items File
if ( bWriteCorrect )
{
aOkOut.LazyOpen();
- aOkOut.WriteLine( *pGSILine );
+ aOkOut.WriteLine( pGSILine->data_ );
}
}
else
{
- ByteString aId = pGSILine->GetUniqId();
+ rtl::OString aId = pGSILine->GetUniqId();
if ( aId != aOldId )
{
if ( pBlock )
{
- bFileHasError |= pBlock->CheckSyntax( nLine, aSourceLang.Len() != 0, bFixTags );
+ bFileHasError |= pBlock->CheckSyntax( nLine, !aSourceLang.isEmpty(), bFixTags );
if ( bWriteError )
- pBlock->WriteError( aErrOut, aSourceLang.Len() != 0 );
+ pBlock->WriteError( aErrOut, !aSourceLang.isEmpty() );
if ( bWriteCorrect )
- pBlock->WriteCorrect( aOkOut, aSourceLang.Len() != 0 );
+ pBlock->WriteCorrect( aOkOut, !aSourceLang.isEmpty() );
if ( bWriteFixed )
pBlock->WriteFixed( aFixOut );
@@ -957,7 +969,7 @@ int _cdecl main( int argc, char *argv[] )
}
if ( pReferenceLine->GetLineFormat() != FORMAT_UNKNOWN )
{
- if ( pReferenceLine->GetUniqId() == aId && pReferenceLine->GetLanguageId().Equals( aSourceLang ) )
+ if ( pReferenceLine->GetUniqId() == aId && pReferenceLine->GetLanguageId() == aSourceLang )
{
pBlock->SetReferenceLine( pReferenceLine );
pReferenceLine = NULL;
@@ -968,7 +980,7 @@ int _cdecl main( int argc, char *argv[] )
}
else
{
- if ( pReferenceLine->GetUniqId() < aId && pReferenceLine->GetLanguageId().Equals( aSourceLang ) )
+ if ( pReferenceLine->GetUniqId() < aId && pReferenceLine->GetLanguageId() == aSourceLang )
PrintError( "No Entry in source file found. Entry has been removed from source file", "File format", "", bPrintContext, pGSILine->GetLineNumber(), pReferenceLine->GetUniqId() );
delete pReferenceLine;
pReferenceLine = NULL;
@@ -995,12 +1007,12 @@ int _cdecl main( int argc, char *argv[] )
}
if ( pBlock )
{
- bFileHasError |= pBlock->CheckSyntax( nLine, aSourceLang.Len() != 0, bFixTags );
+ bFileHasError |= pBlock->CheckSyntax( nLine, !aSourceLang.isEmpty(), bFixTags );
if ( bWriteError )
- pBlock->WriteError( aErrOut, aSourceLang.Len() != 0 );
+ pBlock->WriteError( aErrOut, !aSourceLang.isEmpty() );
if ( bWriteCorrect )
- pBlock->WriteCorrect( aOkOut, aSourceLang.Len() != 0 );
+ pBlock->WriteCorrect( aOkOut, !aSourceLang.isEmpty() );
if ( bWriteFixed )
pBlock->WriteFixed( aFixOut );
diff --git a/l10ntools/source/helper.hxx b/l10ntools/source/helper.hxx
new file mode 100644
index 000000000000..5b20595f9490
--- /dev/null
+++ b/l10ntools/source/helper.hxx
@@ -0,0 +1,70 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * [ Copyright (C) 2012 Red Hat, Inc., Stephan Bergmann <sbergman@redhat.com>
+ * (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef INCLUDED_L10NTOOLS_SOURCE_HELPER_HXX
+#define INCLUDED_L10NTOOLS_SOURCE_HELPER_HXX
+
+#include "sal/config.h"
+
+#include <cassert>
+
+#include "rtl/string.hxx"
+#include "sal/types.h"
+
+namespace helper {
+
+inline bool endsWith(rtl::OString const & text, rtl::OString const & search) {
+ return text.getLength() >= search.getLength()
+ && text.match(search, text.getLength() - search.getLength());
+}
+
+inline sal_Int32 searchAndReplace(
+ rtl::OString * text, rtl::OString const & search,
+ rtl::OString const & replace)
+{
+ assert(text != 0);
+ sal_Int32 i = text->indexOf(search);
+ if (i != -1) {
+ *text = text->replaceAt(i, search.getLength(), replace);
+ }
+ return i;
+}
+
+inline rtl::OString getToken(
+ rtl::OString const & text, sal_Int32 token, char separator)
+{
+ sal_Int32 i = 0;
+ return text.getToken(token, separator, i);
+}
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index a8965959a258..02f091603e3c 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -209,7 +209,7 @@ int _cdecl main( int argc, char *argv[] )
hasNoError = aParser.Merge( sSDFFile, sOutputFile , Export::sLanguages , aMergeDataFile );
}
else
- hasNoError = aParser.CreateSDF( sOutputFile, sPrj, sPrjRoot, sInputFile, new XMLFile( '0' ), "help" );
+ hasNoError = aParser.CreateSDF( sOutputFile, sPrj, sPrjRoot, sInputFile, new XMLFile( rtl::OUString('0') ), "help" );
}else if ( sOutputFileX.getLength() && sOutputFileY.getLength() && hasInputList ) { // Merge multiple files ?
if ( bMergeMode ){
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index ffe31bb6d654..2c17fd7a76f2 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -55,11 +55,11 @@ void HelpParser::Dump(XMLHashMap* rElem_in)
}
}
-void HelpParser::Dump(LangHashMap* rElem_in,const ByteString sKey_in)
+void HelpParser::Dump(LangHashMap* rElem_in,const rtl::OString & sKey_in)
{
ByteString x;
OString y;
- fprintf(stdout,"+------------%s-----------+\n",sKey_in.GetBuffer() );
+ fprintf(stdout,"+------------%s-----------+\n",sKey_in.getStr() );
for(LangHashMap::iterator posn=rElem_in->begin();posn!=rElem_in->end();++posn)
{
x=posn->first;
@@ -70,7 +70,7 @@ void HelpParser::Dump(LangHashMap* rElem_in,const ByteString sKey_in)
}
#endif
-HelpParser::HelpParser( const ByteString &rHelpFile, bool rUTF8 , bool rHasInputList )
+HelpParser::HelpParser( const rtl::OString &rHelpFile, bool rUTF8 , bool rHasInputList )
: sHelpFile( rHelpFile ),
bUTF8 ( rUTF8 ),
bHasInputList( rHasInputList )
@@ -79,8 +79,8 @@ HelpParser::HelpParser( const ByteString &rHelpFile, bool rUTF8 , bool rHasInput
/*****************************************************************************/
bool HelpParser::CreateSDF(
/*****************************************************************************/
- const ByteString &rSDFFile_in, const ByteString &rPrj_in,const ByteString &rRoot_in,
- const ByteString &sHelpFile, XMLFile *pXmlFile, const ByteString &rGsi1){
+ 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") );
@@ -137,11 +137,11 @@ bool HelpParser::CreateSDF(
STREAM_STD_WRITE | STREAM_TRUNC );
if ( !aSDFStream.IsOpen()) {
- fprintf(stdout,"Can't open file %s\n",rSDFFile_in.GetBuffer());
+ fprintf(stdout,"Can't open file %s\n",rSDFFile_in.getStr());
return false;
}
- ByteString sActFileName = makeAbsolutePath( sHelpFile , rRoot_in );
+ rtl::OString sActFileName = makeAbsolutePath( sHelpFile , rRoot_in );
XMLHashMap* aXMLStrHM = file->GetStrings();
LangHashMap* pElem;
@@ -151,9 +151,9 @@ bool HelpParser::CreateSDF(
OUString sOUTimeStamp( sTimeStamp.GetBuffer() , sTimeStamp.Len() , RTL_TEXTENCODING_ASCII_US );
OUStringBuffer sBuffer;
- const OUString sOUPrj( rPrj_in.GetBuffer() , rPrj_in.Len() , RTL_TEXTENCODING_ASCII_US );
- const OUString sOUActFileName(sActFileName.GetBuffer() , sActFileName.Len() , RTL_TEXTENCODING_ASCII_US );
- const OUString sOUGsi1( rGsi1.GetBuffer() , rGsi1.Len() , RTL_TEXTENCODING_ASCII_US );
+ const OUString sOUPrj( rPrj_in.getStr() , rPrj_in.getLength() , RTL_TEXTENCODING_ASCII_US );
+ const OUString sOUActFileName(sActFileName.getStr() , sActFileName.getLength() , RTL_TEXTENCODING_ASCII_US );
+ const OUString sOUGsi1( rGsi1.getStr() , rGsi1.getLength() , RTL_TEXTENCODING_ASCII_US );
Export::InitLanguages( false );
std::vector<rtl::OString> aLanguages = Export::GetLanguages();
@@ -183,7 +183,7 @@ bool HelpParser::CreateSDF(
data = OUString( sTmp );
sBuffer.append( sOUPrj );
sBuffer.append( GSI_TAB ); //"\t";
- if ( rRoot_in.Len())
+ if ( !rRoot_in.isEmpty())
sBuffer.append( sOUActFileName );
sBuffer.append( GSI_SEQUENCE1 ); //"\t0\t";
sBuffer.append( sOUGsi1 ); //"help";
@@ -230,7 +230,7 @@ rtl::OString HelpParser::makeAbsolutePath(const rtl::OString& sHelpFile, const r
return sActFileName.replace('/', '\\');
}
-bool HelpParser::Merge( const ByteString &rSDFFile, const ByteString &rDestinationFile ,
+bool HelpParser::Merge( const rtl::OString &rSDFFile, const rtl::OString &rDestinationFile ,
const rtl::OString& rLanguage , MergeDataFile& aMergeDataFile )
{
@@ -259,7 +259,7 @@ bool HelpParser::Merge( const ByteString &rSDFFile, const ByteString &rDestinati
String fullFilePath;
DirEntry aFile( sXmlFile );
- XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( '0' ) ) );
+ XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( rtl::OUString('0') ) ) );
hasNoError = MergeSingleFile( xmlfile , aMergeDataFile , rLanguage , rDestinationFile );
delete xmlfile;
if( !sUsedTempFile.EqualsIgnoreCaseAscii( "" ) ){
@@ -308,7 +308,7 @@ void HelpParser::parse_languages( std::vector<rtl::OString>& aLanguages , MergeD
}
bool HelpParser::Merge(
- const ByteString &rSDFFile, const ByteString &rPathX , const ByteString &rPathY , bool bISO ,
+ const rtl::OString &rSDFFile, const rtl::OString &rPathX , const rtl::OString &rPathY , bool bISO ,
const std::vector<rtl::OString>& aLanguages , MergeDataFile& aMergeDataFile , bool bCreateDir )
{
@@ -340,7 +340,7 @@ bool HelpParser::Merge(
String fullFilePath;
DirEntry aFile( sXmlFile );
- XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( '0' ) ) );
+ XMLFile* xmlfile = ( aParser.Execute( aFile.GetFull() , sOUHelpFile, new XMLFile( rtl::OUString('0') ) ) );
xmlfile->Extract();
if( xmlfile == NULL)
@@ -377,8 +377,8 @@ bool HelpParser::Merge(
return hasNoError;
}
-bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const ByteString& sLanguage ,
- ByteString sPath )
+bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile , const rtl::OString& sLanguage ,
+ rtl::OString const & sPath )
{
file->Extract();
@@ -501,7 +501,7 @@ bool HelpParser::MergeSingleFile( XMLFile* file , MergeDataFile& aMergeDataFile
return true;
}
-ByteString HelpParser::GetOutpath( const ByteString& rPathX , const ByteString& sCur , const ByteString& rPathY )
+rtl::OString HelpParser::GetOutpath( const rtl::OString& rPathX , const rtl::OString& sCur , const rtl::OString& rPathY )
{
ByteString testpath = rPathX;
static const rtl::OString sDelimiter(rtl::OUStringToOString(DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US));
@@ -539,7 +539,7 @@ void HelpParser::MakeDir(const rtl::OString& rPath)
/* ProcessHelp Methode: search for en-US entry and replace it with the current language*/
-void HelpParser::ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile ){
+void HelpParser::ProcessHelp( LangHashMap* aLangHM , const rtl::OString& sCur , ResData *pResData , MergeDataFile& aMergeDataFile ){
XMLElement* pXMLElement = NULL;
PFormEntrys *pEntrys = NULL;
@@ -551,7 +551,7 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , Re
pEntrys = NULL;
- if( !sCur.EqualsIgnoreCaseAscii("en-US") ){
+ if( !sCur.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("en-US")) ){
pXMLElement = (*aLangHM)[ "en-US" ];
if( pXMLElement == NULL )
{
@@ -565,7 +565,7 @@ void HelpParser::ProcessHelp( LangHashMap* aLangHM , const ByteString& sCur , Re
pEntrys = aMergeDataFile.GetPFormEntrys( pResData );
if( pEntrys != NULL)
{
- ByteString sNewText;
+ rtl::OString sNewText;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur , true );
sNewdata = String( sNewText , RTL_TEXTENCODING_UTF8 );
if ( sNewdata.Len())
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index d738a89a562c..47e3c6b152d1 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -112,7 +112,7 @@ sal_Bool LngParser::CreateSDF(const rtl::OString &rSDFFile,
size_t nPos = 0;
sal_Bool bStart = true;
rtl::OString sGroup, sLine;
- ByteStringHashMap Text;
+ OStringHashMap Text;
ByteString sID;
while( nPos < pLines->size() ) {
@@ -135,7 +135,7 @@ sal_Bool LngParser::CreateSDF(const rtl::OString &rSDFFile,
}
void LngParser::WriteSDF(SvFileStream &aSDFStream,
- ByteStringHashMap &rText_inout, const rtl::OString &rPrj,
+ OStringHashMap &rText_inout, const rtl::OString &rPrj,
const rtl::OString &rRoot, const rtl::OString &rActFileName,
const rtl::OString &rID)
{
@@ -179,7 +179,7 @@ bool LngParser::isNextGroup(rtl::OString &sGroup_out, rtl::OString &sLine_in)
}
void LngParser::ReadLine(const rtl::OString &rLine_in,
- ByteStringHashMap &rText_inout)
+ OStringHashMap &rText_inout)
{
rtl::OString sLang = getToken(rLine_in, 0, '=');
sLang = comphelper::string::stripStart(sLang, ' ');
@@ -230,7 +230,7 @@ sal_Bool LngParser::Merge(
}
while ( nPos < pLines->size()) {
- ByteStringHashMap Text;
+ OStringHashMap Text;
ByteString sID( sGroup );
sal_uLong nLastLangPos = 0;
@@ -276,10 +276,10 @@ sal_Bool LngParser::Merge(
{
if( sLang.Len() )
{
- ByteString sNewText;
+ rtl::OString sNewText;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sLang, sal_True );
- if ( sNewText.Len()) {
+ if ( !sNewText.isEmpty()) {
rtl::OString *pLine = (*pLines)[ nPos ];
ByteString sText1( sLang );
@@ -312,9 +312,9 @@ sal_Bool LngParser::Merge(
if( !sCur.EqualsIgnoreCaseAscii("en-US") && Text[sCur].isEmpty() && pEntrys )
{
- ByteString sNewText;
+ rtl::OString sNewText;
pEntrys->GetText( sNewText, STRING_TYP_TEXT, sCur, sal_True );
- if (( sNewText.Len()) &&
+ if (( !sNewText.isEmpty()) &&
!(( sCur.Equals("x-comment") ) && ( sNewText == "-" )))
{
ByteString sLine;
diff --git a/l10ntools/source/merge.cxx b/l10ntools/source/merge.cxx
index cc4d97defa11..9f02125a3e85 100644
--- a/l10ntools/source/merge.cxx
+++ b/l10ntools/source/merge.cxx
@@ -63,22 +63,22 @@ rtl::OString PFormEntrys::Dump()
return rtl::OString(RTL_CONSTASCII_STRINGPARAM("PFormEntrys\n"));
}
-sal_Bool PFormEntrys::GetTransex3Text( ByteString &rReturn,
- sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel )
+sal_Bool PFormEntrys::GetTransex3Text( rtl::OString &rReturn,
+ sal_uInt16 nTyp, const rtl::OString &nLangIndex, sal_Bool bDel )
{
sal_Bool rc = GetText( rReturn , nTyp , nLangIndex , bDel );
- for( sal_uInt16 idx = 0; idx < rReturn.Len(); idx++ )
+ for( sal_Int32 idx = 0; idx < rReturn.getLength(); idx++ )
{
- if( rReturn.GetChar( idx ) == '\"' && ( idx >= 1 ) && rReturn.GetChar( idx-1 ) == '\\' )
+ if( rReturn[idx] == '\"' && ( idx >= 1 ) && rReturn[idx-1] == '\\' )
{
- rReturn.Erase( idx-1 , 1 );
+ rReturn = rReturn.replaceAt( idx-1, 1, rtl::OString() );
}
}
return rc;
}
/*****************************************************************************/
-sal_Bool PFormEntrys::GetText( ByteString &rReturn,
- sal_uInt16 nTyp, const ByteString &nLangIndex, sal_Bool bDel )
+sal_Bool PFormEntrys::GetText( rtl::OString &rReturn,
+ sal_uInt16 nTyp, const rtl::OString &nLangIndex, sal_Bool bDel )
{
sal_Bool bReturn=sal_True;
diff --git a/l10ntools/source/xmlparse.cxx b/l10ntools/source/xmlparse.cxx
index 829bd76627a3..3a888b8fadd9 100644
--- a/l10ntools/source/xmlparse.cxx
+++ b/l10ntools/source/xmlparse.cxx
@@ -156,43 +156,6 @@ void XMLParentNode::AddChild( XMLChildNode *pChild , size_t pos )
}
/*****************************************************************************/
-int XMLParentNode::GetPosition( ByteString id ){
-/*****************************************************************************/
- XMLElement* a;
-
- static const rtl::OString sEnusStr = rtl::OString(RTL_CONSTASCII_STRINGPARAM(ENGLISH_US_ISO)).toAsciiLowerCase();
- static const rtl::OString sDeStr = rtl::OString(RTL_CONSTASCII_STRINGPARAM(GERMAN_ISO2)).toAsciiLowerCase();
-
- if ( pChildList )
- {
- for (size_t i = 0; i < pChildList->size(); ++i)
- {
- XMLChildNode *pChild = (*pChildList)[ i ];
- if ( pChild->GetNodeType() == XML_NODE_TYPE_ELEMENT )
- {
- a = static_cast<XMLElement* >(pChild);
- ByteString elemid( a->GetId() );
- elemid.ToLowerAscii();
- if ( elemid.Equals( id.ToLowerAscii() ) )
- {
- ByteString elemLID( a->GetLanguageId() );
- elemLID.ToLowerAscii();
- if( elemLID.Equals( sEnusStr) )
- {
- return i;
- }
- else if( elemLID.Equals( sDeStr) )
- {
- return i;
- }
- }
- }
- }
- }
- return -1;
-}
-
-/*****************************************************************************/
int XMLParentNode::RemoveChild( XMLElement *pRefElement )
/*****************************************************************************/
{
@@ -255,7 +218,7 @@ XMLElement *XMLParentNode::GetChildElement( XMLElement *pRefElement )
XMLAttribute *pAttribute = (*pList)[ j ];
XMLAttribute *pCandidate =
(( XMLElement * ) pChild )->GetAttribute(
- *pAttribute );
+ pAttribute->GetName() );
if ( !pCandidate || !pAttribute->IsEqual( *pCandidate ))
bMatch = sal_False;
}
@@ -278,14 +241,14 @@ sal_uInt16 XMLFile::GetNodeType()
}
/*****************************************************************************/
-sal_Bool XMLFile::Write( ByteString &aFilename )
+sal_Bool XMLFile::Write( rtl::OString const &aFilename )
/*****************************************************************************/
{
- if ( aFilename.Len()) {
+ if ( !aFilename.isEmpty()) {
// retry harder if there is a NFS problem,
for( int x = 1 ; x < 3 ; x++ ){ // this looks strange...yes!
- ofstream aFStream( aFilename.GetBuffer() , ios::out | ios::trunc );
+ ofstream aFStream( aFilename.getStr() , ios::out | ios::trunc );
if( !aFStream ) // From time to time the stream can not be opened the first time on NFS volumes,
{ // I wasn't able to track this down. I think this is an NFS issue .....
@@ -317,7 +280,7 @@ sal_Bool XMLFile::Write( ByteString &aFilename )
}
}
}
- cerr << "ERROR: - helpex - Can't create file " << aFilename.GetBuffer() << "\nPossible reason: Disk full ? Mounted NFS volume broken ? Wrong permissions ?\n";
+ cerr << "ERROR: - helpex - Can't create file " << aFilename.getStr() << "\nPossible reason: Disk full ? Mounted NFS volume broken ? Wrong permissions ?\n";
exit( -1 );
}
cerr << "ERROR: - helpex - Empty file name\n";
@@ -349,7 +312,7 @@ sal_Bool XMLFile::Write( ofstream &rStream , XMLNode *pCur )
if ( pElement->GetAttributeList())
for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ) {
rStream << " ";
- String sData(* (*pElement->GetAttributeList())[ j ] );
+ String sData( (*pElement->GetAttributeList())[ j ]->GetName() );
XMLUtil::QuotHTML( sData );
WriteString( rStream , sData );
rStream << "=\"";
@@ -416,7 +379,7 @@ void XMLFile::Print( XMLNode *pCur, sal_uInt16 nLevel )
{
for (size_t j = 0; j < pElement->GetAttributeList()->size(); ++j)
{
- rtl::OString aAttrName(rtl::OUStringToOString(*(*pElement->GetAttributeList())[j],
+ rtl::OString aAttrName(rtl::OUStringToOString((*pElement->GetAttributeList())[j]->GetName(),
RTL_TEXTENCODING_UTF8));
if (!aAttrName.equalsIgnoreAsciiCase(XML_LANG))
{
@@ -468,7 +431,7 @@ XMLFile::~XMLFile()
}
}
/*****************************************************************************/
-XMLFile::XMLFile( const String &rFileName ) // the file name, empty if created from memory stream
+XMLFile::XMLFile( const rtl::OUString &rFileName ) // the file name, empty if created from memory stream
/*****************************************************************************/
: XMLParentNode( NULL ),
sFileName ( rFileName ),
@@ -511,7 +474,7 @@ void XMLFile::InsertL10NElement( XMLElement* pElement ){
if( pElement->GetAttributeList() != NULL ){
for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ )
{
- tmpStr=rtl::OUStringToOString(*(*pElement->GetAttributeList())[ j ], RTL_TEXTENCODING_UTF8);
+ tmpStr=rtl::OUStringToOString((*pElement->GetAttributeList())[ j ]->GetName(), RTL_TEXTENCODING_UTF8);
if( tmpStr.CompareTo(ID)==COMPARE_EQUAL ){ // Get the "id" Attribute
id = rtl::OUStringToOString((*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8);
}
@@ -619,7 +582,7 @@ void XMLFile::SearchL10NElements( XMLParentNode *pCur , int pos)
{
for ( size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; ++j )
{
- const ByteString tmpStr = rtl::OUStringToOString(*(*pElement->GetAttributeList())[j], RTL_TEXTENCODING_UTF8);
+ const ByteString tmpStr = rtl::OUStringToOString((*pElement->GetAttributeList())[j]->GetName(), RTL_TEXTENCODING_UTF8);
if( tmpStr.CompareTo(THEID)==COMPARE_EQUAL ){ // Get the "id" Attribute
tmpStrVal=rtl::OUStringToOString( (*pElement->GetAttributeList())[ j ]->GetValue(),RTL_TEXTENCODING_UTF8 );
}
@@ -695,7 +658,7 @@ bool XMLFile::CheckExportStatus( XMLParentNode *pCur )
{
for (size_t j = 0 , cnt = pElement->GetAttributeList()->size(); j < cnt && bInsert; ++j)
{
- const rtl::OString tmpStr(rtl::OUStringToOString(*(*pElement->GetAttributeList())[j],
+ const rtl::OString tmpStr(rtl::OUStringToOString((*pElement->GetAttributeList())[j]->GetName(),
RTL_TEXTENCODING_UTF8));
if (tmpStr.equalsIgnoreAsciiCase(STATUS))
{
@@ -749,7 +712,7 @@ XMLElement::XMLElement(const XMLElement& obj)
if ( obj.pAttributes ){
pAttributes = new XMLAttributeList();
for ( size_t i = 0; i < obj.pAttributes->size(); i++ )
- AddAttribute( *(*obj.pAttributes)[ i ], (*obj.pAttributes)[ i ]->GetValue() );
+ AddAttribute( (*obj.pAttributes)[ i ]->GetName(), (*obj.pAttributes)[ i ]->GetValue() );
}
}
@@ -775,7 +738,7 @@ XMLElement& XMLElement::operator=(const XMLElement& obj){
if ( obj.pAttributes ){
pAttributes =new XMLAttributeList();
for ( size_t i = 0; i < obj.pAttributes->size(); i++ )
- AddAttribute( *(*obj.pAttributes)[ i ], (*obj.pAttributes)[ i ]->GetValue() );
+ AddAttribute( (*obj.pAttributes)[ i ]->GetName(), (*obj.pAttributes)[ i ]->GetValue() );
}
}
return *this;
@@ -793,13 +756,12 @@ void XMLElement::AddAttribute( const String &rAttribute, const String &rValue )
/*****************************************************************************/
void XMLElement::ChangeLanguageTag( const String &rValue )
{
- static const String rName = String::CreateFromAscii("xml-lang");
SetLanguageId(rtl::OUStringToOString(rValue, RTL_TEXTENCODING_UTF8));
if ( pAttributes )
{
for (size_t i = 0; i < pAttributes->size(); ++i)
{
- if ( *(*pAttributes)[ i ] == rName )
+ if ( (*pAttributes)[ i ]->GetName().equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("xml-lang")) )
(*pAttributes)[ i ]->setValue(rValue);
}
}
@@ -825,12 +787,12 @@ void XMLElement::ChangeLanguageTag( const String &rValue )
}
}
/*****************************************************************************/
-XMLAttribute *XMLElement::GetAttribute( const String &rName )
+XMLAttribute *XMLElement::GetAttribute( const rtl::OUString &rName )
/*****************************************************************************/
{
if ( pAttributes )
for ( size_t i = 0; i < pAttributes->size(); i++ )
- if ( *(*pAttributes)[ i ] == rName )
+ if ( (*pAttributes)[ i ]->GetName() == rName )
return (*pAttributes)[ i ];
return NULL;
@@ -909,7 +871,7 @@ void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement
if ( pElement->GetAttributeList()){
for ( size_t j = 0; j < pElement->GetAttributeList()->size(); j++ ){
- OUString aAttrName( *(*pElement->GetAttributeList())[ j ] );
+ OUString aAttrName( (*pElement->GetAttributeList())[ j ]->GetName() );
if( !aAttrName.equalsIgnoreAsciiCase( XML_LANG ) ) {
buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM(" ")) );
buffer.append( aAttrName );
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 698027de7ed1..fba54e6d9473 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -670,11 +670,11 @@ void XRMResMerge::WorkOnDesc(
ByteString sDescFilename = GetAttribute ( rOpenTag, "xlink:href" );
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sContent;
+ rtl::OString sContent;
if ( !sCur.EqualsIgnoreCaseAscii("en-US") &&
( pEntrys->GetText(
sContent, STRING_TYP_TEXT, sCur, sal_True )) &&
- ( sContent != "-" ) && ( sContent.Len()))
+ ( sContent != "-" ) && !sContent.isEmpty())
{
ByteString sText( sContent );
ByteString sAdditionalLine( "\n " );
@@ -738,11 +738,11 @@ void XRMResMerge::WorkOnText(
PFormEntrys *pEntrys = pMergeDataFile->GetPFormEntrys( pResData );
if ( pEntrys ) {
- ByteString sContent;
+ rtl::OString sContent;
if ( Export::isAllowed( sLang ) &&
( pEntrys->GetText(
sContent, STRING_TYP_TEXT, sLang )) &&
- ( sContent != "-" ) && ( sContent.Len()))
+ ( sContent != "-" ) && !sContent.isEmpty())
{
rText = sContent;
@@ -776,11 +776,11 @@ void XRMResMerge::EndOfText(
ByteString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
- ByteString sContent;
+ rtl::OString sContent;
if ( !sCur.EqualsIgnoreCaseAscii("en-US") &&
( pEntrys->GetText(
sContent, STRING_TYP_TEXT, sCur, sal_True )) &&
- ( sContent != "-" ) && ( sContent.Len()))
+ ( sContent != "-" ) && !sContent.isEmpty())
{
ByteString sText( sContent );
ByteString sAdditionalLine( "\n " );