[Libreoffice-commits] .: 7 commits - sw/source

Caolán McNamara caolan at kemper.freedesktop.org
Wed Dec 15 00:58:27 PST 2010


 sw/source/filter/ww8/writerwordglue.cxx |   32 ---------
 sw/source/filter/ww8/ww8atr.cxx         |   18 +++--
 sw/source/filter/ww8/ww8graf.cxx        |    2 
 sw/source/filter/ww8/ww8par.hxx         |    2 
 sw/source/filter/ww8/ww8par2.cxx        |    2 
 sw/source/filter/ww8/ww8par6.cxx        |  113 +++++++++++++++++++++++---------
 sw/source/filter/ww8/ww8scan.cxx        |   25 ++-----
 sw/source/filter/ww8/ww8scan.hxx        |    2 
 8 files changed, 113 insertions(+), 83 deletions(-)

New commits:
commit 68c021727a33ca95e91be8a4bd74acbc5cc1398d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 14 20:30:52 2010 +0000

    tidy this up, and don't bail out on mislength records

diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 5720af2..7807371 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1052,7 +1052,7 @@ SwFrmFmt* SwWW8ImplReader::InsertTxbxText(SdrTextObj* pTextObj,
                                             Read_PicLoc(nAktId, pParams, 1);
                                         break;
                                 }
-                                aSprmIter++;
+                                aSprmIter.advance();
                             }
 
                             if( !nLoop )
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 5b66561..65172b1 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -1964,7 +1964,7 @@ WW8TabDesc::WW8TabDesc(SwWW8ImplReader* pIoClass, WW8_CP nStartCp) :
                     default:
                         ;
                 }
-                aSprmIter++;
+                aSprmIter.advance();
             }
 
             if( !nLoop )
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index f2c8fd6..44f1f69 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -895,22 +895,17 @@ void WW8SprmIter::SetSprms(const BYTE* pSprms_, long nLen_)
     UpdateMyMembers();
 }
 
-const BYTE* WW8SprmIter::operator ++( int )
+void WW8SprmIter::advance()
 {
     if (nRemLen > 0 )
     {
-        if( nRemLen >= nAktSize )
-        {
-            pSprms += nAktSize;
-            nRemLen -= nAktSize;
-            UpdateMyMembers();
-        }
-        else
-        {
-            throw( ::std::exception() );
-        }
+        USHORT nSize = nAktSize;
+        if (nSize > nRemLen)
+            nSize = nRemLen;
+        pSprms += nSize;
+        nRemLen -= nSize;
+        UpdateMyMembers();
     }
-    return pSprms;
 }
 
 void WW8SprmIter::UpdateMyMembers()
@@ -936,7 +931,7 @@ const BYTE* WW8SprmIter::FindSprm(USHORT nId)
     {
         if( GetAktId() == nId )
             return GetAktParams();              // SPRM found!
-        operator ++(0);
+        advance();
     }
 
     return 0;                                   // SPRM _not_ found
@@ -2828,7 +2823,7 @@ bool WW8PLCFx_Fc_FKP::WW8Fkp::HasSprm(USHORT nId,
     {
         if (aIter.GetAktId() == nId)
             rResult.push_back(aIter.GetAktParams());
-        aIter++;
+        aIter.advance();
     };
     return !rResult.empty();
 }
@@ -3151,7 +3146,7 @@ bool WW8PLCFx_Fc_FKP::HasSprm(USHORT nId, std::vector<const BYTE *> &rResult)
         {
             if (aIter.GetAktId() == nId)
                 rResult.push_back(aIter.GetAktParams());
-            aIter++;
+            aIter.advance();
         };
     }
     return !rResult.empty();
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index cf6541f..af19986 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -261,7 +261,7 @@ public:
         const wwSprmParser &rSprmParser);
     void  SetSprms( const BYTE* pSprms_, long nLen_ );
     const BYTE* FindSprm(USHORT nId);
-    const BYTE*  operator ++( int );
+    void  advance();
     const BYTE* GetSprms() const 
         { return ( pSprms && (0 < nRemLen) ) ? pSprms : 0; }
     const BYTE* GetAktParams() const { return pAktParams; }
commit 406eda86c3bac1dd62e360a95396bf33c3fb4600
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 14 16:18:50 2010 +0000

    Related: #i97332# mirror default font to CJK font for WW6

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 9f534c8..4ecb00e 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3749,7 +3749,10 @@ void SwWW8ImplReader::Read_FontCode( USHORT nId, const BYTE* pData, short nLen )
         if( nLen < 0 ) // Ende des Attributes
         {
             if (eVersion <= ww::eWW6)
+            {
                 closeFont(RES_CHRATR_CTL_FONT);
+                closeFont(RES_CHRATR_CJK_FONT);
+            }
             closeFont(nId);
         }
         else
@@ -3757,7 +3760,10 @@ void SwWW8ImplReader::Read_FontCode( USHORT nId, const BYTE* pData, short nLen )
             USHORT nFCode = SVBT16ToShort( pData );     // Font-Nummer
             openFont(nFCode, nId);
             if (eVersion <= ww::eWW6)
+            {
+                openFont(nFCode, RES_CHRATR_CJK_FONT);
                 openFont(nFCode, RES_CHRATR_CTL_FONT);
+            }
         }
     }
 }
commit 9578468eb86e058632b073d23fec50a8facd27cd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 14 15:54:24 2010 +0000

    Resolves: #i101057# Merge WMF and WW6 code page export logic

diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 6f9921a..3e1905c 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -38,7 +38,6 @@
 
 #include <unicode/ubidi.h>          //ubidi_getLogicalRun
 #include <tools/tenccvt.hxx>        //GetExtendedTextEncoding
-#include <i18nutil/unicode.hxx>     //unicode::getUnicodeScriptType
 #include <com/sun/star/i18n/ScriptType.hdl> //ScriptType
 
 #include <unotools/fontcvt.hxx>  //GetSubsFontName
@@ -332,33 +331,6 @@ namespace myImplHelpers
         return sRet;
     }
 
-    /*
-     Utility to categorize unicode characters into the best fit windows charset
-     range for exporting to ww6, or as a hint to non \u unicode token aware rtf
-     readers
-    */
-    rtl_TextEncoding getScriptClass(sal_Unicode cChar)
-    {
-        using namespace ::com::sun::star::i18n;
-
-        static ScriptTypeList aScripts[] =
-        {
-            { UnicodeScript_kBasicLatin, UnicodeScript_kBasicLatin, RTL_TEXTENCODING_MS_1252},
-            { UnicodeScript_kLatin1Supplement, UnicodeScript_kLatin1Supplement, RTL_TEXTENCODING_MS_1252},
-            { UnicodeScript_kLatinExtendedA, UnicodeScript_kLatinExtendedA, RTL_TEXTENCODING_MS_1250},
-            { UnicodeScript_kLatinExtendedB, UnicodeScript_kLatinExtendedB, RTL_TEXTENCODING_MS_1257},
-            { UnicodeScript_kGreek, UnicodeScript_kGreek, RTL_TEXTENCODING_MS_1253},
-            { UnicodeScript_kCyrillic, UnicodeScript_kCyrillic, RTL_TEXTENCODING_MS_1251},
-            { UnicodeScript_kHebrew, UnicodeScript_kHebrew, RTL_TEXTENCODING_MS_1255},
-            { UnicodeScript_kArabic, UnicodeScript_kArabic, RTL_TEXTENCODING_MS_1256},
-            { UnicodeScript_kThai, UnicodeScript_kThai, RTL_TEXTENCODING_MS_1258},
-            { UnicodeScript_kScriptCount, UnicodeScript_kScriptCount, RTL_TEXTENCODING_MS_1252}
-        };
-
-        return unicode::getUnicodeScriptType(cChar, aScripts,
-            RTL_TEXTENCODING_MS_1252);
-    }
-
     //Utility to remove entries before a given starting position
     class IfBeforeStart
         : public std::unary_function<const sw::util::CharRunEntry&, bool>
@@ -613,10 +585,10 @@ namespace sw
                 while (nPos != nLen)
                 {
                     rtl_TextEncoding ScriptType =
-                        myImplHelpers::getScriptClass(rTxt.GetChar(nPos++));
+                        getBestMSEncodingByChar(rTxt.GetChar(nPos++));
                     while (
                             (nPos != nLen) &&
-                            (ScriptType == myImplHelpers::getScriptClass(rTxt.GetChar(nPos)))
+                            (ScriptType == getBestMSEncodingByChar(rTxt.GetChar(nPos)))
                           )
                     {
                         ++nPos;
commit 368be536d195b494ba6924c05ccaba754f5541e6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 14 15:39:15 2010 +0000

    Related: #i114482# For WW6 shadow the CTL bold/posture with the normal one

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index d457700..9f534c8 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2910,7 +2910,8 @@ void SwWW8ImplReader::Read_BoldUsw( USHORT nId, const BYTE* pData, short nLen )
     const int nContigiousWestern = 8;
     const int nWestern = nContigiousWestern + 1;
     const int nEastern = 2;
-    const int nIds = nWestern + nEastern;
+    const int nCTL = 2;
+    const int nIds = nWestern + nEastern + nCTL;
     static const USHORT nEndIds[ nIds ] =
     {
         RES_CHRATR_WEIGHT,          RES_CHRATR_POSTURE,
@@ -2920,7 +2921,9 @@ void SwWW8ImplReader::Read_BoldUsw( USHORT nId, const BYTE* pData, short nLen )
 
         RES_CHRATR_CROSSEDOUT,
 
-        RES_CHRATR_CJK_WEIGHT,      RES_CHRATR_CJK_POSTURE
+        RES_CHRATR_CJK_WEIGHT,      RES_CHRATR_CJK_POSTURE,
+
+        RES_CHRATR_CTL_WEIGHT,      RES_CHRATR_CTL_POSTURE
     };
 
     ww::WordVersion eVersion = pWwFib->GetFIBVersion();
@@ -2944,11 +2947,19 @@ void SwWW8ImplReader::Read_BoldUsw( USHORT nId, const BYTE* pData, short nLen )
 
     if (nLen < 0)
     {
-        pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nI ] );
-        // reset the CJK Weight and Posture, because they are the same as their
-        // western equivalents in word
         if (nI < 2)
+        {
+            if (eVersion <= ww::eWW6)
+            {
+                // reset the CTL Weight and Posture, because they are the same as their
+                // western equivalents in ww6
+                pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nWestern + nEastern + nI ] );
+            }
+            // reset the CJK Weight and Posture, because they are the same as their
+            // western equivalents in word
             pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nWestern + nI ] );
+        }
+        pCtrlStck->SetAttr( *pPaM->GetPoint(), nEndIds[ nI ] );
         pCtrlStck->SetToggleAttr(nI, false);
         return;
     }
@@ -3104,6 +3115,8 @@ void SwWW8ImplReader::SetToggleBiDiAttr(BYTE nAttrId, bool bOn)
 
 void SwWW8ImplReader::SetToggleAttr(BYTE nAttrId, bool bOn)
 {
+    ww::WordVersion eVersion = pWwFib->GetFIBVersion();
+
     switch (nAttrId)
     {
         case 0:
@@ -3112,6 +3125,11 @@ void SwWW8ImplReader::SetToggleAttr(BYTE nAttrId, bool bOn)
                 NewAttr( aAttr );
                 aAttr.SetWhich( RES_CHRATR_CJK_WEIGHT );
                 NewAttr( aAttr );
+                if (eVersion <= ww::eWW6)
+                {
+                    aAttr.SetWhich( RES_CHRATR_CTL_WEIGHT );
+                    NewAttr( aAttr );
+                }
             }
             break;
         case 1:
@@ -3120,6 +3138,11 @@ void SwWW8ImplReader::SetToggleAttr(BYTE nAttrId, bool bOn)
                 NewAttr( aAttr );
                 aAttr.SetWhich( RES_CHRATR_CJK_POSTURE );
                 NewAttr( aAttr );
+                if (eVersion <= ww::eWW6)
+                {
+                    aAttr.SetWhich( RES_CHRATR_CTL_POSTURE );
+                    NewAttr( aAttr );
+                }
             }
             break;
         case 2:
commit 85b4a6e91104ddff450587dbcb9356bb3f70c72f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 14 15:27:31 2010 +0000

    Related: #i114482# For WW6 shadow the CTL font with the normal one

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index a4b6632..6842044 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1441,6 +1441,8 @@ public:     // eigentlich private, geht aber leider nur public
     void Read_SubSuperProp(     USHORT, const BYTE*, short nLen );
     void Read_Underline(        USHORT, const BYTE*, short nLen );
     void Read_TxtColor(         USHORT, const BYTE*, short nLen );
+    void openFont(USHORT nFCode, USHORT nId);
+    void closeFont(USHORT nId);
     void Read_FontCode(         USHORT, const BYTE*, short nLen );
     void Read_FontSize(         USHORT, const BYTE*, short nLen );
     void Read_CharSet(USHORT , const BYTE* pData, short nLen);
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index eb9e8b3..d457700 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3671,6 +3671,29 @@ void SwWW8ImplReader::ResetCJKCharSetVars()
         maFontSrcCJKCharSets.pop();
 }
 
+void SwWW8ImplReader::openFont(USHORT nFCode, USHORT nId)
+{
+    if (SetNewFontAttr(nFCode, true, nId) && pAktColl && pStyles)
+    {
+        // merken zur Simulation Default-Font
+        if (RES_CHRATR_CJK_FONT == nId)
+            pStyles->bCJKFontChanged = true;
+        else if (RES_CHRATR_CTL_FONT == nId)
+            pStyles->bCTLFontChanged = true;
+        else
+            pStyles->bFontChanged = true;
+    }
+}
+
+void SwWW8ImplReader::closeFont(USHORT nId)
+{
+    pCtrlStck->SetAttr( *pPaM->GetPoint(), nId );
+    if (nId == RES_CHRATR_CJK_FONT)
+        ResetCJKCharSetVars();
+    else
+        ResetCharSetVars();
+}
+
 /*
     Font ein oder ausschalten:
 */
@@ -3698,28 +3721,20 @@ void SwWW8ImplReader::Read_FontCode( USHORT nId, const BYTE* pData, short nLen )
                 return ;
         }
 
+        ww::WordVersion eVersion = pWwFib->GetFIBVersion();
+
         if( nLen < 0 ) // Ende des Attributes
         {
-            pCtrlStck->SetAttr( *pPaM->GetPoint(), nId );
-            if (nId == RES_CHRATR_CJK_FONT)
-                ResetCJKCharSetVars();
-            else            
-                ResetCharSetVars();
+            if (eVersion <= ww::eWW6)
+                closeFont(RES_CHRATR_CTL_FONT);
+            closeFont(nId);
         }
         else
         {
             USHORT nFCode = SVBT16ToShort( pData );     // Font-Nummer
-            if (SetNewFontAttr(nFCode, true, nId)   // Lies Inhalt
-                && pAktColl && pStyles )                // Style-Def ?
-            {
-                // merken zur Simulation Default-Font
-                if (RES_CHRATR_CJK_FONT == nId)
-                    pStyles->bCJKFontChanged = true;
-                else if (RES_CHRATR_CTL_FONT == nId)
-                    pStyles->bCTLFontChanged = true;
-                else
-                    pStyles->bFontChanged = true;
-            }
+            openFont(nFCode, nId);
+            if (eVersion <= ww::eWW6)
+                openFont(nFCode, RES_CHRATR_CTL_FONT);
         }
     }
 }
commit 2c52e2f85cfea9e659c5efa47cef694cf7ddefc8
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 14 15:13:00 2010 +0000

    Related: #i114482# For WW6 shadow the CTL fontsize with the normal one

diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 74bf894..eb9e8b3 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3680,17 +3680,17 @@ void SwWW8ImplReader::Read_FontCode( USHORT nId, const BYTE* pData, short nLen )
     {                       // (siehe sprmCSymbol) gesetzte Font !
         switch( nId )
         {
-            case 113:
+            case 113:       //WW7
             case 0x4A51:    //"Other" font, override with BiDi if it exists
             case 0x4A5E:    //BiDi Font
                 nId = RES_CHRATR_CTL_FONT;
                 break;
-            case 93:
-            case 111:
+            case 93:        //WW6
+            case 111:       //WW7
             case 0x4A4f:
                 nId = RES_CHRATR_FONT;
                 break;
-            case 112:
+            case 112:       //WW7
             case 0x4A50:
                 nId = RES_CHRATR_CJK_FONT;
                 break;
@@ -3733,8 +3733,8 @@ void SwWW8ImplReader::Read_FontSize( USHORT nId, const BYTE* pData, short nLen )
         case 0x4a43:
             nId = RES_CHRATR_FONTSIZE;
             break;
-        case 85:
-        case 116:
+        case 85:  //WW2
+        case 116: //WW7
         case 0x4a61:
             nId = RES_CHRATR_CTL_FONTSIZE;
             break;
@@ -3742,34 +3742,45 @@ void SwWW8ImplReader::Read_FontSize( USHORT nId, const BYTE* pData, short nLen )
             return ;
     }
 
+    ww::WordVersion eVersion = pWwFib->GetFIBVersion();
+
     if( nLen < 0 )          // Ende des Attributes
     {
         pCtrlStck->SetAttr( *pPaM->GetPoint(), nId  );
-        if( RES_CHRATR_FONTSIZE == nId )  // reset additional the CJK size
+        if (eVersion <= ww::eWW6) // reset additionally the CTL size
+            pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_CTL_FONTSIZE );
+        if (RES_CHRATR_FONTSIZE == nId)  // reset additionally the CJK size
             pCtrlStck->SetAttr( *pPaM->GetPoint(), RES_CHRATR_CJK_FONTSIZE );
     }
     else
     {
-        ww::WordVersion eVersion = pWwFib->GetFIBVersion();
-
         // Font-Size in half points e.g. 10 = 1440 / ( 72 * 2 )
         USHORT nFSize = eVersion <= ww::eWW2 ? *pData : SVBT16ToShort(pData);
         nFSize*= 10;
 
         SvxFontHeightItem aSz( nFSize, 100, nId );
         NewAttr( aSz );
-        if( RES_CHRATR_FONTSIZE == nId )  // set additional the CJK size
+        if (RES_CHRATR_FONTSIZE == nId)  // set additionally the CJK size
         {
             aSz.SetWhich( RES_CHRATR_CJK_FONTSIZE );
             NewAttr( aSz );
         }
+        if (eVersion <= ww::eWW6) // set additionally the CTL size
+        {
+            aSz.SetWhich( RES_CHRATR_CTL_FONTSIZE );
+            NewAttr( aSz );
+        }
         if (pAktColl && pStyles)            // Style-Def ?
         {
             // merken zur Simulation Default-FontSize
             if (nId == RES_CHRATR_CTL_FONTSIZE)
                 pStyles->bFCTLSizeChanged = true;
             else
+            {
                 pStyles->bFSizeChanged = true;
+                if (eVersion <= ww::eWW6)
+                    pStyles->bFCTLSizeChanged= true;
+            }
         }
     }
 }
commit 83fe5e604f5b3247c152f64042b0d0ea6dd88799
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Dec 14 14:29:01 2010 +0000

    Related: #i114482# for Word6/95 use CTL font as font when script is CTL

diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index c4cfabf..43c3889 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1080,20 +1080,26 @@ void WW8AttributeOutput::CharFont( const SvxFontItem& rFont )
 
 void WW8AttributeOutput::CharFontCTL( const SvxFontItem& rFont )
 {
+    //Can only export in 8+, in 7- export as normal varient and expect that
+    //upperlevel code has blocked exporting clobbering attributes
+    USHORT nFontID = m_rWW8Export.GetId( rFont );
     if ( m_rWW8Export.bWrtWW8 )
-    {
         m_rWW8Export.InsUInt16( NS_sprm::LN_CFtcBi );
-        m_rWW8Export.InsUInt16( m_rWW8Export.GetId( rFont ) );
-    }
+    else
+        m_rWW8Export.pO->Insert( 93, m_rWW8Export.pO->Count() );
+    m_rWW8Export.InsUInt16( nFontID );
 }
 
 void WW8AttributeOutput::CharFontCJK( const SvxFontItem& rFont )
 {
+    //Can only export in 8+, in 7- export as normal varient and expect that
+    //upperlevel code has blocked exporting clobbering attributes
+    USHORT nFontID = m_rWW8Export.GetId( rFont );
     if ( m_rWW8Export.bWrtWW8 )
-    {
         m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc1 );
-        m_rWW8Export.InsUInt16( m_rWW8Export.GetId( rFont ) );
-    }
+    else
+        m_rWW8Export.pO->Insert( 93, m_rWW8Export.pO->Count() );
+    m_rWW8Export.InsUInt16( nFontID );
 }
 
 void WW8AttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )


More information about the Libreoffice-commits mailing list