Change String to OUString in SwHTMLParser class

I changed some variables in SwHTMLParser class and her dependencies.

Change-Id: Ie8ad6c481df8a904bd358c2e9cd6afeef990d418
Reviewed-on: https://gerrit.libreoffice.org/5330
Reviewed-by: Tor Lillqvist <tml@iki.fi>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
This commit is contained in:
Palenik Mihály
2013-08-09 13:51:08 +02:00
committed by Michael Stahl
parent a745bfdb78
commit 7a504c8752
10 changed files with 115 additions and 119 deletions

View File

@@ -252,13 +252,13 @@ public:
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 rtl_TextEncoding GetEncodingByHttpHeader( SvKeyValueIterator *pHTTPHeader );

View File

@@ -36,19 +36,19 @@ static HTMLOptionEnum const aScriptLangOptEnums[] =
{ 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,71 @@ bool HTMLParser::ParseScriptOptions( String& rLangString, const String& rBaseURL
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.isEmpty() &&
( ' '==(c=rString[0]) || '\t'==c || '\r'==c || '\n'==c ) )
rString = rString.copy( 1, rString.getLength() - 1 );
while( rString.Len() &&
( ' '==(c=rString.GetChar( rString.Len()-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 );
++nPos;
rString = rString.copy( nPos, rString.getLength() - nPos );
}
if( rString.Len() >=3 &&
rString.Copy(rString.Len()-3).CompareToAscii("-->")
== COMPARE_EQUAL )
if( rString.getLength() >=3 &&
rString.endsWith("-->") )
{
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.endsWith("//") )
{
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 );
}
}
}

View File

@@ -63,7 +63,7 @@ void SwHTMLParser::NewScript()
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 @@ void SwHTMLParser::EndScript()
(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 @@ void SwHTMLParser::EndScript()
// get library name
OUString aLibName;
if( aBasicLib.Len() )
if( !aBasicLib.isEmpty() )
aLibName = aBasicLib;
else
aLibName = OUString("Standard");
@@ -136,13 +136,13 @@ void SwHTMLParser::EndScript()
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,12 +172,12 @@ void SwHTMLParser::EndScript()
}
}
aScriptSource.Erase();
aScriptType.Erase();
aScriptURL.Erase();
aScriptSource = "";
aScriptType = "";
aScriptURL = "";
aBasicLib.Erase();
aBasicModule.Erase();
aBasicLib = "";
aBasicModule = "";
}
void SwHTMLParser::AddScriptSource()
@@ -187,7 +187,7 @@ void SwHTMLParser::AddScriptSource()
(HTML_SL_STARBASIC==eScriptLang && aToken.GetChar( 0 ) == '\'') )
{
xub_StrLen nPos = STRING_NOTFOUND;
if( !aBasicLib.Len() )
if( aBasicLib.isEmpty() )
{
nPos = aToken.SearchAscii( OOO_STRING_SVTOOLS_HTML_SB_library );
if( nPos != STRING_NOTFOUND )
@@ -198,7 +198,7 @@ void SwHTMLParser::AddScriptSource()
}
}
if( !aBasicModule.Len() && nPos==STRING_NOTFOUND )
if( aBasicModule.isEmpty() && nPos==STRING_NOTFOUND )
{
nPos = aToken.SearchAscii( OOO_STRING_SVTOOLS_HTML_SB_module );
if( nPos != STRING_NOTFOUND )
@@ -211,17 +211,17 @@ void SwHTMLParser::AddScriptSource()
if( nPos==STRING_NOTFOUND )
{
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.Len() )
{
// Leerzeilen am Anfang werden ignoriert
if( aScriptSource.Len() )
if( !aScriptSource.isEmpty() )
{
aScriptSource += '\n';
aScriptSource += "\n";
}
else
{

View File

@@ -1708,10 +1708,10 @@ void SwHTMLParser::EndStyle()
{
bIgnoreRawData = sal_False;
if( aStyleSource.Len() )
if( !aStyleSource.isEmpty() )
{
pCSS1Parser->ParseStyleSheet( aStyleSource );
aStyleSource.Erase();
aStyleSource = "";
}
}

View File

@@ -261,7 +261,7 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
{
OSL_ENSURE( !pMarquee, "Marquee in Marquee???" );
aContents.Erase();
aContents = "";
String aId, aStyle, aClass;
@@ -572,7 +572,7 @@ void SwHTMLParser::EndMarquee()
((SdrTextObj*)pMarquee)->FitFrameToTextSize();
}
aContents.Erase();
aContents = "";
pMarquee = 0;
}

View File

@@ -574,7 +574,7 @@ void SwHTMLParser::EndField()
}
bInField = sal_False;
aContents.Erase();
aContents = "";
}
void SwHTMLParser::InsertFieldText()
@@ -588,18 +588,15 @@ void SwHTMLParser::InsertFieldText()
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 );
OUString aTmp( aContents );
aContents = "HTML: <" + OUString( *pTag ) + ">" + aTmp;
}
}

View File

@@ -433,7 +433,7 @@ IMAGE_SETEVENT:
// 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();

View File

@@ -279,7 +279,7 @@ void SwHTMLParser::NewNumBulList( int nToken )
bChangeNumFmt = sal_True;
}
else
aBulletGrfs[nLevel].Erase();
aBulletGrfs[nLevel] = "";
// den aktuellen Absatz erst einmal nicht numerieren
{

View File

@@ -238,8 +238,8 @@ sal_uLong HTMLReader::Read( SwDoc &rDoc, const String& rBaseURL, SwPaM &rPam, co
SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCrsr, SvStream& rIn,
const String& rPath,
const String& rBaseURL,
const OUString& rPath,
const OUString& rBaseURL,
int bReadNewDoc,
SfxMedium* pMed, sal_Bool bReadUTF8,
sal_Bool bNoHTMLComments )
@@ -370,19 +370,17 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCrsr, SvStream& rIn,
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 )) )
nPos = nLastPos;
sal_Int32 nLastPos = sJmpMark.lastIndexOf( cMarkSeparator );
sal_Int32 nPos = nLastPos != -1 ? nLastPos : 0;
String sCmp;
if (nPos)
{
sCmp = comphelper::string::remove(
sJmpMark.Copy(nPos + 1), ' ');
sJmpMark.copy(nPos + 1), ' ');
}
if( sCmp.Len() )
@@ -400,13 +398,14 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCrsr, SvStream& rIn,
eJumpTo = JUMPTO_NONE; // das ist nichts gueltiges!
else
// ansonsten ist das ein normaler (Book)Mark
nPos = STRING_LEN;
nPos = -1;
}
else
nPos = STRING_LEN;
nPos = -1;
sJmpMark.Erase( nPos );
if( !sJmpMark.Len() )
if( nPos != -1 )
sJmpMark = sJmpMark.copy( 0, nPos );
if( sJmpMark.isEmpty() )
eJumpTo = JUMPTO_NONE;
}
}
@@ -639,7 +638,7 @@ void SwHTMLParser::Continue( int nToken )
{
// noch die letzten Attribute setzen
{
if( aScriptSource.Len() )
if( !aScriptSource.isEmpty() )
{
SwScriptFieldType *pType =
(SwScriptFieldType*)pDoc->GetSysFldType( RES_SCRIPTFLD );
@@ -988,7 +987,7 @@ void SwHTMLParser::NextToken( int nToken )
switch( nToken )
{
case HTML_TITLE_OFF:
if( IsNewDoc() && sTitle.Len() )
if( IsNewDoc() && !sTitle.isEmpty() )
{
if( pDoc->GetDocShell() ) {
uno::Reference<document::XDocumentPropertiesSupplier>
@@ -1005,15 +1004,15 @@ void SwHTMLParser::NextToken( int nToken )
}
}
bInTitle = sal_False;
sTitle.Erase();
sTitle = "";
break;
case HTML_NONBREAKSPACE:
sTitle += ' ';
sTitle += " ";
break;
case HTML_SOFTHYPH:
sTitle += '-';
sTitle += "-";
break;
case HTML_TEXTTOKEN:
@@ -1021,16 +1020,16 @@ void SwHTMLParser::NextToken( int nToken )
break;
default:
sTitle += '<';
sTitle += "<";
if( (HTML_TOKEN_ONOFF & nToken) && (1 & nToken) )
sTitle += '/';
sTitle += "/";
sTitle += sSaveToken;
if( aToken.Len() )
{
sTitle += ' ';
sTitle += " ";
sTitle += aToken;
}
sTitle += '>';
sTitle += ">";
break;
}
@@ -1071,7 +1070,7 @@ void SwHTMLParser::NextToken( int nToken )
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;
@@ -1212,7 +1211,7 @@ void SwHTMLParser::NextToken( int nToken )
}
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
@@ -1236,18 +1235,18 @@ void SwHTMLParser::NextToken( int nToken )
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;
}
}
@@ -1256,10 +1255,10 @@ void SwHTMLParser::NextToken( int nToken )
switch( nToken )
{
case HTML_BODY_ON:
if( aStyleSource.Len() )
if( !aStyleSource.isEmpty() )
{
pCSS1Parser->ParseStyleSheet( aStyleSource );
aStyleSource.Erase();
aStyleSource = "";
}
if( IsNewDoc() )
{
@@ -1377,8 +1376,8 @@ void SwHTMLParser::NextToken( int nToken )
}
else if( IsReadStyle() )
{
if( aStyleSource.Len() )
aStyleSource += '\n';
if( !aStyleSource.isEmpty() )
aStyleSource += "\n";
aStyleSource += aToken;
}
}
@@ -1884,10 +1883,10 @@ void SwHTMLParser::NextToken( int nToken )
break;
case HTML_HEAD_OFF:
if( aStyleSource.Len() )
if( !aStyleSource.isEmpty() )
{
pCSS1Parser->ParseStyleSheet( aStyleSource );
aStyleSource.Erase();
aStyleSource = "";
}
break;
@@ -2009,7 +2008,7 @@ void SwHTMLParser::NextToken( int nToken )
// 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() &&
if( IsInHeader() && !IsReadPRE() && aUnknownToken.isEmpty() &&
sSaveToken.Len() && '!' != sSaveToken.GetChar(0) &&
'%' != sSaveToken.GetChar(0) )
aUnknownToken = sSaveToken;

View File

@@ -352,20 +352,20 @@ class SwHTMLParser : public SfxHTMLParser, public SwClient
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)
@@ -895,8 +895,8 @@ protected:
public:
SwHTMLParser( SwDoc* pD, SwPaM & rCrsr, SvStream& rIn,
const String& rFileName,
const String& rBaseURL,
const OUString& rFileName,
const OUString& rBaseURL,
int bReadNewDoc = sal_True,
SfxMedium* pMed = 0, sal_Bool bReadUTF8 = sal_False,
sal_Bool bIgnoreHTMLComments = sal_False );