[Libreoffice-commits] core.git: sw/source
Jan Holesovsky
kendy at collabora.com
Tue Feb 25 13:30:55 PST 2014
sw/source/filter/html/css1atr.cxx | 253 ++++++++++++++++----------------------
sw/source/filter/html/htmlatr.cxx | 75 ++++-------
2 files changed, 142 insertions(+), 186 deletions(-)
New commits:
commit 5dee438cc2f1dc48c7bcca963f17dc797e8fb0fe
Author: Jan Holesovsky <kendy at collabora.com>
Date: Tue Feb 25 22:07:44 2014 +0100
html: Another problem caused by lowercasing the tags.
Let's convert the switches to full comprison; it's future-proof, and the
performance difference here is not critical.
Change-Id: I1541acdc89312806f4bf05226efb3a42e81f8019
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 222fd21..972152d 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -670,134 +670,107 @@ sal_uInt16 SwHTMLWriter::GetCSS1Selector( const SwFmt *pFmt, OString& rToken,
if( USER_FMT & nPoolId )
{
// Benutzer-Vorlagen
- const OUString aNm = pPFmt->GetName();
- switch( aNm[0] )
+ const OUString aNm(pPFmt->GetName());
+
+ if (!bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_blockquote)
{
- // nicht mehr unterstuetzt:
- // OOO_STRING_SVTOOLS_HTML_author
- // OOO_STRING_SVTOOLS_HTML_acronym
- // OOO_STRING_SVTOOLS_HTML_abbreviation
- // OOO_STRING_SVTOOLS_HTML_deletedtext
- // OOO_STRING_SVTOOLS_HTML_insertedtext
- // OOO_STRING_SVTOOLS_HTML_language
- // OOO_STRING_SVTOOLS_HTML_person
- case 'B': if( !bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_blockquote )
- {
- rRefPoolId = RES_POOLCOLL_HTML_BLOCKQUOTE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_blockquote);
- }
- break;
- case 'C': if( bChrFmt )
- {
- if( aNm == OOO_STRING_SVTOOLS_HTML_citiation )
- {
- rRefPoolId = RES_POOLCHR_HTML_CITIATION;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_citiation);
- }
- else if( aNm == OOO_STRING_SVTOOLS_HTML_code )
- {
- rRefPoolId = RES_POOLCHR_HTML_CODE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_code);
- }
- }
- break;
- case 'D': if( bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_definstance )
- {
- rRefPoolId = RES_POOLCHR_HTML_DEFINSTANCE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_definstance);
- }
- else if( !bChrFmt )
- {
- sal_uInt16 nDefListLvl = GetDefListLvl( aNm, nPoolId );
- // Die Vorlagen DD 1/DT 1 werden ausgegeben,
- // aber keine von ihnen abgeleiteten Vorlagen,
- // auch nicht DD 2/DT 2 etc.
- if( nDefListLvl )
- {
- if( pPseudo &&
- (nDeep || (nDefListLvl & 0x0fff) > 1) )
- {
- bStop = true;
- }
- else if( nDefListLvl & HTML_DLCOLL_DD )
- {
- rRefPoolId = RES_POOLCOLL_HTML_DD;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_dd);
- }
- else
- {
- rRefPoolId = RES_POOLCOLL_HTML_DT;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_dt);
- }
- }
- }
- break;
- case 'E': if( bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_emphasis )
- {
- rRefPoolId = RES_POOLCHR_HTML_EMPHASIS;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_emphasis);
- }
- break;
- case 'H': if( !bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_horzrule )
- // HR nicht ausgeben!
- bStop = (nDeep==0);
- break;
- case 'K': if( bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_keyboard )
- {
- rRefPoolId = RES_POOLCHR_HTML_KEYBOARD;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_keyboard);
- }
- break;
- case 'L': if( !bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_listing )
- {
- // Listing als PRE exportieren bzw. von
- // PRE abgeleitete Vorlage exportieren
- rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
- rRefPoolId = RES_POOLCOLL_HTML_PRE;
- nDeep = CSS1_FMT_CMPREF;
- }
- break;
- case 'P': if( !bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_preformtxt )
- {
- rRefPoolId = RES_POOLCOLL_HTML_PRE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
- }
- break;
- case 'S': if( bChrFmt )
- {
- if( aNm == OOO_STRING_SVTOOLS_HTML_sample )
- {
- rRefPoolId = RES_POOLCHR_HTML_SAMPLE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_sample);
- }
- else if( aNm == OOO_STRING_SVTOOLS_HTML_strong )
- {
- rRefPoolId = RES_POOLCHR_HTML_STRONG;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_strong);
- }
- }
- break;
- case 'T': if( bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_teletype )
- {
- rRefPoolId = RES_POOLCHR_HTML_TELETYPE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_teletype);
- }
- break;
- case 'V': if( bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_variable )
- {
- rRefPoolId = RES_POOLCHR_HTML_VARIABLE;
- rToken = OString(OOO_STRING_SVTOOLS_HTML_variable);
- }
- break;
- case 'X': if( !bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_xmp )
- {
- // XMP als PRE exportieren (aber nicht die
- // Vorlage als Style)
- rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
- rRefPoolId = RES_POOLCOLL_HTML_PRE;
- nDeep = CSS1_FMT_CMPREF;
- }
- break;
+ rRefPoolId = RES_POOLCOLL_HTML_BLOCKQUOTE;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_blockquote);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_citiation)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_CITIATION;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_citiation);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_code)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_CODE;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_code);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_definstance)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_DEFINSTANCE;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_definstance);
+ }
+ else if (!bChrFmt && (aNm == OOO_STRING_SVTOOLS_HTML_dd || OOO_STRING_SVTOOLS_HTML_dt))
+ {
+ sal_uInt16 nDefListLvl = GetDefListLvl(aNm, nPoolId);
+ // Die Vorlagen DD 1/DT 1 werden ausgegeben,
+ // aber keine von ihnen abgeleiteten Vorlagen,
+ // auch nicht DD 2/DT 2 etc.
+ if (nDefListLvl)
+ {
+ if (pPseudo && (nDeep || (nDefListLvl & 0x0fff) > 1))
+ {
+ bStop = true;
+ }
+ else if (nDefListLvl & HTML_DLCOLL_DD)
+ {
+ rRefPoolId = RES_POOLCOLL_HTML_DD;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_dd);
+ }
+ else
+ {
+ rRefPoolId = RES_POOLCOLL_HTML_DT;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_dt);
+ }
+ }
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_emphasis)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_EMPHASIS;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_emphasis);
+ }
+ else if (!bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_horzrule)
+ {
+ // HR nicht ausgeben!
+ bStop = (nDeep==0);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_keyboard)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_KEYBOARD;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_keyboard);
+ }
+ else if (!bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_listing)
+ {
+ // Listing als PRE exportieren bzw. von
+ // PRE abgeleitete Vorlage exportieren
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
+ rRefPoolId = RES_POOLCOLL_HTML_PRE;
+ nDeep = CSS1_FMT_CMPREF;
+ }
+ else if (!bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_preformtxt)
+ {
+ rRefPoolId = RES_POOLCOLL_HTML_PRE;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_sample)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_SAMPLE;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_sample);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_strong)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_STRONG;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_strong);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_teletype)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_TELETYPE;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_teletype);
+ }
+ else if (bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_variable)
+ {
+ rRefPoolId = RES_POOLCHR_HTML_VARIABLE;
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_variable);
+ }
+ else if (!bChrFmt && aNm == OOO_STRING_SVTOOLS_HTML_xmp)
+ {
+ // XMP als PRE exportieren (aber nicht die
+ // Vorlage als Style)
+ rToken = OString(OOO_STRING_SVTOOLS_HTML_preformtxt);
+ rRefPoolId = RES_POOLCOLL_HTML_PRE;
+ nDeep = CSS1_FMT_CMPREF;
}
// Wenn eine PoolId gesetzt ist, entspricht der Name der
@@ -1625,22 +1598,16 @@ static Writer& OutCSS1_SwFmt( Writer& rWrt, const SwFmt& rFmt,
if( USER_FMT & nPoolFmtId )
{
// Benutzer-Vorlagen
- const OUString aNm = rFmt.GetName();
- switch( aNm[0] )
- {
- case 'D': if( aNm == "DD 1" || aNm == "DT 1" )
- rHTMLWrt.nDfltBottomMargin = 0;
- break;
- case 'L': if(aNm == OOO_STRING_SVTOOLS_HTML_listing )
- rHTMLWrt.nDfltBottomMargin = 0;
- break;
- case 'P': if( aNm == OOO_STRING_SVTOOLS_HTML_preformtxt )
- rHTMLWrt.nDfltBottomMargin = 0;
- break;
- case 'X': if( aNm == OOO_STRING_SVTOOLS_HTML_xmp )
- rHTMLWrt.nDfltBottomMargin = 0;
- break;
- }
+ const OUString aNm(rFmt.GetName());
+
+ if (aNm == "DD 1" || aNm == "DT 1")
+ rHTMLWrt.nDfltBottomMargin = 0;
+ else if (aNm == OOO_STRING_SVTOOLS_HTML_listing)
+ rHTMLWrt.nDfltBottomMargin = 0;
+ else if (aNm == OOO_STRING_SVTOOLS_HTML_preformtxt)
+ rHTMLWrt.nDfltBottomMargin = 0;
+ else if (aNm == OOO_STRING_SVTOOLS_HTML_xmp)
+ rHTMLWrt.nDfltBottomMargin = 0;
}
else
{
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 2d87eba..a274a7d 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -540,50 +540,39 @@ void OutHTML_SwFmt( Writer& rWrt, const SwFmt& rFmt,
// solchen abgeleitet
rInfo.aToken = pFmtInfo->aToken;
- // der erste Buchstabe reicht meistens
- switch( rInfo.aToken[0] )
+ if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_address)
{
- case 'A': OSL_ENSURE( rInfo.aToken == OOO_STRING_SVTOOLS_HTML_address,
- "Doch kein ADDRESS?" );
- rInfo.bParaPossible = sal_True;
- rHWrt.bNoAlign = sal_True;
- break;
-
- case 'B': OSL_ENSURE( rInfo.aToken == OOO_STRING_SVTOOLS_HTML_blockquote,
- "Doch kein BLOCKQUOTE?" );
- rInfo.bParaPossible = sal_True;
- rHWrt.bNoAlign = sal_True;
- break;
-
- case 'P': if( rInfo.aToken.getLength() == 1 )
- {
- bPara = sal_True;
- }
- else
- {
- OSL_ENSURE( rInfo.aToken == OOO_STRING_SVTOOLS_HTML_preformtxt,
- "Doch kein PRE?" );
- if( HTML_PREFORMTXT_ON == rHWrt.nLastParaToken )
- {
- bOutNewLine = sal_True;
- }
- else
- {
- nToken = HTML_PREFORMTXT_ON;
- rHWrt.bNoAlign = sal_True;
- bNoEndTag = sal_True;
- }
- }
- break;
-
- case 'D': OSL_ENSURE( rInfo.aToken == OOO_STRING_SVTOOLS_HTML_dt ||
- rInfo.aToken == OOO_STRING_SVTOOLS_HTML_dd,
- "Doch kein DD/DT?" );
- bDT = rInfo.aToken == OOO_STRING_SVTOOLS_HTML_dt;
- rInfo.bParaPossible = !bDT;
- rHWrt.bNoAlign = sal_True;
- bForceDL = sal_True;
- break;
+ rInfo.bParaPossible = sal_True;
+ rHWrt.bNoAlign = sal_True;
+ }
+ else if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_blockquote)
+ {
+ rInfo.bParaPossible = sal_True;
+ rHWrt.bNoAlign = sal_True;
+ }
+ else if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_parabreak)
+ {
+ bPara = sal_True;
+ }
+ else if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_preformtxt)
+ {
+ if (HTML_PREFORMTXT_ON == rHWrt.nLastParaToken)
+ {
+ bOutNewLine = sal_True;
+ }
+ else
+ {
+ nToken = HTML_PREFORMTXT_ON;
+ rHWrt.bNoAlign = sal_True;
+ bNoEndTag = sal_True;
+ }
+ }
+ else if (rInfo.aToken == OOO_STRING_SVTOOLS_HTML_dt || rInfo.aToken == OOO_STRING_SVTOOLS_HTML_dd)
+ {
+ bDT = rInfo.aToken == OOO_STRING_SVTOOLS_HTML_dt;
+ rInfo.bParaPossible = !bDT;
+ rHWrt.bNoAlign = sal_True;
+ bForceDL = sal_True;
}
}
else
More information about the Libreoffice-commits
mailing list