Reduced tools/string usage further

This commit is contained in:
Stephan Bergmann
2012-02-02 21:36:11 +01:00
parent 88b58e9613
commit a4cbcf2fc5
12 changed files with 583 additions and 599 deletions

View File

@@ -71,7 +71,7 @@ public:
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 SetUText( rtl::OUString const &aNew ) { aText = rtl::OUStringToOString(aNew, RTL_TEXTENCODING_UTF8); 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(); }
@@ -109,7 +109,7 @@ private:
sal_Bool bHasBlockError;
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 IsUTF8( const rtl::OString &aTestee, sal_Bool bFixTags, sal_Int32 &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 );

View File

@@ -29,7 +29,6 @@
#ifndef _TAGTEST_HXX_
#define _TAGTEST_HXX_
#include <tools/string.hxx>
#include <boost/unordered_map.hpp>
#include <vector>
@@ -44,14 +43,14 @@ typedef ::std::vector< ParserMessage* > Impl_ParserMessageList;
class ParserMessageList;
typedef boost::unordered_map<rtl::OString, String, rtl::OStringHash> StringHashMap;
typedef boost::unordered_map<rtl::OString, rtl::OUString, rtl::OStringHash> StringHashMap;
class TokenInfo
{
private:
void SplitTag( ParserMessageList &rErrorList );
String aTagName;
rtl::OUString aTagName;
StringHashMap aProperties;
sal_Bool bClosed; // tag is closed <sdnf/>
sal_Bool bCloseTag; // tag is close Tag </sdnf>
@@ -63,29 +62,29 @@ private:
public:
String aTokenString;
rtl::OUString aTokenString;
TokenId nId;
sal_uInt16 nPos; // Position in String
TokenInfo():bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),nId( 0 ){;}
explicit TokenInfo( TokenId pnId, sal_uInt16 nP ):bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),nId( pnId ),nPos(nP){;}
explicit TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr ):bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),aTokenString( paStr ),nId( pnId ),nPos(nP) {;}
explicit TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr, ParserMessageList &rErrorList );
explicit TokenInfo( TokenId pnId, sal_uInt16 nP, rtl::OUString const & paStr ):bClosed(sal_False),bCloseTag(sal_False),bIsBroken(sal_False),bHasBeenFixed(sal_False),bDone(sal_False),aTokenString( paStr ),nId( pnId ),nPos(nP) {;}
explicit TokenInfo( TokenId pnId, sal_uInt16 nP, rtl::OUString const & paStr, ParserMessageList &rErrorList );
String GetTagName() const;
rtl::OUString GetTagName() const;
String MakeTag() const;
rtl::OUString MakeTag() const;
/**
Is the property to be ignored or does it have the default value anyways
**/
sal_Bool IsPropertyRelevant( const rtl::OString &rName, const String &rValue ) const;
sal_Bool IsPropertyValueValid( const rtl::OString &rName, const String &rValue ) const;
sal_Bool IsPropertyRelevant( const rtl::OString &rName, const rtl::OUString &rValue ) const;
sal_Bool IsPropertyValueValid( const rtl::OString &rName, const rtl::OUString &rValue ) const;
/**
Does the property contain the same value for all languages
e.g.: the href in a link tag
**/
sal_Bool IsPropertyInvariant( const rtl::OString &rName, const String &rValue ) const;
sal_Bool IsPropertyInvariant( const rtl::OString &rName, const rtl::OUString &rValue ) const;
/**
a subset of IsPropertyInvariant but containing only those that are fixable
we dont wat to fix e.g.: ahelp :: visibility
@@ -284,19 +283,19 @@ class SimpleParser
{
private:
sal_uInt16 nPos;
String aSource;
String aLastToken;
rtl::OUString aSource;
rtl::OUString aLastToken;
TokenList aTokenList;
TokenInfo aNextTag; // to store closetag in case of combined tags like <br/>
String GetNextTokenString( ParserMessageList &rErrorList, sal_uInt16 &rTokeStartPos );
rtl::OUString GetNextTokenString( ParserMessageList &rErrorList, sal_uInt16 &rTokeStartPos );
public:
SimpleParser();
void Parse( String PaSource );
void Parse( rtl::OUString const & PaSource );
TokenInfo GetNextToken( ParserMessageList &rErrorList );
static String GetLexem( TokenInfo const &aToken );
static rtl::OUString GetLexem( TokenInfo const &aToken );
TokenList& GetTokenList(){ return aTokenList; }
};
@@ -328,7 +327,7 @@ class TokenParser
public:
TokenParser();
void Parse( const String &aCode, ParserMessageList* pList );
void Parse( const rtl::OUString &aCode, ParserMessageList* pList );
TokenList& GetTokenList(){ return aParser.GetTokenList(); }
};
@@ -340,7 +339,7 @@ private:
ParserMessageList aCompareWarningList;
void CheckTags( TokenList &aReference, TokenList &aTestee, sal_Bool bFixTags );
sal_Bool IsTagMandatory( TokenInfo const &aToken, TokenId &aMetaTokens );
String aFixedTestee;
rtl::OUString aFixedTestee;
public:
void CheckReference( GSILine *aReference );
void CheckTestee( GSILine *aTestee, sal_Bool bHasSourceLine, sal_Bool bFixTags );
@@ -348,7 +347,7 @@ public:
ParserMessageList& GetCompareWarnings(){ return aCompareWarningList; }
sal_Bool HasCompareWarnings(){ return ( !aCompareWarningList.empty() ); }
String GetFixedTestee(){ return aFixedTestee; }
rtl::OUString GetFixedTestee(){ return aFixedTestee; }
};
#endif

View File

@@ -33,7 +33,6 @@
#include <expat.h>
#include <rtl/ustring.hxx>
#include <rtl/ustrbuf.hxx>
#include <tools/string.hxx>
#include <tools/stream.hxx>
#include "export.hxx"
#include "xmlutil.hxx"
@@ -224,23 +223,20 @@ public:
virtual sal_uInt16 GetNodeType();
/// returns file name
const String &GetName() { return sFileName; }
void SetName( const String &rFilename ) { sFileName = rFilename; }
void SetFullName( const String &rFullFilename ) { sFullName = rFullFilename; }
rtl::OUString GetName() { return sFileName; }
void SetName( const rtl::OUString &rFilename ) { sFileName = rFilename; }
void SetFullName( const rtl::OUString &rFullFilename ) { sFullName = rFullFilename; }
const std::vector<rtl::OString> getOrder(){ return order; }
protected:
// writes a string as UTF8 with dos line ends to a given stream
void WriteString( ofstream &rStream, const String &sString );
// quotes the given text for writing to a file
void QuotHTML( String &rString );
void WriteString( ofstream &rStream, const rtl::OUString &sString );
void InsertL10NElement( XMLElement* pElement);
// DATA
String sFileName;
String sFullName;
rtl::OUString sFileName;
rtl::OUString sFullName;
const rtl::OString ID, OLDREF, XML_LANG;
@@ -256,13 +252,10 @@ class XMLUtil{
public:
/// Quot the XML characters and replace \n \t
static void QuotHTML( String &rString );
static void QuotHTML( rtl::OUString &rString );
/// UnQuot the XML characters and restore \n \t
static void UnQuotHTML ( String &rString );
private:
static void UnQuotData( String &rString );
static void UnQuotTags( String &rString );
static void UnQuotHTML ( rtl::OUString &rString );
};
@@ -274,7 +267,7 @@ private:
class XMLElement : public XMLParentNode
{
private:
String sElementName;
rtl::OUString sElementName;
XMLAttributeList *pAttributes;
rtl::OString project,
filename,
@@ -290,7 +283,7 @@ public:
/// create a element node
XMLElement(){}
XMLElement(
const String &rName, // the element name
const rtl::OUString &rName, // the element name
XMLParentNode *Parent // parent node of this element
): XMLParentNode( Parent ),
sElementName( rName ),
@@ -312,15 +305,15 @@ public:
virtual sal_uInt16 GetNodeType();
/// returns element name
const String &GetName() { return sElementName; }
rtl::OUString GetName() { return sElementName; }
/// returns list of attributes of this element
XMLAttributeList *GetAttributeList() { return pAttributes; }
/// adds a new attribute to this element, typically used by parser
void AddAttribute( const String &rAttribute, const String &rValue );
void AddAttribute( const rtl::OUString &rAttribute, const rtl::OUString &rValue );
void ChangeLanguageTag( const String &rValue );
void ChangeLanguageTag( const rtl::OUString &rValue );
// Return a ASCII String representation of this object
OString ToOString();
@@ -359,18 +352,18 @@ public:
class XMLData : public XMLChildNode
{
private:
String sData;
rtl::OUString sData;
bool isNewCreated;
public:
/// create a data node
XMLData(
const String &rData, // the initial data
const rtl::OUString &rData, // the initial data
XMLParentNode *Parent // the parent node of this data, typically a element node
)
: XMLChildNode( Parent ), sData( rData ) , isNewCreated ( false ){}
XMLData(
const String &rData, // the initial data
const rtl::OUString &rData, // the initial data
XMLParentNode *Parent, // the parent node of this data, typically a element node
bool newCreated
)
@@ -382,12 +375,12 @@ public:
virtual sal_uInt16 GetNodeType();
/// returns the data
const String &GetData() { return sData; }
rtl::OUString GetData() { return sData; }
bool isNew() { return isNewCreated; }
/// adds new character data to the existing one
void AddData(
const String &rData // the new data
const rtl::OUString &rData // the new data
);
@@ -401,12 +394,12 @@ public:
class XMLComment : public XMLChildNode
{
private:
String sComment;
rtl::OUString sComment;
public:
/// create a comment node
XMLComment(
const String &rComment, // the comment
const rtl::OUString &rComment, // the comment
XMLParentNode *Parent // the parent node of this comemnt, typically a element node
)
: XMLChildNode( Parent ), sComment( rComment ) {}
@@ -418,7 +411,7 @@ public:
XMLComment& operator=(const XMLComment& obj);
/// returns the comment
const String &GetComment() { return sComment; }
rtl::OUString GetComment() { return sComment; }
};
//-------------------------------------------------------------------------
@@ -428,12 +421,12 @@ public:
class XMLDefault : public XMLChildNode
{
private:
String sDefault;
rtl::OUString sDefault;
public:
/// create a comment node
XMLDefault(
const String &rDefault, // the comment
const rtl::OUString &rDefault, // the comment
XMLParentNode *Parent // the parent node of this comemnt, typically a element node
)
: XMLChildNode( Parent ), sDefault( rDefault ) {}
@@ -446,7 +439,7 @@ public:
virtual sal_uInt16 GetNodeType();
/// returns the comment
const String &GetDefault() { return sDefault; }
rtl::OUString GetDefault() { return sDefault; }
};
//-------------------------------------------------------------------------
@@ -457,7 +450,7 @@ struct XMLError {
XML_Error eCode; // the error code
sal_uLong nLine; // error line number
sal_uLong nColumn; // error column number
String sMessage; // readable error message
rtl::OUString sMessage; // readable error message
};
//-------------------------------------------------------------------------
@@ -498,8 +491,8 @@ public:
/// parse a file, returns NULL on criticall errors
XMLFile *Execute(
const String &rFullFileName,
const String &rFileName, // the file name
const rtl::OUString &rFullFileName,
const rtl::OUString &rFileName, // the file name
XMLFile *pXMLFileIn // the XMLFile
);

View File

@@ -26,9 +26,6 @@
*
************************************************************************/
// global includes
#include <tools/string.hxx>
//
// XRMResParser
//
@@ -36,42 +33,42 @@
class XRMResParser
{
private:
ByteString sGID;
ByteString sLID;
rtl::OString sGID;
rtl::OString sLID;
sal_Bool bError;
sal_Bool bText;
bool sLocalized;
ByteString sCurrentOpenTag;
ByteString sCurrentCloseTag;
ByteString sCurrentText;
rtl::OString sCurrentOpenTag;
rtl::OString sCurrentCloseTag;
rtl::OString sCurrentText;
std::vector<rtl::OString> aLanguages;
protected:
ByteString GetAttribute( const ByteString &rToken, const ByteString &rAttribute );
void Error( const ByteString &rError );
rtl::OString GetAttribute( const rtl::OString &rToken, const rtl::OString &rAttribute );
void Error( const rtl::OString &rError );
virtual void Output( const ByteString& rOutput )=0;
virtual void Output( const rtl::OString& rOutput )=0;
virtual void WorkOnDesc(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
)=0;
virtual void WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
)=0;
virtual void EndOfText(
const ByteString &rOpenTag,
const ByteString &rCloseTag
const rtl::OString &rOpenTag,
const rtl::OString &rCloseTag
)=0;
ByteString GetGID() { return sGID; }
ByteString GetLID() { return sLID; }
rtl::OString GetGID() { return sGID; }
rtl::OString GetLID() { return sLID; }
void ConvertStringToDBFormat( ByteString &rString );
void ConvertStringToXMLFormat( ByteString &rString );
void ConvertStringToDBFormat( rtl::OString &rString );
void ConvertStringToXMLFormat( rtl::OString &rString );
public:
XRMResParser();
@@ -94,7 +91,7 @@ private:
protected:
SvFileStream *pOutputStream;
public:
XRMResOutputParser ( const ByteString &rOutputFile );
XRMResOutputParser ( const rtl::OString &rOutputFile );
virtual ~XRMResOutputParser();
};
@@ -106,30 +103,30 @@ class XRMResExport : public XRMResOutputParser
{
private:
ResData *pResData;
ByteString sPrj;
ByteString sPath;
rtl::OString sPrj;
rtl::OString sPath;
std::vector<rtl::OString> aLanguages;
protected:
void WorkOnDesc(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
);
void WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
);
void EndOfText(
const ByteString &rOpenTag,
const ByteString &rCloseTag
const rtl::OString &rOpenTag,
const rtl::OString &rCloseTag
);
void Output( const ByteString& rOutput );
void Output( const rtl::OString& rOutput );
public:
XRMResExport(
const ByteString &rOutputFile,
const ByteString &rProject,
const ByteString &rFilePath
const rtl::OString &rOutputFile,
const rtl::OString &rProject,
const rtl::OString &rFilePath
);
virtual ~XRMResExport();
};
@@ -142,29 +139,29 @@ class XRMResMerge : public XRMResOutputParser
{
private:
MergeDataFile *pMergeDataFile;
ByteString sFilename;
rtl::OString sFilename;
ResData *pResData;
std::vector<rtl::OString> aLanguages;
protected:
void WorkOnDesc(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
);
void WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
);
void EndOfText(
const ByteString &rOpenTag,
const ByteString &rCloseTag
const rtl::OString &rOpenTag,
const rtl::OString &rCloseTag
);
void Output( const ByteString& rOutput );
void Output( const rtl::OString& rOutput );
public:
XRMResMerge(
const ByteString &rMergeSource,
const ByteString &rOutputFile,
ByteString &rFilename
const rtl::OString &rMergeSource,
const rtl::OString &rOutputFile,
const rtl::OString &rFilename
);
virtual ~XRMResMerge();
};

View File

@@ -58,7 +58,7 @@ Export *pExport = 0L;
#define STATE_LANGUAGES 0X000A
// set of global variables
typedef ::std::vector< ByteString* > FileList;
typedef ::std::vector< rtl::OString > FileList;
FileList aInputFileList;
sal_Bool bEnableExport;
sal_Bool bMergeMode;
@@ -102,7 +102,7 @@ extern char *GetOutputFile( int argc, char* argv[])
// parse command line
for( int i = 1; i < argc; i++ ) {
ByteString sSwitch( argv[ i ] );
rtl::OString sSwitch( argv[ i ] );
if (sSwitch == "-i" || sSwitch == "-I" ) {
nState = STATE_INPUT; // next tokens specifies source files
@@ -142,7 +142,7 @@ extern char *GetOutputFile( int argc, char* argv[])
return NULL; // no valid command line
}
case STATE_INPUT: {
aInputFileList.push_back( new ByteString( argv[ i ] ) );
aInputFileList.push_back( argv[ i ] );
bInput = sal_True; // min. one source file found
}
break;
@@ -216,7 +216,7 @@ int EndExport()
extern const char* getFilename()
{
return (*(aInputFileList[ 0 ])).GetBuffer();
return aInputFileList[0].getStr();
}
/*****************************************************************************/
extern FILE *GetNextFile()
@@ -226,7 +226,7 @@ extern FILE *GetNextFile()
if ( !sTempFile.isEmpty())
{
fclose( pTempFile );
String sTemp(rtl::OStringToOUString(sTempFile,
rtl::OUString sTemp(rtl::OStringToOUString(sTempFile,
RTL_TEXTENCODING_ASCII_US));
DirEntry aTemp( sTemp );
aTemp.Kill();
@@ -234,15 +234,14 @@ extern FILE *GetNextFile()
while ( !aInputFileList.empty() )
{
ByteString sFileName( *(aInputFileList[ 0 ]) );
rtl::OString sFileName(aInputFileList[0]);
rtl::OString sOrigFile( sFileName );
sFileName = Export::GetNativeFile( sFileName );
delete aInputFileList[ 0 ];
aInputFileList.erase( aInputFileList.begin() );
if ( sFileName == "" ) {
if ( sFileName.isEmpty() ) {
fprintf( stderr, "ERROR: Could not precompile File %s\n",
sOrigFile.getStr());
return GetNextFile();
@@ -252,10 +251,10 @@ extern FILE *GetNextFile()
Export::RemoveUTF8ByteOrderMarkerFromFile( sFileName );
// able to open file?
FILE *pFile = fopen( sFileName.GetBuffer(), "r" );
FILE *pFile = fopen( sFileName.getStr(), "r" );
if ( !pFile )
fprintf( stderr, "Error: Could not open File %s\n",
sFileName.GetBuffer());
sFileName.getStr());
else {
pTempFile = pFile;
@@ -266,7 +265,7 @@ extern FILE *GetNextFile()
aEntry.ToAbs();
rtl::OString sFullEntry(rtl::OUStringToOString(aEntry.GetFull(),
RTL_TEXTENCODING_ASCII_US));
aEntry += DirEntry( String( "..", RTL_TEXTENCODING_ASCII_US ));
aEntry += DirEntry(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("..")));
aEntry += DirEntry( sPrjRoot );
rtl::OString sPrjEntry(rtl::OUStringToOString(aEntry.GetFull(),
RTL_TEXTENCODING_ASCII_US));
@@ -423,7 +422,7 @@ Export::Export(const rtl::OString &rOutput, sal_Bool bWrite,
// open output stream
if ( bEnableExport ) {
aOutput.Open( String( rOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
aOutput.Open( rtl::OStringToOUString( rOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
if( !aOutput.IsOpen() ) {
fprintf(stderr, "ERROR : Can't open file %s\n", rOutput.getStr());
exit ( -1 );
@@ -465,7 +464,7 @@ Export::Export(const rtl::OString &rOutput, sal_Bool bWrite,
// open output stream
if ( bEnableExport ) {
aOutput.Open( String( rOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
aOutput.Open( rtl::OStringToOUString( rOutput, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_WRITE | STREAM_TRUNC );
aOutput.SetStreamCharSet( RTL_TEXTENCODING_UTF8 );
aOutput.SetLineDelimiter( LINEEND_CRLF );
}
@@ -647,7 +646,6 @@ int Export::Execute( int nToken, const char * pToken )
pResData = new ResData( sActPForm, FullId() , sFilename );
aResStack.push_back( pResData );
ByteString sBackup( sToken );
sToken = comphelper::string::remove(sToken, '\n');
sToken = comphelper::string::remove(sToken, '\r');
sToken = comphelper::string::remove(sToken, '{');
@@ -656,19 +654,19 @@ int Export::Execute( int nToken, const char * pToken )
rtl::OString sTLower = getToken(sToken, 0, ' ').toAsciiLowerCase();
pResData->sResTyp = sTLower;
rtl::OString sId( sToken.copy( pResData->sResTyp.getLength() + 1 ));
ByteString sCondition;
rtl::OString sCondition;
if ( sId.indexOf( '#' ) != -1 )
{
// between ResTyp, Id and paranthes is a precomp. condition
sCondition = "#";
sCondition += ByteString(getToken(sId, 1, '#'));
sCondition += getToken(sId, 1, '#');
sId = getToken(sId, 0, '#');
}
sId = getToken(sId, 0, '/');
CleanValue( sId );
sId = comphelper::string::remove(sId, '\t');
pResData->SetId( sId, ID_LEVEL_IDENTIFIER );
if ( sCondition.Len())
if (!sCondition.isEmpty())
{
Execute( CONDITION, ""); // execute the precomp. condition
}
@@ -705,7 +703,7 @@ int Export::Execute( int nToken, const char * pToken )
break;
bDontWriteOutput = sal_False;
ByteString sLowerTyp;
rtl::OString sLowerTyp;
if ( pResData )
sLowerTyp = "unknown";
nLevel++;
@@ -803,11 +801,11 @@ int Export::Execute( int nToken, const char * pToken )
case LISTASSIGNMENT:
{
bDontWriteOutput = sal_False;
ByteString sTmpToken(comphelper::string::remove(sToken, ' '));
sal_uInt16 nPos = 0;
nPos = sTmpToken.ToLowerAscii().Search("[en-us]=");
if( nPos != STRING_NOTFOUND ) {
rtl::OString sKey = sTmpToken.Copy( 0 , nPos );
rtl::OString sTmpToken(
comphelper::string::remove(sToken, ' ').toAsciiLowerCase());
sal_Int32 nPos = sTmpToken.indexOf("[en-us]=");
if (nPos != -1) {
rtl::OString sKey(sTmpToken.copy(0 , nPos));
sKey = comphelper::string::remove(sKey, ' ');
sKey = comphelper::string::remove(sKey, '\t');
rtl::OString sValue = getToken(sToken, 1, '=');
@@ -888,7 +886,7 @@ int Export::Execute( int nToken, const char * pToken )
// this is an entry for a String- or FilterList
if ( nList ) {
SetChildWithText();
ByteString sEntry(getToken(sToken, 1, '\"'));
rtl::OString sEntry(getToken(sToken, 1, '\"'));
if ( getTokenCount(sToken, '\"') > 3 )
sEntry += "\"";
if ( sEntry == "\\\"" )
@@ -912,7 +910,7 @@ int Export::Execute( int nToken, const char * pToken )
rtl::OString sKey = getToken(getToken(sToken, 0, '='), 0, '[');
sKey = comphelper::string::remove(sKey, ' ');
sKey = comphelper::string::remove(sKey, '\t');
ByteString sText( GetText( sToken, nToken ));
rtl::OString sText( GetText( sToken, nToken ));
rtl::OString sLang;
if ( getToken(sToken, 0, '=').indexOf('[') != -1 )
{
@@ -920,8 +918,8 @@ int Export::Execute( int nToken, const char * pToken )
CleanValue( sLang );
}
rtl::OString sLangIndex = sLang;
ByteString sOrigKey = sKey;
if ( sText.Len() && !sLang.isEmpty() )
rtl::OString sOrigKey = sKey;
if ( !sText.isEmpty() && !sLang.isEmpty() )
{
sKey = sKey.toAsciiUpperCase();
if (sKey.equalsL(RTL_CONSTASCII_STRINGPARAM("TEXT")) ||
@@ -1050,14 +1048,14 @@ int Export::Execute( int nToken, const char * pToken )
while( helper::searchAndReplace(&sToken, "\r", " " ) != -1 ) {};
while( helper::searchAndReplace(&sToken, "\t", " " ) != -1 ) {};
while( helper::searchAndReplace(&sToken, " ", " " ) != -1 ) {};
ByteString sCondition = getToken(sToken, 0, ' ');
rtl::OString sCondition(getToken(sToken, 0, ' '));
if ( sCondition == "#ifndef" ) {
sActPForm = "!defined ";
sActPForm += ByteString(getToken(sToken, 1, ' '));
sActPForm += getToken(sToken, 1, ' ');
}
else if ( sCondition == "#ifdef" ) {
sActPForm = "defined ";
sActPForm += ByteString(getToken(sToken, 1, ' '));
sActPForm += getToken(sToken, 1, ' ');
}
else if ( sCondition == "#if" ) {
sActPForm = sToken.copy( 4 );
@@ -1124,24 +1122,17 @@ int Export::Execute( int nToken, const char * pToken )
void Export::CutComment( rtl::OString &rText )
/*****************************************************************************/
{
if ( rText.indexOf( "//" ) != -1 ) {
ByteString sWork( rText );
sWork.SearchAndReplaceAll( "\\\"", "XX" );
sal_uInt16 i = 0;
sal_Bool bInner = sal_False;
while ( i < sWork.Len() - 1 ) {
if ( sWork.GetChar( i ) == '\"' )
if (rText.indexOf("//") != -1) {
rtl::OString sWork(rText);
helper::searchAndReplaceAll(&sWork, "\\\"", "XX");
bool bInner = false;
for (sal_Int32 i = 0; i < sWork.getLength() - 1; ++i) {
if (sWork[i] == '"') {
bInner = !bInner;
else if
(( sWork.GetChar( i ) == '/' ) &&
( !bInner ) &&
( sWork.GetChar( i + 1 ) == '/' ))
{
} else if (sWork[i] == '/' && !bInner && sWork[i + 1] == '/' ) {
rText = rText.copy(0, i);
return;
break;
}
i++;
}
}
}
@@ -1169,24 +1160,24 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
( !pResData->sTitle[ SOURCE_LANGUAGE ].isEmpty()))
{
ByteString sGID = pResData->sGId;
ByteString sLID;
if ( !sGID.Len())
rtl::OString sGID = pResData->sGId;
rtl::OString sLID;
if (sGID.isEmpty())
sGID = pResData->sId;
else
sLID = pResData->sId;
ByteString sXText;
ByteString sXHText;
ByteString sXQHText;
ByteString sXTitle;
rtl::OString sXText;
rtl::OString sXHText;
rtl::OString sXQHText;
rtl::OString sXTitle;
ByteString sTimeStamp( Export::GetTimeStamp());
ByteString sCur;
rtl::OString sTimeStamp(Export::GetTimeStamp());
rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
if ( !sCur.EqualsIgnoreCaseAscii("x-comment") ){
if (!sCur.equalsIgnoreAsciiCase("x-comment") ){
if (!pResData->sText[ sCur ].isEmpty())
sXText = pResData->sText[ sCur ];
else {
@@ -1210,10 +1201,10 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
else
sXTitle = pResData->sTitle[ SOURCE_LANGUAGE ];
if ( !sXText.Len())
if (sXText.isEmpty())
sXText = "-";
if ( !sXHText.Len())
if (sXHText.isEmpty())
{
if (!pResData->sHelpText[ SOURCE_LANGUAGE ].isEmpty())
sXHText = pResData->sHelpText[ SOURCE_LANGUAGE ];
@@ -1223,7 +1214,7 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
sXText = pResData->sText[ sCur ];
if ( bEnableExport ) {
ByteString sOutput( sProject ); sOutput += "\t";
rtl::OString sOutput( sProject ); sOutput += "\t";
if ( !sRoot.isEmpty())
sOutput += sActFileName;
sOutput += "\t0\t";
@@ -1232,7 +1223,7 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
sOutput += sLID; sOutput += "\t";
sOutput += pResData->sHelpId; sOutput += "\t";
sOutput += pResData->sPForm; sOutput += "\t";
sOutput += ByteString(rtl::OString::valueOf(static_cast<sal_Int64>(pResData->nWidth))); sOutput += "\t";
sOutput += rtl::OString::valueOf(static_cast<sal_Int64>(pResData->nWidth)); sOutput += "\t";
sOutput += sCur; sOutput += "\t";
@@ -1254,31 +1245,31 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
}
}
if ( pResData->pStringList ) {
ByteString sList( "stringlist" );
rtl::OString sList( "stringlist" );
WriteExportList( pResData, pResData->pStringList, sList, bCreateNew );
if ( bCreateNew )
pResData->pStringList = 0;
}
if ( pResData->pFilterList ) {
ByteString sList( "filterlist" );
rtl::OString sList( "filterlist" );
WriteExportList( pResData, pResData->pFilterList, sList, bCreateNew );
if ( bCreateNew )
pResData->pFilterList = 0;
}
if ( pResData->pItemList ) {
ByteString sList( "itemlist" );
rtl::OString sList( "itemlist" );
WriteExportList( pResData, pResData->pItemList, sList, bCreateNew );
if ( bCreateNew )
pResData->pItemList = 0;
}
if ( pResData->pPairedList ) {
ByteString sList( "pairedlist" );
rtl::OString sList( "pairedlist" );
WriteExportList( pResData, pResData->pPairedList, sList, bCreateNew );
if ( bCreateNew )
pResData->pItemList = 0;
}
if ( pResData->pUIEntries ) {
ByteString sList( "uientries" );
rtl::OString sList( "uientries" );
WriteExportList( pResData, pResData->pUIEntries, sList, bCreateNew );
if ( bCreateNew )
pResData->pUIEntries = 0;
@@ -1289,9 +1280,8 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
rtl::OString Export::GetPairedListID(const rtl::OString& rText)
{
// < "STRING" ; IDENTIFIER ; > ;
ByteString sIdent = getToken(rText, 1, ';');
sIdent.ToUpperAscii();
while( sIdent.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
rtl::OString sIdent(
getToken(rText, 1, ';').toAsciiUpperCase().replace('\t', ' '));
sIdent = comphelper::string::stripEnd(sIdent, ' ');
sIdent = comphelper::string::stripStart(sIdent, ' ');
return sIdent;
@@ -1300,11 +1290,10 @@ rtl::OString Export::GetPairedListID(const rtl::OString& rText)
rtl::OString Export::GetPairedListString(const rtl::OString& rText)
{
// < "STRING" ; IDENTIFIER ; > ;
ByteString sString = getToken(rText, 0, ';');
while( sString.SearchAndReplace( "\t", " " ) != STRING_NOTFOUND ) {};
rtl::OString sString(getToken(rText, 0, ';').replace('\t', ' '));
sString = comphelper::string::stripEnd(sString, ' ');
ByteString s1 = sString.Copy( sString.Search( '\"' )+1 );
sString = s1.Copy( 0 , s1.SearchBackward( '\"' ) );
rtl::OString s1(sString.copy(sString.indexOf('"') + 1));
sString = s1.copy(0, s1.lastIndexOf('"'));
sString = comphelper::string::stripEnd(sString, ' ');
sString = comphelper::string::stripStart(sString, ' ');
return sString;
@@ -1319,8 +1308,8 @@ rtl::OString Export::StripList(const rtl::OString & rText)
sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList,
const rtl::OString &rTyp, sal_Bool bCreateNew)
{
ByteString sGID = pResData->sGId;
if ( !sGID.Len())
rtl::OString sGID(pResData->sGId);
if (sGID.isEmpty())
sGID = pResData->sId;
else {
sGID += ".";
@@ -1328,13 +1317,13 @@ sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList,
sGID = comphelper::string::stripEnd(sGID, '.');
}
ByteString sTimeStamp( Export::GetTimeStamp());
ByteString sCur;
rtl::OString sTimeStamp(Export::GetTimeStamp());
rtl::OString sCur;
for ( size_t i = 0; pExportList != NULL && i < pExportList->size(); i++ )
{
ExportListEntry *pEntry = (*pExportList)[ i ];
ByteString sLID(rtl::OString::valueOf(static_cast<sal_Int64>(i + 1)));
rtl::OString sLID(rtl::OString::valueOf(static_cast<sal_Int64>(i + 1)));
for (unsigned int n = 0; n < aLanguages.size(); ++n)
{
sCur = aLanguages[ n ];
@@ -1342,7 +1331,7 @@ sal_Bool Export::WriteExportList(ResData *pResData, ExportList *pExportList,
{
if ( bEnableExport )
{
ByteString sText((*pEntry)[ SOURCE_LANGUAGE ] );
rtl::OString sText((*pEntry)[ SOURCE_LANGUAGE ] );
// Strip PairList Line String
if (rTyp.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("pairedlist")))
@@ -1515,7 +1504,7 @@ void Export::CleanValue( rtl::OString &rValue )
rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
{
ByteString sReturn;
rtl::OString sReturn;
switch ( nToken )
{
case TEXTLINE:
@@ -1526,38 +1515,29 @@ rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
sTmp = comphelper::string::remove(sTmp, '\n');
sTmp = comphelper::string::remove(sTmp, '\r');
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 ) {}
helper::searchAndReplaceAll(
&sTmp, "\\\\\"", "-=<[BSlashBSlashHKom]>=-\"");
helper::searchAndReplaceAll(&sTmp, "\\\"", "-=<[Hochkomma]>=-");
helper::searchAndReplaceAll(&sTmp, "\\", "-=<[0x7F]>=-");
helper::searchAndReplaceAll(&sTmp, "\\0x7F", "-=<[0x7F]>=-");
sal_uInt16 nStart = 0;
sal_uInt16 nState = TXT_STATE_MACRO;
nState = TXT_STATE_TEXT;
nStart = 1;
for ( sal_uInt16 i = nStart; i < getTokenCount(sTmp, '\"'); ++i )
sal_uInt16 nState = TXT_STATE_TEXT;
for (sal_Int32 i = 0; i < getTokenCount(sTmp, '\"'); ++i)
{
ByteString sToken = getToken(sTmp, i, '\"');
if ( sToken.Len()) {
rtl::OString sToken(getToken(sTmp, i, '"'));
if (!sToken.isEmpty()) {
if ( nState == TXT_STATE_TEXT ) {
sReturn += sToken;
nState = TXT_STATE_MACRO;
}
else {
while( sToken.SearchAndReplace( "\t", " " ) !=
STRING_NOTFOUND ) {};
while( sToken.SearchAndReplace( " ", " " ) !=
STRING_NOTFOUND ) {};
sToken = sToken.replace('\t', ' ');
while (helper::searchAndReplace(&sToken, " ", " ")
!= -1)
{}
sToken = comphelper::string::stripStart(sToken, ' ');
sToken = comphelper::string::stripEnd(sToken, ' ');
if ( sToken.Len()) {
if (!sToken.isEmpty()) {
sReturn += "\\\" ";
sReturn += sToken;
sReturn += " \\\"";
@@ -1567,19 +1547,13 @@ rtl::OString Export::GetText(const rtl::OString &rSource, int nToken)
}
}
while ( sReturn.SearchAndReplace( "-=<[0x7F]>=-", "" )
!= STRING_NOTFOUND ) {};
while ( sReturn.SearchAndReplace( "-=<[Hochkomma]>=-", "\"" )
!= STRING_NOTFOUND ) {};
while ( sReturn.SearchAndReplace( "-=<[BSlashBSlashHKom]>=-", "\\\\" )
!= STRING_NOTFOUND ) {};
while ( sReturn.SearchAndReplace( "\\\\", "-=<[BSlashBSlash]>=-" )
!= STRING_NOTFOUND ) {};
while ( sReturn.SearchAndReplace( "-=<[BSlashBSlash]>=-", "\\" )
!= STRING_NOTFOUND ) {};
helper::searchAndReplaceAll(&sReturn, "-=<[0x7F]>=-", "");
helper::searchAndReplaceAll(&sReturn, "-=<[Hochkomma]>=-", "\"");
helper::searchAndReplaceAll(
&sReturn, "-=<[BSlashBSlashHKom]>=-", "\\\\");
helper::searchAndReplaceAll(
&sReturn, "\\\\", "-=<[BSlashBSlash]>=-");
helper::searchAndReplaceAll(&sReturn, "-=<[BSlashBSlash]>=-", "\\");
}
break;
}
@@ -1590,50 +1564,44 @@ void Export::WriteToMerged(const rtl::OString &rText , bool bSDFContent)
{
if ( !bDontWriteOutput || !bUnmerge )
{
ByteString sText( rText );
while ( sText.SearchAndReplace( " \n", "\n" ) != STRING_NOTFOUND ) {};
if( pParseQueue->bNextIsM && bSDFContent && sText.Len() > 2 ){
for( sal_uInt16 n = 0 ; n < sText.Len() ; n++ ){
if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
rtl::OString sText(rText);
while (helper::searchAndReplace(&sText, " \n", "\n") != -1) {}
if (pParseQueue->bNextIsM && bSDFContent && sText.getLength() > 2) {
for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
if (sText[n] == '\n' && sText[n - 1] != '\\') {
sText = sText.replaceAt(n++, 0, "\\");
}
}
}
else if( pParseQueue->bLastWasM && sText.Len() > 2 ){
for( sal_uInt16 n = 0 ; n < sText.Len() ; n++ ){
if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
} else if (pParseQueue->bLastWasM && sText.getLength() > 2) {
for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
if (sText[n] == '\n' && sText[n - 1] != '\\') {
sText = sText.replaceAt(n++, 0, "\\");
}
if( sText.GetChar( n ) == '\n' )pParseQueue->bMflag=true;
}
}
else if( pParseQueue->bCurrentIsM && bSDFContent && sText.Len() > 2 ){
for( sal_uInt16 n = 0 ; n < sText.Len() ; n++ ){
if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
pParseQueue->bMflag=true;
if (sText[n] == '\n') {
pParseQueue->bMflag = true;
}
}
}
else if( pParseQueue->bMflag ){
for( sal_uInt16 n = 1 ; n < sText.Len() ; n++ ){
if( sText.GetChar( n ) == '\n' && sText.GetChar( n-1 ) != '\\'){
sText.Insert('\\' , n++ );
}
}
}
for (sal_uInt16 i = 0; i < sText.Len(); ++i)
} else if (pParseQueue->bCurrentIsM && bSDFContent
&& sText.getLength() > 2)
{
if ( sText.GetChar( i ) != '\n' )
{
sal_Char cChar = sText.GetChar(i);
aOutput.Write(&cChar, 1);
for (sal_Int32 n = 0; n < sText.getLength(); ++n) {
if (sText[n] == '\n' && sText[n - 1] != '\\') {
sText = sText.replaceAt(n++, 0, "\\");
pParseQueue->bMflag = true;
}
}
else
{
aOutput.WriteLine( ByteString());
} else if (pParseQueue->bMflag) {
for (sal_Int32 n = 1; n < sText.getLength(); ++n) {
if (sText[n] == '\n' && sText[n - 1] != '\\') {
sText = sText.replaceAt(n++, 0, "\\");
}
}
} for (sal_Int32 i = 0; i < sText.getLength(); ++i) {
if (sText[i] == '\n') {
aOutput.WriteLine(rtl::OString());
} else {
char cChar = sText[i];
aOutput.Write(&cChar, 1);
}
}
}
@@ -1698,7 +1666,7 @@ void Export::ConvertMergeContent( rtl::OString &rText )
rText = sNew.makeStringAndClear();
if ( bNoOpen ) {
ByteString sTmp( rText );
rtl::OString sTmp( rText );
rText = "\"";
rText += sTmp;
}
@@ -1712,11 +1680,11 @@ sal_Bool Export::PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
// position to merge in:
sal_Int32 nStart = 0;
sal_Int32 nEnd = 0;
ByteString sOldId = pResData->sId;
ByteString sOldGId = pResData->sGId;
ByteString sOldTyp = pResData->sResTyp;
rtl::OString sOldId = pResData->sId;
rtl::OString sOldGId = pResData->sGId;
rtl::OString sOldTyp = pResData->sResTyp;
ByteString sOrigText( rText );
rtl::OString sOrigText( rText );
switch ( nTyp ) {
case LIST_STRING :
@@ -1785,7 +1753,7 @@ sal_Bool Export::PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
if (( sLastListLine.indexOf( '>' ) != -1 ) &&
( sLastListLine.indexOf( '<' ) == -1 ))
{
ByteString sTmp = sLastListLine;
rtl::OString sTmp = sLastListLine;
sLastListLine = "<";
sLastListLine += sTmp;
}
@@ -1850,8 +1818,7 @@ sal_Bool Export::PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );
// Init Languages
ByteString sTmp = Export::sLanguages;
if( sTmp.ToUpperAscii().Equals("ALL") )
if( Export::sLanguages.equalsIgnoreAsciiCase("ALL") )
SetLanguages( pMergeDataFile->GetLanguages() );
else if( !isInitialized )InitLanguages();
@@ -1878,7 +1845,7 @@ sal_Bool Export::PrepareTextToMerge(rtl::OString &rText, sal_uInt16 nTyp,
if (Export::isSourceLanguage(rLangIndex))
return sal_False;
ByteString sPostFix( rText.copy( ++nEnd ));
rtl::OString sPostFix( rText.copy( ++nEnd ));
rText = rText.copy(0, nStart);
ConvertMergeContent( sContent );
@@ -1900,8 +1867,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
pMergeDataFile = new MergeDataFile( sMergeSrc, sFile, bErrorLog );
// Init Languages
ByteString sTmp = Export::sLanguages;
if( sTmp.ToUpperAscii().Equals("ALL") )
if (Export::sLanguages.equalsIgnoreAsciiCase("ALL"))
SetLanguages( pMergeDataFile->GetLanguages() );
else if( !isInitialized )InitLanguages();
@@ -1915,16 +1881,14 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
sal_Bool bAddSemikolon = sal_False;
sal_Bool bFirst = sal_True;
ByteString sCur;
ByteString sTmp = Export::sLanguages;
rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
rtl::OString sText;
sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TEXT, sCur , sal_True );
if ( bText && !sText.isEmpty() && sText != "-" ) {
ByteString sOutput;
rtl::OString sOutput;
if ( bNextMustBeDefineEOL) {
if ( bFirst )
sOutput += "\t\\\n";
@@ -1960,7 +1924,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
if ( bAddSemikolon ) {
ByteString sOutput( ";" );
rtl::OString sOutput( ";" );
WriteToMerged( sOutput , false );
}
}
@@ -1968,7 +1932,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
if ( pEntry && pResData->bQuickHelpText ) {
sal_Bool bAddSemikolon = sal_False;
sal_Bool bFirst = sal_True;
ByteString sCur;
rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
@@ -1976,7 +1940,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
rtl::OString sText;
sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_QUICKHELPTEXT, sCur, sal_True );
if ( bText && !sText.isEmpty() && sText != "-" ) {
ByteString sOutput;
rtl::OString sOutput;
if ( bNextMustBeDefineEOL) {
if ( bFirst )
sOutput += "\t\\\n";
@@ -2006,7 +1970,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
}
}
if ( bAddSemikolon ) {
ByteString sOutput( ";" );
rtl::OString sOutput( ";" );
WriteToMerged( sOutput , false );
}
}
@@ -2014,7 +1978,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
if ( pEntry && pResData->bTitle ) {
sal_Bool bAddSemikolon = sal_False;
sal_Bool bFirst = sal_True;
ByteString sCur;
rtl::OString sCur;
for( unsigned int n = 0; n < aLanguages.size(); n++ ){
sCur = aLanguages[ n ];
@@ -2022,7 +1986,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
rtl::OString sText;
sal_Bool bText = pEntry->GetTransex3Text( sText, STRING_TYP_TITLE, sCur, sal_True );
if ( bText && !sText.isEmpty() && sText != "-" ) {
ByteString sOutput;
rtl::OString sOutput;
if ( bNextMustBeDefineEOL) {
if ( bFirst )
sOutput += "\t\\\n";
@@ -2052,7 +2016,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
}
}
if ( bAddSemikolon ) {
ByteString sOutput( ";" );
rtl::OString sOutput( ";" );
WriteToMerged( sOutput ,false);
}
}
@@ -2060,13 +2024,13 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
if ( pResData->bList ) {
bool bPairedList = false;
ByteString sOldId = pResData->sId;
ByteString sOldGId = pResData->sGId;
ByteString sOldTyp = pResData->sResTyp;
rtl::OString sOldId = pResData->sId;
rtl::OString sOldGId = pResData->sGId;
rtl::OString sOldTyp = pResData->sResTyp;
if (!pResData->sGId.isEmpty())
pResData->sGId = pResData->sGId + rtl::OString('.');
pResData->sGId = pResData->sGId + sOldId;
ByteString sSpace;
rtl::OString sSpace;
for ( sal_uInt16 i = 1; i < nLevel-1; i++ )
sSpace += "\t";
for ( sal_uInt16 nT = LIST_STRING; nT <= LIST_UIENTRIES; nT++ ) {
@@ -2090,7 +2054,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
pResData->sId = GetPairedListID ( (*pListE)[ SOURCE_LANGUAGE ] );
}
else
pResData->sId = ByteString("1");
pResData->sId = "1";
PFormEntrys *pEntrys;
sal_uLong nLIndex = 0;
@@ -2169,7 +2133,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
sal_Int32 nStart, nEnd;
nStart = sLine.indexOf( '"' );
ByteString sPostFix;
rtl::OString sPostFix;
if( !bPairedList ){
nEnd = sLine.lastIndexOf( '"' );
sPostFix = sLine.copy( ++nEnd );
@@ -2188,7 +2152,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
sLine += sPostFix;
}
ByteString sText1( "\t" );
rtl::OString sText1( "\t" );
sText1 += sLine;
if ( bDefine || bNextMustBeDefineEOL )
sText1 += " ;\\\n";
@@ -2218,7 +2182,10 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
pEntrys = oldEntry;
}
if ( nIdx > 1 ) {
ByteString sFooter( sSpace.Copy( 1 ));
rtl::OString sFooter;
if (!sSpace.isEmpty()) {
sFooter = sSpace.copy(1);
}
if ( bNextMustBeDefineEOL )
sFooter += "};";
else if ( !bDefine )
@@ -2270,7 +2237,7 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
}
while( PrepareTextToMerge( sLine, nList, m_sListLang, pResData ) && ( nListIndex <= nMaxIndex )) {
ByteString sText( "\t" );
rtl::OString sText( "\t" );
sText += sLine;
sText += " ;";
sText += "\n";

View File

@@ -114,9 +114,9 @@ void Export::DumpMap(const rtl::OString& rMapName,
return;
for(OStringHashMap::const_iterator idbg = aMap.begin(); idbg != aMap.end(); ++idbg)
{
ByteString a( idbg->first );
ByteString b( idbg->second );
printf("[%s]= %s",a.GetBuffer(),b.GetBuffer());
rtl::OString a( idbg->first );
rtl::OString b( idbg->second );
printf("[%s]= %s",a.getStr(),b.getStr());
printf("\n");
}
printf("\n");
@@ -343,7 +343,7 @@ void Export::InitLanguages( bool bMergeMode ){
/*****************************************************************************/
if( !isInitialized )
{
ByteString sTmp;
rtl::OString sTmp;
OStringBoolHashMap aEnvLangs;
sal_Int32 nIndex = 0;
@@ -353,7 +353,7 @@ void Export::InitLanguages( bool bMergeMode ){
sTmp = getToken(aToken, 0, '=');
sTmp = comphelper::string::strip(sTmp, ' ');
if( bMergeMode && !isAllowed( sTmp ) ){}
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) ){
else if( !( (sTmp[0]=='x' || sTmp[0]=='X') && sTmp[1]=='-' ) ){
aLanguages.push_back( sTmp );
}
}
@@ -366,7 +366,7 @@ void Export::InitLanguages( bool bMergeMode ){
/*****************************************************************************/
void Export::InitForcedLanguages( bool bMergeMode ){
/*****************************************************************************/
ByteString sTmp;
rtl::OString sTmp;
OStringBoolHashMap aEnvLangs;
sal_Int32 nIndex = 0;
@@ -377,7 +377,7 @@ void Export::InitForcedLanguages( bool bMergeMode ){
sTmp = getToken(aToken, 0, '=');
sTmp = comphelper::string::strip(sTmp, ' ');
if( bMergeMode && isAllowed( sTmp ) ){}
else if( !( (sTmp.GetChar(0)=='x' || sTmp.GetChar(0)=='X') && sTmp.GetChar(1)=='-' ) )
else if( !( (sTmp[0]=='x' || sTmp[0]=='X') && sTmp[1]=='-' ) )
aForcedLanguages.push_back( sTmp );
}
while ( nIndex >= 0 );
@@ -399,8 +399,8 @@ sal_Bool Export::ConvertLineEnds(
rtl::OString const & sSource, rtl::OString const & sDestination )
/*****************************************************************************/
{
String sSourceFile( sSource, RTL_TEXTENCODING_ASCII_US );
String sDestinationFile( sDestination, RTL_TEXTENCODING_ASCII_US );
rtl::OUString sSourceFile(rtl::OStringToOUString(sSource, RTL_TEXTENCODING_ASCII_US));
rtl::OUString sDestinationFile(rtl::OStringToOUString(sDestination, RTL_TEXTENCODING_ASCII_US));
SvFileStream aSource( sSourceFile, STREAM_READ );
if ( !aSource.IsOpen())
@@ -512,10 +512,10 @@ DirEntry Export::GetTempFile()
int nRC = osl::FileBase::createTempFile( 0 , 0 , sTempFilename );
if( nRC ) printf(" osl::FileBase::createTempFile RC = %d",nRC);
String strTmp( *sTempFilename );
rtl::OUString strTmp( *sTempFilename );
INetURLObject::DecodeMechanism eMechanism = INetURLObject::DECODE_TO_IURI;
String sDecodedStr = INetURLObject::decode( strTmp , '%' , eMechanism );
rtl::OUString sDecodedStr = INetURLObject::decode( strTmp , '%' , eMechanism );
rtl::OString sTmp(rtl::OUStringToOString(sDecodedStr , RTL_TEXTENCODING_UTF8));
#if defined(WNT)

View File

@@ -64,9 +64,9 @@ void PrintError( rtl::OString const & aMsg, rtl::OString const & aPrefix,
PrintMessage( "Error:", aMsg, aPrefix, aContext, bPrintContext, nLine, aUniqueId );
}
sal_Bool LanguageOK( ByteString aLang )
sal_Bool LanguageOK( rtl::OString const & aLang )
{
if ( !aLang.Len() )
if (aLang.isEmpty())
return sal_False;
using comphelper::string::isdigitAsciiString;
@@ -80,11 +80,11 @@ sal_Bool LanguageOK( ByteString aLang )
return islowerAsciiString(aLang);
else if ( getTokenCount(aLang, '-') == 2 )
{
ByteString aTok0( getToken(aLang, 0, '-') );
ByteString aTok1( getToken(aLang, 1, '-') );
return aTok0.Len() && islowerAsciiString(aTok0)
&& aTok1.Len() && isupperAsciiString(aTok1)
&& !aTok1.EqualsIgnoreCaseAscii( aTok0 );
rtl::OString aTok0( getToken(aLang, 0, '-') );
rtl::OString aTok1( getToken(aLang, 1, '-') );
return !aTok0.isEmpty() && islowerAsciiString(aTok0)
&& !aTok1.isEmpty() && isupperAsciiString(aTok1)
&& !aTok1.equalsIgnoreAsciiCase( aTok0 );
}
return sal_False;
@@ -99,7 +99,7 @@ class LazySvFileStream : public SvFileStream
{
private:
String aFileName;
rtl::OUString aFileName;
sal_Bool bOpened;
StreamMode eOpenMode;
@@ -110,7 +110,7 @@ public:
, eOpenMode( 0 )
{};
void SetOpenParams( const String& rFileName, StreamMode eOpenModeP )
void SetOpenParams( const rtl::OUString& rFileName, StreamMode eOpenModeP )
{
aFileName = rFileName;
eOpenMode = eOpenModeP;
@@ -207,28 +207,27 @@ void GSILine::NotOK()
void GSILine::ReassembleLine()
/*****************************************************************************/
{
ByteString aReassemble;
if ( GetLineFormat() == FORMAT_SDF )
{
sal_uInt16 i;
for ( i = 0 ; i < 10 ; i++ )
rtl::OStringBuffer aReassemble;
for (sal_Int32 i = 0; i < 10; ++i)
{
aReassemble.Append( helper::getToken( data_, i, '\t' ) );
aReassemble.Append( "\t" );
aReassemble.append( helper::getToken( data_, i, '\t' ) );
aReassemble.append( "\t" );
}
aReassemble.Append( aText );
aReassemble.Append( "\t" );
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" );
aReassemble.Append( aTitle );
for ( i = 14 ; i < 15 ; i++ )
aReassemble.append( aText );
aReassemble.append( "\t" );
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" );
aReassemble.append( aTitle );
for (sal_Int32 i = 14; i < 15; ++i)
{
aReassemble.Append( "\t" );
aReassemble.Append( helper::getToken( data_, i, '\t' ) );
aReassemble.append( "\t" );
aReassemble.append( helper::getToken( data_, i, '\t' ) );
}
*(ByteString*)this = aReassemble;
data_ = aReassemble.makeStringAndClear();
}
else
PrintError( "Cannot reassemble line of unknown type (internal Error).", "Line format", "", sal_False, GetLineNumber(), GetUniqId() );
@@ -329,7 +328,7 @@ void GSIBlock::PrintList( ParserMessageList *pList, rtl::OString const & aPrefix
for ( size_t i = 0 ; i < pList->size() ; i++ )
{
ParserMessage *pMsg = (*pList)[ i ];
ByteString aContext;
rtl::OString aContext;
if ( bPrintContext )
{
if ( pMsg->GetTagBegin() == STRING_NOTFOUND )
@@ -345,21 +344,28 @@ void GSIBlock::PrintList( ParserMessageList *pList, rtl::OString const & aPrefix
}
/*****************************************************************************/
sal_Bool GSIBlock::IsUTF8( const rtl::OString &aTestee, sal_Bool bFixTags, sal_uInt16 &nErrorPos, rtl::OString &aErrorMsg, sal_Bool &bHasBeenFixed, rtl::OString &aFixed ) const
sal_Bool GSIBlock::IsUTF8( const rtl::OString &aTestee, sal_Bool bFixTags, sal_Int32 &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 )) )
rtl::OUString aUTF8Tester(
rtl::OStringToOUString(aTestee, RTL_TEXTENCODING_UTF8));
nErrorPos = rtl::OUStringToOString(aUTF8Tester, RTL_TEXTENCODING_UTF8).
indexOf(aTestee);
if (nErrorPos != -1)
{
aUTF8Tester = String( aTestee.getStr(), nErrorPos, RTL_TEXTENCODING_UTF8 );
nErrorPos = aUTF8Tester.Len();
aUTF8Tester = rtl::OUString(
aTestee.getStr(), nErrorPos, RTL_TEXTENCODING_UTF8);
nErrorPos = aUTF8Tester.getLength();
aErrorMsg = "UTF8 Encoding seems to be broken";
return sal_False;
}
nErrorPos = aUTF8Tester.SearchChar( String::CreateFromAscii( "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0e\x0f"
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f" ).GetBuffer() );
if ( nErrorPos != STRING_NOTFOUND )
nErrorPos = helper::indexOfAnyAsciiL(
aUTF8Tester,
RTL_CONSTASCII_STRINGPARAM(
"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0e\x0f\x10\x11\x12"
"\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f\x7f"));
if (nErrorPos != -1)
{
aErrorMsg = "String contains illegal character";
return sal_False;
@@ -378,16 +384,16 @@ sal_Bool GSIBlock::IsUTF8( const rtl::OString &aTestee, sal_Bool bFixTags, sal_u
sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
/*****************************************************************************/
{
sal_uInt16 nErrorPos = 0;
sal_Int32 nErrorPos = 0;
rtl::OString aErrorMsg;
sal_Bool bError = sal_False;
rtl::OString aFixed;
sal_Bool bHasBeenFixed = sal_False;
if ( !IsUTF8( pTestee->GetText(), bFixTags, nErrorPos, aErrorMsg, bHasBeenFixed, aFixed ) )
{
ByteString aContext( pTestee->GetText().copy( nErrorPos, 20 ) );
rtl::OString 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(),
.append(nErrorPos).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
bError = sal_True;
if ( bHasBeenFixed )
@@ -400,7 +406,7 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
{
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(),
.append(nErrorPos).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
bError = sal_True;
if ( bHasBeenFixed )
@@ -413,7 +419,7 @@ sal_Bool GSIBlock::TestUTF8( GSILine* pTestee, sal_Bool bFixTags )
{
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(),
.append(nErrorPos).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
bError = sal_True;
if ( bHasBeenFixed )
@@ -436,11 +442,13 @@ sal_Bool GSIBlock::HasSuspiciousChars( GSILine* pTestee, GSILine* pSource )
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();
rtl::OUString aUTF8Tester(
rtl::OStringToOUString(
pTestee->GetText().copy(0, nPos), RTL_TEXTENCODING_UTF8));
sal_Int32 nErrorPos = aUTF8Tester.getLength();
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(),
.append(nErrorPos).getStr(),
"Text format", aContext, pTestee->GetLineNumber(), pTestee->GetUniqId());
pTestee->NotOK();
return sal_True;
@@ -494,10 +502,10 @@ sal_Bool GSIBlock::CheckSyntax( sal_uLong nLine, sal_Bool bRequireSourceLine, sa
{
if ( pSourceLine && pSourceLine->data_ != pReferenceLine->data_ )
{
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() );
sal_Int32 nPos = pSourceLine->data_.indexOf( pReferenceLine->data_ );
rtl::OStringBuffer 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.makeStringAndClear(), pSourceLine->GetLineNumber(), pSourceLine->GetUniqId() );
pSourceLine->NotOK();
bHasError = sal_True;
}
@@ -662,13 +670,13 @@ int _cdecl main( int argc, char *argv[] )
sal_Bool bWriteFixed = sal_False;
sal_Bool bFixTags = sal_False;
sal_Bool bAllowSuspicious = sal_False;
String aErrorFilename;
String aCorrectFilename;
String aFixedFilename;
rtl::OUString aErrorFilename;
rtl::OUString aCorrectFilename;
rtl::OUString aFixedFilename;
sal_Bool bFileHasError = sal_False;
rtl::OString aSourceLang( "en-US" ); // English is default
ByteString aFilename;
ByteString aReferenceFilename;
rtl::OString aFilename;
rtl::OString aReferenceFilename;
sal_Bool bReferenceFile = sal_False;
for ( sal_uInt16 i = 1 ; i < argc ; i++ )
{
@@ -685,7 +693,10 @@ int _cdecl main( int argc, char *argv[] )
if ( (*(argv[ i ]+3)) == 'f' )
if ( (i+1) < argc )
{
aErrorFilename = String( argv[ i+1 ], RTL_TEXTENCODING_ASCII_US );
aErrorFilename = rtl::OUString(
argv[i + 1],
rtl_str_getLength(argv[i + 1]),
RTL_TEXTENCODING_ASCII_US);
bWriteError = sal_True;
i++;
}
@@ -701,7 +712,10 @@ int _cdecl main( int argc, char *argv[] )
if ( (*(argv[ i ]+3)) == 'f' )
if ( (i+1) < argc )
{
aCorrectFilename = String( argv[ i+1 ], RTL_TEXTENCODING_ASCII_US );
aCorrectFilename = rtl::OUString(
argv[i + 1],
rtl_str_getLength(argv[i + 1]),
RTL_TEXTENCODING_ASCII_US);
bWriteCorrect = sal_True;
i++;
}
@@ -716,7 +730,10 @@ int _cdecl main( int argc, char *argv[] )
if ( (*(argv[ i ]+3)) == 'f' )
if ( (i+1) < argc )
{
aFixedFilename = String( argv[ i+1 ], RTL_TEXTENCODING_ASCII_US );
aFixedFilename = rtl::OUString(
argv[i + 1],
rtl_str_getLength(argv[i + 1]),
RTL_TEXTENCODING_ASCII_US);
bWriteFixed = sal_True;
bFixTags = sal_True;
i++;
@@ -790,8 +807,8 @@ int _cdecl main( int argc, char *argv[] )
}
else
{
if ( !aFilename.Len())
aFilename = ByteString( argv[ i ] );
if (aFilename.isEmpty())
aFilename = argv[i];
else
{
fprintf( stderr, "\nERROR: Only one filename may be specified!\n\n");
@@ -801,7 +818,7 @@ int _cdecl main( int argc, char *argv[] )
}
if ( !aFilename.Len() || bError )
if (aFilename.isEmpty() || bError)
{
Help();
exit ( 0 );
@@ -823,42 +840,42 @@ int _cdecl main( int argc, char *argv[] )
DirEntry aSource = DirEntry( String( aFilename, RTL_TEXTENCODING_ASCII_US ));
DirEntry aSource = DirEntry( rtl::OStringToOUString( aFilename, RTL_TEXTENCODING_ASCII_US ));
if ( !aSource.Exists()) {
fprintf( stderr, "\nERROR: GSI-File %s not found!\n\n", aFilename.GetBuffer() );
fprintf( stderr, "\nERROR: GSI-File %s not found!\n\n", aFilename.getStr() );
exit ( 2 );
}
SvFileStream aGSI( String( aFilename, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
SvFileStream aGSI( rtl::OStringToOUString( aFilename, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
if ( !aGSI.IsOpen()) {
fprintf( stderr, "\nERROR: Could not open GSI-File %s!\n\n", aFilename.GetBuffer() );
fprintf( stderr, "\nERROR: Could not open GSI-File %s!\n\n", aFilename.getStr() );
exit ( 3 );
}
SvFileStream aReferenceGSI;
if ( bReferenceFile )
{
DirEntry aReferenceSource = DirEntry( String( aReferenceFilename, RTL_TEXTENCODING_ASCII_US ));
DirEntry aReferenceSource = DirEntry( rtl::OStringToOUString( aReferenceFilename, RTL_TEXTENCODING_ASCII_US ));
if ( !aReferenceSource.Exists()) {
fprintf( stderr, "\nERROR: GSI-File %s not found!\n\n", aFilename.GetBuffer() );
fprintf( stderr, "\nERROR: GSI-File %s not found!\n\n", aFilename.getStr() );
exit ( 2 );
}
aReferenceGSI.Open( String( aReferenceFilename, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
aReferenceGSI.Open( rtl::OStringToOUString( aReferenceFilename, RTL_TEXTENCODING_ASCII_US ), STREAM_STD_READ );
if ( !aReferenceGSI.IsOpen()) {
fprintf( stderr, "\nERROR: Could not open Input-File %s!\n\n", aFilename.GetBuffer() );
fprintf( stderr, "\nERROR: Could not open Input-File %s!\n\n", aFilename.getStr() );
exit ( 3 );
}
}
LazySvFileStream aOkOut;
String aBaseName = aSource.GetBase();
rtl::OUString aBaseName(aSource.GetBase());
if ( bWriteCorrect )
{
if ( !aCorrectFilename.Len() )
if (aCorrectFilename.isEmpty())
{
String sTmpBase( aBaseName );
sTmpBase += String( "_ok", RTL_TEXTENCODING_ASCII_US );
rtl::OUString sTmpBase(aBaseName);
sTmpBase += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_ok"));
aSource.SetBase( sTmpBase );
aCorrectFilename = aSource.GetFull();
}
@@ -868,10 +885,10 @@ int _cdecl main( int argc, char *argv[] )
LazySvFileStream aErrOut;
if ( bWriteError )
{
if ( !aErrorFilename.Len() )
if (aErrorFilename.isEmpty())
{
String sTmpBase( aBaseName );
sTmpBase += String( "_err", RTL_TEXTENCODING_ASCII_US );
rtl::OUString sTmpBase(aBaseName);
sTmpBase += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_err"));
aSource.SetBase( sTmpBase );
aErrorFilename = aSource.GetFull();
}
@@ -881,10 +898,10 @@ int _cdecl main( int argc, char *argv[] )
LazySvFileStream aFixOut;
if ( bWriteFixed )
{
if ( !aFixedFilename.Len() )
if (aFixedFilename.isEmpty())
{
String sTmpBase( aBaseName );
sTmpBase += String( "_fix", RTL_TEXTENCODING_ASCII_US );
rtl::OUString sTmpBase(aBaseName);
sTmpBase += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("_fix"));
aSource.SetBase( sTmpBase );
aFixedFilename = aSource.GetFull();
}
@@ -894,7 +911,6 @@ int _cdecl main( int argc, char *argv[] )
rtl::OString sReferenceLine;
GSILine* pReferenceLine = NULL;
ByteString aOldReferenceId("No Valid ID"); // just set to something which can never be an ID
sal_uLong nReferenceLine = 0;
rtl::OString sGSILine;

View File

@@ -56,6 +56,21 @@ inline sal_Int32 searchAndReplace(
return i;
}
inline void searchAndReplaceAll(
rtl::OString * text, rtl::OString const & search,
rtl::OString const & replace)
{
assert(text != 0);
for (sal_Int32 i = 0;;) {
i = text->indexOf(search, i);
if (i == -1) {
break;
}
*text = text->replaceAt(i, search.getLength(), replace);
i += replace.getLength();
}
}
inline rtl::OString getToken(
rtl::OString const & text, sal_Int32 token, char separator)
{
@@ -63,6 +78,23 @@ inline rtl::OString getToken(
return text.getToken(token, separator, i);
}
inline sal_Int32 indexOfAnyAsciiL(
rtl::OUString const & text, char const * chars, sal_Int32 charsLen,
sal_Int32 index = 0)
{
for (; index != text.getLength(); ++index) {
sal_Unicode c = text[index];
if (c <= 0x7F
&& (rtl_str_indexOfChar_WithLength(
chars, charsLen, static_cast< char >(c))
!= -1))
{
return index;
}
}
return -1;
}
}
#endif

View File

@@ -57,7 +57,7 @@ void HelpParser::Dump(XMLHashMap* rElem_in)
void HelpParser::Dump(LangHashMap* rElem_in,const rtl::OString & sKey_in)
{
ByteString x;
rtl::OString x;
OString y;
fprintf(stdout,"+------------%s-----------+\n",sKey_in.getStr() );
for(LangHashMap::iterator posn=rElem_in->begin();posn!=rElem_in->end();++posn)
@@ -111,15 +111,13 @@ bool HelpParser::CreateSDF(
sXmlFile = String( sHelpFile , RTL_TEXTENCODING_ASCII_US );
}
// ByteString fullFilePath;
//DirEntry aFile( sXmlFile );
//makeAbsolutePath( sHelpFile , rRoot_in);
ByteString fullFilePath = rPrj_in;
fullFilePath.Append( "\\" );
fullFilePath.Append( makeAbsolutePath( sHelpFile , rRoot_in ) );
fullFilePath.SearchAndReplaceAll( "\\", "/" );
rtl::OString fullFilePath = rPrj_in;
fullFilePath += "\\";
fullFilePath += makeAbsolutePath( sHelpFile , rRoot_in );
fullFilePath = fullFilePath.replace('\\', '/');
String strFullPath( fullFilePath.GetBuffer() , RTL_TEXTENCODING_ASCII_US );
rtl::OUString strFullPath(
rtl::OStringToOUString(fullFilePath, RTL_TEXTENCODING_ASCII_US));
//printf( "%s\n", fullFilePath.GetBuffer() );
std::auto_ptr <XMLFile> file ( aParser.Execute( strFullPath , sXmlFile, pXmlFile ) );
@@ -147,8 +145,9 @@ bool HelpParser::CreateSDF(
LangHashMap* pElem;
XMLElement* pXMLElement = NULL;
ByteString sTimeStamp( Export::GetTimeStamp() );
OUString sOUTimeStamp( sTimeStamp.GetBuffer() , sTimeStamp.Len() , RTL_TEXTENCODING_ASCII_US );
OUString sOUTimeStamp(
rtl::OStringToOUString(
Export::GetTimeStamp(), RTL_TEXTENCODING_ASCII_US));
OUStringBuffer sBuffer;
const OUString sOUPrj( rPrj_in.getStr() , rPrj_in.getLength() , RTL_TEXTENCODING_ASCII_US );

View File

@@ -35,6 +35,7 @@
#endif
#include "gsicheck.hxx"
#include "helper.hxx"
#define HAS_FLAG( nFlags, nFlag ) ( ( nFlags & nFlag ) != 0 )
#define SET_FLAG( nFlags, nFlag ) ( nFlags |= nFlag )
@@ -42,7 +43,7 @@
TokenInfo::TokenInfo( TokenId pnId, sal_uInt16 nP, String paStr, ParserMessageList &rErrorList )
TokenInfo::TokenInfo( TokenId pnId, sal_uInt16 nP, rtl::OUString const & paStr, ParserMessageList &rErrorList )
: bClosed(sal_False)
, bCloseTag(sal_False)
, bIsBroken(sal_False)
@@ -90,9 +91,9 @@ CLOSETAG_HAS_TAG_NAME '>' -> FINISHED
*/
void TokenInfo::SplitTag( ParserMessageList &rErrorList )
{
sal_uInt16 nLastPos = 2; // skip initial \<
sal_uInt16 nCheckPos = nLastPos;
String aDelims( String::CreateFromAscii( " \\=>/" ) );
sal_Int32 nLastPos = 2; // skip initial \<
sal_Int32 nCheckPos = nLastPos;
static char const aDelims[] = " \\=>/";
String aPortion;
String aValue; // store the value of a property
rtl::OString aName; // store the name of a property/tag
@@ -102,18 +103,19 @@ void TokenInfo::SplitTag( ParserMessageList &rErrorList )
tagcheck aState = TC_START;
// skip blanks
while ( nLastPos < aTokenString.Len() && aTokenString.GetChar( nLastPos ) == ' ')
while ( nLastPos < aTokenString.getLength() && aTokenString[nLastPos] == ' ')
nLastPos++;
nCheckPos = aTokenString.SearchChar( aDelims.GetBuffer(), nLastPos );
while ( nCheckPos != STRING_NOTFOUND && !( aState == TC_FINISHED || aState == TC_ERROR ) )
nCheckPos = helper::indexOfAnyAsciiL(
aTokenString, RTL_CONSTASCII_STRINGPARAM(aDelims), nLastPos);
while ( nCheckPos != -1 && !( aState == TC_FINISHED || aState == TC_ERROR ) )
{
aPortion = aTokenString.Copy( nLastPos, nCheckPos-nLastPos );
aPortion = aTokenString.copy( nLastPos, nCheckPos-nLastPos );
if ( aTokenString.GetChar( nCheckPos ) == '\\' )
if ( aTokenString[nCheckPos] == '\\' )
nCheckPos++;
cDelim = aTokenString.GetChar( nCheckPos );
cDelim = aTokenString[nCheckPos];
nCheckPos++;
switch ( aState )
@@ -374,10 +376,11 @@ void TokenInfo::SplitTag( ParserMessageList &rErrorList )
// skip further blanks
if ( cDelim == ' ' && aState != TC_INSIDE_STRING )
while ( nLastPos < aTokenString.Len() && aTokenString.GetChar( nLastPos ) == ' ')
while ( nLastPos < aTokenString.getLength() && aTokenString[nLastPos] == ' ')
nLastPos++;
nCheckPos = aTokenString.SearchChar( aDelims.GetBuffer(), nLastPos );
nCheckPos = helper::indexOfAnyAsciiL(
aTokenString, RTL_CONSTASCII_STRINGPARAM(aDelims), nLastPos);
}
if ( aState != TC_FINISHED )
{
@@ -386,19 +389,19 @@ void TokenInfo::SplitTag( ParserMessageList &rErrorList )
}
}
sal_Bool TokenInfo::IsPropertyRelevant( const rtl::OString &rName, const String &rValue ) const
sal_Bool TokenInfo::IsPropertyRelevant( const rtl::OString &rName, const rtl::OUString &rValue ) const
{
if ( aTagName.EqualsAscii( "alt" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("xml-lang")) )
if ( aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("alt")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("xml-lang")) )
return sal_False;
if ( aTagName.EqualsAscii( "ahelp" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("visibility")) && rValue.EqualsAscii("visible") )
if ( aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ahelp")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("visibility")) && rValue.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("visible")) )
return sal_False;
if ( aTagName.EqualsAscii( "image" ) && (rName.equalsL(RTL_CONSTASCII_STRINGPARAM("width")) || rName.equalsL(RTL_CONSTASCII_STRINGPARAM("height"))) )
if ( aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("image")) && (rName.equalsL(RTL_CONSTASCII_STRINGPARAM("width")) || rName.equalsL(RTL_CONSTASCII_STRINGPARAM("height"))) )
return sal_False;
return sal_True;
}
sal_Bool TokenInfo::IsPropertyValueValid( const rtl::OString &rName, const String &rValue ) const
sal_Bool TokenInfo::IsPropertyValueValid( const rtl::OString &rName, const rtl::OUString &rValue ) const
{
/* removed due to i56740
if ( aTagName.EqualsAscii( "switchinline" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("select")) )
@@ -407,28 +410,28 @@ sal_Bool TokenInfo::IsPropertyValueValid( const rtl::OString &rName, const Strin
rValue.EqualsAscii("appl") ||
rValue.EqualsAscii("distrib");
} */
if ( aTagName.EqualsAscii( "caseinline" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("select")) )
if ( aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("caseinline")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("select")) )
{
return /*!rValue.EqualsAscii("OS2") && removed due to i56740 */
!rValue.EqualsAscii("");
return !rValue.isEmpty();
}
// we don't know any better so we assume it to be OK
return sal_True;
}
sal_Bool TokenInfo::IsPropertyInvariant( const rtl::OString &rName, const String &rValue ) const
sal_Bool TokenInfo::IsPropertyInvariant( const rtl::OString &rName, const rtl::OUString &rValue ) const
{
if ( aTagName.EqualsAscii( "link" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("name")) )
if ( aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("link")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("name")) )
return sal_False;
if ( aTagName.EqualsAscii( "link" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("href")) )
if ( aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("link")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("href")) )
{ // check for external reference
if ( rValue.Copy( 0, 5 ).EqualsIgnoreCaseAscii( "http:" )
|| rValue.Copy( 0, 6 ).EqualsIgnoreCaseAscii( "https:" )
|| rValue.Copy( 0, 4 ).EqualsIgnoreCaseAscii( "ftp:" ) )
return sal_False;
else
return sal_True;
return
!(rValue.matchIgnoreAsciiCaseAsciiL(
RTL_CONSTASCII_STRINGPARAM("http:"))
|| rValue.matchIgnoreAsciiCaseAsciiL(
RTL_CONSTASCII_STRINGPARAM("https:"))
|| rValue.matchIgnoreAsciiCaseAsciiL(
RTL_CONSTASCII_STRINGPARAM("ftp:")));
}
return sal_True;
}
@@ -436,12 +439,12 @@ sal_Bool TokenInfo::IsPropertyInvariant( const rtl::OString &rName, const String
sal_Bool TokenInfo::IsPropertyFixable( const rtl::OString &rName ) const
{
// name everything that is allowed to be fixed automatically here
if ( (aTagName.EqualsAscii( "ahelp" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("hid")))
|| (aTagName.EqualsAscii( "link" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("href")))
|| (aTagName.EqualsAscii( "alt" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("id")))
|| (aTagName.EqualsAscii( "variable" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("id")))
|| (aTagName.EqualsAscii( "image" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("src")))
|| (aTagName.EqualsAscii( "image" ) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("id")) ))
if ( (aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ahelp")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("hid")))
|| (aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("link")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("href")))
|| (aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("alt")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("id")))
|| (aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("variable")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("id")))
|| (aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("image")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("src")))
|| (aTagName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("image")) && rName.equalsL(RTL_CONSTASCII_STRINGPARAM("id")) ))
return sal_True;
return sal_False;
}
@@ -455,7 +458,7 @@ sal_Bool TokenInfo::MatchesTranslation( TokenInfo& rInfo, sal_Bool bGenErrors, P
if ( nId != rInfo.nId )
return sal_False;
if ( !aTagName.Equals( rInfo.aTagName ) )
if ( aTagName != rInfo.aTagName )
return sal_False;
// If one of the tags has formating errors already it does make no sense to check here, so return right away
@@ -471,7 +474,7 @@ sal_Bool TokenInfo::MatchesTranslation( TokenInfo& rInfo, sal_Bool bGenErrors, P
{
if ( IsPropertyInvariant( iProp->first, iProp->second ) )
{
if ( !rInfo.aProperties.find( iProp->first )->second.Equals( iProp->second ) )
if ( rInfo.aProperties.find( iProp->first )->second != iProp->second )
{
if ( bGenErrors )
{
@@ -518,12 +521,12 @@ sal_Bool TokenInfo::MatchesTranslation( TokenInfo& rInfo, sal_Bool bGenErrors, P
return sal_True;
}
String TokenInfo::GetTagName() const
rtl::OUString TokenInfo::GetTagName() const
{
return aTagName;
}
String TokenInfo::MakeTag() const
rtl::OUString TokenInfo::MakeTag() const
{
String aRet;
aRet.AppendAscii("\\<");
@@ -574,7 +577,7 @@ void ParserMessageList::clear()
struct Tag
{
String GetName() const { return String::CreateFromAscii( pName ); };
rtl::OUString GetName() const { return rtl::OUString::createFromAscii( pName ); };
const char* pName;
TokenId nTag;
};
@@ -662,11 +665,11 @@ SimpleParser::SimpleParser()
{
}
void SimpleParser::Parse( String PaSource )
void SimpleParser::Parse( rtl::OUString const & PaSource )
{
aSource = PaSource;
nPos = 0;
aLastToken.Erase();
aLastToken = rtl::OUString();
aNextTag = TokenInfo( TAG_NOMORETAGS, TOK_INVALIDPOS );
aTokenList.clear();
};
@@ -683,18 +686,21 @@ TokenInfo SimpleParser::GetNextToken( ParserMessageList &rErrorList )
else
{
aLastToken = GetNextTokenString( rErrorList, nTokenStartPos );
if ( aLastToken.Len() == 0 )
if ( aLastToken.isEmpty() )
return TokenInfo( TAG_NOMORETAGS, TOK_INVALIDPOS );
// do we have a \< ... \> style tag?
if ( aLastToken.Copy(0,2).EqualsAscii( "\\<" ) )
if (aLastToken.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("\\<")))
{
// check for paired \" \"
bool bEven = true;
sal_uInt16 nQuotePos = 0;
sal_uInt16 nQuotedQuotesPos = aLastToken.SearchAscii( "\\\"" );
sal_uInt16 nQuotedBackPos = aLastToken.SearchAscii( "\\\\" ); // this is only to kick out quoted backslashes
while ( nQuotedQuotesPos != STRING_NOTFOUND )
sal_Int32 nQuotePos = 0;
sal_Int32 nQuotedQuotesPos =
aLastToken.indexOfAsciiL(RTL_CONSTASCII_STRINGPARAM("\\\""));
sal_Int32 nQuotedBackPos = aLastToken.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\\\"));
// this is only to kick out quoted backslashes
while (nQuotedQuotesPos != -1)
{
if ( nQuotedBackPos <= nQuotedQuotesPos )
nQuotePos = nQuotedBackPos+2;
@@ -703,8 +709,11 @@ TokenInfo SimpleParser::GetNextToken( ParserMessageList &rErrorList )
nQuotePos = nQuotedQuotesPos+2;
bEven = !bEven;
}
nQuotedQuotesPos = aLastToken.SearchAscii( "\\\"", nQuotePos );
nQuotedBackPos = aLastToken.SearchAscii( "\\\\", nQuotePos ); // this is only to kick out quoted backslashes
nQuotedQuotesPos = aLastToken.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\\""), nQuotePos);
nQuotedBackPos = aLastToken.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\\\"), nQuotePos);
// this is only to kick out quoted backslashes
}
if ( !bEven )
{
@@ -712,19 +721,18 @@ TokenInfo SimpleParser::GetNextToken( ParserMessageList &rErrorList )
}
// check if we have an end-tag or a start-tag
sal_uInt16 nNonBlankStartPos,nNonBlankEndPos;
nNonBlankStartPos = 2;
while ( aLastToken.GetChar(nNonBlankStartPos) == ' ' )
sal_Int32 nNonBlankStartPos = 2;
while (aLastToken[nNonBlankStartPos] == ' ')
nNonBlankStartPos++;
if ( aLastToken.GetChar(nNonBlankStartPos) == '/' )
if (aLastToken[nNonBlankStartPos] == '/')
aResult = TokenInfo( TAG_COMMONEND, nTokenStartPos, aLastToken, rErrorList );
else
{
aResult = TokenInfo( TAG_COMMONSTART, nTokenStartPos, aLastToken, rErrorList );
nNonBlankEndPos = aLastToken.Len() -3;
while ( aLastToken.GetChar(nNonBlankEndPos) == ' ' )
sal_Int32 nNonBlankEndPos = aLastToken.getLength() - 3;
while (aLastToken[nNonBlankEndPos] == ' ')
nNonBlankEndPos--;
if ( aLastToken.GetChar( nNonBlankEndPos ) == '/' )
if (aLastToken[nNonBlankEndPos] == '/')
aNextTag = TokenInfo( TAG_COMMONEND, nTokenStartPos, String::CreateFromAscii("\\</").Append(aResult.GetTagName()).AppendAscii("\\>"), rErrorList );
}
}
@@ -744,15 +752,19 @@ TokenInfo SimpleParser::GetNextToken( ParserMessageList &rErrorList )
return aResult;
}
String SimpleParser::GetNextTokenString( ParserMessageList &rErrorList, sal_uInt16 &rTagStartPos )
rtl::OUString SimpleParser::GetNextTokenString( ParserMessageList &rErrorList, sal_uInt16 &rTagStartPos )
{
sal_uInt16 nStyle2StartPos = aSource.SearchAscii( "$[", nPos );
sal_uInt16 nStyle3StartPos = aSource.SearchAscii( "\\<", nPos );
sal_uInt16 nStyle4StartPos = aSource.SearchAscii( "\\\\", nPos ); // this is only to kick out quoted backslashes
sal_Int32 nStyle2StartPos = aSource.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("$["), nPos );
sal_Int32 nStyle3StartPos = aSource.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\<"), nPos);
sal_Int32 nStyle4StartPos = aSource.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\\\"), nPos);
// this is only to kick out quoted backslashes
rTagStartPos = 0;
if ( STRING_NOTFOUND == nStyle2StartPos && STRING_NOTFOUND == nStyle3StartPos )
if (nStyle2StartPos == -1 && nStyle3StartPos == -1)
return String(); // no more tokens
if ( nStyle4StartPos < nStyle2StartPos && nStyle4StartPos <= nStyle3StartPos ) // <= to make sure \\ is always handled first
@@ -763,42 +775,48 @@ String SimpleParser::GetNextTokenString( ParserMessageList &rErrorList, sal_uInt
if ( nStyle2StartPos < nStyle3StartPos )
{ // test for $[ ... ] style tokens
sal_uInt16 nEndPos = aSource.SearchAscii( "]", nStyle2StartPos);
if ( nEndPos == STRING_NOTFOUND )
sal_Int32 nEndPos = aSource.indexOf(']', nStyle2StartPos);
if (nEndPos == -1)
{ // Token is incomplete. Skip start and search for better ones
nPos = nStyle2StartPos +2;
return GetNextTokenString( rErrorList, rTagStartPos );
}
nPos = nEndPos;
rTagStartPos = nStyle2StartPos;
return aSource.Copy( nStyle2StartPos, nEndPos-nStyle2StartPos +1 );
return aSource.copy(nStyle2StartPos, nEndPos - nStyle2StartPos + 1);
}
else
{ // test for \< ... \> style tokens
sal_uInt16 nEndPos = aSource.SearchAscii( "\\>", nStyle3StartPos);
sal_uInt16 nQuotedBackPos = aSource.SearchAscii( "\\\\", nStyle3StartPos ); // this is only to kick out quoted backslashes
while ( nQuotedBackPos <= nEndPos && nQuotedBackPos != STRING_NOTFOUND )
sal_Int32 nEndPos = aSource.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\>"), nStyle3StartPos);
sal_Int32 nQuotedBackPos = aSource.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\\\"), nStyle3StartPos);
// this is only to kick out quoted backslashes
while (nQuotedBackPos <= nEndPos && nQuotedBackPos != -1)
{
nEndPos = aSource.SearchAscii( "\\>", nQuotedBackPos +2);
nQuotedBackPos = aSource.SearchAscii( "\\\\", nQuotedBackPos +2 ); // this is only to kick out quoted backslashes
nEndPos = aSource.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\>"), nQuotedBackPos + 2);
nQuotedBackPos = aSource.indexOfAsciiL(
RTL_CONSTASCII_STRINGPARAM("\\\\"), nQuotedBackPos + 2);
// this is only to kick out quoted backslashes
}
if ( nEndPos == STRING_NOTFOUND )
if (nEndPos == -1)
{ // Token is incomplete. Skip start and search for better ones
nPos = nStyle3StartPos +2;
rErrorList.AddError( 24, "Tag Start '\\<' without Tag End '\\>'", TokenInfo( TAG_UNKNOWN_TAG, nStyle3StartPos, aSource.Copy( nStyle3StartPos-10, 20 ) ) );
rErrorList.AddError( 24, "Tag Start '\\<' without Tag End '\\>'", TokenInfo( TAG_UNKNOWN_TAG, nStyle3StartPos, aSource.copy(nStyle3StartPos - 10, 20) ) );
return GetNextTokenString( rErrorList, rTagStartPos );
}
// check for paired quoted " --> \"sometext\"
nPos = nEndPos;
rTagStartPos = nStyle3StartPos;
return aSource.Copy( nStyle3StartPos, nEndPos-nStyle3StartPos +2 );
return aSource.copy(nStyle3StartPos, nEndPos-nStyle3StartPos + 2);
}
}
String SimpleParser::GetLexem( TokenInfo const &aToken )
rtl::OUString SimpleParser::GetLexem( TokenInfo const &aToken )
{
if ( aToken.aTokenString.Len() )
if ( !aToken.aTokenString.isEmpty() )
return aToken.aTokenString;
else
{
@@ -815,7 +833,7 @@ TokenParser::TokenParser()
: pErrorList( NULL )
{}
void TokenParser::Parse( const String &aCode, ParserMessageList* pList )
void TokenParser::Parse( const rtl::OUString &aCode, ParserMessageList* pList )
{
pErrorList = pList;
@@ -1300,7 +1318,7 @@ sal_Bool TokenParser::match( const TokenInfo &aCurrentToken, const TokenInfo &rE
if ( aCurrentToken.nId == aExpectedToken.nId )
{
if ( ( aCurrentToken.nId == TAG_COMMONEND
&& aCurrentToken.GetTagName().Equals( aExpectedToken.GetTagName() ) )
&& aCurrentToken.GetTagName() == aExpectedToken.GetTagName() )
|| aCurrentToken.nId != TAG_COMMONEND )
{
aTag = aParser.GetNextToken( *pErrorList );
@@ -1310,7 +1328,9 @@ sal_Bool TokenParser::match( const TokenInfo &aCurrentToken, const TokenInfo &rE
if ( aExpectedToken.nId == TAG_COMMONEND )
{
aExpectedToken.aTokenString.Insert( String::CreateFromAscii( "Close tag for " ), 0 );
aExpectedToken.aTokenString =
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Close tag for "))
+ aExpectedToken.aTokenString;
}
rtl::OString sTmp(RTL_CONSTASCII_STRINGPARAM("Expected Symbol"));
@@ -1537,7 +1557,7 @@ void LingTest::CheckTestee( GSILine *aTestee, sal_Bool bHasSourceLine, sal_Bool
if ( aTesteeTokens[ --i ].HasBeenFixed() )
{
bFixesDone = sal_True;
aFixedTestee.Replace( aTesteeTokens[ i ].nPos, aTesteeTokens[ i ].aTokenString.Len(), aTesteeTokens[ i ].MakeTag() );
aFixedTestee = aFixedTestee.replaceAt( aTesteeTokens[ i ].nPos, aTesteeTokens[ i ].aTokenString.getLength(), aTesteeTokens[ i ].MakeTag() );
}
}
if ( bFixesDone )

View File

@@ -287,7 +287,7 @@ sal_Bool XMLFile::Write( rtl::OString const &aFilename )
exit( -1 );
}
void XMLFile::WriteString( ofstream &rStream, const String &sString )
void XMLFile::WriteString( ofstream &rStream, const rtl::OUString &sString )
{
rtl::OString sText(rtl::OUStringToOString(sString, RTL_TEXTENCODING_UTF8));
rStream << sText.getStr();
@@ -312,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 ]->GetName() );
rtl::OUString sData( (*pElement->GetAttributeList())[ j ]->GetName() );
XMLUtil::QuotHTML( sData );
WriteString( rStream , sData );
rStream << "=\"";
@@ -335,7 +335,7 @@ sal_Bool XMLFile::Write( ofstream &rStream , XMLNode *pCur )
break;
case XML_NODE_TYPE_DATA: {
XMLData *pData = ( XMLData * ) pCur;
String sData( pData->GetData());
rtl::OUString sData( pData->GetData());
XMLUtil::QuotHTML( sData );
WriteString( rStream, sData );
}
@@ -745,7 +745,7 @@ XMLElement& XMLElement::operator=(const XMLElement& obj){
}
/*****************************************************************************/
void XMLElement::AddAttribute( const String &rAttribute, const String &rValue )
void XMLElement::AddAttribute( const rtl::OUString &rAttribute, const rtl::OUString &rValue )
/*****************************************************************************/
{
if ( !pAttributes )
@@ -754,7 +754,7 @@ void XMLElement::AddAttribute( const String &rAttribute, const String &rValue )
}
/*****************************************************************************/
void XMLElement::ChangeLanguageTag( const String &rValue )
void XMLElement::ChangeLanguageTag( const rtl::OUString &rValue )
{
SetLanguageId(rtl::OUStringToOString(rValue, RTL_TEXTENCODING_UTF8));
if ( pAttributes )
@@ -842,8 +842,6 @@ OUString XMLElement::ToOUString(){
/*****************************************************************************/
void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement ){
/*****************************************************************************/
//YD FIXME somewhere COMMENT is defined as 4!
static const String _COMMENT = String::CreateFromAscii("comment");
static const OUString XML_LANG ( RTL_CONSTASCII_USTRINGPARAM("xml-lang") );
if(pCur!=NULL){
@@ -865,7 +863,7 @@ void XMLElement::Print(XMLNode *pCur, OUStringBuffer& buffer , bool rootelement
case XML_NODE_TYPE_ELEMENT: {
XMLElement *pElement = ( XMLElement * ) pCur;
if( !pElement->GetName().EqualsIgnoreCaseAscii( _COMMENT ) ){
if( !pElement->GetName().equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("comment")) ){
buffer.append( OUString(RTL_CONSTASCII_USTRINGPARAM("\\<")) );
buffer.append( pElement->GetName() );
if ( pElement->GetAttributeList()){
@@ -946,7 +944,7 @@ XMLData& XMLData::operator=(const XMLData& obj){
return *this;
}
/*****************************************************************************/
void XMLData::AddData( const String &rData) {
void XMLData::AddData( const rtl::OUString &rData) {
/*****************************************************************************/
sData += rData;
}
@@ -1118,11 +1116,11 @@ void SimpleXMLParser::CharacterData(
/*****************************************************************************/
{
if ( !pCurData ){
String x=String( XML_CHAR_N_TO_OUSTRING( s, len ));
rtl::OUString x = XML_CHAR_N_TO_OUSTRING( s, len );
XMLUtil::UnQuotHTML(x);
pCurData = new XMLData( x , pCurNode );
}else{
String x=String( XML_CHAR_N_TO_OUSTRING( s, len ));
rtl::OUString x = XML_CHAR_N_TO_OUSTRING( s, len );
XMLUtil::UnQuotHTML(x);
pCurData->AddData( x );
@@ -1149,10 +1147,9 @@ void SimpleXMLParser::Default(
}
/*****************************************************************************/
XMLFile *SimpleXMLParser::Execute( const String &rFullFileName , const String &rFileName, XMLFile* pXMLFileIn )
XMLFile *SimpleXMLParser::Execute( const rtl::OUString &rFullFileName , const rtl::OUString &rFileName, XMLFile* pXMLFileIn )
/*****************************************************************************/
{
// printf("DBG: SimpleXMLParser::Execute( %s )", ByteString( rFileName , RTL_TEXTENCODING_ASCII_US ).GetBuffer() );
aErrorInformation.eCode = XML_ERROR_NONE;
aErrorInformation.nLine = 0;
aErrorInformation.nColumn = 0;
@@ -1193,7 +1190,7 @@ XMLFile *SimpleXMLParser::Execute( SvMemoryStream *pStream )
aErrorInformation.eCode = XML_ERROR_NONE;
aErrorInformation.nLine = 0;
aErrorInformation.nColumn = 0;
if ( pXMLFile->GetName().Len()) {
if ( !pXMLFile->GetName().isEmpty()) {
aErrorInformation.sMessage = String::CreateFromAscii( "File " );
aErrorInformation.sMessage += pXMLFile->GetName();
aErrorInformation.sMessage += String::CreateFromAscii( " parsed successfully" );
@@ -1209,7 +1206,7 @@ XMLFile *SimpleXMLParser::Execute( SvMemoryStream *pStream )
aErrorInformation.nColumn = XML_GetErrorColumnNumber( aParser );
aErrorInformation.sMessage = String::CreateFromAscii( "ERROR: " );
if ( pXMLFile->GetName().Len())
if ( !pXMLFile->GetName().isEmpty())
aErrorInformation.sMessage += pXMLFile->GetName();
else
aErrorInformation.sMessage += String::CreateFromAscii( "XML-File" );
@@ -1256,108 +1253,79 @@ XMLFile *SimpleXMLParser::Execute( SvMemoryStream *pStream )
}
/*****************************************************************************/
void XMLUtil::QuotHTML( String &rString )
void XMLUtil::QuotHTML( rtl::OUString &rString )
/*****************************************************************************/
{
OUStringBuffer sReturn;
static const String LT(String::CreateFromAscii("<"));
static const String QLT(String::CreateFromAscii("&lt;"));
static const String GT(String::CreateFromAscii(">"));
static const String QGT(String::CreateFromAscii("&gt;"));
static const String QUOT(String::CreateFromAscii("\\"));
static const String QQUOT(String::CreateFromAscii("&quot;"));
static const String APOS(String::CreateFromAscii("\""));
static const String QAPOS(String::CreateFromAscii("&apos;"));
static const String AMP(String::CreateFromAscii("&"));
static const String QAMP(String::CreateFromAscii("&amp;"));
static const String SLASH(String::CreateFromAscii("\\"));
for ( sal_uInt16 i = 0; i < rString.Len(); i++) {
if ( i < rString.Len()) {
switch ( rString.GetChar( i )) {
case '\\': if( i+1 <= rString.Len() ){
switch( rString.GetChar( i+1 ) ){
case '<': sReturn.append( LT );i++;break;
case '>': sReturn.append( GT );i++;break;
case '\\': sReturn.append( QUOT );i++;break;
case '\"': sReturn.append( APOS );i++;break;
default: sReturn.append( SLASH );break;
}
}
break;
for (sal_Int32 i = 0; i < rString.getLength(); ++i) {
switch (rString[i]) {
case '\\':
if (i < rString.getLength()) {
switch (rString[i + 1]) {
case '"':
case '<':
sReturn.append( QLT );
break;
case '>':
sReturn.append( QGT );
case '\\':
++i;
break;
case '\"':
sReturn.append( QQUOT );
break;
case '&':
if (
( ( i + 4 ) < rString.Len()) &&
( String( rString.Copy( i, 5 ) ).Equals( QAMP ) )
)
sReturn.append( rString.GetChar( i ) );
else
sReturn.append( QAMP );
break;
default:
sReturn.append( rString.GetChar( i ) );
break;
}
}
// fall through
default:
sReturn.append(rString[i]);
break;
case '<':
sReturn.appendAscii(RTL_CONSTASCII_STRINGPARAM("&lt;"));
break;
case '>':
sReturn.appendAscii(RTL_CONSTASCII_STRINGPARAM("&gt;"));
break;
case '"':
sReturn.appendAscii(RTL_CONSTASCII_STRINGPARAM("&quot;"));
break;
case '&':
if (rString.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("&amp;"), i))
sReturn.append('&');
else
sReturn.appendAscii(RTL_CONSTASCII_STRINGPARAM("&amp;"));
break;
}
}
rString = String( sReturn.makeStringAndClear() );
rString = sReturn.makeStringAndClear();
}
void XMLUtil::UnQuotHTML( String &rString ){
UnQuotData( rString );
}
void XMLUtil::UnQuotData( String &rString_in )
{
void XMLUtil::UnQuotHTML( rtl::OUString &rString ){
rtl::OStringBuffer sReturn;
ByteString sString(rtl::OUStringToOString(rString_in , RTL_TEXTENCODING_UTF8));
while (sString.Len())
{
if ( sString.Copy( 0, 1 ) == "\\" ) {
sReturn.append("\\\\");
sString.Erase( 0, 1 );
}
else if ( sString.Copy( 0, 5 ) == "&amp;" ) {
rtl::OString sString(rtl::OUStringToOString(rString, RTL_TEXTENCODING_UTF8));
for (sal_Int32 i = 0; i != sString.getLength();) {
if (sString[i] == '\\') {
sReturn.append(RTL_CONSTASCII_STRINGPARAM("\\\\"));
++i;
} else if (sString.match("&amp;", i)) {
sReturn.append('&');
sString.Erase( 0, 5 );
}
else if ( sString.Copy( 0, 4 ) == "&lt;" ) {
i += RTL_CONSTASCII_LENGTH("&amp;");
} else if (sString.match("&lt;", i)) {
sReturn.append('<');
sString.Erase( 0, 4 );
}
else if ( sString.Copy( 0, 4 ) == "&gt;" ) {
i += RTL_CONSTASCII_LENGTH("&lt;");
} else if (sString.match("&gt;", i)) {
sReturn.append('>');
sString.Erase( 0, 4 );
}
else if ( sString.Copy( 0, 6 ) == "&quot;" ) {
sReturn.append('\"');
sString.Erase( 0, 6 );
}
else if ( sString.Copy( 0, 6 ) == "&apos;" ) {
i += RTL_CONSTASCII_LENGTH("&gt;");
} else if (sString.match("&quot;", i)) {
sReturn.append('"');
i += RTL_CONSTASCII_LENGTH("&quot;");
} else if (sString.match("&apos;", i)) {
sReturn.append('\'');
sString.Erase( 0, 6 );
}
else {
sReturn.append(sString.GetChar(0));
sString.Erase( 0, 1 );
i += RTL_CONSTASCII_LENGTH("&apos;");
} else {
sReturn.append(sString[i]);
++i;
}
}
rString_in = rtl::OStringToOUString(sReturn.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
rString = rtl::OStringToOUString(sReturn.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -33,6 +33,7 @@
// local includes
#include "export.hxx"
#include "helper.hxx"
#include "xrmmerge.hxx"
#include "tokens.h"
#include <iostream>
@@ -302,7 +303,7 @@ int XRMResParser::Execute( int nToken, char * pToken )
switch ( nToken ) {
case XRM_TEXT_START:{
ByteString sNewLID = GetAttribute( rToken, "id" );
rtl::OString sNewLID = GetAttribute( rToken, "id" );
if ( sNewLID != sLID ) {
sLID = sNewLID;
}
@@ -404,7 +405,7 @@ int XRMResParser::Execute( int nToken, char * pToken )
}
/*****************************************************************************/
ByteString XRMResParser::GetAttribute( const ByteString &rToken, const ByteString &rAttribute )
rtl::OString XRMResParser::GetAttribute( const rtl::OString &rToken, const rtl::OString &rAttribute )
/*****************************************************************************/
{
ByteString sTmp( rToken );
@@ -426,17 +427,17 @@ ByteString XRMResParser::GetAttribute( const ByteString &rToken, const ByteStrin
/*****************************************************************************/
void XRMResParser::Error( const ByteString &rError )
void XRMResParser::Error( const rtl::OString &rError )
/*****************************************************************************/
{
yyerror(( char * ) rError.GetBuffer());
yyerror(( char * ) rError.getStr());
}
/*****************************************************************************/
void XRMResParser::ConvertStringToDBFormat( ByteString &rString )
void XRMResParser::ConvertStringToDBFormat( rtl::OString &rString )
/*****************************************************************************/
{
ByteString sResult;
rtl::OString sResult;
do {
sResult = rString;
rString = comphelper::string::stripStart(rString, _LF);
@@ -444,14 +445,14 @@ void XRMResParser::ConvertStringToDBFormat( ByteString &rString )
rString = comphelper::string::stripEnd(rString, '\t');
} while ( sResult != rString );
rString.SearchAndReplaceAll( "\t", "\\t" );
helper::searchAndReplaceAll(&rString, "\t", "\\t");
}
/*****************************************************************************/
void XRMResParser::ConvertStringToXMLFormat( ByteString &rString )
void XRMResParser::ConvertStringToXMLFormat( rtl::OString &rString )
/*****************************************************************************/
{
rString.SearchAndReplaceAll( "\\t", "\t" );
helper::searchAndReplaceAll(&rString, "\\t", "\t");
}
@@ -461,7 +462,7 @@ void XRMResParser::ConvertStringToXMLFormat( ByteString &rString )
//
/*****************************************************************************/
XRMResOutputParser::XRMResOutputParser ( const ByteString &rOutputFile )
XRMResOutputParser::XRMResOutputParser ( const rtl::OString &rOutputFile )
/*****************************************************************************/
{
aLanguages = Export::GetLanguages();
@@ -496,8 +497,8 @@ XRMResOutputParser::~XRMResOutputParser()
/*****************************************************************************/
XRMResExport::XRMResExport(
const ByteString &rOutputFile, const ByteString &rProject,
const ByteString &rFilePath )
const rtl::OString &rOutputFile, const rtl::OString &rProject,
const rtl::OString &rFilePath )
/*****************************************************************************/
: XRMResOutputParser( rOutputFile ),
pResData( NULL ),
@@ -514,16 +515,12 @@ XRMResExport::~XRMResExport()
delete pResData;
}
void XRMResExport::Output( const ByteString& rOutput )
{
// Dummy to suppress warnings caused by poor class design
(void) rOutput;
}
void XRMResExport::Output( const rtl::OString& ) {}
/*****************************************************************************/
void XRMResExport::WorkOnDesc(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
)
/*****************************************************************************/
{
@@ -543,7 +540,7 @@ void XRMResExport::WorkOnDesc(
file.close();
memblock[size] = '\0';
rText = ByteString(memblock);
rText.SearchAndReplaceAll( "\n", "\\n" );
helper::searchAndReplaceAll(&rText, "\n", "\\n");
delete[] memblock;
}
WorkOnText( rOpenTag, rText );
@@ -552,8 +549,8 @@ void XRMResExport::WorkOnDesc(
//*****************************************************************************/
void XRMResExport::WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
)
/*****************************************************************************/
{
@@ -566,22 +563,18 @@ void XRMResExport::WorkOnText(
pResData->sId = GetLID();
}
ByteString sText(rText);
rtl::OString sText(rText);
ConvertStringToDBFormat(sText);
pResData->sText[sLang] = sText;
}
/*****************************************************************************/
void XRMResExport::EndOfText(
const ByteString &rOpenTag,
const ByteString &rCloseTag
const rtl::OString &,
const rtl::OString &
)
/*****************************************************************************/
{
(void) rOpenTag; // FIXME
(void) rCloseTag; // FIXME
if ( pResData && pOutputStream )
{
ByteString sTimeStamp( Export::GetTimeStamp());
@@ -627,15 +620,15 @@ void XRMResExport::EndOfText(
/*****************************************************************************/
XRMResMerge::XRMResMerge(
const ByteString &rMergeSource, const ByteString &rOutputFile,
ByteString &rFilename)
const rtl::OString &rMergeSource, const rtl::OString &rOutputFile,
const rtl::OString &rFilename)
/*****************************************************************************/
: XRMResOutputParser( rOutputFile ),
pMergeDataFile( NULL ),
sFilename( rFilename ) ,
pResData( NULL )
{
if ( rMergeSource.Len())
if (!rMergeSource.isEmpty())
pMergeDataFile = new MergeDataFile(
rMergeSource, sInputFileName, bErrorLog);
if( Export::sLanguages.equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("ALL")))
@@ -657,8 +650,8 @@ XRMResMerge::~XRMResMerge()
/*****************************************************************************/
void XRMResMerge::WorkOnDesc(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
)
/*****************************************************************************/
{
@@ -721,8 +714,8 @@ void XRMResMerge::WorkOnDesc(
/*****************************************************************************/
void XRMResMerge::WorkOnText(
const ByteString &rOpenTag,
ByteString &rText
const rtl::OString &rOpenTag,
rtl::OString &rText
)
/*****************************************************************************/
{
@@ -753,18 +746,18 @@ void XRMResMerge::WorkOnText(
}
/*****************************************************************************/
void XRMResMerge::Output( const ByteString& rOutput )
void XRMResMerge::Output( const rtl::OString& rOutput )
/*****************************************************************************/
{
//printf("W: %s\n",rOutput.GetBuffer());
if ( pOutputStream && rOutput.Len() > 0 )
pOutputStream->Write( rOutput.GetBuffer(), rOutput.Len());
if ( pOutputStream && !rOutput.isEmpty() )
pOutputStream->Write( rOutput.getStr(), rOutput.getLength());
}
/*****************************************************************************/
void XRMResMerge::EndOfText(
const ByteString &rOpenTag,
const ByteString &rCloseTag
const rtl::OString &rOpenTag,
const rtl::OString &rCloseTag
)
/*****************************************************************************/
{