[Libreoffice-commits] .: 2 commits - extensions/source filter/source sc/source sd/source sw/source unusedcode.easy vcl/generic vcl/inc vcl/source

Caolán McNamara caolan at kemper.freedesktop.org
Wed Jun 20 04:07:16 PDT 2012


 extensions/source/propctrlr/standardcontrol.cxx |    3 
 filter/source/msfilter/msdffimp.cxx             |   10 -
 filter/source/msfilter/svdfppt.cxx              |   13 -
 sc/source/ui/docshell/impex.cxx                 |    4 
 sd/source/filter/ppt/propread.cxx               |    6 
 sw/source/core/unocore/unochart.cxx             |    4 
 sw/source/core/unocore/unotbl.cxx               |   14 +-
 unusedcode.easy                                 |    2 
 vcl/generic/fontmanager/fontsubst.cxx           |   59 +++++++-
 vcl/inc/outfont.hxx                             |   43 ++++--
 vcl/source/gdi/outdev3.cxx                      |  165 ++++++++++++++++++------
 11 files changed, 239 insertions(+), 84 deletions(-)

New commits:
commit 81099135677ac6997473ca01a297c32025c58662
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Jun 20 09:58:08 2012 +0100

    ditch last (?) uses of UniString::UniString(sal_Unicode, ...)
    
    Change-Id: Ie04a3465100d2f013f34168aaf136a20cd2f7e0d

diff --git a/extensions/source/propctrlr/standardcontrol.cxx b/extensions/source/propctrlr/standardcontrol.cxx
index 9fe02ca..0a42576 100644
--- a/extensions/source/propctrlr/standardcontrol.cxx
+++ b/extensions/source/propctrlr/standardcontrol.cxx
@@ -199,8 +199,7 @@ namespace pcr
             _rValue >>= nValue;
             if ( nValue )
             {
-                sal_Unicode nCharacter = nValue;
-                sText = String( &nCharacter, 1 );
+                sText = rtl::OUString(static_cast<sal_Unicode>(nValue));
             }
         }
         else
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 865bcfd..fbcc445 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -3728,7 +3728,7 @@ void SvxMSDffManager::ReadObjText( const String& rText, SdrObject* pObj ) const
         rOutliner.SetVertical( pText->IsVerticalWriting() );
 
         sal_uInt16 nParaIndex = 0;
-        sal_uInt32 nParaSize;
+        sal_Int32 nParaSize;
         const sal_Unicode* pCurrent, *pBuf = rText.GetBuffer();
         const sal_Unicode* pEnd = rText.GetBuffer() + rText.Len();
 
@@ -3752,12 +3752,12 @@ void SvxMSDffManager::ReadObjText( const String& rText, SdrObject* pObj ) const
                     break;
                 }
                 else
-                    nParaSize++;
+                    ++nParaSize;
             }
             ESelection aSelection( nParaIndex, 0, nParaIndex, 0 );
-            String aParagraph( pCurrent, (sal_uInt16)nParaSize );
-            if ( !nParaIndex && !aParagraph.Len() )                 // SJ: we are crashing if the first paragraph is empty ?
-                aParagraph += (sal_Unicode)' ';                     // otherwise these two lines can be removed.
+            rtl::OUString aParagraph( pCurrent, nParaSize );
+            if ( !nParaIndex && aParagraph.isEmpty() )              // SJ: we are crashing if the first paragraph is empty ?
+                aParagraph += rtl::OUString(' ');                   // otherwise these two lines can be removed.
             rOutliner.Insert( aParagraph, nParaIndex, 0 );
             rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() );
 
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index d4988a0..5575ef4 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -442,7 +442,7 @@ SvStream& operator>>( SvStream& rIn, PptFontEntityAtom& rAtom )
         cData[ i ] = ( nTemp >> 8 ) | ( nTemp << 8 );
 #endif
     }
-    rAtom.aName = String( cData, i );
+    rAtom.aName = rtl::OUString(cData, i);
     OutputDevice* pDev = (OutputDevice*)Application::GetDefaultDevice();
     rAtom.bAvailable = pDev->IsFontAvailable( rAtom.aName );
     aHd.SeekToEndOfRecord( rIn );
@@ -2217,14 +2217,14 @@ SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj*
             {
                 PPTPortionObj* pPortion;
                 sal_Unicode* pParaText = new sal_Unicode[ nTextSize ];
-                sal_uInt32 nCurrentIndex = 0;
+                sal_Int32 nCurrentIndex = 0;
                 for ( pPortion = pPara->First(); pPortion; pPortion = pPara->Next() )
                 {
                     if ( pPortion->mpFieldItem )
                         pParaText[ nCurrentIndex++ ] = ' ';
                     else
                     {
-                        sal_uInt32 nCharacters = pPortion->Count();
+                        sal_Int32 nCharacters = pPortion->Count();
                         const sal_Unicode* pSource = pPortion->maString.GetBuffer();
                         sal_Unicode* pDest = pParaText + nCurrentIndex;
 
@@ -2233,9 +2233,8 @@ SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj*
                         PptFontEntityAtom* pFontEnityAtom = GetFontEnityAtom( nFont );
                         if ( pFontEnityAtom && ( pFontEnityAtom->eCharSet == RTL_TEXTENCODING_SYMBOL ) )
                         {
-                            sal_uInt32 i;
                             sal_Unicode nUnicode;
-                            for ( i = 0; i < nCharacters; i++ )
+                            for (sal_Int32 i = 0; i < nCharacters; i++ )
                             {
                                 nUnicode = pSource[ i ];
                                 if ( ! ( nUnicode & 0xff00 ) )
@@ -2253,7 +2252,7 @@ SdrObject* SdrPowerPointImport::ApplyTextObj( PPTTextObj* pTextObj, SdrTextObj*
 
                 ESelection aSelection( nParaIndex, 0, nParaIndex, 0 );
                 rOutliner.Insert( String(), nParaIndex, pPara->pParaSet->mnDepth );
-                rOutliner.QuickInsertText( String( pParaText, (sal_uInt16)nCurrentIndex ), aSelection );
+                rOutliner.QuickInsertText( rtl::OUString(pParaText, nCurrentIndex), aSelection );
                 rOutliner.SetParaAttribs( nParaIndex, rOutliner.GetEmptyItemSet() );
                 if ( pS )
                     rOutliner.SetStyleSheet( nParaIndex, pS );
@@ -5054,7 +5053,7 @@ void PPTStyleTextPropReader::Init( SvStream& rIn, SdrPowerPointImport& rMan, con
             }
         }
         if ( i )
-            aString = String( pBuf, (sal_uInt16)i );
+            aString = rtl::OUString(pBuf, i);
         delete[] pBuf;
     }
     else if( aTextHd.nRecType == PPT_PST_TextBytesAtom )
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index a0bb6cd..392d855 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -1881,8 +1881,8 @@ bool ScImportExport::Sylk2Doc( SvStream& rStrm )
                                 const sal_Unicode* p0 = p;
                                 while( *p && *p != ';' )
                                     p++;
-                                String aNumber( p0, sal::static_int_cast<xub_StrLen>( p - p0 ) );
-                                nFormat = aNumber.ToInt32();
+                                rtl::OUString aNumber(p0, p - p0);
+                                nFormat = aNumber.toInt32();
                             }
                             break;
                     }
diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx
index 8ca34eb..52b9e5b 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -114,7 +114,7 @@ sal_Bool PropItem::Read( String& rString, sal_uInt32 nStringType, sal_Bool bAlig
                             sal_Unicode* pWString = (sal_Unicode*)pString;
                             for ( i = 0; i < nItemSize; i++ )
                                 *this >> pWString[ i ];
-                            rString = String( pWString, lcl_getMaxSafeStrLen(nItemSize) );
+                            rString = rtl::OUString(pWString, lcl_getMaxSafeStrLen(nItemSize));
                         }
                         else
                             rString = String();
@@ -156,7 +156,7 @@ sal_Bool PropItem::Read( String& rString, sal_uInt32 nStringType, sal_Bool bAlig
                     if ( pString[ i - 1 ] == 0 )
                     {
                         if ( (sal_uInt16)nItemSize > 1 )
-                            rString = String( pString, lcl_getMaxSafeStrLen(nItemSize) );
+                            rString = rtl::OUString(pString, lcl_getMaxSafeStrLen(nItemSize));
                         else
                             rString = String();
                         bRetValue = sal_True;
@@ -304,7 +304,7 @@ sal_Bool Section::GetDictionary( Dictionary& rDict )
                         sal_Unicode* pWString = (sal_Unicode*)pString;
                         for ( i = 0; i < nSize; i++ )
                             aStream >> pWString[ i ];
-                        aString = String( pWString, lcl_getMaxSafeStrLen(nSize) );
+                        aString = rtl::OUString(pWString, lcl_getMaxSafeStrLen(nSize));
                     }
                     else
                         aString = rtl::OUString(pString, lcl_getMaxSafeStrLen(nSize), mnTextEnc);
diff --git a/sw/source/core/unocore/unochart.cxx b/sw/source/core/unocore/unochart.cxx
index d5628f7..9ddee96 100644
--- a/sw/source/core/unocore/unochart.cxx
+++ b/sw/source/core/unocore/unochart.cxx
@@ -2190,12 +2190,12 @@ uno::Sequence< OUString > SAL_CALL SwChartDataSequence::generateLabel(
                             if (bUseCol)
                             {
                                 aRplc = String::CreateFromAscii( "%COLUMNLETTER" );
-                                aNew = String( aCellName.GetBuffer(), static_cast<xub_StrLen>(pBuf - aCellName.GetBuffer()) );
+                                aNew = rtl::OUString(aCellName.GetBuffer(), pBuf - aCellName.GetBuffer());
                             }
                             else
                             {
                                 aRplc = String::CreateFromAscii( "%ROWNUMBER" );
-                                aNew = String( pBuf, static_cast<xub_StrLen>((aCellName.GetBuffer() + nLen) - pBuf) );
+                                aNew = rtl::OUString(pBuf, (aCellName.GetBuffer() + nLen) - pBuf);
                             }
                             xub_StrLen nPos = aTxt.Search( aRplc );
                             if (nPos != STRING_NOTFOUND)
diff --git a/sw/source/core/unocore/unotbl.cxx b/sw/source/core/unocore/unotbl.cxx
index 7fd61af..78027ba 100644
--- a/sw/source/core/unocore/unotbl.cxx
+++ b/sw/source/core/unocore/unotbl.cxx
@@ -350,18 +350,18 @@ void lcl_GetCellPosition( const String &rCellName,
         // start of number found?
         if (pBuf < pEnd && ('0' <= *pBuf && *pBuf <= '9'))
         {
-            String aColTxt( rCellName.GetBuffer(), static_cast< xub_StrLen >(pBuf - rCellName.GetBuffer()) );
-            String aRowTxt( pBuf, static_cast< xub_StrLen >(rCellName.GetBuffer() + nLen - pBuf) );
-            if (aColTxt.Len() && aRowTxt.Len())
+            rtl::OUString aColTxt(rCellName.GetBuffer(), pBuf - rCellName.GetBuffer());
+            rtl::OUString aRowTxt(pBuf, (rCellName.GetBuffer() + nLen - pBuf));
+            if (!aColTxt.isEmpty() && !aRowTxt.isEmpty())
             {
                 sal_Int32 nColIdx = 0;
-                sal_Int32 nLength = aColTxt.Len();
-                for (xub_StrLen i = 0;  i < nLength;  ++i)
+                sal_Int32 nLength = aColTxt.getLength();
+                for (sal_Int32 i = 0;  i < nLength;  ++i)
                 {
                     nColIdx = 52 * nColIdx;
                     if (i < nLength - 1)
                         ++nColIdx;
-                    sal_Unicode cChar = aColTxt.GetBuffer()[i];
+                    sal_Unicode cChar = aColTxt[i];
                     if ('A' <= cChar && cChar <= 'Z')
                         nColIdx = nColIdx + (cChar - 'A');
                     else if ('a' <= cChar && cChar <= 'z')
@@ -374,7 +374,7 @@ void lcl_GetCellPosition( const String &rCellName,
                 }
 
                 rColumn = nColIdx;
-                rRow    = aRowTxt.ToInt32() - 1;    // - 1 because indices ought to be 0 based
+                rRow    = aRowTxt.toInt32() - 1;    // - 1 because indices ought to be 0 based
             }
         }
     }
diff --git a/unusedcode.easy b/unusedcode.easy
index d23ad1b..ffc27a2 100755
--- a/unusedcode.easy
+++ b/unusedcode.easy
@@ -206,7 +206,7 @@ VCLXPrinterServer::getImplementationId()
 VCLXPrinterServer::getTypes()
 VclEventListeners2::~VclEventListeners2()
 ViewShell::getIDocumentFieldsAccess() const
-VirtualDevice::SetOutputSizePixelAndBuffer(Size const&, boost::shared_array<unsigned char> const&)
+VirtualDevice::SetOutputSizePixelScaleOffsetAndBuffer(Size const&, Fraction const&, Point const&, boost::shared_array<unsigned char> const&)
 Window::PostUserEvent(unsigned long&, unsigned long, void*)
 X11SalGraphics::SetMask(int&, int&, unsigned int&, unsigned int&, int&, int&, unsigned long)
 X509Certificate_NssImpl::getImplementation(com::sun::star::uno::Reference<com::sun::star::uno::XInterface>)
commit 8c023fd645c8b83637ffcde4055886b2e4f94393
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Jun 19 22:23:33 2012 +0100

    Resolves: fdo#47636 cache fontconfig font substitutions
    
    But this time cache on *all* properties, not just the name, which doesn't cut
    it, given the things fontconfig can do, e.g. fdo#41556
    
    Change-Id: Idfc1dbac67b6912e4985570a0b7c6ccdf47fa4a5

diff --git a/vcl/generic/fontmanager/fontsubst.cxx b/vcl/generic/fontmanager/fontsubst.cxx
index 4f3ec48..3f51fe5 100644
--- a/vcl/generic/fontmanager/fontsubst.cxx
+++ b/vcl/generic/fontmanager/fontsubst.cxx
@@ -42,15 +42,27 @@
 #include "salprn.hxx"
 #include "region.h"
 
+#include <list>
+
 // ===========================================================================
 // platform specific font substitution hooks
 // ===========================================================================
 
+struct FontSelectPatternAttributesHash
+{
+    size_t operator()(const FontSelectPatternAttributes& rAttributes) const
+        { return rAttributes.hashCode(); }
+};
+
 class FcPreMatchSubstititution
 :   public ImplPreMatchFontSubstitution
 {
 public:
     bool FindFontSubstitute( FontSelectPattern& ) const;
+    typedef ::std::pair<FontSelectPatternAttributes, FontSelectPatternAttributes> value_type;
+private:
+    typedef ::std::list<value_type> CachedFontMapType;
+    mutable CachedFontMapType maCachedFontMap;
 };
 
 class FcGlyphFallbackSubstititution
@@ -135,6 +147,19 @@ namespace
             rOrig.meWidthType == rNew.meWidthType
           );
     }
+
+    class equal
+    {
+    private:
+        const FontSelectPatternAttributes& mrAttributes;
+    public:
+        equal(const FontSelectPatternAttributes& rAttributes)
+            : mrAttributes(rAttributes)
+        {
+        }
+        bool operator()(const FcPreMatchSubstititution::value_type& rOther) const
+            { return rOther.first == mrAttributes; }
+    };
 }
 
 //--------------------------------------------------------------------------
@@ -149,11 +174,26 @@ bool FcPreMatchSubstititution::FindFontSubstitute( FontSelectPattern &rFontSelDa
     ||  0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) )
         return false;
 
-    //Note: see fdo#41556 if you feel compelled to cache the results here,
-    //remember that fontconfig can return e.g. an italic font for a non-italic
-    //input and/or different fonts depending on fontsize, bold, etc settings so
-    //don't cache just on the name, cache on all the input and don't just
-    //return the original selection data with the fontname updated
+    //see fdo#41556 and fdo#47636
+    //fontconfig can return e.g. an italic font for a non-italic input and/or
+    //different fonts depending on fontsize, bold, etc settings so don't cache
+    //just on the name, cache map all the input and all the output not just map
+    //from original selection to output fontname
+    FontSelectPatternAttributes& rPatternAttributes = rFontSelData;
+    CachedFontMapType &rCachedFontMap = const_cast<CachedFontMapType &>(maCachedFontMap);
+    CachedFontMapType::iterator itr = std::find_if(rCachedFontMap.begin(), rCachedFontMap.end(), equal(rPatternAttributes));
+    if (itr != rCachedFontMap.end())
+    {
+        // Cached substitution
+        rFontSelData.copyAttributes(itr->second);
+        if (itr != rCachedFontMap.begin())
+        {
+            // MRU, move it to the front
+            rCachedFontMap.splice(rCachedFontMap.begin(), rCachedFontMap, itr);
+        }
+        return true;
+    }
+
     rtl::OUString aDummy;
     const FontSelectPattern aOut = GetFcSubstitute( rFontSelData, aDummy );
 
@@ -178,7 +218,14 @@ bool FcPreMatchSubstititution::FindFontSubstitute( FontSelectPattern &rFontSelDa
 #endif
 
     if( bHaveSubstitute )
+    {
+        rCachedFontMap.push_front(value_type(rFontSelData, aOut));
+        //fairly arbitrary limit in this case, but I recall measuring max 8
+        //fonts as the typical max amount of fonts in medium sized documents
+        if (rCachedFontMap.size() > 8)
+            rCachedFontMap.pop_back();
         rFontSelData = aOut;
+    }
 
     return bHaveSubstitute;
 }
@@ -190,7 +237,7 @@ bool FcGlyphFallbackSubstititution::FindFontSubstitute( FontSelectPattern& rFont
 {
     // We dont' actually want to talk to Fontconfig at all for symbol fonts
     if( rFontSelData.IsSymbolFont() )
-    return false;
+        return false;
     // StarSymbol is a unicode font, but it still deserves the symbol flag
     if( 0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "starsymbol", 10)
     ||  0 == rFontSelData.maSearchName.CompareIgnoreCaseToAscii( "opensymbol", 10) )
diff --git a/vcl/inc/outfont.hxx b/vcl/inc/outfont.hxx
index 70398d6..345ecc1 100644
--- a/vcl/inc/outfont.hxx
+++ b/vcl/inc/outfont.hxx
@@ -71,6 +71,12 @@ public: // TODO: create matching interface class
     FontWidth       GetWidthType() const    { return meWidthType; }
     bool            IsSymbolFont() const    { return mbSymbolFlag; }
 
+    bool operator==(const ImplFontAttributes& rOther) const;
+    bool operator!=(const ImplFontAttributes& rOther) const
+    {
+        return !(*this == rOther);
+    }
+
 public: // TODO: hide members behind accessor methods
     String          maName;         // Font Family Name
     String          maStyleName;    // Font Style Name
@@ -109,7 +115,6 @@ public: // TODO: hide members behind accessor methods
 // ----------------
 // - PhysicalFontFace -
 // ----------------
-// DONE: rename ImplFontData to PhysicalFontFace
 // TODO: no more direct access to members
 // TODO: add reference counting
 // TODO: get rid of height/width for scalable fonts
@@ -152,24 +157,27 @@ friend class ImplDevFontListData;
     PhysicalFontFace*       mpNext;
 };
 
-// ----------------------
-// - FontSelectPattern -
-// ----------------------
-
-class FontSelectPattern : public ImplFontAttributes
+class FontSelectPatternAttributes : public ImplFontAttributes
 {
 public:
-                        FontSelectPattern( const Font&, const String& rSearchName,
-                                           const Size&, float fExactHeight );
-                        FontSelectPattern( const PhysicalFontFace&, const Size&,
-                                           float fExactHeight, int nOrientation, bool bVertical );
+                        FontSelectPatternAttributes( const Font&, const String& rSearchName,
+                            const Size&, float fExactHeight );
+                        FontSelectPatternAttributes( const PhysicalFontFace&, const Size&,
+                            float fExactHeight, int nOrientation, bool bVertical );
+
+    size_t              hashCode() const;
+    bool operator==(const FontSelectPatternAttributes& rOther) const;
+    bool operator!=(const FontSelectPatternAttributes& rOther) const
+    {
+        return !(*this == rOther);
+    }
 
-public: // TODO: change to private
+public:
     String              maTargetName;       // name of the font name token that is chosen
     String              maSearchName;       // name of the font that matches best
     int                 mnWidth;            // width of font in pixel units
     int                 mnHeight;           // height of font in pixel units
-    float               mfExactHeight;       // requested height (in pixels with subpixel details)
+    float               mfExactHeight;      // requested height (in pixels with subpixel details)
     int                 mnOrientation;      // text orientation in 3600 system
     LanguageType        meLanguage;         // text language
     bool                mbVertical;         // vertical mode of requested font
@@ -177,9 +185,20 @@ public: // TODO: change to private
 
     bool                mbEmbolden;         // Force emboldening
     ItalicMatrix        maItalicMatrix;     // Force matrix for slant
+};
 
+class FontSelectPattern : public FontSelectPatternAttributes
+{
+public:
+                        FontSelectPattern( const Font&, const String& rSearchName,
+                            const Size&, float fExactHeight );
+                        FontSelectPattern( const PhysicalFontFace&, const Size&,
+                            float fExactHeight, int nOrientation, bool bVertical );
+
+public: // TODO: change to private
     const PhysicalFontFace* mpFontData;         // a matching PhysicalFontFace object
     ImplFontEntry*      mpFontEntry;        // pointer to the resulting FontCache entry
+    void copyAttributes(const FontSelectPatternAttributes &rAttributes);
 };
 
 // -------------------
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 3459afc..fc166ae 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -2139,21 +2139,17 @@ ImplGetDevSizeList* ImplDevFontList::GetDevSizeList( const String& rFontName ) c
     return pGetDevSizeList;
 }
 
-// =======================================================================
-
-FontSelectPattern::FontSelectPattern( const Font& rFont,
-    const String& rSearchName, const Size& rSize, float fExactHeight)
-:   maSearchName( rSearchName ),
-    mnWidth( rSize.Width() ),
-    mnHeight( rSize.Height() ),
-    mfExactHeight( fExactHeight),
-    mnOrientation( rFont.GetOrientation() ),
-    meLanguage( rFont.GetLanguage() ),
-    mbVertical( rFont.IsVertical() ),
-    mbNonAntialiased( false ),
-    mbEmbolden( false ),
-    mpFontData( NULL ),
-    mpFontEntry( NULL )
+FontSelectPatternAttributes::FontSelectPatternAttributes( const Font& rFont,
+    const String& rSearchName, const Size& rSize, float fExactHeight )
+    : maSearchName( rSearchName )
+    , mnWidth( rSize.Width() )
+    , mnHeight( rSize.Height() )
+    , mfExactHeight( fExactHeight)
+    , mnOrientation( rFont.GetOrientation() )
+    , meLanguage( rFont.GetLanguage() )
+    , mbVertical( rFont.IsVertical() )
+    , mbNonAntialiased( false )
+    , mbEmbolden( false )
 {
     maTargetName = maName;
 
@@ -2175,51 +2171,115 @@ FontSelectPattern::FontSelectPattern( const Font& rFont,
         mnWidth = -mnWidth;
 }
 
-// -----------------------------------------------------------------------
+FontSelectPattern::FontSelectPattern( const Font& rFont,
+    const String& rSearchName, const Size& rSize, float fExactHeight)
+    : FontSelectPatternAttributes(rFont, rSearchName, rSize, fExactHeight)
+    , mpFontData( NULL )
+    , mpFontEntry( NULL )
+{
+}
+
 // NOTE: this ctor is still used on Windows. Do not remove.
-FontSelectPattern::FontSelectPattern( const PhysicalFontFace& rFontData,
+FontSelectPatternAttributes::FontSelectPatternAttributes( const PhysicalFontFace& rFontData,
     const Size& rSize, float fExactHeight, int nOrientation, bool bVertical )
-:   ImplFontAttributes( rFontData ),
-    mnWidth( rSize.Width() ),
-    mnHeight( rSize.Height() ),
-    mfExactHeight( fExactHeight ),
-    mnOrientation( nOrientation ),
-    meLanguage( 0 ),
-    mbVertical( bVertical ),
-    mbNonAntialiased( false ),
-    mbEmbolden( false ),
-    mpFontData( &rFontData ),
-    mpFontEntry( NULL )
+    : ImplFontAttributes( rFontData )
+    , mnWidth( rSize.Width() )
+    , mnHeight( rSize.Height() )
+    , mfExactHeight( fExactHeight )
+    , mnOrientation( nOrientation )
+    , meLanguage( 0 )
+    , mbVertical( bVertical )
+    , mbNonAntialiased( false )
+    , mbEmbolden( false )
 {
     maTargetName = maSearchName = maName;
     // NOTE: no normalization for width/height/orientation
 }
 
+FontSelectPattern::FontSelectPattern( const PhysicalFontFace& rFontData,
+    const Size& rSize, float fExactHeight, int nOrientation, bool bVertical )
+    : FontSelectPatternAttributes(rFontData, rSize, fExactHeight, nOrientation, bVertical)
+    , mpFontData( &rFontData )
+    , mpFontEntry( NULL )
+{
+}
+
+void FontSelectPattern::copyAttributes(const FontSelectPatternAttributes &rAttributes)
+{
+    static_cast<FontSelectPatternAttributes&>(*this) = rAttributes;
+}
+
 // =======================================================================
 
 size_t ImplFontCache::IFSD_Hash::operator()( const FontSelectPattern& rFSD ) const
 {
+    return rFSD.hashCode();
+}
+
+size_t FontSelectPatternAttributes::hashCode() const
+{
     // TODO: does it pay off to improve this hash function?
     static FontNameHash aFontNameHash;
-    size_t nHash = aFontNameHash( rFSD.maSearchName );
+    size_t nHash = aFontNameHash( maSearchName );
 #ifdef ENABLE_GRAPHITE
     // check for features and generate a unique hash if necessary
-    if (rFSD.maTargetName.Search(grutils::GrFeatureParser::FEAT_PREFIX)
+    if (maTargetName.Search(grutils::GrFeatureParser::FEAT_PREFIX)
         != STRING_NOTFOUND)
     {
-        nHash = aFontNameHash( rFSD.maTargetName );
+        nHash = aFontNameHash( maTargetName );
     }
 #endif
-    nHash += 11 * rFSD.mnHeight;
-    nHash += 19 * rFSD.meWeight;
-    nHash += 29 * rFSD.meItalic;
-    nHash += 37 * rFSD.mnOrientation;
-    nHash += 41 * rFSD.meLanguage;
-    if( rFSD.mbVertical )
+    nHash += 11 * mnHeight;
+    nHash += 19 * meWeight;
+    nHash += 29 * meItalic;
+    nHash += 37 * mnOrientation;
+    nHash += 41 * meLanguage;
+    if( mbVertical )
         nHash += 53;
     return nHash;
 }
 
+bool FontSelectPatternAttributes::operator==(const FontSelectPatternAttributes& rOther) const
+{
+    if (static_cast<const ImplFontAttributes&>(*this) != static_cast<const ImplFontAttributes&>(rOther))
+        return false;
+
+    if (maTargetName != rOther.maTargetName)
+        return false;
+
+    if (maSearchName != rOther.maSearchName)
+        return false;
+
+    if (mnWidth != rOther.mnWidth)
+        return false;
+
+    if (mnHeight != rOther.mnHeight)
+        return false;
+
+    if (mfExactHeight != rOther.mfExactHeight)
+        return false;
+
+    if (mnOrientation != rOther.mnOrientation)
+        return false;
+
+    if (meLanguage != rOther.meLanguage)
+        return false;
+
+    if (mbVertical != rOther.mbVertical)
+        return false;
+
+    if (mbNonAntialiased != rOther.mbNonAntialiased)
+        return false;
+
+    if (mbEmbolden != rOther.mbEmbolden)
+        return false;
+
+    if (maItalicMatrix != rOther.maItalicMatrix)
+        return false;
+
+    return true;
+}
+
 // -----------------------------------------------------------------------
 
 bool ImplFontCache::IFSD_Equal::operator()(const FontSelectPattern& rA, const FontSelectPattern& rB) const
@@ -3332,6 +3392,37 @@ void OutputDevice::ImplInitAboveTextLineSize()
 
 // -----------------------------------------------------------------------
 
+bool ImplFontAttributes::operator==(const ImplFontAttributes& rOther) const
+{
+    if (maName != rOther.maName)
+        return false;
+
+    if (maStyleName != rOther.maStyleName)
+        return false;
+
+    if (meWeight != rOther.meWeight)
+        return false;
+
+    if (meItalic != rOther.meItalic)
+        return false;
+
+    if (meFamily != rOther.meFamily)
+        return false;
+
+    if (mePitch != rOther.mePitch)
+        return false;
+
+    if (meWidthType != rOther.meWidthType)
+        return false;
+
+    if (mbSymbolFlag != rOther.mbSymbolFlag)
+        return false;
+
+    return true;
+}
+
+// -----------------------------------------------------------------------
+
 ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData )
 :   ImplFontAttributes( rFontSelData )
 {


More information about the Libreoffice-commits mailing list