[Libreoffice-commits] core.git: vcl/inc vcl/qt5 vcl/quartz vcl/source vcl/unx vcl/win

Noel Grandin noel.grandin at collabora.co.uk
Thu Jun 7 11:28:17 UTC 2018


 vcl/inc/PhysicalFontFace.hxx               |   10 +++++-----
 vcl/inc/PhysicalFontFamily.hxx             |    4 ++--
 vcl/inc/fontinstance.hxx                   |    5 +++--
 vcl/inc/outdev.h                           |    4 ++--
 vcl/inc/qt5/Qt5FontFace.hxx                |    2 +-
 vcl/inc/quartz/salgdi.h                    |    4 ++--
 vcl/inc/unx/freetype_glyphcache.hxx        |    2 +-
 vcl/inc/win/salgdi.h                       |    2 +-
 vcl/qt5/Qt5FontFace.cxx                    |    2 +-
 vcl/quartz/ctfonts.cxx                     |   15 +++++----------
 vcl/quartz/salgdi.cxx                      |    4 ++--
 vcl/source/font/PhysicalFontCollection.cxx |    5 +----
 vcl/source/font/PhysicalFontFace.cxx       |    8 ++++++++
 vcl/source/font/PhysicalFontFamily.cxx     |   16 +++++++---------
 vcl/source/font/fontinstance.cxx           |    2 +-
 vcl/source/gdi/pdfwriter_impl.cxx          |    4 ++--
 vcl/source/gdi/pdfwriter_impl.hxx          |    2 +-
 vcl/unx/generic/print/genpspgraphics.cxx   |    6 +++---
 vcl/win/gdi/salfont.cxx                    |   16 ++++++++--------
 19 files changed, 56 insertions(+), 57 deletions(-)

New commits:
commit 77a01802d1a0452814718789bb0c76adeeb747c0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jun 5 14:48:51 2018 +0200

    manage PhysicalFontFace by rtl::Reference
    
    Change-Id: I8f66b5afb066fe83abb83c56ebde6f21197f894b
    Reviewed-on: https://gerrit.libreoffice.org/55333
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index 39237ff46f89..2406b6cf41da 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -20,6 +20,8 @@
 #ifndef INCLUDED_VCL_INC_PHYSICALFONTFACE_HXX
 #define INCLUDED_VCL_INC_PHYSICALFONTFACE_HXX
 
+#include <salhelper/simplereferenceobject.hxx>
+#include <rtl/ref.hxx>
 #include <vcl/dllapi.h>
 
 #include "fontattributes.hxx"
@@ -40,7 +42,6 @@ public:
 
 
 // TODO: no more direct access to members
-// TODO: add reference counting
 // TODO: get rid of height/width for scalable fonts
 // TODO: make cloning cheaper
 
@@ -50,13 +51,11 @@ public:
  * It acts as a factory for its corresponding LogicalFontInstances and
  * can be extended to cache device and font instance specific data.
  */
-class VCL_PLUGIN_PUBLIC PhysicalFontFace : public FontAttributes
+class VCL_PLUGIN_PUBLIC PhysicalFontFace : public FontAttributes, public salhelper::SimpleReferenceObject
 {
 public:
-    virtual                ~PhysicalFontFace() {}
-
     virtual LogicalFontInstance* CreateFontInstance(const FontSelectPattern&) const;
-    virtual PhysicalFontFace* Clone() const = 0;
+    virtual rtl::Reference<PhysicalFontFace> Clone() const = 0;
 
     int                     GetHeight() const           { return mnHeight; }
     int                     GetWidth() const            { return mnWidth; }
@@ -68,6 +67,7 @@ public:
 
 protected:
     explicit PhysicalFontFace(const FontAttributes&);
+    PhysicalFontFace(const PhysicalFontFace&);
     void                    SetBitmapSize( int nW, int nH ) { mnWidth=nW; mnHeight=nH; }
 
     long                    mnWidth;    // Width (in pixels)
diff --git a/vcl/inc/PhysicalFontFamily.hxx b/vcl/inc/PhysicalFontFamily.hxx
index e88db8203809..990256590c88 100644
--- a/vcl/inc/PhysicalFontFamily.hxx
+++ b/vcl/inc/PhysicalFontFamily.hxx
@@ -67,7 +67,7 @@ public:
     void                InitMatchData( const utl::FontSubstConfiguration&,
                                        const OUString& rSearchName );
 
-    bool                AddFontFace( PhysicalFontFace* );
+    void                AddFontFace( PhysicalFontFace* );
 
     PhysicalFontFace*   FindBestFontFace( const FontSelectPattern& rFSD ) const;
 
@@ -78,7 +78,7 @@ static void             CalcType( ImplFontAttrs& rType, FontWeight& rWeight, Fon
                                   FontFamily eFamily, const utl::FontNameAttr* pFontAttr );
 
 private:
-    std::vector< std::unique_ptr<PhysicalFontFace> > maFontFaces;
+    std::vector< rtl::Reference<PhysicalFontFace> > maFontFaces;
 
     OUString            maFamilyName;       // original font family name
     OUString            maSearchName;       // normalized font family name
diff --git a/vcl/inc/fontinstance.hxx b/vcl/inc/fontinstance.hxx
index 90ed83d3ab33..317b7181198d 100644
--- a/vcl/inc/fontinstance.hxx
+++ b/vcl/inc/fontinstance.hxx
@@ -23,6 +23,7 @@
 #include "fontselect.hxx"
 #include "impfontmetricdata.hxx"
 
+#include <rtl/ref.hxx>
 #include <unordered_map>
 #include <memory>
 
@@ -64,7 +65,7 @@ public: // TODO: make data members private
     double GetAverageWidthFactor() const { return m_nAveWidthFactor; }
     const FontSelectPattern& GetFontSelectPattern() const { return m_aFontSelData; }
 
-    const PhysicalFontFace* GetFontFace() const { return m_pFontFace; }
+    const PhysicalFontFace* GetFontFace() const { return m_pFontFace.get(); }
     const ImplFontCache* GetFontCache() const { return mpFontCache; }
 
     int GetKashidaWidth();
@@ -91,7 +92,7 @@ private:
     const FontSelectPattern m_aFontSelData;
     hb_font_t* m_pHbFont;
     double m_nAveWidthFactor;
-    const PhysicalFontFace* m_pFontFace;
+    rtl::Reference<PhysicalFontFace> m_pFontFace;
 };
 
 inline hb_font_t* LogicalFontInstance::GetHbFont()
diff --git a/vcl/inc/outdev.h b/vcl/inc/outdev.h
index 3b626f3b0d8e..2aabdfa93acf 100644
--- a/vcl/inc/outdev.h
+++ b/vcl/inc/outdev.h
@@ -41,12 +41,12 @@ enum class AddFontSubstituteFlags;
 class ImplDeviceFontList
 {
 private:
-    std::vector<PhysicalFontFace*> maDevFontVector;
+    std::vector<rtl::Reference<PhysicalFontFace>> maDevFontVector;
 
 public:
                         ImplDeviceFontList()        { maDevFontVector.reserve(1024); }
     void                Add( PhysicalFontFace* pFace )  { maDevFontVector.push_back( pFace ); }
-    PhysicalFontFace*   Get( int nIndex ) const     { return maDevFontVector[ nIndex ]; }
+    PhysicalFontFace*   Get( int nIndex ) const     { return maDevFontVector[ nIndex ].get(); }
     int                 Count() const               { return maDevFontVector.size(); }
 };
 
diff --git a/vcl/inc/qt5/Qt5FontFace.hxx b/vcl/inc/qt5/Qt5FontFace.hxx
index 9468cf15b4e3..4cc21010a8b7 100644
--- a/vcl/inc/qt5/Qt5FontFace.hxx
+++ b/vcl/inc/qt5/Qt5FontFace.hxx
@@ -38,7 +38,7 @@ public:
 
     static Qt5FontFace* fromQFont(const QFont& rFont);
 
-    PhysicalFontFace* Clone() const override;
+    rtl::Reference<PhysicalFontFace> Clone() const override;
     sal_IntPtr GetFontId() const override;
 
     int GetFontTable(const char pTagName[5], unsigned char*) const;
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 064b2125e8be..2f53a44d694e 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -61,7 +61,7 @@ public:
                                     CoreTextFontFace( const FontAttributes&, sal_IntPtr nFontID );
     virtual                         ~CoreTextFontFace() override;
 
-    PhysicalFontFace*               Clone() const override;
+    rtl::Reference<PhysicalFontFace> Clone() const override;
     sal_IntPtr                      GetFontId() const override;
 
     int                             GetFontTable( uint32_t nTagCode, unsigned char* ) const;
@@ -128,7 +128,7 @@ private:
     CTFontCollectionRef mpCTFontCollection;
     CFArrayRef mpCTFontArray;
 
-    std::unordered_map<sal_IntPtr,CoreTextFontFace*> maFontContainer;
+    std::unordered_map<sal_IntPtr, rtl::Reference<CoreTextFontFace>> maFontContainer;
 };
 
 
diff --git a/vcl/inc/unx/freetype_glyphcache.hxx b/vcl/inc/unx/freetype_glyphcache.hxx
index 0a7b88887b24..d6b87b7ab7a9 100644
--- a/vcl/inc/unx/freetype_glyphcache.hxx
+++ b/vcl/inc/unx/freetype_glyphcache.hxx
@@ -115,7 +115,7 @@ public:
                             FreetypeFontFace( FreetypeFontInfo*, const FontAttributes& );
 
     virtual LogicalFontInstance* CreateFontInstance( const FontSelectPattern& ) const override;
-    virtual PhysicalFontFace* Clone() const override   { return new FreetypeFontFace( *this ); }
+    virtual rtl::Reference<PhysicalFontFace> Clone() const override   { return new FreetypeFontFace( *this ); }
     virtual sal_IntPtr      GetFontId() const override { return mpFreetypeFontInfo->GetFontId(); }
 };
 
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index f2580aa05d5d..59190f87e17d 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -63,7 +63,7 @@ public:
                                 BYTE nPitchAndFamily  );
     virtual                 ~WinFontFace() override;
 
-    virtual PhysicalFontFace* Clone() const override;
+    virtual rtl::Reference<PhysicalFontFace> Clone() const override;
     virtual LogicalFontInstance* CreateFontInstance( const FontSelectPattern& ) const override;
     virtual sal_IntPtr      GetFontId() const override;
     void                    SetFontId( sal_IntPtr nId ) { mnId = nId; }
diff --git a/vcl/qt5/Qt5FontFace.cxx b/vcl/qt5/Qt5FontFace.cxx
index ade0f1c95c72..bd3994a721ee 100644
--- a/vcl/qt5/Qt5FontFace.cxx
+++ b/vcl/qt5/Qt5FontFace.cxx
@@ -115,6 +115,6 @@ bool Qt5FontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilities)
     return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
 }
 
-PhysicalFontFace* Qt5FontFace::Clone() const { return new Qt5FontFace(*this); }
+rtl::Reference<PhysicalFontFace> Qt5FontFace::Clone() const { return new Qt5FontFace(*this); }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/quartz/ctfonts.cxx b/vcl/quartz/ctfonts.cxx
index ac20c1e9f4c5..1d72f601eafa 100644
--- a/vcl/quartz/ctfonts.cxx
+++ b/vcl/quartz/ctfonts.cxx
@@ -283,7 +283,7 @@ hb_font_t* CoreTextStyle::ImplInitHbFont()
     return InitHbFont(pHbFace);
 }
 
-PhysicalFontFace* CoreTextFontFace::Clone() const
+rtl::Reference<PhysicalFontFace> CoreTextFontFace::Clone() const
 {
     return new CoreTextFontFace( *this);
 }
@@ -504,9 +504,9 @@ static void fontEnumCallBack( const void* pValue, void* pContext )
     if( bFontEnabled)
     {
         const sal_IntPtr nFontId = reinterpret_cast<sal_IntPtr>(pValue);
-        CoreTextFontFace* pFontData = new CoreTextFontFace( rDFA, nFontId );
+        rtl::Reference<CoreTextFontFace> pFontData = new CoreTextFontFace( rDFA, nFontId );
         SystemFontList* pFontList = static_cast<SystemFontList*>(pContext);
-        pFontList->AddFont( pFontData );
+        pFontList->AddFont( pFontData.get() );
     }
 }
 
@@ -517,11 +517,6 @@ SystemFontList::SystemFontList()
 
 SystemFontList::~SystemFontList()
 {
-    auto it = maFontContainer.cbegin();
-    for(; it != maFontContainer.cend(); ++it )
-    {
-        delete (*it).second;
-    }
     maFontContainer.clear();
 
     if( mpCTFontArray )
@@ -545,7 +540,7 @@ void SystemFontList::AnnounceFonts( PhysicalFontCollection& rFontCollection ) co
     auto it = maFontContainer.cbegin();
     for(; it != maFontContainer.cend(); ++it )
     {
-        rFontCollection.Add( (*it).second->Clone() );
+        rFontCollection.Add( (*it).second->Clone().get() );
     }
 }
 
@@ -556,7 +551,7 @@ CoreTextFontFace* SystemFontList::GetFontDataFromId( sal_IntPtr nFontId ) const
     {
         return nullptr;
     }
-    return (*it).second;
+    return (*it).second.get();
 }
 
 bool SystemFontList::Init()
diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 3189ddcb271e..90fad58fc051 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -801,8 +801,8 @@ void AquaSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFontData, bool bV
             free( const_cast<TTSimpleGlyphMetrics *>(pGlyphMetrics) );
         }
 
-        CoreTextFontFace rCTFontData(*pFontData, pFontData->GetFontId());
-        FontCharMapRef xFCMap = rCTFontData.GetFontCharMap();
+        rtl::Reference<CoreTextFontFace> rCTFontData(new CoreTextFontFace(*pFontData, pFontData->GetFontId()));
+        FontCharMapRef xFCMap = rCTFontData->GetFontCharMap();
         SAL_WARN_IF( !xFCMap.is() || !xFCMap->GetCharCount(), "vcl", "no charmap" );
 
         // get unicode<->glyph encoding
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 343f6054364f..25edddd07b3d 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -283,10 +283,7 @@ void PhysicalFontCollection::Add( PhysicalFontFace* pNewData )
 
     PhysicalFontFamily* pFoundData = FindOrCreateFontFamily( aSearchName );
 
-    bool bKeepNewData = pFoundData->AddFontFace( pNewData );
-
-    if( !bKeepNewData )
-        delete pNewData;
+    pFoundData->AddFontFace( pNewData );
 }
 
 // find the font from the normalized font family name
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 40948c41e77e..690fd1fdc401 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -37,6 +37,14 @@ PhysicalFontFace::PhysicalFontFace( const FontAttributes& rDFA )
             SetSymbolFlag( true );
 }
 
+PhysicalFontFace::PhysicalFontFace( const PhysicalFontFace& other )
+    : FontAttributes( other )
+    , salhelper::SimpleReferenceObject()
+    , mnWidth(other.mnWidth)
+    , mnHeight(other.mnWidth)
+{
+}
+
 LogicalFontInstance* PhysicalFontFace::CreateFontInstance(const FontSelectPattern& rFSD) const
 {
     return new LogicalFontInstance(*this, rFSD);
diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx
index 34ad038a38a7..d0c1c2dad165 100644
--- a/vcl/source/font/PhysicalFontFamily.cxx
+++ b/vcl/source/font/PhysicalFontFamily.cxx
@@ -100,7 +100,7 @@ PhysicalFontFamily::~PhysicalFontFamily()
 {
 }
 
-bool PhysicalFontFamily::AddFontFace( PhysicalFontFace* pNewFontFace )
+void PhysicalFontFamily::AddFontFace( PhysicalFontFace* pNewFontFace )
 {
     if( maFontFaces.empty() )
     {
@@ -162,19 +162,18 @@ bool PhysicalFontFamily::AddFontFace( PhysicalFontFace* pNewFontFace )
 
         // ignore duplicate if its quality is worse
         if( pNewFontFace->GetQuality() < pFoundFontFace->GetQuality() )
-            return false;
+            return;
 
         // keep the device font if its quality is good enough
         if( pNewFontFace->GetQuality() == pFoundFontFace->GetQuality() )
-            return false;
+            return;
 
         // replace existing font face with a better one
-        it->reset(pNewFontFace); // insert at sort position
-        return true;
+        *it = pNewFontFace; // insert at sort position
+        return;
     }
 
     maFontFaces.emplace(it, pNewFontFace); // insert at sort position
-    return true;
 }
 
 // get font attributes using the normalized font family name
@@ -265,7 +264,7 @@ void PhysicalFontFamily::UpdateCloneFontList(PhysicalFontCollection& rFontCollec
             pFamily = rFontCollection.FindOrCreateFontFamily(aFamilyName);
         }
         assert(pFamily);
-        PhysicalFontFace* pClonedFace = pFoundFontFace->Clone();
+        rtl::Reference<PhysicalFontFace> pClonedFace = pFoundFontFace->Clone();
 
 #if OSL_DEBUG_LEVEL > 0
         OUString aClonedFamilyName = GetEnglishSearchFontName( pClonedFace->GetFamilyName() );
@@ -273,8 +272,7 @@ void PhysicalFontFamily::UpdateCloneFontList(PhysicalFontCollection& rFontCollec
         assert( rFontCollection.FindOrCreateFontFamily( aClonedFamilyName ) == pFamily );
 #endif
 
-        if (! pFamily->AddFontFace( pClonedFace ) )
-            delete pClonedFace;
+        pFamily->AddFontFace( pClonedFace.get() );
     }
 }
 
diff --git a/vcl/source/font/fontinstance.cxx b/vcl/source/font/fontinstance.cxx
index 6837329fbfaf..fca20fd03ca3 100644
--- a/vcl/source/font/fontinstance.cxx
+++ b/vcl/source/font/fontinstance.cxx
@@ -52,7 +52,7 @@ LogicalFontInstance::LogicalFontInstance(const PhysicalFontFace& rFontFace, cons
     , m_aFontSelData(rFontSelData)
     , m_pHbFont(nullptr)
     , m_nAveWidthFactor(1.0f)
-    , m_pFontFace(&rFontFace)
+    , m_pFontFace(&const_cast<PhysicalFontFace&>(rFontFace))
 {
     const_cast<FontSelectPattern*>(&m_aFontSelData)->mpFontInstance = this;
 }
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 0c9442c8971e..7fee16967ea5 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3468,8 +3468,8 @@ bool PDFWriterImpl::emitFonts()
     // emit builtin font for widget appearances / variable text
     for (auto & item : m_aBuiltinFontToObjectMap)
     {
-        PdfBuiltinFontFace aData(m_aBuiltinFonts[item.first]);
-        item.second = emitBuiltinFont( &aData, item.second );
+        rtl::Reference<PdfBuiltinFontFace> aData(new PdfBuiltinFontFace(m_aBuiltinFonts[item.first]));
+        item.second = emitBuiltinFont( aData.get(), item.second );
     }
     appendBuiltinFontsToDict( aFontDict );
     aFontDict.append( "\n>>\nendobj\n\n" );
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index b4c1b3a454e6..e17ca2a5f73a 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -1290,7 +1290,7 @@ public:
     explicit                            PdfBuiltinFontFace( const PDFWriterImpl::BuiltinFont& );
     const PDFWriterImpl::BuiltinFont&   GetBuiltinFont() const  { return mrBuiltin; }
 
-    virtual PhysicalFontFace*           Clone() const override { return new PdfBuiltinFontFace(*this); }
+    virtual rtl::Reference<PhysicalFontFace> Clone() const override { return new PdfBuiltinFontFace(*this); }
     virtual sal_IntPtr                  GetFontId() const override { return reinterpret_cast<sal_IntPtr>(&mrBuiltin); }
 };
 
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 52cd6c3985ef..f8df235fb236 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -520,7 +520,7 @@ private:
 public:
     explicit ImplPspFontData( const psp::FastPrintFontInfo& );
     virtual sal_IntPtr      GetFontId() const override { return mnFontId; }
-    virtual PhysicalFontFace*   Clone() const override { return new ImplPspFontData( *this ); }
+    virtual rtl::Reference<PhysicalFontFace> Clone() const override { return new ImplPspFontData( *this ); }
 };
 
 ImplPspFontData::ImplPspFontData(const psp::FastPrintFontInfo& rInfo)
@@ -889,9 +889,9 @@ void GenPspGraphics::AnnounceFonts( PhysicalFontCollection* pFontCollection, con
                 nQuality += 10;
     }
 
-    ImplPspFontData* pFD = new ImplPspFontData( aInfo );
+    rtl::Reference<ImplPspFontData> pFD(new ImplPspFontData( aInfo ));
     pFD->IncreaseQualityBy( nQuality );
-    pFontCollection->Add( pFD );
+    pFontCollection->Add( pFD.get() );
 }
 
 bool GenPspGraphics::blendBitmap( const SalTwoRect&, const SalBitmap& )
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 1313778ccebb..fb4160f80190 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -559,7 +559,7 @@ static FontAttributes WinFont2DevFontAttributes( const ENUMLOGFONTEXW& rEnumFont
 }
 
 
-static WinFontFace* ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* pLogFont,
+static rtl::Reference<WinFontFace> ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* pLogFont,
                                          const NEWTEXTMETRICW* pMetric,
                                          DWORD nFontType )
 {
@@ -567,7 +567,7 @@ static WinFontFace* ImplLogMetricToDevFontDataW( const ENUMLOGFONTEXW* pLogFont,
     if ( nFontType & RASTER_FONTTYPE )
         nHeight = pMetric->tmHeight - pMetric->tmInternalLeading;
 
-    WinFontFace* pData = new WinFontFace(
+    rtl::Reference<WinFontFace> pData = new WinFontFace(
         WinFont2DevFontAttributes(*pLogFont, *pMetric),
         nHeight,
         pLogFont->elfLogFont.lfCharSet,
@@ -658,7 +658,7 @@ sal_IntPtr WinFontFace::GetFontId() const
     return mnId;
 }
 
-PhysicalFontFace* WinFontFace::Clone() const
+rtl::Reference<PhysicalFontFace> WinFontFace::Clone() const
 {
     return new WinFontFace(*this);
 }
@@ -1088,10 +1088,10 @@ int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe,
             return 1;
         }
 
-        WinFontFace* pData = ImplLogMetricToDevFontDataW( pLogFont, &(pMetric->ntmTm), nFontType );
+        rtl::Reference<WinFontFace> pData = ImplLogMetricToDevFontDataW( pLogFont, &(pMetric->ntmTm), nFontType );
         pData->SetFontId( sal_IntPtr( pInfo->mnFontCount++ ) );
 
-        pInfo->mpList->Add( pData );
+        pInfo->mpList->Add( pData.get() );
     }
 
     return 1;
@@ -1292,11 +1292,11 @@ bool WinSalGraphics::AddTempDevFont( PhysicalFontCollection* pFontCollection,
         aDFS.maMapName = aFontName;
     */
 
-    WinFontFace* pFontData = new WinFontFace( aDFA, 0,
+    rtl::Reference<WinFontFace> pFontData = new WinFontFace( aDFA, 0,
         sal::static_int_cast<BYTE>(DEFAULT_CHARSET),
         sal::static_int_cast<BYTE>(TMPF_VECTOR|TMPF_TRUETYPE) );
-    pFontData->SetFontId( reinterpret_cast<sal_IntPtr>(pFontData) );
-    pFontCollection->Add( pFontData );
+    pFontData->SetFontId( reinterpret_cast<sal_IntPtr>(pFontData.get()) );
+    pFontCollection->Add( pFontData.get() );
     return true;
 }
 


More information about the Libreoffice-commits mailing list