[Libreoffice-commits] core.git: sw/source

Matteo Casalin matteo.casalin at yahoo.com
Tue Jun 23 15:03:46 PDT 2015


 sw/source/filter/html/swhtml.cxx |   97 ++++++++++++++++++++-------------------
 1 file changed, 52 insertions(+), 45 deletions(-)

New commits:
commit 492ff21d6543d800b0cd424eafbcd409bc19f695
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Mon Jun 8 23:17:50 2015 +0200

    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 at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 9d7b928..1f92ffc 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())


More information about the Libreoffice-commits mailing list