Hi,
I have submitted a patch for review:
https://gerrit.libreoffice.org/4253
To pull it, you can do:
git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/53/4253/1
String=>OUString big chunk of paring related code
Change-Id: I65d84991291fb2ade03132d424ed833a89bbc430
---
M dbaccess/source/ui/misc/RtfReader.cxx
M editeng/source/editeng/eehtml.cxx
M editeng/source/rtf/svxrtf.cxx
M include/editeng/svxrtf.hxx
M include/svtools/parhtml.hxx
M include/svtools/svparser.hxx
M sc/source/filter/html/htmlpars.cxx
M sfx2/source/bastyp/frmhtml.cxx
M sfx2/source/bastyp/sfxhtml.cxx
M sfx2/source/doc/objmisc.cxx
M svtools/source/svhtml/htmlsupp.cxx
M svtools/source/svhtml/parhtml.cxx
M svtools/source/svrtf/parrtf.cxx
M svtools/source/svrtf/svparser.cxx
M sw/source/filter/html/htmlbas.cxx
M sw/source/filter/html/htmlcss1.cxx
M sw/source/filter/html/htmldraw.cxx
M sw/source/filter/html/htmlfld.cxx
M sw/source/filter/html/htmlform.cxx
M sw/source/filter/html/htmlgrin.cxx
M sw/source/filter/html/htmlnum.cxx
M sw/source/filter/html/htmlplug.cxx
M sw/source/filter/html/htmlsect.cxx
M sw/source/filter/html/htmltab.cxx
M sw/source/filter/html/swhtml.cxx
M sw/source/filter/html/swhtml.hxx
26 files changed, 801 insertions(+), 727 deletions(-)
diff --git a/dbaccess/source/ui/misc/RtfReader.cxx b/dbaccess/source/ui/misc/RtfReader.cxx
index 8e85fbe..6dc16f3 100644
--- a/dbaccess/source/ui/misc/RtfReader.cxx
+++ b/dbaccess/source/ui/misc/RtfReader.cxx
@@ -128,14 +128,15 @@
{
switch(nTmpToken2)
{
- case RTF_RED: aColor.SetRed((sal_uInt8)nTokenValue); break;
- case RTF_BLUE: aColor.SetBlue((sal_uInt8)nTokenValue); break;
- case RTF_GREEN: aColor.SetGreen((sal_uInt8)nTokenValue); break;
- default: break;
+ case RTF_RED: aColor.SetRed((sal_uInt8)nTokenValue); break;
+ case RTF_BLUE: aColor.SetBlue((sal_uInt8)nTokenValue); break;
+ case RTF_GREEN: aColor.SetGreen((sal_uInt8)nTokenValue); break;
+ default: break;
}
nTmpToken2 = GetNextToken();
}
- while(aToken.GetChar(0) != ';' && eState != SVPAR_ERROR && eState !=
SVPAR_ACCEPTED);
+ while(aToken[0] != ';' && eState != SVPAR_ERROR && eState !=
SVPAR_ACCEPTED);
+
m_vecColor.push_back(aColor.GetRGBColor());
nTmpToken2 = GetNextToken();
}
diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx
index 31b0e43..f78287a 100644
--- a/editeng/source/editeng/eehtml.cxx
+++ b/editeng/source/editeng/eehtml.cxx
@@ -174,7 +174,7 @@
}
break;
case HTML_RAWDATA:
- if (IsReadStyle() && aToken.Len())
+ if (IsReadStyle() && !aToken.isEmpty())
{
// Each token represents a single line.
maStyleSource.append(aToken);
@@ -715,17 +715,15 @@
const HTMLOption& aOption = aOptions[i];
switch( aOption.GetToken() )
{
- case HTML_O_ALIGN:
- {
- if ( aOption.GetString().CompareIgnoreCaseToAscii(
OOO_STRING_SVTOOLS_HTML_AL_right ) == COMPARE_EQUAL )
- eAdjust = SVX_ADJUST_RIGHT;
- else if ( aOption.GetString().CompareIgnoreCaseToAscii(
OOO_STRING_SVTOOLS_HTML_AL_middle ) == COMPARE_EQUAL )
- eAdjust = SVX_ADJUST_CENTER;
- else if ( aOption.GetString().CompareIgnoreCaseToAscii(
OOO_STRING_SVTOOLS_HTML_AL_center ) == COMPARE_EQUAL )
- eAdjust = SVX_ADJUST_CENTER;
- else
- eAdjust = SVX_ADJUST_LEFT;
- }
+ case HTML_O_ALIGN:
+ if ( aOption.GetString().startsWithIgnoreAsciiCase(
OOO_STRING_SVTOOLS_HTML_AL_right ))
+ eAdjust = SVX_ADJUST_RIGHT;
+ else if ( aOption.GetString().startsWithIgnoreAsciiCase(
OOO_STRING_SVTOOLS_HTML_AL_middle ))
+ eAdjust = SVX_ADJUST_CENTER;
+ else if ( aOption.GetString().startsWithIgnoreAsciiCase(
OOO_STRING_SVTOOLS_HTML_AL_center ))
+ eAdjust = SVX_ADJUST_CENTER;
+ else
+ eAdjust = SVX_ADJUST_LEFT;
break;
}
}
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 90bcd84..12a5489 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -425,9 +425,9 @@
case RTF_BLUE: nBlue = sal_uInt8(nTokenValue); break;
case RTF_TEXTTOKEN:
- if( 1 == aToken.Len()
- ? aToken.GetChar( 0 ) != ';'
- : STRING_NOTFOUND == aToken.Search( ';' ) )
+ if( 1 == aToken.getLength()
+ ? aToken[ 0 ] != ';'
+ : aToken.indexOf( ';' ) < 0 )
break; // At least the ';' must be found
// else no break !!
@@ -557,7 +557,7 @@
break;
case RTF_TEXTTOKEN:
DelCharAtEnd( aToken, ';' );
- if ( aToken.Len() )
+ if ( !aToken.isEmpty() )
{
if( bIsAltFntNm )
sAltNm = aToken;
@@ -795,14 +795,16 @@
}
}
-String& SvxRTFParser::DelCharAtEnd( String& rStr, const sal_Unicode cDel )
+OUString& SvxRTFParser::DelCharAtEnd( OUString& rStr, const sal_Unicode cDel )
{
- if( rStr.Len() && ' ' == rStr.GetChar( 0 ))
+ if( !rStr.isEmpty() && ' ' == rStr[ 0 ])
rStr = comphelper::string::stripStart(rStr, ' ');
- if( rStr.Len() && ' ' == rStr.GetChar( rStr.Len()-1 ))
+ if( !rStr.isEmpty() && ' ' == rStr[ rStr.getLength()-1 ])
rStr = comphelper::string::stripEnd(rStr, ' ');
- if( rStr.Len() && cDel == rStr.GetChar( rStr.Len()-1 ))
- rStr.Erase( rStr.Len()-1 );
+ if( !rStr.isEmpty() && cDel == rStr[ rStr.getLength()-1 ])
+ {
+ rStr = rStr.copy(0, rStr.getLength()-1 );
+ }
return rStr;
}
diff --git a/include/editeng/svxrtf.hxx b/include/editeng/svxrtf.hxx
index 56a1240..175a750 100644
--- a/include/editeng/svxrtf.hxx
+++ b/include/editeng/svxrtf.hxx
@@ -246,7 +246,7 @@
virtual void InsertPara() = 0;
- String& DelCharAtEnd( String& rStr, const sal_Unicode cDel );
+ OUString& DelCharAtEnd( OUString& rStr, const sal_Unicode cDel );
// is called for each token that is recognized in CallParser
virtual void NextToken( int nToken );
diff --git a/include/svtools/parhtml.hxx b/include/svtools/parhtml.hxx
index 7df1d76..5125160 100644
--- a/include/svtools/parhtml.hxx
+++ b/include/svtools/parhtml.hxx
@@ -87,20 +87,20 @@
class SVT_DLLPUBLIC HTMLOption
{
- String aValue; // der Wert der Option (immer als String)
- String aToken; // der Name der Option als String
+ OUString aValue; // der Wert der Option (immer als String)
+ OUString aToken; // der Name der Option als String
sal_uInt16 nToken; // und das entsprechende Token
public:
- HTMLOption( sal_uInt16 nTyp, const String& rToken, const String& rValue );
+ HTMLOption( sal_uInt16 nTyp, const OUString& rToken, const OUString& rValue );
// der Name der Option ...
sal_uInt16 GetToken() const { return nToken; } // ... als Enum
- const String& GetTokenString() const { return aToken; } // ... als String
+ const OUString& GetTokenString() const { return aToken; } // ... als String
// der Wert der Option ...
- const String& GetString() const { return aValue; } // ... als String
+ const OUString& GetString() const { return aValue; } // ... als String
sal_uInt32 GetNumber() const; // ... als Zahl
sal_Int32 GetSNumber() const; // ... als Zahl
@@ -146,10 +146,10 @@
int mnPendingOffToken; ///< OFF token pending for a <XX.../> ON/OFF ON token
- String aEndToken;
+ OUString aEndToken;
protected:
- String sSaveToken; // das gelesene Tag als String
+ OUString sSaveToken; // das gelesene Tag als String
int ScanText( const sal_Unicode cBreak = 0U );
@@ -208,7 +208,7 @@
// Lesen eines <SCRIPT> aufgerufen werden
void EndScanScript() { bReadScript = false; }
- void ReadRawData( const sal_Char *pEndToken ) { aEndToken.AssignAscii(pEndToken); }
+ void ReadRawData( const sal_Char *pEndToken ) { aEndToken = OUString(pEndToken,
strlen(pEndToken), RTL_TEXTENCODING_ASCII_US); }
// Token ohne \-Sequenzen
void UnescapeToken();
@@ -224,7 +224,7 @@
protected:
- static rtl_TextEncoding GetEncodingByMIME( const String& rMime );
+ static rtl_TextEncoding GetEncodingByMIME( const OUString& rMime );
/// template method: called when ParseMetaOptions adds a user-defined meta
virtual void AddMetaUserDefined( OUString const & i_rMetaName );
@@ -252,15 +252,15 @@
bool bSwitchToUCS2 = false,
rtl_TextEncoding eEnc=RTL_TEXTENCODING_DONTKNOW );
- bool ParseScriptOptions( String& rLangString, const String&, HTMLScriptLanguage& rLang,
- String& rSrc, String& rLibrary, String& rModule );
+ bool ParseScriptOptions( OUString& rLangString, const OUString&, HTMLScriptLanguage& rLang,
+ OUString& rSrc, OUString& rLibrary, OUString& rModule );
// Einen Kommentar um den Inhalt von <SCRIPT> oder <STYLE> entfernen
// Bei 'bFull' wird ggf. die gesammte Zeile hinter einem "<!--"
// entfernt (fuer JavaSript)
- static void RemoveSGMLComment( String &rString, sal_Bool bFull );
+ static void RemoveSGMLComment( OUString &rString, sal_Bool bFull );
- static bool InternalImgToPrivateURL( String& rURL );
+ static bool InternalImgToPrivateURL( OUString& rURL );
static rtl_TextEncoding GetEncodingByHttpHeader( SvKeyValueIterator *pHTTPHeader );
bool SetEncodingByHTTPHeader( SvKeyValueIterator *pHTTPHeader );
};
diff --git a/include/svtools/svparser.hxx b/include/svtools/svparser.hxx
index bd2ee96..ad725f4 100644
--- a/include/svtools/svparser.hxx
+++ b/include/svtools/svparser.hxx
@@ -48,7 +48,7 @@
protected:
SvStream& rInput;
- String aToken; // gescanntes Token
+ OUString aToken; // gescanntes Token
sal_uLong nlLineNr; // akt. Zeilen Nummer
sal_uLong nlLinePos; // akt. Spalten Nummer
@@ -79,7 +79,7 @@
struct TokenStackType
{
- String sToken;
+ OUString sToken;
long nTokenValue;
sal_Bool bTokenHasValue;
int nTokenId;
@@ -207,8 +207,8 @@
{
/** Representation.
*/
- String m_aKey;
- String m_aValue;
+ OUString m_aKey;
+ OUString m_aValue;
public:
/** Construction.
@@ -216,7 +216,7 @@
SvKeyValue (void)
{}
- SvKeyValue (const String &rKey, const String &rValue)
+ SvKeyValue (const OUString &rKey, const OUString &rValue)
: m_aKey (rKey), m_aValue (rValue)
{}
@@ -235,11 +235,11 @@
/** Operation.
*/
- const String& GetKey (void) const { return m_aKey; }
- const String& GetValue (void) const { return m_aValue; }
+ const OUString& GetKey (void) const { return m_aKey; }
+ const OUString& GetValue (void) const { return m_aValue; }
- void SetKey (const String &rKey ) { m_aKey = rKey; }
- void SetValue (const String &rValue) { m_aValue = rValue; }
+ void SetKey (const OUString &rKey ) { m_aKey = rKey; }
+ void SetValue (const OUString &rValue) { m_aValue = rValue; }
};
/*========================================================================
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 584aaef..f605303 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1007,12 +1007,12 @@
{
case HTML_O_COLSPAN:
{
- pActEntry->nColOverlap = ( SCCOL ) rOption.GetString().ToInt32();
+ pActEntry->nColOverlap = ( SCCOL ) rOption.GetString().toInt32();
}
break;
case HTML_O_ROWSPAN:
{
- pActEntry->nRowOverlap = ( SCROW ) rOption.GetString().ToInt32();
+ pActEntry->nRowOverlap = ( SCROW ) rOption.GetString().toInt32();
}
break;
case HTML_O_ALIGN:
@@ -1995,7 +1995,7 @@
switch( itr->GetToken() )
{
case HTML_O_BORDER:
- mbBorderOn = ((itr->GetString().Len() == 0) || (itr->GetNumber() != 0));
+ mbBorderOn = ((itr->GetString().getLength() == 0) || (itr->GetNumber() != 0));
break;
case HTML_O_ID:
maTableName = itr->GetString();
@@ -2221,10 +2221,10 @@
switch (itr->GetToken())
{
case HTML_O_COLSPAN:
- aSpanSize.mnCols = static_cast<SCCOL>( getLimitedValue<sal_Int32>(
itr->GetString().ToInt32(), 1, 256 ) );
+ aSpanSize.mnCols = static_cast<SCCOL>( getLimitedValue<sal_Int32>(
itr->GetString().toInt32(), 1, 256 ) );
break;
case HTML_O_ROWSPAN:
- aSpanSize.mnRows = static_cast<SCROW>( getLimitedValue<sal_Int32>(
itr->GetString().ToInt32(), 1, 256 ) );
+ aSpanSize.mnRows = static_cast<SCROW>( getLimitedValue<sal_Int32>(
itr->GetString().toInt32(), 1, 256 ) );
break;
case HTML_O_SDVAL:
pValStr.reset(new OUString(itr->GetString()));
diff --git a/sfx2/source/bastyp/frmhtml.cxx b/sfx2/source/bastyp/frmhtml.cxx
index a907782..3528b39 100644
--- a/sfx2/source/bastyp/frmhtml.cxx
+++ b/sfx2/source/bastyp/frmhtml.cxx
@@ -113,8 +113,7 @@
pFrame->SetResizable( sal_False );
break;
default:
- if ( aOption.GetTokenString().EqualsIgnoreCaseAscii(
- HTML_O_READONLY ) )
+ if ( aOption.GetTokenString().equalsIgnoreAsciiCase(HTML_O_READONLY ) )
{
String aStr = aOption.GetString();
sal_Bool bReadonly = sal_True;
@@ -122,7 +121,7 @@
bReadonly = sal_False;
pFrame->SetReadOnly( bReadonly );
}
- else if ( aOption.GetTokenString().EqualsIgnoreCaseAscii(
+ else if ( aOption.GetTokenString().equalsIgnoreAsciiCase(
HTML_O_EDIT ) )
{
String aStr = aOption.GetString();
diff --git a/sfx2/source/bastyp/sfxhtml.cxx b/sfx2/source/bastyp/sfxhtml.cxx
index bbbd5de..926ec07 100644
--- a/sfx2/source/bastyp/sfxhtml.cxx
+++ b/sfx2/source/bastyp/sfxhtml.cxx
@@ -274,10 +274,10 @@
for( sal_Bool bCont = pHTTPHeader->GetFirst( aKV ); bCont;
bCont = pHTTPHeader->GetNext( aKV ) )
{
- if( aKV.GetKey().EqualsIgnoreCaseAscii(
+ if( aKV.GetKey().equalsIgnoreAsciiCase(
OOO_STRING_SVTOOLS_HTML_META_content_script_type ) )
{
- if( aKV.GetValue().Len() )
+ if( !aKV.GetValue().isEmpty() )
{
String aTmp( aKV.GetValue() );
if( aTmp.EqualsIgnoreCaseAscii( sHTML_MIME_text, 0, 5 ) )
diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx
index 49fb3b2..528a6bf 100644
--- a/sfx2/source/doc/objmisc.cxx
+++ b/sfx2/source/doc/objmisc.cxx
@@ -1627,7 +1627,7 @@
void SfxHeaderAttributes_Impl::SetAttribute( const SvKeyValue& rKV )
{
String aValue = rKV.GetValue();
- if( rKV.GetKey().CompareIgnoreCaseToAscii( "refresh" ) == COMPARE_EQUAL &&
rKV.GetValue().Len() )
+ if( rKV.GetKey().startsWithIgnoreAsciiCase( "refresh" ) && !rKV.GetValue().isEmpty() )
{
sal_uInt32 nTime = aValue.GetToken( 0, ';' ).ToInt32() ;
String aURL = comphelper::string::strip(aValue.GetToken( 1, ';' ), ' ');
@@ -1649,7 +1649,7 @@
// ignore
}
}
- else if( rKV.GetKey().CompareIgnoreCaseToAscii( "expires" ) == COMPARE_EQUAL )
+ else if( rKV.GetKey().startsWithIgnoreAsciiCase( "expires" ))
{
DateTime aDateTime( DateTime::EMPTY );
if( INetRFC822Message::ParseDateField( rKV.GetValue(), aDateTime ) )
diff --git a/svtools/source/svhtml/htmlsupp.cxx b/svtools/source/svhtml/htmlsupp.cxx
index 3d90fec..688c975 100644
--- a/svtools/source/svhtml/htmlsupp.cxx
+++ b/svtools/source/svhtml/htmlsupp.cxx
@@ -36,19 +36,19 @@
{ 0, 0 }
};
-bool HTMLParser::ParseScriptOptions( String& rLangString, const String& rBaseURL,
+bool HTMLParser::ParseScriptOptions( OUString& rLangString, const OUString& rBaseURL,
HTMLScriptLanguage& rLang,
- String& rSrc,
- String& rLibrary,
- String& rModule )
+ OUString& rSrc,
+ OUString& rLibrary,
+ OUString& rModule )
{
const HTMLOptions& aScriptOptions = GetOptions();
- rLangString.Erase();
+ rLangString = "";
rLang = HTML_SL_JAVASCRIPT;
- rSrc.Erase();
- rLibrary.Erase();
- rModule.Erase();
+ rSrc = "";
+ rLibrary = "";
+ rModule = "";
for( size_t i = aScriptOptions.size(); i; )
{
@@ -82,71 +82,80 @@
return true;
}
-void HTMLParser::RemoveSGMLComment( String &rString, sal_Bool bFull )
+void HTMLParser::RemoveSGMLComment( OUString &rString, sal_Bool bFull )
{
sal_Unicode c = 0;
- while( rString.Len() &&
- ( ' '==(c=rString.GetChar(0)) || '\t'==c || '\r'==c || '\n'==c ) )
- rString.Erase( 0, 1 );
-
- while( rString.Len() &&
- ( ' '==(c=rString.GetChar( rString.Len()-1))
+ while( !rString.isEmpty() &&
+ ( ' '==(c=rString[0]) || '\t'==c || '\r'==c || '\n'==c ) )
+ {
+ rString = rString.copy(1);
+ }
+ while( !rString.isEmpty() &&
+ ( ' '==(c=rString[ rString.getLength()-1])
|| '\t'==c || '\r'==c || '\n'==c ) )
- rString.Erase( rString.Len()-1 );
-
+ {
+ rString = rString.copy(0, rString.getLength()-1 );
+ }
// remove SGML comments
- if( rString.Len() >= 4 &&
- rString.CompareToAscii( "<!--", 4 ) == COMPARE_EQUAL )
+ if( rString.getLength() >= 4 &&
+ rString.startsWith( "<!--"))
{
- xub_StrLen nPos = 3;
+ sal_Int32 nPos = 3;
if( bFull )
{
// the whole line
nPos = 4;
- while( nPos < rString.Len() &&
- ( ( c = rString.GetChar( nPos )) != '\r' && c != '\n' ) )
+ while( nPos < rString.getLength() &&
+ ( ( c = rString[ nPos ]) != '\r' && c != '\n' ) )
+ {
++nPos;
- if( c == '\r' && nPos+1 < rString.Len() &&
- '\n' == rString.GetChar( nPos+1 ))
+ }
+ if( c == '\r' && nPos+1 < rString.getLength() &&
+ '\n' == rString[ nPos+1 ])
+ {
++nPos;
+ }
else if( c != '\n' )
+ {
nPos = 3;
+ }
}
- rString.Erase( 0, ++nPos );
+ rString = rString.copy(++nPos);
}
- if( rString.Len() >=3 &&
- rString.Copy(rString.Len()-3).CompareToAscii("-->")
- == COMPARE_EQUAL )
+ if( rString.getLength() >=3 &&
+ rString.copy(rString.getLength()-3).startsWith("-->"))
{
- rString.Erase( rString.Len()-3 );
+ rString = rString.copy(0,rString.getLength()-3 );
if( bFull )
{
// "//" or "'", maybe preceding CR/LF
rString = comphelper::string::stripEnd(rString, ' ');
- xub_StrLen nDel = 0, nLen = rString.Len();
+ sal_Int32 nDel = 0, nLen = rString.getLength();
if( nLen >= 2 &&
- rString.Copy(nLen-2).CompareToAscii("//") == COMPARE_EQUAL )
+ rString[nLen-2] == '/' && rString[nLen - 1] == '/')
{
nDel = 2;
}
- else if( nLen && '\'' == rString.GetChar(nLen-1) )
+ else if( nLen && '\'' == rString[nLen-1] )
{
nDel = 1;
}
if( nDel && nLen >= nDel+1 )
{
- c = rString.GetChar( nLen-(nDel+1) );
+ c = rString[ nLen-(nDel+1) ];
if( '\r'==c || '\n'==c )
{
nDel++;
if( '\n'==c && nLen >= nDel+1 &&
- '\r'==rString.GetChar( nLen-(nDel+1) ) )
+ '\r'==rString[ nLen-(nDel+1) ] )
+ {
nDel++;
+ }
}
}
- rString.Erase( nLen-nDel );
+ rString = rString.copy(0, nLen-nDel );
}
}
}
diff --git a/svtools/source/svhtml/parhtml.cxx b/svtools/source/svhtml/parhtml.cxx
index a95ec79..4d3fbf7 100644
--- a/svtools/source/svhtml/parhtml.cxx
+++ b/svtools/source/svhtml/parhtml.cxx
@@ -98,11 +98,16 @@
sal_uInt16 nValue = nDflt;
while( pOptEnums->pName )
- if( aValue.EqualsIgnoreCaseAscii( pOptEnums->pName ) )
+ {
+ if( aValue.equalsIgnoreAsciiCaseAscii( pOptEnums->pName ) )
+ {
break;
+ }
else
+ {
pOptEnums++;
-
+ }
+ }
if( pOptEnums->pName )
nValue = pOptEnums->nValue;
@@ -113,21 +118,20 @@
{
while( pOptEnums->pName )
{
- if( aValue.EqualsIgnoreCaseAscii( pOptEnums->pName ) )
+ if( aValue.equalsIgnoreAsciiCaseAscii( pOptEnums->pName ) )
break;
else
pOptEnums++;
}
- const sal_Char *pName = pOptEnums->pName;
- if( pName )
+ if( pOptEnums->pName )
rEnum = pOptEnums->nValue;
- return (pName != 0);
+ return (pOptEnums->pName != 0);
}
-HTMLOption::HTMLOption( sal_uInt16 nTok, const String& rToken,
- const String& rValue )
+HTMLOption::HTMLOption( sal_uInt16 nTok, const OUString& rToken,
+ const OUString& rValue )
: aValue(rValue)
, aToken(rToken)
, nToken( nTok )
@@ -168,9 +172,9 @@
// numerals in the string.
bool bInNum = false;
sal_uLong nNum = 0;
- for( xub_StrLen i=0; i<aValue.Len(); i++ )
+ for( sal_Int32 i=0; i<aValue.getLength(); i++ )
{
- register sal_Unicode c = aValue.GetChar( i );
+ register sal_Unicode c = aValue[ i ];
if( c>='0' && c<='9' )
{
nNum *= 10;
@@ -194,29 +198,29 @@
// Check whether numbers are separated by ',' and
// insert 0 if necessary
xub_StrLen nPos = 0;
- while( nPos < aValue.Len() )
+ while( nPos < aValue.getLength() )
{
register sal_Unicode c;
- while( nPos < aValue.Len() &&
- ((c=aValue.GetChar(nPos)) == ' ' || c == '\t' ||
+ while( nPos < aValue.getLength() &&
+ ((c=aValue[nPos]) == ' ' || c == '\t' ||
c == '\n' || c== '\r' ) )
nPos++;
- if( nPos==aValue.Len() )
+ if( nPos==aValue.getLength() )
rNumbers.push_back(0);
else
{
- xub_StrLen nEnd = aValue.Search( (sal_Unicode)',', nPos );
- if( STRING_NOTFOUND==nEnd )
+ xub_StrLen nEnd = aValue.indexOf( (sal_Unicode)',', nPos );
+ if( nEnd < 0 )
{
- sal_Int32 nTmp = aValue.Copy(nPos).ToInt32();
+ sal_Int32 nTmp = aValue.copy(nPos).toInt32();
rNumbers.push_back( nTmp >= 0 ? (sal_uInt32)nTmp : 0 );
- nPos = aValue.Len();
+ nPos = aValue.getLength();
}
else
{
sal_Int32 nTmp =
- aValue.Copy(nPos,nEnd-nPos).ToInt32();
+ aValue.copy(nPos,nEnd-nPos).toInt32();
rNumbers.push_back( nTmp >= 0 ? (sal_uInt32)nTmp : 0 );
nPos = nEnd+1;
}
@@ -230,27 +234,27 @@
DBG_ASSERT( (nToken>=HTML_OPTION_COLOR_START && nToken<HTML_OPTION_COLOR_END) ||
nToken==HTML_O_SIZE,
"GetColor: Option is not a color." );
- String aTmp( aValue );
- aTmp.ToUpperAscii();
+ OUString aTmp( aValue.toAsciiUpperCase());
+
sal_uInt32 nColor = SAL_MAX_UINT32;
- if( '#'!=aTmp.GetChar( 0 ) )
+ if( '#'!=aTmp[ 0 ] )
nColor = GetHTMLColor( aTmp );
if( SAL_MAX_UINT32 == nColor )
{
nColor = 0;
- xub_StrLen nPos = 0;
+ sal_Int32 nPos = 0;
for( sal_uInt32 i=0; i<6; i++ )
{
// Whatever Netscape does to get color values,
// at maximum three characters < '0' are ignored.
- register sal_Unicode c = nPos<aTmp.Len() ? aTmp.GetChar( nPos++ )
+ register sal_Unicode c = nPos<aTmp.getLength() ? aTmp[ nPos++ ]
: '0';
if( c < '0' )
{
- c = nPos<aTmp.Len() ? aTmp.GetChar(nPos++) : '0';
+ c = nPos<aTmp.getLength() ? aTmp[nPos++] : '0';
if( c < '0' )
- c = nPos<aTmp.Len() ? aTmp.GetChar(nPos++) : '0';
+ c = nPos<aTmp.getLength() ? aTmp[nPos++] : '0';
}
nColor *= 16;
if( c >= '0' && c <= '9' )
@@ -579,11 +583,10 @@
else
{
// If not scanning a tag return token
- aToken +=
- String( sTmpBuffer.makeStringAndClear() );
+ aToken += sTmpBuffer.makeStringAndClear();
if( cChar )
{
- if( aToken.Len() )
+ if( !aToken.isEmpty() )
{
// restart with character
nNextCh = '&';
@@ -602,21 +605,22 @@
// Hack: _GetNextChar shall not read the
// next character
if( ';' != nNextCh )
- aToken += ' ';
+ aToken += " ";
if( 1U == cChar )
return HTML_NONBREAKSPACE;
if( 2U == cChar )
return HTML_SOFTHYPH;
}
- aToken += (sal_Unicode)'&';
- aToken +=
- String(sEntityBuffer.makeStringAndClear());
+ aToken += "&";
+ aToken += sEntityBuffer.makeStringAndClear();
break;
}
}
}
else
+ {
nNextCh = 0U;
+ }
}
// &{...};-JavaScript-Macros are not supported any longer.
else if( IsParserWorking() )
@@ -637,7 +641,7 @@
// options.
sTmpBuffer.append( (sal_Unicode)'\\' );
if( MAX_LEN == sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
}
if( IsParserWorking() )
{
@@ -648,7 +652,7 @@
{
// Restart with '&', the remainder is returned as
// text token.
- if( aToken.Len() || sTmpBuffer.getLength() )
+ if( !aToken.isEmpty() || sTmpBuffer.getLength() )
{
// _GetNextChar() returns the previous text and
// during the next execution a new character is read.
@@ -675,7 +679,7 @@
// Innerhalb von Tags kennzeichnen
sTmpBuffer.append( (sal_Unicode)'\\' );
if( MAX_LEN == sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
}
sTmpBuffer.append( (sal_Unicode)'\\' );
break;
@@ -766,10 +770,10 @@
if( sal_Unicode(EOF) == (nNextCh = GetNextChar()) &&
rInput.IsEof() )
{
- if( aToken.Len() || sTmpBuffer.getLength() > 1L )
+ if( !aToken.isEmpty() || sTmpBuffer.getLength() > 1L )
{
// Have seen s.th. aside from blanks?
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
return HTML_TEXTTOKEN;
}
else
@@ -787,17 +791,20 @@
default:
bEqSignFound = false;
if( (nNextCh==cBreak && !cQuote) ||
- (sal_uLong(aToken.Len()) + MAX_LEN) > sal_uLong(STRING_MAXLEN & ~1 ))
+ (sal_uLong(aToken.getLength()) + MAX_LEN) > sal_uLong(STRING_MAXLEN & ~1 ))
+ {
bContinue = false;
+ }
else
{
- do {
+ do
+ {
// All remaining characters make their way into the text.
sTmpBuffer.append( nNextCh );
if( MAX_LEN == sTmpBuffer.getLength() )
{
- aToken += String(sTmpBuffer.makeStringAndClear());
- if( (sal_uLong(aToken.Len()) + MAX_LEN) >
+ aToken += sTmpBuffer.makeStringAndClear();
+ if( (sal_uLong(aToken.getLength()) + MAX_LEN) >
sal_uLong(STRING_MAXLEN & ~1 ) )
{
nNextCh = GetNextChar();
@@ -805,27 +812,28 @@
}
}
if( ( sal_Unicode(EOF) == (nNextCh = GetNextChar()) &&
- rInput.IsEof() ) ||
- !IsParserWorking() )
+ rInput.IsEof() ) || !IsParserWorking() )
{
if( sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
return HTML_TEXTTOKEN;
}
- } while( HTML_ISALPHA( nNextCh ) || HTML_ISDIGIT( nNextCh ) );
+ }
+ while( HTML_ISALPHA( nNextCh ) || HTML_ISDIGIT( nNextCh ) );
+
bNextCh = false;
}
}
if( MAX_LEN == sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
if( bContinue && bNextCh )
nNextCh = GetNextChar();
}
if( sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
return HTML_TEXTTOKEN;
}
@@ -840,7 +848,7 @@
// thus we don't have to search it again.
bReadScript = false;
bReadStyle = false;
- aEndToken.Erase();
+ aEndToken = "";
bEndTokenFound = false;
return 0;
@@ -860,7 +868,7 @@
// Maybe we've reached the end.
// Save what we have read previously...
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
// and remember position in stream.
sal_uLong nStreamPos = rInput.Tell();
@@ -891,7 +899,7 @@
String aTok( sTmpBuffer.toString() );
aTok.ToUpperAscii();
bool bDone = false;
- if( bReadScript || aEndToken.Len() )
+ if( bReadScript || !aEndToken.isEmpty() )
{
if( !bReadComment )
{
@@ -938,13 +946,13 @@
bContinue = false;
// nToken==0 means, _GetNextToken continues to read
- if( !aToken.Len() && (bReadStyle || bReadScript) )
+ if( aToken.isEmpty() && (bReadStyle || bReadScript) )
{
// Immediately close environment (or context?)
// and parse the end token
bReadScript = false;
bReadStyle = false;
- aEndToken.Erase();
+ aEndToken = "";
nToken = 0;
}
else
@@ -967,9 +975,9 @@
else
{
// remember "</" , everything else we find in the buffer
- aToken += (sal_Unicode)'<';
+ aToken += "<";
if( bOffState )
- aToken += (sal_Unicode)'/';
+ aToken += "/";
bNextCh = false;
}
@@ -986,7 +994,7 @@
bTwoMinus = true;
if( MAX_LEN == sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
sTmpBuffer.append( nNextCh );
nNextCh = GetNextChar();
}
@@ -1016,7 +1024,7 @@
if( rInput.IsEof() )
{
bContinue = false;
- if( aToken.Len() || sTmpBuffer.getLength() )
+ if( !aToken.isEmpty() || sTmpBuffer.getLength() )
{
bEndTokenFound = true;
}
@@ -1024,7 +1032,7 @@
{
bReadScript = false;
bReadStyle = false;
- aEndToken.Erase();
+ aEndToken = "";
nToken = 0;
}
break;
@@ -1038,7 +1046,7 @@
if( (!bContinue && sTmpBuffer.getLength() > 0L) ||
MAX_LEN == sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
if( bContinue && bNextCh )
nNextCh = GetNextChar();
@@ -1056,14 +1064,14 @@
int HTMLParser::_GetNextToken()
{
int nRet = 0;
- sSaveToken.Erase();
+ sSaveToken = "";
if (mnPendingOffToken)
{
// HTML_<TOKEN>_OFF generated for HTML_<TOKEN>_ON
nRet = mnPendingOffToken;
mnPendingOffToken = 0;
- aToken.Erase();
+ aToken = "";
return nRet;
}
@@ -1085,7 +1093,7 @@
bReadNextChar = false;
}
- if( bReadScript || bReadStyle || aEndToken.Len() )
+ if( bReadScript || bReadStyle || !aEndToken.isEmpty() )
{
nRet = _GetNextRawToken();
if( nRet || !IsParserWorking() )
@@ -1114,13 +1122,13 @@
do {
sTmpBuffer.append( nNextCh );
if( MAX_LEN == sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
nNextCh = GetNextChar();
} while( '>' != nNextCh && '/' != nNextCh && !HTML_ISSPACE( nNextCh ) &&
IsParserWorking() && !rInput.IsEof() );
if( sTmpBuffer.getLength() )
- aToken += String(sTmpBuffer.makeStringAndClear());
+ aToken += sTmpBuffer.makeStringAndClear();
// Skip blanks
while( HTML_ISSPACE( nNextCh ) && IsParserWorking() )
@@ -1135,7 +1143,7 @@
// Search token in table:
sSaveToken = aToken;
- aToken.ToUpperAscii();
+ aToken = aToken.toAsciiUpperCase();
if( 0 == (nRet = GetHTMLToken( aToken )) )
// Unknown control
nRet = HTML_UNKNOWNCONTROL_ON;
@@ -1162,11 +1170,11 @@
// and append a blank.
aToken = sSaveToken;
if( '>'!=nNextCh )
- aToken += (sal_Unicode)' ';
+ aToken += " ";
sal_uLong nCStreamPos = 0;
sal_uLong nCLineNr = 0;
sal_uLong nCLinePos = 0;
- xub_StrLen nCStrLen = 0;
+ sal_Int32 nCStrLen = 0;
bool bDone = false;
// Read until closing -->. If not found restart at first >
@@ -1177,18 +1185,17 @@
if( !nCStreamPos )
{
nCStreamPos = rInput.Tell();
- nCStrLen = aToken.Len();
+ nCStrLen = aToken.getLength();
nCLineNr = GetLineNr();
nCLinePos = GetLinePos();
}
- bDone = aToken.Len() >= 2 &&
- aToken.Copy(aToken.Len()-2,2).
- EqualsAscii( "--" );
+ bDone = (aToken.getLength() >= 2) &&
+ (aToken.copy(aToken.getLength() - 2,2) == "--");
if( !bDone )
- aToken += nNextCh;
+ aToken += OUString(nNextCh);
}
else
- aToken += nNextCh;
+ aToken += OUString(nNextCh);
if( !bDone )
nNextCh = GetNextChar();
}
@@ -1198,14 +1205,14 @@
SetLineNr( nCLineNr );
SetLinePos( nCLinePos );
ClearTxtConvContext();
- aToken.Erase( nCStrLen );
+ aToken = aToken.copy(0, nCStrLen);
nNextCh = '>';
}
}
else
{
// TokenString not needed anymore
- aToken.Erase();
+ aToken = "";
}
// Read until closing '>'
@@ -1217,11 +1224,11 @@
// generate pending HTML_<TOKEN>_OFF for HTML_<TOKEN>_ON
// Do not convert this to a single HTML_<TOKEN>_OFF
// which lead to fdo#56772.
- if ((HTML_TOKEN_ONOFF & nRet) && (aToken.Len() >= 1) &&
- ('/' == aToken.GetChar(aToken.Len()-1)))
+ if ((HTML_TOKEN_ONOFF & nRet) && (aToken.getLength() >= 1) &&
+ ('/' == aToken[aToken.getLength()-1]))
{
mnPendingOffToken = nRet + 1; // HTML_<TOKEN>_ON ->
HTML_<TOKEN>_OFF
- aToken.Erase( aToken.Len()-1, 1); // remove trailing '/'
+ aToken = aToken.copy(0, aToken.getLength()-1); // remove trailing '/'
}
if( sal_Unicode(EOF) == nNextCh && rInput.IsEof() )
{
@@ -1232,7 +1239,7 @@
SetLinePos( nLinePos );
ClearTxtConvContext();
- aToken = '<';
+ aToken = "<";
nRet = HTML_TEXTTOKEN;
nNextCh = GetNextChar();
bNextCh = false;
@@ -1257,15 +1264,17 @@
SetLinePos( nLinePos );
ClearTxtConvContext();
- aToken = '<';
+ aToken = "<";
nRet = HTML_TEXTTOKEN;
nNextCh = GetNextChar();
bNextCh = false;
break;
}
if( SVPAR_PENDING == eState )
+ {
bReadNextChar = bReadNextCharSave;
- aToken.Erase();
+ }
+ aToken = "";
}
else if( '%' == nNextCh )
{
@@ -1278,11 +1287,11 @@
// Read until closing %>. If not found restart at first >.
while( !bDone && !rInput.IsEof() && IsParserWorking() )
{
- bDone = '>'==nNextCh && aToken.Len() >= 1 &&
- '%' == aToken.GetChar( aToken.Len()-1 );
+ bDone = '>'==nNextCh && aToken.getLength() >= 1 &&
+ '%' == aToken[ aToken.getLength()-1] ;
if( !bDone )
{
- aToken += nNextCh;
+ aToken += OUString(nNextCh);
nNextCh = GetNextChar();
}
}
@@ -1292,19 +1301,19 @@
SetLineNr( nCLineNr );
SetLinePos( nCLinePos );
ClearTxtConvContext();
- aToken.AssignAscii( "<%", 2 );
+ aToken = "<%";
nRet = HTML_TEXTTOKEN;
break;
}
if( IsParserWorking() )
{
sSaveToken = aToken;
- aToken.Erase();
+ aToken = "";
}
}
else
{
- aToken = '<';
+ aToken = "<";
nRet = HTML_TEXTTOKEN;
bNextCh = false;
break;
@@ -1395,7 +1404,7 @@
scan_text:
// "normal" text to come
nRet = ScanText();
- bNextCh = 0 == aToken.Len();
+ bNextCh = 0 == aToken.getLength();
// the text should be processed
if( !bNextCh && eState == SVPAR_PENDING )
@@ -1427,16 +1436,16 @@
void HTMLParser::UnescapeToken()
{
- xub_StrLen nPos=0;
+ sal_Int32 nPos=0;
bool bEscape = false;
- while( nPos < aToken.Len() )
+ while( nPos < aToken.getLength() )
{
bool bOldEscape = bEscape;
bEscape = false;
- if( '\\'==aToken.GetChar(nPos) && !bOldEscape )
+ if( '\\'==aToken[nPos] && !bOldEscape )
{
- aToken.Erase( nPos, 1 );
+ aToken = aToken.copy(0, nPos) + aToken.copy(nPos + 1);
bEscape = true;
}
else
@@ -1448,34 +1457,35 @@
const HTMLOptions& HTMLParser::GetOptions( sal_uInt16 *pNoConvertToken ) const
{
+ OUString sToken(aToken);
+
// If the options for the current token have already been returned,
// return them once again.
if (!maOptions.empty())
return maOptions;
- xub_StrLen nPos = 0;
- while( nPos < aToken.Len() )
+ sal_Int32 nPos = 0;
+ while( nPos < sToken.getLength() )
{
// A letter? Option beginning here.
- if( HTML_ISALPHA( aToken.GetChar(nPos) ) )
+ if( HTML_ISALPHA( sToken[nPos] ) )
{
int nToken;
- String aValue;
- xub_StrLen nStt = nPos;
+ OUString aValue;
+ sal_Int32 nStt = nPos;
sal_Unicode cChar = 0;
// Actually only certain characters allowed.
// Netscape only looks for "=" and white space (c.f.
// Mozilla: PA_FetchRequestedNameValues in lipparse/pa_mdl.c)
- while( nPos < aToken.Len() && '=' != (cChar=aToken.GetChar(nPos)) &&
+ while( nPos < sToken.getLength() && '=' != (cChar=sToken[nPos]) &&
HTML_ISPRINTABLE(cChar) && !HTML_ISSPACE(cChar) )
nPos++;
- String sName( aToken.Copy( nStt, nPos-nStt ) );
+ OUString sName( sToken.copy( nStt, nPos-nStt ) );
// PlugIns require original token name. Convert to upper case only for searching.
- String sNameUpperCase( sName );
- sNameUpperCase.ToUpperAscii();
+ OUString sNameUpperCase( sName.toAsciiUpperCase() );
nToken = GetHTMLOption( sNameUpperCase ); // Name is ready
DBG_ASSERTWARNING( nToken!=HTML_O_UNKNOWN,
@@ -1484,24 +1494,25 @@
nToken >= HTML_OPTION_SCRIPT_END) &&
(!pNoConvertToken || nToken != *pNoConvertToken);
- while( nPos < aToken.Len() &&
- ( !HTML_ISPRINTABLE( (cChar=aToken.GetChar(nPos)) ) ||
+ while( nPos < sToken.getLength() &&
+ ( !HTML_ISPRINTABLE( (cChar=sToken[nPos]) ) ||
HTML_ISSPACE(cChar) ) )
nPos++;
// Option with value?
- if( nPos!=aToken.Len() && '='==cChar )
+ if( nPos!=sToken.getLength() && '='==cChar )
{
nPos++;
- while( nPos < aToken.Len() &&
- ( !HTML_ISPRINTABLE( (cChar=aToken.GetChar(nPos)) ) ||
+ while( nPos < sToken.getLength() &&
+ ( !HTML_ISPRINTABLE( (cChar=sToken[nPos]) ) ||
' '==cChar || '\t'==cChar || '\r'==cChar || '\n'==cChar ) )
- nPos++;
-
- if( nPos != aToken.Len() )
{
- xub_StrLen nLen = 0;
+ nPos++;
+ }
+ if( nPos != sToken.getLength() )
+ {
+ sal_Int32 nLen = 0;
nStt = nPos;
if( ('"'==cChar) || ('\'')==cChar )
{
@@ -1509,17 +1520,24 @@
nPos++; nStt++;
bool bDone = false;
bool bEscape = false;
- while( nPos < aToken.Len() && !bDone )
+ while( nPos < sToken.getLength() && !bDone )
{
bool bOldEscape = bEscape;
bEscape = false;
- cChar = aToken.GetChar(nPos);
+ cChar = sToken[nPos];
switch( cChar )
{
case '\r':
case '\n':
if( bStripCRLF )
- ((String &)aToken).Erase( nPos, 1 );
+ {
+ OUString aTemp(sToken.copy(0, nPos));
+ if(sToken.getLength() > nPos)
+ {
+ aTemp += sToken.copy(nPos + 1);
+ }
+ sToken = aTemp;
+ }
else
nPos++, nLen++;
break;
@@ -1530,7 +1548,12 @@
}
else
{
- ((String &)aToken).Erase( nPos, 1 );
+ OUString aTemp = sToken.copy(0, nPos);
+ if(sToken.getLength() > nPos)
+ {
+ aTemp = sToken.copy(nPos + 1);
+ }
+ sToken = aTemp;
bEscape = true;
}
break;
@@ -1545,7 +1568,7 @@
break;
}
}
- if( nPos!=aToken.Len() )
+ if( nPos!=sToken.getLength() )
nPos++;
}
else
@@ -1553,11 +1576,11 @@
// More liberal than the standard: allow all printable characters
bool bEscape = false;
bool bDone = false;
- while( nPos < aToken.Len() && !bDone )
+ while( nPos < sToken.getLength() && !bDone )
{
bool bOldEscape = bEscape;
bEscape = false;
- sal_Unicode c = aToken.GetChar(nPos);
+ sal_Unicode c = sToken[nPos];
switch( c )
{
case ' ':
@@ -1579,7 +1602,12 @@
}
else
{
- ((String &)aToken).Erase( nPos, 1 );
+ OUString aTemp = sToken.copy(0, nPos);
+ if(sToken.getLength() > nPos)
+ {
+ aTemp = sToken.copy(nPos + 1);
+ }
+ sToken = aTemp;
bEscape = true;
}
break;
@@ -1595,7 +1623,9 @@
}
if( nLen )
- aValue = aToken.Copy( nStt, nLen );
+ {
+ aValue = sToken.copy( nStt, nLen );
+ }
}
}
@@ -1637,8 +1667,8 @@
case HTML_TABCHAR:
{
sal_Int32 nSpaces = (8 - (nPre_LinePos % 8));
- DBG_ASSERT( !aToken.Len(), "Why is the token not empty?" );
- if (aToken.Len() < nSpaces)
+ DBG_ASSERT( aToken.isEmpty(), "Why is the token not empty?" );
+ if (aToken.getLength() < nSpaces)
{
using comphelper::string::padToLength;
OUStringBuffer aBuf(aToken);
@@ -1650,7 +1680,7 @@
break;
// Keep those
case HTML_TEXTTOKEN:
- nPre_LinePos += aToken.Len();
+ nPre_LinePos += aToken.getLength();
break;
case HTML_SELECT_ON:
@@ -1817,20 +1847,23 @@
{
if( (HTML_TOKEN_ONOFF & nToken) && (1 & nToken) )
{
- sSaveToken.Insert( '<', 0 );
- sSaveToken.Insert( '/', 1 );
+ sSaveToken = "</" + sSaveToken;
}
else
- sSaveToken.Insert( '<', 0 );
- if( aToken.Len() )
+ {
+ sSaveToken = "<" + sSaveToken;
+ }
+ if( aToken.getLength() )
{
UnescapeToken();
- sSaveToken += (sal_Unicode)' ';
- aToken.Insert( sSaveToken, 0 );
+ sSaveToken += " ";
+ aToken = sSaveToken + aToken;
}
else
+ {
aToken = sSaveToken;
- aToken += (sal_Unicode)'>';
+ }
+ aToken += ">";
nToken = HTML_TEXTTOKEN;
}
break;
@@ -1978,69 +2011,69 @@
return false;
}
-bool HTMLParser::InternalImgToPrivateURL( String& rURL )
+bool HTMLParser::InternalImgToPrivateURL( OUString& rURL )
{
- if( rURL.Len() < 19 || 'i' != rURL.GetChar(0) ||
- rURL.CompareToAscii( OOO_STRING_SVTOOLS_HTML_internal_gopher, 9 ) != COMPARE_EQUAL )
+ if( rURL.getLength() < 19 || 'i' != rURL[0] ||
+ !rURL.startsWith( OOO_STRING_SVTOOLS_HTML_internal_gopher))
+ {
return false;
+ }
bool bFound = false;
- if( rURL.CompareToAscii( OOO_STRING_SVTOOLS_HTML_internal_gopher,16) == COMPARE_EQUAL )
+ if( rURL.startsWith( OOO_STRING_SVTOOLS_HTML_internal_gopher))
{
- String aName( rURL.Copy(16) );
- switch( aName.GetChar(0) )
+ OUString aName( rURL.copy(16) );
+ switch( aName[0] )
{
case 'b':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_binary );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_binary;
break;
case 'i':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_image ) ||
- aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_index );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_image ||
+ aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_index;
break;
case 'm':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_menu ) ||
- aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_movie );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_menu ||
+ aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_movie;
break;
case 's':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_sound );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_sound;
break;
case 't':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_telnet ) ||
- aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_text );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_telnet ||
+ aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_text;
break;
case 'u':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_GOPHER_unknown );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_GOPHER_unknown;
break;
}
}
- else if( rURL.CompareToAscii( OOO_STRING_SVTOOLS_HTML_internal_icon,14) == COMPARE_EQUAL )
+ else if( rURL.startsWith( OOO_STRING_SVTOOLS_HTML_internal_icon))
{
- String aName( rURL.Copy(14) );
- switch( aName.GetChar(0) )
+ OUString aName( rURL.copy(14) );
+ switch( aName[0] )
{
case 'b':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_ICON_baddata );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_ICON_baddata;
break;
case 'd':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_ICON_delayed );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_ICON_delayed;
break;
case 'e':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_ICON_embed );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_ICON_embed;
break;
case 'i':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_ICON_insecure );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_ICON_insecure;
break;
case 'n':
- bFound = aName.EqualsAscii( OOO_STRING_SVTOOLS_HTML_INT_ICON_notfound );
+ bFound = aName == OOO_STRING_SVTOOLS_HTML_INT_ICON_notfound;
break;
}
}
if( bFound )
{
- String sTmp ( rURL );
- rURL.AssignAscii( OOO_STRING_SVTOOLS_HTML_private_image );
- rURL.Append( sTmp );
+ rURL = OUString( OOO_STRING_SVTOOLS_HTML_private_image ) + rURL;
}
return bFound;
@@ -2259,7 +2292,7 @@
return bRet;
}
-rtl_TextEncoding HTMLParser::GetEncodingByMIME( const String& rMime )
+rtl_TextEncoding HTMLParser::GetEncodingByMIME( const OUString& rMime )
{
OUString sType;
OUString sSubType;
@@ -2285,9 +2318,9 @@
for( bool bCont = pHTTPHeader->GetFirst( aKV ); bCont;
bCont = pHTTPHeader->GetNext( aKV ) )
{
- if( aKV.GetKey().EqualsIgnoreCaseAscii( OOO_STRING_SVTOOLS_HTML_META_content_type ) )
+ if( aKV.GetKey().equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_META_content_type ) )
{
- if( aKV.GetValue().Len() )
+ if( !aKV.GetValue().isEmpty() )
{
eRet = HTMLParser::GetEncodingByMIME( aKV.GetValue() );
}
diff --git a/svtools/source/svrtf/parrtf.cxx b/svtools/source/svrtf/parrtf.cxx
index f064a56..4881e8d 100644
--- a/svtools/source/svrtf/parrtf.cxx
+++ b/svtools/source/svrtf/parrtf.cxx
@@ -53,124 +53,131 @@
int SvRTFParser::_GetNextToken()
{
int nRet = 0;
- do {
+ do
+ {
int bNextCh = true;
switch( nNextCh )
{
case '\\':
+ // Steuerzeichen
+ switch( nNextCh = GetNextChar() )
{
- // Steuerzeichen
- switch( nNextCh = GetNextChar() )
+ case '{':
+ case '}':
+ case '\\':
+ case '+': // habe ich in einem RTF-File gefunden
+ case '~': // nonbreaking space
+ case '-': // optional hyphen
+ case '_': // nonbreaking hyphen
+ case '\'': // HexValue
+ nNextCh = '\\';
+ rInput.SeekRel( -1 );
+ ScanText();
+ nRet = RTF_TEXTTOKEN;
+ bNextCh = 0 == nNextCh;
+ break;
+
+ case '*': // ignoreflag
+ nRet = RTF_IGNOREFLAG;
+ break;
+ case ':': // subentry in an index entry
+ nRet = RTF_SUBENTRYINDEX;
+ break;
+ case '|': // formula-charakter
+ nRet = RTF_FORMULA;
+ break;
+
+ case 0x0a:
+ case 0x0d:
+ nRet = RTF_PAR;
+ break;
+
+ default:
+ if( RTF_ISALPHA( nNextCh ) )
{
- case '{':
- case '}':
- case '\\':
- case '+': // habe ich in einem RTF-File gefunden
- case '~': // nonbreaking space
- case '-': // optional hyphen
- case '_': // nonbreaking hyphen
- case '\'': // HexValue
- nNextCh = '\\';
- rInput.SeekRel( -1 );
- ScanText();
- nRet = RTF_TEXTTOKEN;
- bNextCh = 0 == nNextCh;
- break;
-
- case '*': // ignoreflag
- nRet = RTF_IGNOREFLAG;
- break;
- case ':': // subentry in an index entry
- nRet = RTF_SUBENTRYINDEX;
- break;
- case '|': // formula-charakter
- nRet = RTF_FORMULA;
- break;
-
- case 0x0a:
- case 0x0d:
- nRet = RTF_PAR;
- break;
-
- default:
- if( RTF_ISALPHA( nNextCh ) )
+ aToken = "\\";
{
- aToken = '\\';
+ OUStringBuffer aStrBuffer(MAX_TOKEN_LEN);
+ sal_Int32 nStrLen = 0;
+ do
{
- String aStrBuffer;
- sal_Unicode* pStr = aStrBuffer.AllocBuffer(
- MAX_TOKEN_LEN );
- xub_StrLen nStrLen = 0;
- do {
- *(pStr + nStrLen++) = nNextCh;
- if( MAX_TOKEN_LEN == nStrLen )
- {
- aToken += aStrBuffer;
- aToken.GetBufferAccess(); // make unique string!
- nStrLen = 0;
- }
- nNextCh = GetNextChar();
- } while( RTF_ISALPHA( nNextCh ) );
- if( nStrLen )
+ aStrBuffer.append((sal_Unicode)nNextCh);
+ nStrLen += 1;
+ if( MAX_TOKEN_LEN == nStrLen )
{
- aStrBuffer.ReleaseBufferAccess( nStrLen );
- aToken += aStrBuffer;
+ aToken += aStrBuffer.makeStringAndClear();
+ nStrLen = 0;
}
- }
-
- // Minus fuer numerischen Parameter
- int bNegValue = false;
- if( '-' == nNextCh )
- {
- bNegValue = true;
nNextCh = GetNextChar();
}
+ while( RTF_ISALPHA( nNextCh ) );
+ if( nStrLen )
+ {
+ aToken += aStrBuffer.makeStringAndClear();
+ }
+ }
- // evt. Numerischer Parameter
- if( RTF_ISDIGIT( nNextCh ) )
+ // Minus fuer numerischen Parameter
+ int bNegValue = false;
+ if( '-' == nNextCh )
+ {
+ bNegValue = true;
+ nNextCh = GetNextChar();
+ }
+
+ // evt. Numerischer Parameter
+ if( RTF_ISDIGIT( nNextCh ) )
+ {
+ nTokenValue = 0;
+ do
{
- nTokenValue = 0;
- do {
- nTokenValue *= 10;
- nTokenValue += nNextCh - '0';
- nNextCh = GetNextChar();
- } while( RTF_ISDIGIT( nNextCh ) );
- if( bNegValue )
- nTokenValue = -nTokenValue;
- bTokenHasValue=true;
- }
- else if( bNegValue ) // das Minus wieder zurueck
- {
- nNextCh = '-';
- rInput.SeekRel( -1 );
- }
- if( ' ' == nNextCh ) // Blank gehoert zum Token!
+ nTokenValue *= 10;
+ nTokenValue += nNextCh - '0';
nNextCh = GetNextChar();
+ }
+ while( RTF_ISDIGIT( nNextCh ) );
- // suche das Token in der Tabelle:
- if( 0 == (nRet = GetRTFToken( aToken )) )
- // Unknown Control
- nRet = RTF_UNKNOWNCONTROL;
-
- // bug 76812 - unicode token handled as normal text
- bNextCh = false;
- switch( nRet )
+ if( bNegValue )
{
- case RTF_UC:
- if( 0 <= nTokenValue )
- {
- nUCharOverread = (sal_uInt8)nTokenValue;
- //cmc: other ifdef breaks #i3584
- aParserStates.top().
- nUCharOverread = nUCharOverread;
- }
- aToken.Erase(); // #i47831# erase token to prevent the token from
beeing treated as text
- // read next token
- nRet = 0;
- break;
+ nTokenValue = -nTokenValue;
+ }
+ bTokenHasValue=true;
+ }
+ else if( bNegValue ) // das Minus wieder zurueck
+ {
+ nNextCh = '-';
+ rInput.SeekRel( -1 );
+ }
+ if( ' ' == nNextCh ) // Blank gehoert zum Token!
+ {
+ nNextCh = GetNextChar();
+ }
+ // suche das Token in der Tabelle:
+ if( 0 == (nRet = GetRTFToken( aToken )) )
+ {
+ // Unknown Control
+ nRet = RTF_UNKNOWNCONTROL;
+ }
+ // bug 76812 - unicode token handled as normal text
+ bNextCh = false;
+ switch( nRet )
+ {
+ case RTF_UC:
+ if( 0 <= nTokenValue )
+ {
+ nUCharOverread = (sal_uInt8)nTokenValue;
+ //cmc: other ifdef breaks #i3584
+ aParserStates.top().
+ nUCharOverread = nUCharOverread;
+ }
+ aToken = ""; // #i47831# erase token to prevent the token from beeing
treated as text
+ // read next token
+ nRet = 0;
+ break;
- case RTF_UPR:
- if (!_inSkipGroup) {
+ case RTF_UPR:
+ if (!_inSkipGroup)
+ {
// UPR - overread the group with the ansi
// information
while( '{' != _GetNextToken() )
@@ -178,45 +185,44 @@
SkipGroup();
_GetNextToken(); // overread the last bracket
nRet = 0;
- }
- break;
-
- case RTF_U:
- if( !bRTF_InTextRead )
- {
- nRet = RTF_TEXTTOKEN;
- aToken = (sal_Unicode)nTokenValue;
-
- // overread the next n "RTF" characters. This
- // can be also \{, \}, \'88
- for( sal_uInt8 m = 0; m < nUCharOverread; ++m )
- {
- sal_Unicode cAnsi = nNextCh;
- while( 0xD == cAnsi )
- cAnsi = GetNextChar();
- while( 0xA == cAnsi )
- cAnsi = GetNextChar();
-
- if( '\\' == cAnsi &&
- '\'' == ( cAnsi = GetNextChar() ))
- // HexValue ueberlesen
- cAnsi = GetHexValue();
- nNextCh = GetNextChar();
- }
- ScanText();
- bNextCh = 0 == nNextCh;
- }
- break;
}
+ break;
+
+ case RTF_U:
+ if( !bRTF_InTextRead )
+ {
+ nRet = RTF_TEXTTOKEN;
+ aToken = OUString((sal_Unicode)nTokenValue);
+
+ // overread the next n "RTF" characters. This
+ // can be also \{, \}, \'88
+ for( sal_uInt8 m = 0; m < nUCharOverread; ++m )
+ {
+ sal_Unicode cAnsi = nNextCh;
+ while( 0xD == cAnsi )
+ cAnsi = GetNextChar();
+ while( 0xA == cAnsi )
+ cAnsi = GetNextChar();
+
+ if( '\\' == cAnsi &&
+ '\'' == ( cAnsi = GetNextChar() ))
+ // HexValue ueberlesen
+ cAnsi = GetHexValue();
+ nNextCh = GetNextChar();
+ }
+ ScanText();
+ bNextCh = 0 == nNextCh;
+ }
+ break;
}
- else if( SVPAR_PENDING != eState )
- {
- // Bug 34631 - "\ " ueberlesen - Blank als Zeichen
- // eState = SVPAR_ERROR;
- bNextCh = false;
- }
- break;
}
+ else if( SVPAR_PENDING != eState )
+ {
+ // Bug 34631 - "\ " ueberlesen - Blank als Zeichen
+ // eState = SVPAR_ERROR;
+ bNextCh = false;
+ }
+ break;
}
break;
@@ -226,18 +232,16 @@
break;
case '{':
+ if( 0 <= nOpenBrakets )
{
- if( 0 <= nOpenBrakets )
- {
- RtfParserState_Impl aState( nUCharOverread, GetSrcEncoding() );
- aParserStates.push( aState );
- }
- ++nOpenBrakets;
- DBG_ASSERT(
+ RtfParserState_Impl aState( nUCharOverread, GetSrcEncoding() );
+ aParserStates.push( aState );
+ }
+ ++nOpenBrakets;
+ DBG_ASSERT(
static_cast<size_t>(nOpenBrakets) == aParserStates.size(),
"ParserStateStack unequal to bracket count" );
- nRet = nNextCh;
- }
+ nRet = nNextCh;
break;
case '}':
@@ -279,7 +283,9 @@
if( bNextCh )
nNextCh = GetNextChar();
- } while( !nRet && SVPAR_WORKING == eState );
+ }
+ while( !nRet && SVPAR_WORKING == eState );
+
return nRet;
}
@@ -306,154 +312,157 @@
void SvRTFParser::ScanText( const sal_Unicode cBreak )
{
- String aStrBuffer;
+ OUStringBuffer aStrBuffer;
int bWeiter = true;
- while( bWeiter && IsParserWorking() && aStrBuffer.Len() < MAX_STRING_LEN)
+ while( bWeiter && IsParserWorking() && aStrBuffer.getLength() < MAX_STRING_LEN)
{
int bNextCh = true;
+ OStringBuffer aByteString;
switch( nNextCh )
{
case '\\':
+ switch (nNextCh = GetNextChar())
{
- switch (nNextCh = GetNextChar())
+ case '\'':
+ for(;;)
{
- case '\'':
+ char c = (char)GetHexValue();
+ /*
+ * Note: \'00 is a valid internal character in a
+ * string in RTF. OStringBuffer supports
+ * appending nulls fine
+ */
+ aByteString.append(c);
+
+ bool bBreak = false;
+ sal_Char nSlash = '\\';
+ while (!bBreak)
{
-
- OStringBuffer aByteString;
- while (1)
+ wchar_t __next=GetNextChar();
+ if (__next>0xFF) // fix for #i43933# and #i35653#
{
- char c = (char)GetHexValue();
- /*
- * Note: \'00 is a valid internal character in a
- * string in RTF. OStringBuffer supports
- * appending nulls fine
- */
- aByteString.append(c);
-
- bool bBreak = false;
- sal_Char nSlash = '\\';
- while (!bBreak)
+ if (aByteString.getLength())
{
- wchar_t __next=GetNextChar();
- if (__next>0xFF) // fix for #i43933# and #i35653#
- {
- if (aByteString.getLength())
-
aStrBuffer.Append(String(OStringToOUString(aByteString.makeStringAndClear(), GetSrcEncoding())));
- aStrBuffer.Append((sal_Unicode)__next);
-
- continue;
- }
- nSlash = (sal_Char)__next;
- while (nSlash == 0xD || nSlash == 0xA)
- nSlash = (sal_Char)GetNextChar();
-
- switch (nSlash)
- {
- case '{':
- case '}':
- case '\\':
- bBreak = true;
- break;
- default:
- aByteString.append(nSlash);
- break;
- }
+
aStrBuffer.append(OStringToOUString(aByteString.makeStringAndClear(), GetSrcEncoding()));
}
+ aStrBuffer.append((sal_Unicode)__next);
- nNextCh = GetNextChar();
-
- if (nSlash != '\\' || nNextCh != '\'')
- {
- rInput.SeekRel(-1);
- nNextCh = nSlash;
- break;
- }
+ continue;
+ }
+ nSlash = (sal_Char)__next;
+ while (nSlash == 0xD || nSlash == 0xA)
+ {
+ nSlash = (sal_Char)GetNextChar();
}
- bNextCh = false;
-
- if (aByteString.getLength())
-
aStrBuffer.Append(String(OStringToOUString(aByteString.makeStringAndClear(), GetSrcEncoding())));
+ switch (nSlash)
+ {
+ case '{':
+ case '}':
+ case '\\':
+ bBreak = true;
+ break;
+ default:
+ aByteString.append(nSlash);
+ break;
+ }
}
- break;
- case '\\':
- case '}':
- case '{':
- case '+': // habe ich in einem RTF-File gefunden
- aStrBuffer.Append(nNextCh);
- break;
- case '~': // nonbreaking space
- aStrBuffer.Append(static_cast< sal_Unicode >(0xA0));
- break;
- case '-': // optional hyphen
- aStrBuffer.Append(static_cast< sal_Unicode >(0xAD));
- break;
- case '_': // nonbreaking hyphen
- aStrBuffer.Append(static_cast< sal_Unicode >(0x2011));
- break;
- case 'u':
- // UNI-Code Zeichen lesen
+ nNextCh = GetNextChar();
+
+ if (nSlash != '\\' || nNextCh != '\'')
{
+ rInput.SeekRel(-1);
+ nNextCh = nSlash;
+ break;
+ }
+ }
+
+ bNextCh = false;
+
+ if (aByteString.getLength())
+ {
+ aStrBuffer.append(OStringToOUString(aByteString.makeStringAndClear(),
GetSrcEncoding()));
+ }
+ break;
+ case '\\':
+ case '}':
+ case '{':
+ case '+': // habe ich in einem RTF-File gefunden
+ aStrBuffer.append(nNextCh);
+ break;
+ case '~': // nonbreaking space
+ aStrBuffer.append((sal_Unicode)0x00A0);
+ break;
+ case '-': // optional hyphen
+ aStrBuffer.append((sal_Unicode)0x00AD);
+ break;
+ case '_': // nonbreaking hyphen
+ aStrBuffer.append((sal_Unicode)0x2011);
+ break;
+
+ case 'u':
+ // UNI-Code Zeichen lesen
+ nNextCh = GetNextChar();
+ rInput.SeekRel( -2 );
+
+ if( '-' == nNextCh || RTF_ISDIGIT( nNextCh ) )
+ {
+ bRTF_InTextRead = true;
+
+ OUString sSave( aToken );
+ nNextCh = '\\';
+#ifdef DBG_UTIL
+ int nToken =
+#endif
+ _GetNextToken();
+ DBG_ASSERT( RTF_U == nToken, "doch kein UNI-Code Zeichen" );
+ // dont convert symbol chars
+ aStrBuffer.append((sal_Unicode)nTokenValue);
+
+ // overread the next n "RTF" characters. This
+ // can be also \{, \}, \'88
+ for( sal_uInt8 m = 0; m < nUCharOverread; ++m )
+ {
+ sal_Unicode cAnsi = nNextCh;
+ while( 0xD == cAnsi )
+ {
+ cAnsi = GetNextChar();
+ }
+ while( 0xA == cAnsi )
+ {
+ cAnsi = GetNextChar();
+ }
+ if( '\\' == cAnsi &&
+ '\'' == ( cAnsi = GetNextChar() ))
+ {
+ // HexValue ueberlesen
+ cAnsi = GetHexValue();
+ }
nNextCh = GetNextChar();
- rInput.SeekRel( -2 );
-
- if( '-' == nNextCh || RTF_ISDIGIT( nNextCh ) )
- {
- bRTF_InTextRead = true;
-
- String sSave( aToken );
- nNextCh = '\\';
- #ifdef DBG_UTIL
- int nToken =
- #endif
- _GetNextToken();
- DBG_ASSERT( RTF_U == nToken, "doch kein UNI-Code Zeichen" );
- // dont convert symbol chars
- aStrBuffer.Append(
- static_cast< sal_Unicode >(nTokenValue));
-
- // overread the next n "RTF" characters. This
- // can be also \{, \}, \'88
- for( sal_uInt8 m = 0; m < nUCharOverread; ++m )
- {
- sal_Unicode cAnsi = nNextCh;
- while( 0xD == cAnsi )
- cAnsi = GetNextChar();
- while( 0xA == cAnsi )
- cAnsi = GetNextChar();
-
- if( '\\' == cAnsi &&
- '\'' == ( cAnsi = GetNextChar() ))
- // HexValue ueberlesen
- cAnsi = GetHexValue();
- nNextCh = GetNextChar();
- }
- bNextCh = false;
- aToken = sSave;
- bRTF_InTextRead = false;
- }
- else
- {
- nNextCh = '\\';
- bWeiter = false; // Abbrechen, String zusammen
- }
}
- break;
-
- default:
- rInput.SeekRel( -1 );
+ bNextCh = false;
+ aToken = sSave;
+ bRTF_InTextRead = false;
+ }
+ else
+ {
nNextCh = '\\';
bWeiter = false; // Abbrechen, String zusammen
- break;
}
+ break;
+
+ default:
+ rInput.SeekRel( -1 );
+ nNextCh = '\\';
+ bWeiter = false; // Abbrechen, String zusammen
+ break;
}
break;
case sal_Unicode(EOF):
- eState = SVPAR_ERROR;
- // weiter
+ eState = SVPAR_ERROR;
+ // weiter
case '{':
case '}':
bWeiter = false;
@@ -464,35 +473,40 @@
break;
default:
- if( nNextCh == cBreak || aStrBuffer.Len() >= MAX_STRING_LEN)
+ if( nNextCh == cBreak || aStrBuffer.getLength() >= MAX_STRING_LEN)
+ {
bWeiter = false;
+ }
else
{
- do {
+ do
+ {
// alle anderen Zeichen kommen in den Text
- aStrBuffer.Append(nNextCh);
+ aStrBuffer.append(nNextCh);
if (sal_Unicode(EOF) == (nNextCh = GetNextChar()))
{
- if (aStrBuffer.Len())
- aToken += aStrBuffer;
+ if (aStrBuffer.getLength())
+ aToken += aStrBuffer.makeStringAndClear();
return;
}
- } while
- (
- (RTF_ISALPHA(nNextCh) || RTF_ISDIGIT(nNextCh)) &&
- (aStrBuffer.Len() < MAX_STRING_LEN)
- );
+ }
+ while ( (RTF_ISALPHA(nNextCh) || RTF_ISDIGIT(nNextCh)) &&
+ (aStrBuffer.getLength() < MAX_STRING_LEN) );
bNextCh = false;
}
}
if( bWeiter && bNextCh )
+ {
nNextCh = GetNextChar();
+ }
}
- if (aStrBuffer.Len())
- aToken += aStrBuffer;
+ if (aStrBuffer.getLength())
+ {
+ aToken += aStrBuffer.makeStringAndClear();
+ }
}
@@ -500,24 +514,25 @@
void SvRTFParser::SkipGroup()
{
-short nBrackets=1;
-if (_inSkipGroup>0)
- return;
-_inSkipGroup++;
+ short nBrackets=1;
+
+ if (_inSkipGroup>0)
+ return;
+ _inSkipGroup++;
//#i16185# fecking \bin keyword
do
{
switch (nNextCh)
{
- case '{':
- ++nBrackets;
- break;
- case '}':
- if (!--nBrackets) {
- _inSkipGroup--;
- return;
- }
- break;
+ case '{':
+ ++nBrackets;
+ break;
+ case '}':
+ if (!--nBrackets) {
+ _inSkipGroup--;
+ return;
+ }
+ break;
}
int nToken = _GetNextToken();
if (nToken == RTF_BIN)
@@ -530,10 +545,13 @@
{
nNextCh = GetNextChar();
}
- } while (sal_Unicode(EOF) != nNextCh && IsParserWorking());
+ }
+ while (sal_Unicode(EOF) != nNextCh && IsParserWorking());
if( SVPAR_PENDING != eState && '}' != nNextCh )
+ {
eState = SVPAR_ERROR;
+ }
_inSkipGroup--;
}
@@ -558,11 +576,14 @@
AddRef();
Continue( 0 );
if( SVPAR_PENDING != eState )
+ {
ReleaseRef(); // dann brauchen wir den Parser nicht mehr!
+ }
}
else
+ {
eState = SVPAR_ERROR;
-
+ }
return eState;
}
@@ -572,8 +593,9 @@
// "Zeichensatz wurde geaendert." );
if( !nToken )
+ {
nToken = GetNextToken();
-
+ }
while( IsParserWorking() )
{
SaveState( nToken );
@@ -581,29 +603,32 @@
{
case '}':
if( nOpenBrakets )
+ {
goto NEXTTOKEN;
+ }
eState = SVPAR_ACCEPTED;
break;
case '{':
// eine unbekannte Gruppe ?
+ if( RTF_IGNOREFLAG != GetNextToken() )
{
- if( RTF_IGNOREFLAG != GetNextToken() )
- nToken = SkipToken( -1 );
- else if( RTF_UNKNOWNCONTROL != GetNextToken() )
- nToken = SkipToken( -2 );
- else
- {
- // gleich herausfiltern
- ReadUnknownData();
- nToken = GetNextToken();
- if( '}' != nToken )
- eState = SVPAR_ERROR;
- break; // auf zum naechsten Token!!
- }
+ nToken = SkipToken( -1 );
+ }
+ else if( RTF_UNKNOWNCONTROL != GetNextToken() )
+ {
+ nToken = SkipToken( -2 );
+ }
+ else
+ {
+ // gleich herausfiltern
+ ReadUnknownData();
+ nToken = GetNextToken();
+ if( '}' != nToken )
+ eState = SVPAR_ERROR;
+ break; // auf zum naechsten Token!!
}
goto NEXTTOKEN;
-
case RTF_UNKNOWNCONTROL:
break; // unbekannte Token ueberspringen
case RTF_NEXTTYPE:
@@ -629,12 +654,16 @@
break;
}
if( IsParserWorking() )
+ {
SaveState( 0 ); // bis hierhin abgearbeitet,
// weiter mit neuem Token!
+ }
nToken = GetNextToken();
}
if( SVPAR_ACCEPTED == eState && 0 < nOpenBrakets )
+ {
eState = SVPAR_ERROR;
+ }
}
void SvRTFParser::SetEncoding( rtl_TextEncoding eEnc )
@@ -643,7 +672,9 @@
eEnc = GetCodeSet();
if (!aParserStates.empty())
+ {
aParserStates.top().eCodeSet = eEnc;
+ }
SetSrcEncoding(eEnc);
}
diff --git a/svtools/source/svrtf/svparser.cxx b/svtools/source/svrtf/svparser.cxx
index 5f2bcba..8ed4b61 100644
--- a/svtools/source/svrtf/svparser.cxx
+++ b/svtools/source/svrtf/svparser.cxx
@@ -27,12 +27,12 @@
// Struktur, um sich die akt. Daten zumerken
struct SvParser_Impl
{
- String aToken; // gescanntes Token
- sal_uLong nFilePos; // akt. Position im Stream
- sal_uLong nlLineNr; // akt. Zeilen Nummer
- sal_uLong nlLinePos; // akt. Spalten Nummer
+ OUString aToken; // gescanntes Token
+ sal_uLong nFilePos; // akt. Position im Stream
+ sal_uLong nlLineNr; // akt. Zeilen Nummer
+ sal_uLong nlLinePos; // akt. Spalten Nummer
long nTokenValue; // zusaetzlicher Wert (RTF)
- sal_Bool bTokenHasValue; // indicates whether nTokenValue is valid
+ sal_Bool bTokenHasValue; // indicates whether nTokenValue is valid
int nToken; // akt. Token
sal_Unicode nNextCh; // akt. Zeichen
@@ -382,7 +382,7 @@
if( !nTokenStackPos )
{
- aToken.Erase(); // Token-Buffer loeschen
+ aToken = ""; // Token-Buffer loeschen
nTokenValue = -1; // Kennzeichen fuer kein Value gelesen
bTokenHasValue = false;
diff --git a/sw/source/filter/html/htmlbas.cxx b/sw/source/filter/html/htmlbas.cxx
index 44fbb39..276e6b6 100644
--- a/sw/source/filter/html/htmlbas.cxx
+++ b/sw/source/filter/html/htmlbas.cxx
@@ -63,7 +63,7 @@
ParseScriptOptions( aScriptType, sBaseURL, eScriptLang, aScriptURL,
aBasicLib, aBasicModule );
- if( aScriptURL.Len() )
+ if( !aScriptURL.isEmpty() )
{
// Den Inhalt des Script-Tags ignorieren
bIgnoreRawData = sal_True;
@@ -96,13 +96,13 @@
(SwScriptFieldType*)pDoc->GetSysFldType( RES_SCRIPTFLD );
SwScriptField aFld( pType, aScriptType,
- aScriptURL.Len() ? aScriptURL : aScriptSource,
- aScriptURL.Len()!=0 );
+ !aScriptURL.isEmpty() ? aScriptURL : aScriptSource,
+ !aScriptURL.isEmpty() );
InsertAttr( SwFmtFld( aFld ) );
}
SwDocShell *pDocSh = pDoc->GetDocShell();
- if( aScriptSource.Len() && pDocSh &&
+ if( !aScriptSource.isEmpty() && pDocSh &&
bInsIntoBasic && IsNewDoc() )
{
// Fuer JavaScript und StarBasic noch ein Basic-Modul anlegen
@@ -111,7 +111,7 @@
// get library name
OUString aLibName;
- if( aBasicLib.Len() )
+ if( !aBasicLib.isEmpty() )
aLibName = aBasicLib;
else
aLibName = OUString("Standard");
@@ -136,13 +136,13 @@
if ( xModLib.is() )
{
- if( !aBasicModule.Len() )
+ if( aBasicModule.isEmpty() )
{
// create module name
sal_Bool bFound = sal_True;
while( bFound )
{
- aBasicModule.AssignAscii( "Modul" );
+ aBasicModule = "Modul";
aBasicModule += OUString::number( (sal_Int32)(++nSBModuleCnt) );
bFound = xModLib->hasByName( OUString( aBasicModule ) );
}
@@ -172,56 +172,54 @@
}
}
- aScriptSource.Erase();
- aScriptType.Erase();
- aScriptURL.Erase();
+ aScriptSource = "";
+ aScriptType = "";
+ aScriptURL = "";
- aBasicLib.Erase();
- aBasicModule.Erase();
+ aBasicLib = "";
+ aBasicModule = "";
}
void SwHTMLParser::AddScriptSource()
{
// Hier merken wir und nur ein par Strings
- if( aToken.Len() > 2 &&
- (HTML_SL_STARBASIC==eScriptLang && aToken.GetChar( 0 ) == '\'') )
+ if( aToken.getLength() > 2 &&
+ (HTML_SL_STARBASIC==eScriptLang && aToken[ 0 ] == '\'') )
{
- xub_StrLen nPos = STRING_NOTFOUND;
- if( !aBasicLib.Len() )
+ sal_Int32 nPos = -1;
+ if( aBasicLib.isEmpty() )
{
- nPos = aToken.SearchAscii( OOO_STRING_SVTOOLS_HTML_SB_library );
- if( nPos != STRING_NOTFOUND )
+ nPos = aToken.indexOf( OOO_STRING_SVTOOLS_HTML_SB_library );
+ if( nPos >= 0 )
{
- aBasicLib =
- aToken.Copy( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_library) - 1 );
+ aBasicLib = aToken.copy( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_library) - 1 );
aBasicLib = comphelper::string::strip(aBasicLib, ' ');
}
}
- if( !aBasicModule.Len() && nPos==STRING_NOTFOUND )
+ if( aBasicModule.isEmpty() && nPos== -1 )
{
- nPos = aToken.SearchAscii( OOO_STRING_SVTOOLS_HTML_SB_module );
- if( nPos != STRING_NOTFOUND )
+ nPos = aToken.indexOf( OOO_STRING_SVTOOLS_HTML_SB_module );
+ if( nPos >= 0 )
{
- aBasicModule =
- aToken.Copy( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_module) - 1 );
+ aBasicModule = aToken.copy( nPos + sizeof(OOO_STRING_SVTOOLS_HTML_SB_module) - 1 );
aBasicModule = comphelper::string::strip(aBasicModule, ' ');
}
}
- if( nPos==STRING_NOTFOUND )
+ if( nPos== -1 )
{
- if( aScriptSource.Len() )
- aScriptSource += '\n';
- (aScriptSource += aToken);
+ if( !aScriptSource.isEmpty() )
+ aScriptSource += "\n";
+ aScriptSource += aToken;
}
}
- else if( aScriptSource.Len() || aToken.Len() )
+ else if( !aScriptSource.isEmpty() || !aToken.isEmpty() )
{
// Leerzeilen am Anfang werden ignoriert
- if( aScriptSource.Len() )
+ if( !aScriptSource.isEmpty() )
{
- aScriptSource += '\n';
+ aScriptSource += "\n";
}
else
{
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
index 6423ce5..73ccb27 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -1716,10 +1716,10 @@
{
bIgnoreRawData = sal_False;
- if( aStyleSource.Len() )
+ if( !aStyleSource.isEmpty() )
{
pCSS1Parser->ParseStyleSheet( aStyleSource );
- aStyleSource.Erase();
+ aStyleSource = "";
}
}
diff --git a/sw/source/filter/html/htmldraw.cxx b/sw/source/filter/html/htmldraw.cxx
index d098988..5b00977 100644
--- a/sw/source/filter/html/htmldraw.cxx
+++ b/sw/source/filter/html/htmldraw.cxx
@@ -261,7 +261,7 @@
{
OSL_ENSURE( !pMarquee, "Marquee in Marquee???" );
- aContents.Erase();
+ aContents = "";
String aId, aStyle, aClass;
@@ -312,7 +312,7 @@
case HTML_O_LOOP:
if( rOption.GetString().
- EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_LOOP_infinite) )
+ equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_LOOP_infinite) )
{
nCount = 0;
}
@@ -334,7 +334,7 @@
case HTML_O_WIDTH:
// erstmal nur als Pixelwerte merken!
nWidth = rOption.GetNumber();
- bPrcWidth = rOption.GetString().Search('%') != STRING_NOTFOUND;
+ bPrcWidth = rOption.GetString().indexOf('%') >= 0;
if( bPrcWidth && nWidth>100 )
nWidth = 100;
break;
@@ -342,7 +342,7 @@
case HTML_O_HEIGHT:
// erstmal nur als Pixelwerte merken!
nHeight = rOption.GetNumber();
- if( rOption.GetString().Search('%') != STRING_NOTFOUND )
+ if( rOption.GetString().indexOf('%') >= 0)
nHeight = 0;
break;
@@ -572,7 +572,7 @@
((SdrTextObj*)pMarquee)->FitFrameToTextSize();
}
- aContents.Erase();
+ aContents = "";
pMarquee = 0;
}
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
index 3213bfc..6c960d9 100644
--- a/sw/source/filter/html/htmlfld.cxx
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -574,7 +574,7 @@
}
bInField = sal_False;
- aContents.Erase();
+ aContents = "";
}
void SwHTMLParser::InsertFieldText()
@@ -588,18 +588,18 @@
void SwHTMLParser::InsertCommentText( const sal_Char *pTag )
{
- sal_Bool bEmpty = aContents.Len() == 0;
+ sal_Bool bEmpty = aContents.isEmpty();
if( !bEmpty )
- aContents += '\n';
+ aContents += "\n";
aContents += aToken;
if( bEmpty && pTag )
{
String aTmp( aContents );
- aContents.AssignAscii( "HTML: <" );
- aContents.AppendAscii( pTag );
- aContents.Append( '>' );
- aContents.Append( aTmp );
+ aContents = "HTML: <" ;
+ aContents += OUString( pTag, strlen(pTag), RTL_TEXTENCODING_ASCII_US );
+ aContents += ">";
+ aContents += aTmp;
}
}
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index ec85ccc..90ef09c 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -2240,7 +2240,7 @@
default:
rText += '<';
rText += sSaveToken;
- if( aToken.Len() )
+ if( !aToken.isEmpty() )
{
rText += ' ';
rText += aToken;
@@ -2617,13 +2617,13 @@
{
String& rText = pFormImpl->GetStringList().back();
- if( aToken.Len() && ' '==aToken.GetChar( 0 ) )
+ if( !aToken.isEmpty() && ' '==aToken[ 0 ] )
{
xub_StrLen nLen = rText.Len();
if( !nLen || ' '==rText.GetChar( nLen-1 ))
- aToken.Erase( 0, 1 );
+ aToken = aToken.copy(1);
}
- if( aToken.Len() )
+ if( !aToken.isEmpty() )
rText += aToken;
}
}
diff --git a/sw/source/filter/html/htmlgrin.cxx b/sw/source/filter/html/htmlgrin.cxx
index de89a59..2b1efde 100644
--- a/sw/source/filter/html/htmlgrin.cxx
+++ b/sw/source/filter/html/htmlgrin.cxx
@@ -309,7 +309,8 @@
void SwHTMLParser::InsertImage()
{
// und jetzt auswerten
- String sGrfNm, sAltNm, aId, aClass, aStyle, aMap, sHTMLGrfName;
+ OUString sGrfNm;
+ OUString sAltNm, aId, aClass, aStyle, aMap, sHTMLGrfName;
sal_Int16 eVertOri = text::VertOrientation::TOP;
sal_Int16 eHoriOri = text::HoriOrientation::NONE;
long nWidth=0, nHeight=0;
@@ -358,14 +359,14 @@
case HTML_O_WIDTH:
// erstmal nur als Pixelwerte merken!
nWidth = rOption.GetNumber();
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
if( bPrcWidth && nWidth>100 )
nWidth = 100;
break;
case HTML_O_HEIGHT:
// erstmal nur als Pixelwerte merken!
nHeight = rOption.GetNumber();
- bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcHeight = (rOption.GetString().indexOf('%') >= 0);
if( bPrcHeight && nHeight>100 )
nHeight = 100;
break;
@@ -425,7 +426,7 @@
}
}
- if( !sGrfNm.Len() )
+ if( sGrfNm.isEmpty() )
return;
// Wenn wir in einer Numerierung stehen und der Absatz noch leer und
@@ -433,7 +434,7 @@
// einer Bullet-Liste
if( !pPam->GetPoint()->nContent.GetIndex() &&
GetNumInfo().GetDepth() > 0 && GetNumInfo().GetDepth() <= MAXLEVEL &&
- aBulletGrfs[GetNumInfo().GetDepth()-1].Len() &&
+ !aBulletGrfs[GetNumInfo().GetDepth()-1].isEmpty() &&
aBulletGrfs[GetNumInfo().GetDepth()-1]==sGrfNm )
{
SwTxtNode* pTxtNode = pPam->GetNode()->GetTxtNode();
@@ -626,16 +627,16 @@
// Image-Map setzen
aMap = comphelper::string::stripEnd(aMap, ' ');
- if( aMap.Len() )
+ if( !aMap.isEmpty() )
{
// Da wir nur lokale Image-Maps kennen nehmen wireinfach alles
// hinter dem # als Namen
- xub_StrLen nPos = aMap.Search( '#' );
+ sal_Int32 nPos = aMap.indexOf( '#' );
String aName;
- if ( STRING_NOTFOUND==nPos )
+ if ( nPos < 0 )
aName = aMap ;
else
- aName = aMap.Copy(nPos+1);
+ aName = aMap.copy(nPos+1);
ImageMap *pImgMap = FindImageMap( aName );
if( pImgMap )
@@ -699,7 +700,7 @@
SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFlyFmt->GetCntnt().GetCntntIdx()
->GetIndex()+1 ]->GetGrfNode();
- if( sHTMLGrfName.Len() )
+ if( !sHTMLGrfName.isEmpty() )
{
pFlyFmt->SetName( sHTMLGrfName );
@@ -711,7 +712,7 @@
}
}
- if( sAltNm.Len() )
+ if( !sAltNm.isEmpty() )
pGrfNd->SetTitle( sAltNm );
if( bSetTwipSize )
@@ -784,7 +785,7 @@
// Ggf. Frames anlegen und Auto-gebundenen Rahmen registrieren
RegisterFlyFrm( pFlyFmt );
- if( aId.Len() )
+ if( !aId.isEmpty() )
InsertBookmark( aId );
}
diff --git a/sw/source/filter/html/htmlnum.cxx b/sw/source/filter/html/htmlnum.cxx
index 3555f87..c564b838 100644
--- a/sw/source/filter/html/htmlnum.cxx
+++ b/sw/source/filter/html/htmlnum.cxx
@@ -163,7 +163,8 @@
}
// und es ggf. durch die Optionen veraendern
- String aId, aStyle, aClass, aBulletSrc, aLang, aDir;
+ String aId, aStyle, aClass, aLang, aDir;
+ OUString aBulletSrc;
sal_Int16 eVertOri = text::VertOrientation::NONE;
sal_uInt16 nWidth=USHRT_MAX, nHeight=USHRT_MAX;
const HTMLOptions& rHTMLOptions = GetOptions();
@@ -176,13 +177,13 @@
aId = rOption.GetString();
break;
case HTML_O_TYPE:
- if( bNewNumFmt && rOption.GetString().Len() )
+ if( bNewNumFmt && !rOption.GetString().isEmpty() )
{
switch( nToken )
{
case HTML_ORDERLIST_ON:
bChangeNumFmt = sal_True;
- switch( rOption.GetString().GetChar(0) )
+ switch( rOption.GetString()[0] )
{
case 'A': aNumFmt.SetNumberingType(SVX_NUM_CHARS_UPPER_LETTER); break;
case 'a': aNumFmt.SetNumberingType(SVX_NUM_CHARS_LOWER_LETTER); break;
@@ -248,7 +249,7 @@
}
}
- if( aBulletSrc.Len() )
+ if( !aBulletSrc.isEmpty() )
{
// Eine Bullet-Liste mit Grafiken
aNumFmt.SetNumberingType(SVX_NUM_BITMAP);
@@ -279,8 +280,9 @@
bChangeNumFmt = sal_True;
}
else
- aBulletGrfs[nLevel].Erase();
-
+ {
+ aBulletGrfs[nLevel] = "";
+ }
// den aktuellen Absatz erst einmal nicht numerieren
{
sal_uInt8 nLvl = nLevel;
diff --git a/sw/source/filter/html/htmlplug.cxx b/sw/source/filter/html/htmlplug.cxx
index 6e5235f..e0818fc 100644
--- a/sw/source/filter/html/htmlplug.cxx
+++ b/sw/source/filter/html/htmlplug.cxx
@@ -343,14 +343,14 @@
case HTML_O_WIDTH:
if( USHRT_MAX==aSize.Width() )
{
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
aSize.Width() = (long)rOption.GetNumber();
}
break;
case HTML_O_HEIGHT:
if( USHRT_MAX==aSize.Height() )
{
- bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcHeight = (rOption.GetString().indexOf('%') >= 0);
aSize.Height() = (long)rOption.GetNumber();
}
break;
@@ -363,9 +363,9 @@
aSpace.Height() = (long)rOption.GetNumber();
break;
case HTML_O_UNKNOWN:
- if( rOption.GetTokenString().EqualsIgnoreCaseAscii( OOO_STRING_SW_HTML_O_Hidden ) )
+ if( rOption.GetTokenString().equalsIgnoreAsciiCase( OOO_STRING_SW_HTML_O_Hidden ) )
bHidden =
- !rOption.GetString().EqualsIgnoreCaseAscii( sHTML_O_Hidden_False );
+ !rOption.GetString().equalsIgnoreAsciiCase( sHTML_O_Hidden_False );
break;
}
@@ -533,11 +533,11 @@
aStandBy = rOption.GetString();
break;
case HTML_O_WIDTH:
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
aSize.Width() = (long)rOption.GetNumber();
break;
case HTML_O_HEIGHT:
- bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcHeight = (rOption.GetString().indexOf('%') >= 0);
aSize.Height() = (long)rOption.GetNumber();
break;
case HTML_O_ALIGN:
@@ -697,11 +697,11 @@
eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
break;
case HTML_O_WIDTH:
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
aSize.Width() = (long)rOption.GetNumber();
break;
case HTML_O_HEIGHT:
- bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcHeight = (rOption.GetString().indexOf('%') >= 0);
aSize.Height() = (long)rOption.GetNumber();
break;
case HTML_O_HSPACE:
@@ -848,11 +848,11 @@
eHoriOri = rOption.GetEnum( aHTMLImgHAlignTable, eHoriOri );
break;
case HTML_O_WIDTH:
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
aSize.Width() = (long)rOption.GetNumber();
break;
case HTML_O_HEIGHT:
- bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcHeight = (rOption.GetString().indexOf('%') >= 0);
aSize.Height() = (long)rOption.GetNumber();
break;
case HTML_O_HSPACE:
diff --git a/sw/source/filter/html/htmlsect.cxx b/sw/source/filter/html/htmlsect.cxx
index b9e76da..3228101 100644
--- a/sw/source/filter/html/htmlsect.cxx
+++ b/sw/source/filter/html/htmlsect.cxx
@@ -571,7 +571,7 @@
break;
case HTML_O_WIDTH:
nWidth = rOption.GetNumber();
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
if( bPrcWidth && nWidth>100 )
nWidth = 100;
break;
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index b0b96f2..f733c06 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -3222,19 +3222,19 @@
break;
case HTML_O_WIDTH:
nWidth = (sal_uInt16)rOption.GetNumber(); // nur fuer Netscape
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
if( bPrcWidth && nWidth>100 )
nWidth = 100;
break;
case HTML_O_HEIGHT:
nHeight = (sal_uInt16)rOption.GetNumber(); // nur fuer Netscape
- if( rOption.GetString().Search('%') != STRING_NOTFOUND)
+ if( rOption.GetString().indexOf('%') >= 0)
nHeight = 0; // keine %-Angaben beruecksichtigen
break;
case HTML_O_BGCOLOR:
// Leere BGCOLOR bei <TABLE>, <TR> und <TD>/<TH> wie Netscape
// ignorieren, bei allen anderen Tags *wirklich* nicht.
- if( rOption.GetString().Len() )
+ if( !rOption.GetString().isEmpty() )
{
rOption.GetColor( aBGColor );
bBGColor = sal_True;
@@ -4095,8 +4095,8 @@
case HTML_TEXTTOKEN:
// keine Section fuer einen leeren String anlegen
- if( !pSaveStruct->IsInSection() && 1==aToken.Len() &&
- ' '==aToken.GetChar(0) )
+ if( !pSaveStruct->IsInSection() && 1==aToken.getLength() &&
+ ' '==aToken[0] )
break;
default:
if( !pSaveStruct->IsInSection() )
@@ -4275,7 +4275,7 @@
case HTML_O_BGCOLOR:
// Leere BGCOLOR bei <TABLE>, <TR> und <TD>/<TH> wie Netsc.
// ignorieren, bei allen anderen Tags *wirklich* nicht.
- if( rOption.GetString().Len() )
+ if( !rOption.GetString().isEmpty() )
{
rOption.GetColor( aBGColor );
bBGColor = sal_True;
@@ -4392,7 +4392,7 @@
case HTML_TEXTTOKEN:
if( (pCurTable->GetContext() ||
!pCurTable->HasParentSection()) &&
- 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ 1==aToken.getLength() && ' '==aToken[0] )
break;
default:
pCurTable->MakeParentContents();
@@ -4553,7 +4553,7 @@
// Blank-Strings sind Folge von CR+LF und kein Text
if( (pCurTable->GetContext() ||
!pCurTable->HasParentSection()) &&
- 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ 1==aToken.getLength() && ' '==aToken[0] )
break;
default:
pCurTable->MakeParentContents();
@@ -4657,7 +4657,7 @@
case HTML_O_WIDTH:
pSaveStruct->nColGrpWidth = (sal_uInt16)rOption.GetNumber();
pSaveStruct->bRelColGrpWidth =
- (rOption.GetString().Search('*') != STRING_NOTFOUND);
+ (rOption.GetString().indexOf('*') >= 0);
break;
case HTML_O_ALIGN:
pSaveStruct->eColGrpAdjust =
@@ -4740,7 +4740,7 @@
case HTML_O_WIDTH:
nColWidth = (sal_uInt16)rOption.GetNumber();
bRelColWidth =
- (rOption.GetString().Search('*') != STRING_NOTFOUND);
+ (rOption.GetString().indexOf('*') >= 0);
break;
case HTML_O_ALIGN:
eColAdjust =
@@ -4770,7 +4770,7 @@
case HTML_TEXTTOKEN:
if( (pCurTable->GetContext() ||
!pCurTable->HasParentSection()) &&
- 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ 1==aToken.getLength() && ' '==aToken[0] )
break;
default:
pCurTable->MakeParentContents();
@@ -4876,7 +4876,7 @@
const HTMLOption& rOption = rHTMLOptions[--i];
if( HTML_O_ALIGN == rOption.GetToken() )
{
- if( rOption.GetString().EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_VA_bottom))
+ if( rOption.GetString().equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_VA_bottom))
bTop = sal_False;
}
}
@@ -5112,13 +5112,13 @@
break;
case HTML_O_WIDTH:
nWidth = (sal_uInt16)rOption.GetNumber();
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
if( bPrcWidth && nWidth>100 )
nWidth = 100;
break;
case HTML_O_HEIGHT:
nHeight = (sal_uInt16)rOption.GetNumber();
- if( rOption.GetString().Search('%') != STRING_NOTFOUND )
+ if( rOption.GetString().indexOf('%') >= 0 )
nHeight = 0; // keine %-Anagben benutzen!!!
break;
case HTML_O_CELLPADDING:
@@ -5142,8 +5142,8 @@
break;
case HTML_O_BORDER:
// BORDER und BORDER=BORDER wie BORDER=1 behandeln
- if( rOption.GetString().Len() &&
- !rOption.GetString().EqualsIgnoreCaseAscii(OOO_STRING_SVTOOLS_HTML_O_border) )
+ if( !rOption.GetString().isEmpty() &&
+ !rOption.GetString().equalsIgnoreAsciiCase(OOO_STRING_SVTOOLS_HTML_O_border) )
nBorder = (sal_uInt16)rOption.GetNumber();
else
nBorder = 1;
@@ -5164,7 +5164,7 @@
case HTML_O_BGCOLOR:
// Leere BGCOLOR bei <TABLE>, <TR> und <TD>/<TH> wie Netscape
// ignorieren, bei allen anderen Tags *wirklich* nicht.
- if( rOption.GetString().Len() )
+ if( !rOption.GetString().isEmpty() )
{
rOption.GetColor( aBGColor );
bBGColor = sal_True;
@@ -5342,7 +5342,7 @@
// Blank-Strings sind u. U. eine Folge von CR+LF und kein Text
if( (pCurTable->GetContext() ||
!pCurTable->HasParentSection()) &&
- 1==aToken.Len() && ' '==aToken.GetChar(0) )
+ 1==aToken.getLength() && ' '==aToken[0] )
break;
default:
pCurTable->MakeParentContents();
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 11fe376..fd593c9 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -370,19 +370,19 @@
if( pMed )
{
sJmpMark = pMed->GetURLObject().GetMark();
- if( sJmpMark.Len() )
+ if( !sJmpMark.isEmpty() )
{
eJumpTo = JUMPTO_MARK;
xub_StrLen nLastPos, nPos = 0;
- while( STRING_NOTFOUND != ( nLastPos =
- sJmpMark.Search( cMarkSeparator, nPos + 1 )) )
+ while(( nLastPos =
+ sJmpMark.indexOf( cMarkSeparator, nPos + 1 )) >= 0 )
nPos = nLastPos;
String sCmp;
if (nPos)
{
sCmp = comphelper::string::remove(
- sJmpMark.Copy(nPos + 1), ' ');
+ sJmpMark.copy(nPos + 1), ' ');
}
if( sCmp.Len() )
@@ -405,8 +405,8 @@
else
nPos = STRING_LEN;
- sJmpMark.Erase( nPos );
- if( !sJmpMark.Len() )
+ sJmpMark = sJmpMark.copy(0, nPos );
+ if( sJmpMark.isEmpty() )
eJumpTo = JUMPTO_NONE;
}
}
@@ -640,7 +640,7 @@
{
// noch die letzten Attribute setzen
{
- if( aScriptSource.Len() )
+ if( !aScriptSource.isEmpty() )
{
SwScriptFieldType *pType =
(SwScriptFieldType*)pDoc->GetSysFldType( RES_SCRIPTFLD );
@@ -989,7 +989,7 @@
switch( nToken )
{
case HTML_TITLE_OFF:
- if( IsNewDoc() && sTitle.Len() )
+ if( IsNewDoc() && !sTitle.isEmpty() )
{
if( pDoc->GetDocShell() ) {
uno::Reference<document::XDocumentPropertiesSupplier>
@@ -1006,15 +1006,15 @@
}
}
bInTitle = sal_False;
- sTitle.Erase();
+ sTitle = "";
break;
case HTML_NONBREAKSPACE:
- sTitle += ' ';
+ sTitle += " ";
break;
case HTML_SOFTHYPH:
- sTitle += '-';
+ sTitle += "-";
break;
case HTML_TEXTTOKEN:
@@ -1022,16 +1022,16 @@
break;
default:
- sTitle += '<';
+ sTitle += "<";
if( (HTML_TOKEN_ONOFF & nToken) && (1 & nToken) )
- sTitle += '/';
+ sTitle += "/";
sTitle += sSaveToken;
- if( aToken.Len() )
+ if( !aToken.isEmpty() )
{
- sTitle += ' ';
+ sTitle += " ";
sTitle += aToken;
}
- sTitle += '>';
+ sTitle += ">";
break;
}
@@ -1072,7 +1072,7 @@
case HTML_NOEMBED_OFF:
aContents = convertLineEnd(aContents, GetSystemLineEnd());
InsertComment( aContents, OOO_STRING_SVTOOLS_HTML_noembed );
- aContents.Erase();
+ aContents = "";
bCallNextToken = sal_False;
bInNoEmbed = sal_False;
break;
@@ -1213,11 +1213,11 @@
}
return;
}
- else if( aUnknownToken.Len() )
+ else if( !aUnknownToken.isEmpty() )
{
// Paste content of unknown tags.
// (but surely if we are not in the header section) fdo#36080 fdo#34666
- if (aToken.Len() > 0 && !IsInHeader() )
+ if (!aToken.isEmpty() && !IsInHeader() )
{
if( !bDocInitalized )
DocumentDetected();
@@ -1237,18 +1237,18 @@
switch( nToken )
{
case HTML_UNKNOWNCONTROL_OFF:
- if( aUnknownToken.CompareTo(sSaveToken) != COMPARE_EQUAL )
+ if( !aUnknownToken.startsWith(sSaveToken))
return;
case HTML_FRAMESET_ON:
case HTML_HEAD_OFF:
case HTML_BODY_ON:
case HTML_IMAGE: // Don't know why Netscape acts this way.
- aUnknownToken.Erase();
+ aUnknownToken = "";
break;
case HTML_TEXTTOKEN:
return;
default:
- aUnknownToken.Erase();
+ aUnknownToken = "";
break;
}
}
@@ -1257,10 +1257,10 @@
switch( nToken )
{
case HTML_BODY_ON:
- if( aStyleSource.Len() )
+ if( !aStyleSource.isEmpty() )
{
pCSS1Parser->ParseStyleSheet( aStyleSource );
- aStyleSource.Erase();
+ aStyleSource = "";
}
if( IsNewDoc() )
{
@@ -1378,8 +1378,8 @@
}
else if( IsReadStyle() )
{
- if( aStyleSource.Len() )
- aStyleSource += '\n';
+ if( !aStyleSource.isEmpty() )
+ aStyleSource += "\n";
aStyleSource += aToken;
}
}
@@ -1450,7 +1450,7 @@
case HTML_TEXTTOKEN:
// insert string without spanning attributes at the end.
- if( aToken.Len() && ' '==aToken.GetChar(0) && !IsReadPRE() )
+ if( !aToken.isEmpty() && ' '==aToken[0] && !IsReadPRE() )
{
xub_StrLen nPos = pPam->GetPoint()->nContent.GetIndex();
if( nPos )
@@ -1459,19 +1459,19 @@
pPam->GetPoint()->nNode.GetNode().GetTxtNode()->GetTxt();
sal_Unicode cLast = rText.GetChar(--nPos);
if( ' ' == cLast || '\x0a' == cLast)
- aToken.Erase(0,1);
+ aToken = aToken.copy(1);
}
else
- aToken.Erase(0,1);
+ aToken = aToken.copy(1);
- if( !aToken.Len() )
+ if( aToken.isEmpty() )
{
bUpperSpace = bUpperSpaceSave;
break;
}
}
- if( aToken.Len() )
+ if( !aToken.isEmpty() )
{
if( !bDocInitalized )
DocumentDetected();
@@ -1885,10 +1885,10 @@
break;
case HTML_HEAD_OFF:
- if( aStyleSource.Len() )
+ if( !aStyleSource.isEmpty() )
{
pCSS1Parser->ParseStyleSheet( aStyleSource );
- aStyleSource.Erase();
+ aStyleSource = "";
}
break;
@@ -1944,15 +1944,15 @@
break;
case HTML_COMMENT:
- if( ( aToken.Len() > 5 ) && ( ! bIgnoreHTMLComments ) )
+ if( ( aToken.getLength() > 5 ) && ( ! bIgnoreHTMLComments ) )
{
// insert as Post-It
// If there are no space characters right behind
// the <!-- and on front of the -->, leave the comment untouched.
- if( ' ' == aToken.GetChar( 3 ) &&
- ' ' == aToken.GetChar( aToken.Len()-3 ) )
+ if( ' ' == aToken[ 3 ] &&
+ ' ' == aToken[ aToken.getLength()-3 ] )
{
- String aComment( aToken.Copy( 3, aToken.Len()-5 ) );
+ String aComment( aToken.copy( 3, aToken.getLength()-5 ) );
InsertComment(comphelper::string::strip(aComment, ' '));
}
else
@@ -2010,9 +2010,9 @@
// does not start with a '!'.
// (but judging from the code, also if does not start with a '%')
// (and also if we're not somewhere we consider PRE)
- if( IsInHeader() && !IsReadPRE() && !aUnknownToken.Len() &&
- sSaveToken.Len() && '!' != sSaveToken.GetChar(0) &&
- '%' != sSaveToken.GetChar(0) )
+ if( IsInHeader() && !IsReadPRE() && aUnknownToken.isEmpty() &&
+ !sSaveToken.isEmpty() && '!' != sSaveToken[0] &&
+ '%' != sSaveToken[0] )
aUnknownToken = sSaveToken;
// no break
@@ -2030,7 +2030,7 @@
if( (HTML_TOKEN_ONOFF & nToken) != 0 && (1 & nToken) != 0 )
aComment += '/';
aComment += sSaveToken;
- if( aToken.Len() )
+ if( !aToken.isEmpty() )
{
UnescapeToken();
(aComment += ' ') += aToken;
@@ -3673,11 +3673,11 @@
switch( rOption.GetToken() )
{
case HTML_O_SIZE:
- if( HTML_FONT_ON==nToken && rOption.GetString().Len() )
+ if( HTML_FONT_ON==nToken && !rOption.GetString().isEmpty() )
{
sal_Int32 nSSize;
- if( '+' == rOption.GetString().GetChar(0) ||
- '-' == rOption.GetString().GetChar(0) )
+ if( '+' == rOption.GetString()[0] ||
+ '-' == rOption.GetString()[0] )
nSSize = nBaseSize + rOption.GetSNumber();
else
nSSize = (sal_Int32)rOption.GetNumber();
@@ -4874,12 +4874,12 @@
break;
case HTML_O_WIDTH:
// erstmal nur als Pixelwerte merken!
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
aSize.Width() = (long)rOption.GetNumber();
break;
case HTML_O_HEIGHT:
// erstmal nur als Pixelwerte merken!
- bPrcHeight = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcHeight = (rOption.GetString().indexOf('%') >= 0);
aSize.Height() = (long)rOption.GetNumber();
break;
case HTML_O_SIZE:
@@ -5257,7 +5257,7 @@
nSize = (sal_uInt16)rOption.GetNumber();
break;
case HTML_O_WIDTH:
- bPrcWidth = (rOption.GetString().Search('%') != STRING_NOTFOUND);
+ bPrcWidth = (rOption.GetString().indexOf('%') >= 0);
nWidth = (sal_uInt16)rOption.GetNumber();
if( bPrcWidth && nWidth>=100 )
{
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index d3e0ab4..8f751db 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -352,20 +352,20 @@
friend class _CellSaveStruct;
friend class _CaptionSaveStruct;
- String aPathToFile;
- String sBaseURL;
- String sSaveBaseURL;
- String aBasicLib;
- String aBasicModule;
- String aScriptSource; // Inhalt des aktuellen Script-Blocks
- String aScriptType; // Type des gelesenen Scripts (StarBasic/VB/JAVA)
- String aScriptURL; // URL eines Scripts
- String aStyleSource; // Inhalt des aktuellen Style-Sheets
- String aContents; // Text des akteullen Marquee, Feldes etc.
- String sTitle;
- String aUnknownToken; // ein gestartetes unbekanntes Token
- String aBulletGrfs[MAXLEVEL];
- String sJmpMark;
+ OUString aPathToFile;
+ OUString sBaseURL;
+ OUString sSaveBaseURL;
+ OUString aBasicLib;
+ OUString aBasicModule;
+ OUString aScriptSource; // Inhalt des aktuellen Script-Blocks
+ OUString aScriptType; // Type des gelesenen Scripts (StarBasic/VB/JAVA)
+ OUString aScriptURL; // URL eines Scripts
+ OUString aStyleSource; // Inhalt des aktuellen Style-Sheets
+ OUString aContents; // Text des akteullen Marquee, Feldes etc.
+ OUString sTitle;
+ OUString aUnknownToken; // ein gestartetes unbekanntes Token
+ OUString aBulletGrfs[MAXLEVEL];
+ OUString sJmpMark;
std::vector<sal_uInt16> aBaseFontStack; // Stack fuer <BASEFONT>
// Bit 0-2: Fontgroesse (1-7)
--
To view, visit https://gerrit.libreoffice.org/4253
To unsubscribe, visit https://gerrit.libreoffice.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I65d84991291fb2ade03132d424ed833a89bbc430
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Norbert Thiebaud <nthiebaud@gmail.com>
Context
- [PATCH] String=>OUString big chunk of paring related code · Norbert Thiebaud (via Code Review)
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.