summaryrefslogtreecommitdiff
path: root/sw/source/filter/html/swhtml.cxx
diff options
context:
space:
mode:
authorMatteo Casalin <matteo.casalin@yahoo.com>2015-06-08 23:17:50 +0200
committerMichael Stahl <mstahl@redhat.com>2015-06-23 22:03:22 +0000
commit492ff21d6543d800b0cd424eafbcd409bc19f695 (patch)
treeefd8feacdfa0de1ca76f11bed0d1c66158f888ab /sw/source/filter/html/swhtml.cxx
parentc7811b9d36c0d9b2a000cf1616e473de474ad112 (diff)
sw: HTML import: Do not mix normal, CTL or CJK attributes
The original code used 15 elements for positions, the 'repaired' one lost 10 of them. Also, do not try to be too smart and be verbose, letting the compiler perform optimizations (regression from 1b0f7ee1e04d7b0fe81f7458ae2116615e0f6889) Change-Id: I0a1bc22d1abab083292de17b091c8be872fcee24 Reviewed-on: https://gerrit.libreoffice.org/16169 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw/source/filter/html/swhtml.cxx')
-rw-r--r--sw/source/filter/html/swhtml.cxx97
1 files changed, 52 insertions, 45 deletions
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 9d7b928d33f9..1f92ffce742a 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2293,58 +2293,65 @@ bool SwHTMLParser::AppendTextNode( SwHTMLAppendMode eMode, bool bUpdateNum )
SwTextAttr *pHt = rHints.GetTextHint( i );
sal_uInt16 nWhich = pHt->Which();
sal_Int16 nIdx = -1;
- //In 'hintids.hxx', the following five attributes don't follow
- //each other in the Latin attributes as they do among CJK and
- //CTL attributes, so the old code just made a mess, IMHO.
- //E.g. 29-22=7, which should be LANGUAGE, but it's FONT.
- //Moreover, it should occur between 0 and 4.
- //Since it would be too risky to change the attribute codes,
- //I repaired the following source code the 'brute force' way.
-
- //Old code:
- /*
- if( RES_CHRATR_CJK_FONT <= nWhich &&
- nWhich <= RES_CHRATR_CTL_WEIGHT )
+ bool bFont = false;
+ switch( nWhich )
{
- nIdx = static_cast< sal_uInt16 >(nWhich - RES_CHRATR_CJK_FONT + 5);
- }
- else switch...
- */
-
- if( RES_CHRATR_CJK_FONT == nWhich || RES_CHRATR_CTL_FONT == nWhich )
- {
- nIdx = 0;
- }
- else if( RES_CHRATR_CJK_FONTSIZE == nWhich || RES_CHRATR_CTL_FONTSIZE == nWhich )
- {
- nIdx = 1;
- }
- else if( RES_CHRATR_CJK_LANGUAGE == nWhich || RES_CHRATR_CTL_LANGUAGE == nWhich )
- {
- nIdx = 2;
- }
- else if( RES_CHRATR_CJK_POSTURE == nWhich || RES_CHRATR_CTL_POSTURE == nWhich )
- {
- nIdx = 3;
- }
- else if( RES_CHRATR_CJK_WEIGHT == nWhich || RES_CHRATR_CTL_WEIGHT == nWhich )
- {
- nIdx = 4;
- }
- else switch( nWhich )
- {
- case RES_CHRATR_FONT: nIdx = 0; break;
- case RES_CHRATR_FONTSIZE: nIdx = 1; break;
- case RES_CHRATR_LANGUAGE: nIdx = 2; break;
- case RES_CHRATR_POSTURE: nIdx = 3; break;
- case RES_CHRATR_WEIGHT: nIdx = 4; break;
+ case RES_CHRATR_FONT:
+ nIdx = 0;
+ bFont = true;
+ break;
+ case RES_CHRATR_FONTSIZE:
+ nIdx = 1;
+ break;
+ case RES_CHRATR_LANGUAGE:
+ nIdx = 2;
+ break;
+ case RES_CHRATR_POSTURE:
+ nIdx = 3;
+ break;
+ case RES_CHRATR_WEIGHT:
+ nIdx = 4;
+ break;
+ case RES_CHRATR_CJK_FONT:
+ nIdx = 5;
+ bFont = true;
+ break;
+ case RES_CHRATR_CJK_FONTSIZE:
+ nIdx = 6;
+ break;
+ case RES_CHRATR_CJK_LANGUAGE:
+ nIdx = 7;
+ break;
+ case RES_CHRATR_CJK_POSTURE:
+ nIdx = 8;
+ break;
+ case RES_CHRATR_CJK_WEIGHT:
+ nIdx = 9;
+ break;
+ case RES_CHRATR_CTL_FONT:
+ nIdx = 10;
+ bFont = true;
+ break;
+ case RES_CHRATR_CTL_FONTSIZE:
+ nIdx = 11;
+ break;
+ case RES_CHRATR_CTL_LANGUAGE:
+ nIdx = 12;
+ break;
+ case RES_CHRATR_CTL_POSTURE:
+ nIdx = 13;
+ break;
+ case RES_CHRATR_CTL_WEIGHT:
+ nIdx = 14;
+ break;
+ default:
+ break;
}
if( nIdx != -1 )
{
sal_Int32 nStt = pHt->GetStart();
if( nStt >= aEndPos[nIdx] )
{
- bool bFont = (nIdx % 5) == 0;
const SfxPoolItem& rItem =
static_cast<const SwContentNode *>(pTextNd)->GetAttr( nWhich );
if( bFont ? swhtml_css1atr_equalFontItems(rItem,pHt->GetAttr())