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

Matteo Casalin matteo.casalin at yahoo.com
Sun Sep 1 12:04:11 PDT 2013


 sw/source/filter/ww8/ww8par.hxx   |    2 
 sw/source/filter/ww8/ww8par2.cxx  |    2 
 sw/source/filter/ww8/ww8par5.cxx  |    4 -
 sw/source/filter/ww8/ww8par6.cxx  |   80 ++++++++++++--------------------------
 sw/source/filter/ww8/ww8scan.cxx  |   30 ++++++--------
 sw/source/filter/ww8/ww8struc.hxx |    2 
 6 files changed, 45 insertions(+), 75 deletions(-)

New commits:
commit b0db7c60f12c0eb9931856507b40332086d42106
Author: Matteo Casalin <matteo.casalin at yahoo.com>
Date:   Sat Aug 31 15:25:24 2013 +0200

    String to OUString
    
    Change-Id: Ibb2489e4e895f3f855208fe20749f7078a360710
    Reviewed-on: https://gerrit.libreoffice.org/5737
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 4613727..4409fdb 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -1344,7 +1344,7 @@ private:
                   const bool bFirstLineOfStSet = false,
                   const bool bLeftIndentSet = false );
 
-    bool GetFontParams(sal_uInt16, FontFamily&, String&, FontPitch&,
+    bool GetFontParams(sal_uInt16, FontFamily&, OUString&, FontPitch&,
         rtl_TextEncoding&);
     bool SetNewFontAttr(sal_uInt16 nFCode, bool bSetEnums, sal_uInt16 nWhich);
     void ResetCharSetVars();
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 3bf32a7..955266e 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -645,7 +645,7 @@ void SwWW8ImplReader::SetAnlvStrings(SwNumFmt &rNum, WW8_ANLV &rAV,
         if( bListSymbol )
         {
             FontFamily eFamily;
-            String aName;
+            OUString aName;
             FontPitch ePitch;
 
             if( GetFontParams( SVBT16ToShort( rAV.ftc ), eFamily, aName,
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index ea6cd21..c4383ed 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -2355,11 +2355,11 @@ eF_ResT SwWW8ImplReader::Read_F_Macro( WW8FieldDesc*, String& rStr)
         for ( ; i < pFonts->GetMax(); i++ )
         {
             FontFamily eFamily;
-            String aFontName;
+            OUString aFontName;
             FontPitch ePitch;
             CharSet eSrcCharSet;
             if( GetFontParams( i, eFamily, aFontName, ePitch, eSrcCharSet )
-                && aFontName.EqualsAscii("Wingdings") )
+                && aFontName=="Wingdings" )
             {
                 break;
             }
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index a01fb7d..e8766e0 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -3359,7 +3359,7 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, sh
     }
 }
 bool SwWW8ImplReader::GetFontParams( sal_uInt16 nFCode, FontFamily& reFamily,
-    String& rName, FontPitch& rePitch, CharSet& reCharSet )
+    OUString& rName, FontPitch& rePitch, CharSet& reCharSet )
 {
     // Die Defines, aus denen diese Tabellen erzeugt werden, stehen in windows.h
     static const FontPitch ePitchA[] =
@@ -3370,14 +3370,14 @@ bool SwWW8ImplReader::GetFontParams( sal_uInt16 nFCode, FontFamily& reFamily,
     static const FontFamily eFamilyA[] =
     {
         FAMILY_DONTKNOW, FAMILY_ROMAN, FAMILY_SWISS, FAMILY_MODERN,
-        FAMILY_SCRIPT, FAMILY_DECORATIVE
+        FAMILY_SCRIPT, FAMILY_DECORATIVE, FAMILY_DONTKNOW, FAMILY_DONTKNOW
     };
 
     const WW8_FFN* pF = pFonts->GetFont( nFCode );  // Info dazu
     if( !pF )                                   // FontNummer unbekannt ?
         return false;                           // dann ignorieren
 
-    rName = String( pF->sFontname );
+    rName = pF->sFontname;
 
     // pF->prg : Pitch
     rePitch = ePitchA[pF->prg];
@@ -3396,62 +3396,34 @@ bool SwWW8ImplReader::GetFontParams( sal_uInt16 nFCode, FontFamily& reFamily,
             reCharSet = rtl_getTextEncodingFromWindowsCharset( pF->chs );
     }
 
-    // pF->ff : Family
-    sal_uInt8 b = pF->ff;
-
     // make sure Font Family Code is set correctly
     // at least for the most important fonts
     // ( might be set wrong when Doc was not created by
     //   Winword but by third party program like Applixware... )
-        /*
-        0: FAMILY_DONTKNOW
-        1: FAMILY_ROMAN
-        2: FAMILY_SWISS
-        3: FAMILY_MODERN
-        4: FAMILY_SCRIPT
-        5: FAMILY_DECORATIVE
-    */
-#define FONTNAMETAB_SZ    14
-#define MAX_FONTNAME_ROMAN 6
-    static const sal_Char
-        // first comes ROMAN
-        sFontName0[] = "\x07""Tms Rmn",
-        sFontName1[] = "\x07""Timmons",
-        sFontName2[] = "\x08""CG Times",
-        sFontName3[] = "\x08""MS Serif",
-        sFontName4[] = "\x08""Garamond",
-        sFontName5[] = "\x11""Times Roman",
-        sFontName6[] = "\x15""Times New Roman",
-        // from here SWISS --> see above: #define MAX_FONTNAME_ROMAN 6
-        sFontName7[] = "\x04""Helv",
-        sFontName8[] = "\x05""Arial",
-        sFontName9[] = "\x07""Univers",
-        sFontName10[]= "\x11""LinePrinter",
-        sFontName11[]= "\x11""Lucida Sans",
-        sFontName12[]= "\x11""Small Fonts",
-        sFontName13[]= "\x13""MS Sans Serif";
-    static const sal_Char* const aFontNameTab[ FONTNAMETAB_SZ ] =
-    {
-        sFontName0,  sFontName1,  sFontName2,  sFontName3,
-        sFontName4,  sFontName5,  sFontName6,  sFontName7,
-        sFontName8,  sFontName9,  sFontName10, sFontName11,
-        sFontName12, sFontName13
-    };
-
-    for( sal_uInt16 n = 0;  n < FONTNAMETAB_SZ; n++ )
-    {
-        const sal_Char* pCmp = aFontNameTab[ n ];
-        xub_StrLen nLen = *pCmp++;
-        if( rName.EqualsIgnoreCaseAscii(pCmp, 0, nLen) )
-        {
-            b = n <= MAX_FONTNAME_ROMAN ? 1 : 2;
-            break;
-        }
+    if (rName.startsWithIgnoreAsciiCase("Tms Rmn") ||
+        rName.startsWithIgnoreAsciiCase("Timmons") ||
+        rName.startsWithIgnoreAsciiCase("CG Times") ||
+        rName.startsWithIgnoreAsciiCase("MS Serif") ||
+        rName.startsWithIgnoreAsciiCase("Garamond") ||
+        rName.startsWithIgnoreAsciiCase("Times Roman") ||
+        rName.startsWithIgnoreAsciiCase("Times New Roman"))
+    {
+        reFamily = FAMILY_ROMAN;
+    }
+    else if (rName.startsWithIgnoreAsciiCase("Helv") ||
+             rName.startsWithIgnoreAsciiCase("Arial") ||
+             rName.startsWithIgnoreAsciiCase("Univers") ||
+             rName.startsWithIgnoreAsciiCase("LinePrinter") ||
+             rName.startsWithIgnoreAsciiCase("Lucida Sans") ||
+             rName.startsWithIgnoreAsciiCase("Small Fonts") ||
+             rName.startsWithIgnoreAsciiCase("MS Sans Serif"))
+    {
+        reFamily = FAMILY_SWISS;
     }
-    if (b < (sizeof(eFamilyA)/sizeof(eFamilyA[0])))
-        reFamily = eFamilyA[b];
     else
-        reFamily = FAMILY_DONTKNOW;
+    {
+        reFamily = eFamilyA[pF->ff];
+    }
 
     return true;
 }
@@ -3460,7 +3432,7 @@ bool SwWW8ImplReader::SetNewFontAttr(sal_uInt16 nFCode, bool bSetEnums,
     sal_uInt16 nWhich)
 {
     FontFamily eFamily;
-    String aName;
+    OUString aName;
     FontPitch ePitch;
     CharSet eSrcCharSet;
 
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 55faade..f050025 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -6133,7 +6133,7 @@ struct WW8_FFN_Ver8 : public WW8_FFN_BASE
 };
 
 // #i43762# check font name for illegal characters
-static void lcl_checkFontname( String& sString )
+static void lcl_checkFontname( OUString& sString )
 {
     // for efficiency, we'd like to use String methods as far as possible.
     // Hence, we will:
@@ -6143,24 +6143,23 @@ static void lcl_checkFontname( String& sString )
     //    completely removed
 
     // convert all invalid chars to \u0001
-    sal_Unicode* pBuffer = sString.GetBufferAccess();
-    xub_StrLen nLen = sString.Len();
+    OUStringBuffer aBuf(sString);
+    const sal_Int32 nLen = aBuf.getLength();
     bool bFound = false;
-    for( xub_StrLen n = 0; n < nLen; n++ )
+    for ( sal_Int32 n = 0; n < nLen; ++n )
     {
-        if( pBuffer[n] < sal_Unicode( 0x20 ) )
+        if ( aBuf[n] < 0x20 )
         {
-            pBuffer[n] = sal_Unicode( 1 );
+            aBuf[n] = 1;
             bFound = true;
         }
     }
-    sString.ReleaseBufferAccess();
+    sString = aBuf.makeStringAndClear();
 
     // if anything was found, remove \u0001 + leading/trailing ';'
     if( bFound )
     {
-        sString = comphelper::string::remove(sString, 1);
-        sString = comphelper::string::strip(sString, ';');
+        sString = comphelper::string::strip(sString.replaceAll("\001", ""), ';');
     }
 }
 
@@ -6292,22 +6291,22 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
                 rtl_TextEncoding eEnc = WW8Fib::GetFIBCharset(p->chs);
                 if ((eEnc == RTL_TEXTENCODING_SYMBOL) || (eEnc == RTL_TEXTENCODING_DONTKNOW))
                     eEnc = RTL_TEXTENCODING_MS_1252;
-                p->sFontname = String(pVer6->szFfn, eEnc);
+                p->sFontname = OUString(pVer6->szFfn, rtl_str_getLength(pVer6->szFfn), eEnc);
                 const sal_uInt16 maxStrSize = sizeof (pVer6->szFfn) / sizeof (pVer6->szFfn[0]);
                 if (p->ibszAlt && p->ibszAlt < maxStrSize) //don't start after end of string
                 {
-                    p->sFontname.Append(';');
-                    p->sFontname += String(pVer6->szFfn+p->ibszAlt, eEnc);
+                    const sal_Char *pAlt = pVer6->szFfn+p->ibszAlt;
+                    p->sFontname += ";" + OUString(pAlt, rtl_str_getLength(pAlt), eEnc);
                 }
                 else
                 {
                     //#i18369# if its a symbol font set Symbol as fallback
                     if (
                          RTL_TEXTENCODING_SYMBOL == WW8Fib::GetFIBCharset(p->chs)
-                         && !p->sFontname.EqualsAscii("Symbol")
+                         && p->sFontname!="Symbol"
                        )
                     {
-                        p->sFontname.AppendAscii(";Symbol");
+                        p->sFontname += ";Symbol";
                     }
                 }
                 pVer6 = (WW8_FFN_Ver6*)( ((sal_uInt8*)pVer6) + pVer6->cbFfnM1 + 1 );
@@ -6371,12 +6370,11 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
                 p->sFontname = pPrimary;
                 if (p->ibszAlt && p->ibszAlt < nMaxNullTerminatedPossible)
                 {
-                    p->sFontname.Append(';');
                     sal_Unicode *pSecondary = pPrimary + p->ibszAlt;
 #ifdef OSL_BIGENDIAN
                     swapEndian(pSecondary);
 #endif
-                    p->sFontname.Append(pSecondary);
+                    p->sFontname += ";" + OUString(pSecondary);
                 }
 
                 // #i43762# check font name for illegal characters
diff --git a/sw/source/filter/ww8/ww8struc.hxx b/sw/source/filter/ww8/ww8struc.hxx
index 06b3578..b4ed4a2 100644
--- a/sw/source/filter/ww8/ww8struc.hxx
+++ b/sw/source/filter/ww8/ww8struc.hxx
@@ -216,7 +216,7 @@ struct WW8_FFN_BASE     // Font Descriptor
 struct WW8_FFN : public WW8_FFN_BASE
 {
     // ab Ver8 als Unicode
-    String sFontname;// 0x6 bzw. 0x40 ab Ver8 zero terminated string that
+    OUString sFontname;// 0x6 bzw. 0x40 ab Ver8 zero terminated string that
                                         // records name of font.
                                         // Maximal size of szFfn is 65 characters.
                                         // Vorsicht: Dieses Array kann auch kleiner sein!!!


More information about the Libreoffice-commits mailing list