[Libreoffice-commits] core.git: lotuswordpro/Library_lwpft.mk lotuswordpro/source

Stephan Bergmann sbergman at redhat.com
Fri Jun 6 06:20:21 PDT 2014


 lotuswordpro/Library_lwpft.mk                        |    1 +
 lotuswordpro/source/filter/lwpcharacterstyle.cxx     |    2 +-
 lotuswordpro/source/filter/lwpdrawobj.cxx            |    6 +++---
 lotuswordpro/source/filter/lwpdrawobj.hxx            |    6 +++++-
 lotuswordpro/source/filter/lwpfont.cxx               |   18 +++++++++---------
 lotuswordpro/source/filter/lwpfont.hxx               |   14 +++++++-------
 lotuswordpro/source/filter/lwpframelayout.cxx        |    4 ++--
 lotuswordpro/source/filter/lwpfrib.cxx               |    6 +++---
 lotuswordpro/source/filter/lwpfrib.hxx               |    2 +-
 lotuswordpro/source/filter/lwplayout.cxx             |    5 ++---
 lotuswordpro/source/filter/lwplayout.hxx             |   10 +++++++---
 lotuswordpro/source/filter/lwpparastyle.cxx          |    2 +-
 lotuswordpro/source/filter/lwptablelayout.cxx        |    4 ++--
 lotuswordpro/source/filter/xfilter/xfcellstyle.cxx   |    9 ++++-----
 lotuswordpro/source/filter/xfilter/xfcellstyle.hxx   |    6 +++++-
 lotuswordpro/source/filter/xfilter/xffont.hxx        |    8 +++++++-
 lotuswordpro/source/filter/xfilter/xffontfactory.cxx |   12 +++---------
 lotuswordpro/source/filter/xfilter/xffontfactory.hxx |   10 +++++++---
 lotuswordpro/source/filter/xfilter/xfparastyle.cxx   |   16 ++++++----------
 lotuswordpro/source/filter/xfilter/xfparastyle.hxx   |   10 +++++++---
 lotuswordpro/source/filter/xfilter/xfstylecont.cxx   |   16 ++++++----------
 lotuswordpro/source/filter/xfilter/xftextstyle.cxx   |   11 +++++------
 lotuswordpro/source/filter/xfilter/xftextstyle.hxx   |   10 +++++++---
 23 files changed, 101 insertions(+), 87 deletions(-)

New commits:
commit fa49b57806e1215f156a525cf9123078a32841cb
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Jun 6 15:19:50 2014 +0200

    Fix memory leaks, by refcounting XFFont
    
    Change-Id: Iecfddf21f19313f46ee2544fad9c4df1e399e0f5

diff --git a/lotuswordpro/Library_lwpft.mk b/lotuswordpro/Library_lwpft.mk
index 8cc8b96..1ed0483 100644
--- a/lotuswordpro/Library_lwpft.mk
+++ b/lotuswordpro/Library_lwpft.mk
@@ -18,6 +18,7 @@ $(eval $(call gb_Library_use_libraries,lwpft,\
     cppu \
     cppuhelper \
     sal \
+    salhelper \
 	i18nlangtag \
     sfx \
     sot \
diff --git a/lotuswordpro/source/filter/lwpcharacterstyle.cxx b/lotuswordpro/source/filter/lwpcharacterstyle.cxx
index 5c4de3f..1cb925b 100644
--- a/lotuswordpro/source/filter/lwpcharacterstyle.cxx
+++ b/lotuswordpro/source/filter/lwpcharacterstyle.cxx
@@ -181,7 +181,7 @@ void LwpTextStyle::RegisterStyle()
 
     //Create font
     LwpFontManager* pFontMgr = m_pFoundry->GetFontManger();
-    XFFont* pFont = pFontMgr->CreateFont(m_nFinalFontID);
+    rtl::Reference<XFFont> pFont = pFontMgr->CreateFont(m_nFinalFontID);
     pStyle->SetFont(pFont);
 
     //Set other properties if needed
diff --git a/lotuswordpro/source/filter/lwpdrawobj.cxx b/lotuswordpro/source/filter/lwpdrawobj.cxx
index d3ac87d..6ef548b 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.cxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.cxx
@@ -972,7 +972,7 @@ LwpDrawTextBox::~LwpDrawTextBox()
     }
 }
 
-void LwpDrawTextBox::SetFontStyle(XFFont* pFont, SdwTextBoxRecord* pRec)
+void LwpDrawTextBox::SetFontStyle(rtl::Reference<XFFont> const & pFont, SdwTextBoxRecord* pRec)
 {
     // color
     XFColor aXFColor(pRec->aTextColor.nR, pRec->aTextColor.nG,
@@ -1065,7 +1065,7 @@ OUString LwpDrawTextBox::RegisterStyle()
 
     // font style
     // the pFont need to be deleted myself?
-    XFFont* pFont = new XFFont();
+    rtl::Reference<XFFont> pFont = new XFFont();
 
     rtl_TextEncoding aEncoding =  RTL_TEXTENCODING_MS_1252;
     OUString aFontName = OUString((sal_Char*)m_aTextRec.tmpTextFaceName,
@@ -1257,7 +1257,7 @@ OUString LwpDrawTextArt::RegisterStyle()
 
     // font style
     // the pFont need to be deleted myself?
-    XFFont* pFont = new XFFont();
+    rtl::Reference<XFFont> pFont = new XFFont();
 
     rtl_TextEncoding aEncoding =  RTL_TEXTENCODING_MS_1252;
     OUString aFontName = OUString((sal_Char*)m_aTextArtRec.tmpTextFaceName,
diff --git a/lotuswordpro/source/filter/lwpdrawobj.hxx b/lotuswordpro/source/filter/lwpdrawobj.hxx
index 33dad65..457a1fb 100644
--- a/lotuswordpro/source/filter/lwpdrawobj.hxx
+++ b/lotuswordpro/source/filter/lwpdrawobj.hxx
@@ -62,6 +62,10 @@
 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDRAWOBJ_HXX
 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPDRAWOBJ_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "lwpsdwdrawheader.hxx"
 
 class SvStream;
@@ -303,7 +307,7 @@ private:
 public:
     LwpDrawTextBox(SvStream* pStream);
     virtual ~LwpDrawTextBox();
-    static void SetFontStyle(XFFont* pFont, SdwTextBoxRecord* pRec);
+    static void SetFontStyle(rtl::Reference<XFFont> const & pFont, SdwTextBoxRecord* pRec);
 
 protected:
     virtual void Read() SAL_OVERRIDE;
diff --git a/lotuswordpro/source/filter/lwpfont.cxx b/lotuswordpro/source/filter/lwpfont.cxx
index b7e72f6..3ee7e1b 100644
--- a/lotuswordpro/source/filter/lwpfont.cxx
+++ b/lotuswordpro/source/filter/lwpfont.cxx
@@ -71,7 +71,7 @@ void LwpFontAttrEntry::Read(LwpObjectStream *pStrm)
 }
 
 #include "xfilter/xfdefs.hxx"
-void LwpFontAttrEntry::Override( XFFont*pFont )
+void LwpFontAttrEntry::Override( rtl::Reference<XFFont> const & pFont )
 {
     if (IsBoldOverridden())
         pFont->SetBold(Is(BOLD));
@@ -293,7 +293,7 @@ void LwpFontNameEntry::Read(LwpObjectStream *pStrm)
     pStrm->SkipExtra();
 }
 #include "xfilter/xfcolor.hxx"
-void LwpFontNameEntry::Override(XFFont* pFont)
+void LwpFontNameEntry::Override(rtl::Reference<XFFont> const & pFont)
 {
     if (IsPointSizeOverridden())
         pFont->SetFontSize(static_cast<sal_uInt8>(m_nPointSize/65536L));
@@ -387,7 +387,7 @@ void LwpFontNameManager::Read(LwpObjectStream *pStrm)
     pStrm->SkipExtra();
 }
 
-void    LwpFontNameManager::Override(sal_uInt16 index, XFFont* pFont)
+void    LwpFontNameManager::Override(sal_uInt16 index, rtl::Reference<XFFont> const & pFont)
     //index: start from 1
 {
     if (index > m_nCount || index < 1)
@@ -417,7 +417,7 @@ void LwpFontAttrManager::Read(LwpObjectStream *pStrm)
     pStrm->SkipExtra();
 }
 
-void    LwpFontAttrManager::Override(sal_uInt16 index, XFFont* pFont)
+void    LwpFontAttrManager::Override(sal_uInt16 index, rtl::Reference<XFFont> const & pFont)
     //index: start from 1
 {
     if (index > m_nCount || index < 1)
@@ -477,9 +477,9 @@ Prerequisite: pStyle has been created and the paragraph properties has been set
 /*
 Create XFFont based on the fotID
 */
-XFFont* LwpFontManager::CreateFont(sal_uInt32 fontID)
+rtl::Reference<XFFont> LwpFontManager::CreateFont(sal_uInt32 fontID)
 {
-    XFFont* pFont = new XFFont();
+    rtl::Reference<XFFont> pFont = new XFFont();
     m_FNMgr.Override(GetFontNameIndex(fontID), pFont);
     m_AttrMgr.Override(GetFontAttrIndex(fontID), pFont);
     return pFont;
@@ -490,9 +490,9 @@ Called XFFont based on the override result of two font ids.
 Refer to CFontManager::OverrideID
 */
 //OUString LwpFontManager::GetOverrideStyle(sal_uInt32 fontID, sal_uInt32 overID)
-XFFont* LwpFontManager::CreateOverrideFont(sal_uInt32 fontID, sal_uInt32 overID)
+rtl::Reference<XFFont> LwpFontManager::CreateOverrideFont(sal_uInt32 fontID, sal_uInt32 overID)
 {
-    XFFont* pFont = new XFFont();   //To be deleted by XFFontFactory
+    rtl::Reference<XFFont> pFont = new XFFont();   //To be deleted by XFFontFactory
     if(fontID)
     {
         Override(fontID, pFont);
@@ -504,7 +504,7 @@ XFFont* LwpFontManager::CreateOverrideFont(sal_uInt32 fontID, sal_uInt32 overID)
     return pFont;
 }
 
-void LwpFontManager::Override(sal_uInt32 fontID, XFFont* pFont)
+void LwpFontManager::Override(sal_uInt32 fontID, rtl::Reference<XFFont> const & pFont)
 {
     m_FNMgr.Override(GetFontNameIndex(fontID), pFont);
     m_AttrMgr.Override(GetFontAttrIndex(fontID), pFont);
diff --git a/lotuswordpro/source/filter/lwpfont.hxx b/lotuswordpro/source/filter/lwpfont.hxx
index f8e0578..cda119d 100644
--- a/lotuswordpro/source/filter/lwpfont.hxx
+++ b/lotuswordpro/source/filter/lwpfont.hxx
@@ -124,7 +124,7 @@ public:
     void Read(LwpObjectStream *pStrm);
     inline sal_uInt16 GetFaceID(){return m_nFaceName;}
     inline sal_uInt16 GetAltFaceID(){return m_nAltFaceName;}
-    void Override(XFFont* pFont);
+    void Override(rtl::Reference<XFFont> const & pFont);
     inline bool IsFaceNameOverridden();
     inline bool IsAltFaceNameOverridden();
 private:
@@ -174,7 +174,7 @@ private:
 
 public:
     void Read(LwpObjectStream *pStrm);
-    void    Override(sal_uInt16 index, XFFont* pFont);
+    void    Override(sal_uInt16 index, rtl::Reference<XFFont> const & pFont);
 };
 
 class LwpFontAttrEntry
@@ -192,7 +192,7 @@ public:
     ~LwpFontAttrEntry(){}
 public:
     void Read(LwpObjectStream *pStrm);
-    void Override(XFFont*pFont);
+    void Override(rtl::Reference<XFFont> const & pFont);
 private:
     sal_uInt16 m_nAttrBits;
     sal_uInt16 m_nAttrOverrideBits;
@@ -257,7 +257,7 @@ public:
     ~LwpFontAttrManager();
 public:
     void Read(LwpObjectStream *pStrm);
-    void Override(sal_uInt16 index, XFFont*pFont);
+    void Override(sal_uInt16 index, rtl::Reference<XFFont> const & pFont);
 private:
     sal_uInt16 m_nCount;
     LwpFontAttrEntry* m_pFontAttrs;
@@ -274,12 +274,12 @@ private:
 
 public:
     void Read(LwpObjectStream *pStrm);
-    XFFont* CreateOverrideFont(sal_uInt32 fontID, sal_uInt32 overID);
-    XFFont*  CreateFont(sal_uInt32 fontID);
+    rtl::Reference<XFFont> CreateOverrideFont(sal_uInt32 fontID, sal_uInt32 overID);
+    rtl::Reference<XFFont> CreateFont(sal_uInt32 fontID);
     OUString GetNameByID(sal_uInt32 fontID);
 
 private:
-    void Override(sal_uInt32 fontID, XFFont* pFont);
+    void Override(sal_uInt32 fontID, rtl::Reference<XFFont> const & pFont);
     inline sal_uInt16 GetFontNameIndex(sal_uInt32 fontID);
     inline sal_uInt16 GetFontAttrIndex(sal_uInt32 fontID);
 };
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 173bb7e..948a35f 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -691,8 +691,8 @@ void LwpFrame::ParseAnchorType(XFFrame *pXFFrame)
             //because of the different feature between Word Pro and SODC, I simulate the vertical base offset
             //between anchor and frame orgin using the font height.
             //LwpPara* pPara = static_cast<LwpPara*>(m_pLayout->GetPosition()->obj());
-            XFFont* pFont = m_pLayout->GetFont();
-            if(pFont)
+            rtl::Reference<XFFont> pFont = m_pLayout->GetFont();
+            if(pFont.is())
             {
                 offset = (double)(pFont->GetFontSize())*CM_PER_INCH/POINTS_PER_INCH;
             }
diff --git a/lotuswordpro/source/filter/lwpfrib.cxx b/lotuswordpro/source/filter/lwpfrib.cxx
index f753ece..4543c96 100644
--- a/lotuswordpro/source/filter/lwpfrib.cxx
+++ b/lotuswordpro/source/filter/lwpfrib.cxx
@@ -242,7 +242,7 @@ void LwpFrib::RegisterStyle(LwpFoundry* pFoundry)
     //we only read four modifiers, in these modifiers,CodePage and LangOverride are not styles,
     //so we can only handle fontid and characstyle, if others ,we should not reg style
     //note by ,1-27
-    XFFont* pFont;
+    rtl::Reference<XFFont> pFont;
     XFTextStyle* pStyle = NULL;
     m_StyleName = "";
     XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager();
@@ -412,9 +412,9 @@ void LwpFrib::ConvertHyperLink(XFContentContainer* pXFPara,LwpHyperlinkMgr* pHyp
 *  @descr:   Get the current frib font style
 *  @return:  XFFont pointer
 */
-XFFont* LwpFrib::GetFont()
+rtl::Reference<XFFont> LwpFrib::GetFont()
 {
-    XFFont* pFont = NULL;
+    rtl::Reference<XFFont> pFont;
     if(m_pModifiers&&m_pModifiers->FontID)
     {
         LwpFoundry* pFoundry = m_pPara->GetFoundry();
diff --git a/lotuswordpro/source/filter/lwpfrib.hxx b/lotuswordpro/source/filter/lwpfrib.hxx
index 21252aa..de50c6d 100644
--- a/lotuswordpro/source/filter/lwpfrib.hxx
+++ b/lotuswordpro/source/filter/lwpfrib.hxx
@@ -120,7 +120,7 @@ public:
     bool HasNextFrib();
     void ConvertChars(XFContentContainer* pXFPara,const OUString& text);
     void ConvertHyperLink(XFContentContainer* pXFPara,LwpHyperlinkMgr* pHyperlink,const OUString& text);
-    XFFont* GetFont();
+    rtl::Reference<XFFont> GetFont();
 
     sal_uInt8 GetRevisionType(){return m_nRevisionType;}
     bool GetRevisionFlag(){return m_bRevisionFlag;}
diff --git a/lotuswordpro/source/filter/lwplayout.cxx b/lotuswordpro/source/filter/lwplayout.cxx
index ac118a3..141cf1f 100644
--- a/lotuswordpro/source/filter/lwplayout.cxx
+++ b/lotuswordpro/source/filter/lwplayout.cxx
@@ -1939,7 +1939,6 @@ LwpPlacableLayout::LwpPlacableLayout( LwpObjectHeader &objHdr, LwpSvStream* pStr
     , m_nBuoyancy(0)
     , m_nBaseLineOffset(0)
     , m_nPageNumber(0)
-    , m_pFont(NULL)
 {}
 
 LwpPlacableLayout::~LwpPlacableLayout()
@@ -2127,7 +2126,7 @@ bool LwpPlacableLayout::IsAnchorCell()
 * @descr:   Get font style for setting position of frame
 *
 */
-XFFont* LwpPlacableLayout::GetFont()
+rtl::Reference<XFFont> LwpPlacableLayout::GetFont()
 {
     return m_pFont;
 }
@@ -2135,7 +2134,7 @@ XFFont* LwpPlacableLayout::GetFont()
 * @descr:   Set font style for setting position of frame
 *
 */
-void LwpPlacableLayout::SetFont(XFFont * pFont)
+void LwpPlacableLayout::SetFont(rtl::Reference<XFFont> const & pFont)
 {
     m_pFont = pFont;
 }
diff --git a/lotuswordpro/source/filter/lwplayout.hxx b/lotuswordpro/source/filter/lwplayout.hxx
index ba5d40c..073031c 100644
--- a/lotuswordpro/source/filter/lwplayout.hxx
+++ b/lotuswordpro/source/filter/lwplayout.hxx
@@ -65,6 +65,10 @@
 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUT_HXX
 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_LWPLAYOUT_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "lwpheader.hxx"
 #include "lwpobj.hxx"
 #include "lwpobjhdr.hxx"
@@ -406,8 +410,8 @@ public:
     virtual bool IsAnchorFrame() SAL_OVERRIDE;
     virtual bool IsAnchorCell() SAL_OVERRIDE;
     virtual void XFConvertFrame(XFContentContainer* /*pCont*/, sal_Int32 /*nStart*/ = 0, sal_Int32 /*nEnd*/ = 0, bool /*bAll*/ = false) {}
-    XFFont* GetFont();
-    void SetFont(XFFont* pFont);
+    rtl::Reference<XFFont> GetFont();
+    void SetFont(rtl::Reference<XFFont> const & pFont);
     enum WrapType
     {
         LAY_WRAP_AROUND = 1,
@@ -430,7 +434,7 @@ protected:
     LwpAtomHolder m_Script;
     LwpObjectID m_LayRelativity;
     sal_uInt16 m_nPageNumber;//for frame anchored to page
-    XFFont* m_pFont;//for frame position
+    rtl::Reference<XFFont> m_pFont;//for frame position
 };
 #endif
 
diff --git a/lotuswordpro/source/filter/lwpparastyle.cxx b/lotuswordpro/source/filter/lwpparastyle.cxx
index 70b8e93..04e25dd 100644
--- a/lotuswordpro/source/filter/lwpparastyle.cxx
+++ b/lotuswordpro/source/filter/lwpparastyle.cxx
@@ -693,7 +693,7 @@ void LwpParaStyle::RegisterStyle()
 
     //Create font
     LwpFontManager* pFontMgr = m_pFoundry->GetFontManger();
-    XFFont* pFont = pFontMgr->CreateFont(m_nFinalFontID);
+    rtl::Reference<XFFont> pFont = pFontMgr->CreateFont(m_nFinalFontID);
     pStyle->SetFont(pFont);
 
     //Set other paragraph properties...
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 0fe5952..3a98f79 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -1214,11 +1214,11 @@ void LwpTableLayout::PostProcessParagraph(XFCell *pCell, sal_uInt16 nRowID, sal_
 
                 if (bColorMod)
                 {
-                    XFFont* pFont = pOverStyle->GetFont();
+                    rtl::Reference<XFFont> pFont = pOverStyle->GetFont();
                     XFColor aColor = pFont->GetColor();
                     if ( aColor == aNullColor )
                     {
-                        XFFont* pNewFont = new XFFont;
+                        rtl::Reference<XFFont> pNewFont = new XFFont;
                         aColor = pNumStyle->GetColor();
                         pNewFont->SetColor(aColor);
                         pOverStyle->SetFont(pNewFont);
diff --git a/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx b/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx
index f5b8d19..42bf245 100644
--- a/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfcellstyle.cxx
@@ -68,7 +68,6 @@ XFCellStyle::XFCellStyle()
     m_eVertAlign = enumXFAlignNone;
     m_fTextIndent = 0;
     m_pBorders = NULL;
-    m_pFont = NULL;
     m_pBackImage = NULL;
     m_bWrapText = false;
 }
@@ -160,14 +159,14 @@ bool    XFCellStyle::Equal(IXFStyle *pStyle)
         return false;
 
     //font:
-    if( m_pFont )
+    if( m_pFont.is() )
     {
-        if( !pOther->m_pFont )
+        if( !pOther->m_pFont.is() )
             return false;
         if(*m_pFont != *pOther->m_pFont )
             return false;
     }
-    else if( pOther->m_pFont )
+    else if( pOther->m_pFont.is() )
         return false;
 
     //border:
@@ -255,7 +254,7 @@ void XFCellStyle::ToXml(IXFStream *pStrm)
         pAttrList->AddAttribute("fo:background-color", m_aBackColor.ToString() );
     }
     //Font properties:
-    if( m_pFont )
+    if( m_pFont.is() )
         m_pFont->ToXml(pStrm);
 
     pStrm->StartElement("style:properties");
diff --git a/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx b/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx
index f9f51bd..85a267b 100644
--- a/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfcellstyle.hxx
@@ -60,6 +60,10 @@
 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFCELLSTYLE_HXX
 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFCELLSTYLE_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "xfstyle.hxx"
 #include "xfcolor.hxx"
 #include "xfmargins.hxx"
@@ -142,7 +146,7 @@ private:
     XFBGImage   *m_pBackImage;
     XFMargins   m_aMargin;
     XFPadding   m_aPadding;
-    XFFont      *m_pFont;
+    rtl::Reference<XFFont> m_pFont;
     XFShadow    m_aShadow;
     XFBorders   *m_pBorders;
     bool    m_bWrapText;
diff --git a/lotuswordpro/source/filter/xfilter/xffont.hxx b/lotuswordpro/source/filter/xfilter/xffont.hxx
index 999daa2..676f08a 100644
--- a/lotuswordpro/source/filter/xfilter/xffont.hxx
+++ b/lotuswordpro/source/filter/xfilter/xffont.hxx
@@ -60,6 +60,10 @@
 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONT_HXX
 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONT_HXX
 
+#include <sal/config.h>
+
+#include <salhelper/simplereferenceobject.hxx>
+
 #include "xfglobal.hxx"
 #include "xfcolor.hxx"
 
@@ -111,7 +115,7 @@
  * font underline
  * font underline color
  */
-class XFFont
+class XFFont: public salhelper::SimpleReferenceObject
 {
 public:
     XFFont();
@@ -262,6 +266,8 @@ public:
     friend bool operator!=(XFFont& f1, XFFont& f2);
     friend class    XFFontFactory;
 private:
+    virtual ~XFFont() {}
+
     OUString   m_strFontName;
     OUString   m_strFontNameAsia;
     OUString   m_strFontNameComplex;
diff --git a/lotuswordpro/source/filter/xfilter/xffontfactory.cxx b/lotuswordpro/source/filter/xfilter/xffontfactory.cxx
index 841d538..7bdaf8f 100644
--- a/lotuswordpro/source/filter/xfilter/xffontfactory.cxx
+++ b/lotuswordpro/source/filter/xfilter/xffontfactory.cxx
@@ -70,23 +70,17 @@ XFFontFactory::~XFFontFactory()
 
 void XFFontFactory::Reset()
 {
-    std::vector<XFFont*>::iterator it;
-    for( it = s_aFonts.begin(); it != s_aFonts.end(); ++it )
-    {
-        XFFont *pFont = (*it);
-        delete pFont;
-    }
     s_aFonts.clear();
 }
 
-void XFFontFactory::AddFont(XFFont *pFont)
+void XFFontFactory::AddFont(rtl::Reference<XFFont> const & pFont)
 {
     s_aFonts.push_back( pFont );
 }
 
-XFFont* XFFontFactory::FindSameFont(XFFont *pFont)
+rtl::Reference<XFFont> XFFontFactory::FindSameFont(rtl::Reference<XFFont> const & pFont)
 {
-    std::vector<XFFont*>::iterator it;
+    std::vector< rtl::Reference<XFFont> >::iterator it;
     for( it = s_aFonts.begin(); it != s_aFonts.end(); ++it )
     {
         if( *pFont == **it )
diff --git a/lotuswordpro/source/filter/xfilter/xffontfactory.hxx b/lotuswordpro/source/filter/xfilter/xffontfactory.hxx
index 7cc979f..59f95f8 100644
--- a/lotuswordpro/source/filter/xfilter/xffontfactory.hxx
+++ b/lotuswordpro/source/filter/xfilter/xffontfactory.hxx
@@ -60,6 +60,10 @@
 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONTFACTORY_HXX
 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFFONTFACTORY_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "xfglobal.hxx"
 #include "xffont.hxx"
 #include <vector>
@@ -88,17 +92,17 @@ private:
      * @descr   Add a font. if there exist a font with same properties with pFont, them the font object
      *          will not be added.
      */
-    void    AddFont(XFFont *pFont);
+    void    AddFont(rtl::Reference<XFFont> const & pFont);
 
     /**
      * @descr   Find whether same font object exists.
      */
-    XFFont* FindSameFont(XFFont *pFont);
+    rtl::Reference<XFFont> FindSameFont(rtl::Reference<XFFont> const & pFont);
 
     friend class XFStyleContainer;
 
 private:
-    std::vector<XFFont*>    s_aFonts;
+    std::vector< rtl::Reference<XFFont> > s_aFonts;
 };
 
 #endif
diff --git a/lotuswordpro/source/filter/xfilter/xfparastyle.cxx b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
index 1770346..1b73242 100644
--- a/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfparastyle.cxx
@@ -71,7 +71,6 @@ XFParaStyle::XFParaStyle()
     , m_bJustSingleWord(false)
     , m_bKeepWithNext(false)
     , m_fTextIndent(0)
-    , m_pFont(NULL)
     , m_pBorders(NULL)
     , m_pBGImage(NULL)
     , m_nPageNumber(0)
@@ -149,10 +148,7 @@ XFParaStyle& XFParaStyle::operator=(const XFParaStyle& other)
         m_nLineNumberRestart = other.m_nLineNumberRestart;
         m_bNumberRight = other.m_bNumberRight;
 
-        if( other.m_pFont )
-            m_pFont = other.m_pFont;
-        else
-            m_pFont = NULL;
+        m_pFont = other.m_pFont;
 
         if( other.m_pBorders )
             m_pBorders = new XFBorders(*other.m_pBorders);
@@ -201,7 +197,7 @@ enumXFStyle XFParaStyle::GetStyleFamily()
     return enumXFStylePara;
 }
 
-void    XFParaStyle::SetFont(XFFont *pFont)
+void    XFParaStyle::SetFont(rtl::Reference<XFFont> const & pFont)
 {
     m_pFont = pFont;
 }
@@ -360,14 +356,14 @@ bool    XFParaStyle::Equal(IXFStyle *pStyle)
         return false;
 
     //font:
-    if( m_pFont )
+    if( m_pFont.is() )
     {
-        if( !pOther->m_pFont )
+        if( !pOther->m_pFont.is() )
             return false;
         if(*m_pFont != *pOther->m_pFont )
             return false;
     }
-    else if( pOther->m_pFont )
+    else if( pOther->m_pFont.is() )
         return false;
 
     //border:
@@ -466,7 +462,7 @@ void    XFParaStyle::ToXml(IXFStream *pStrm)
         pAttrList->AddAttribute("fo:background-color", m_aBackColor.ToString() );
     }
     //Font properties:
-    if( m_pFont )
+    if( m_pFont.is() )
         m_pFont->ToXml(pStrm);
 
     //page number:
diff --git a/lotuswordpro/source/filter/xfilter/xfparastyle.hxx b/lotuswordpro/source/filter/xfilter/xfparastyle.hxx
index 29a13b3..9f3c4af 100644
--- a/lotuswordpro/source/filter/xfilter/xfparastyle.hxx
+++ b/lotuswordpro/source/filter/xfilter/xfparastyle.hxx
@@ -62,6 +62,10 @@
 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFPARASTYLE_HXX
 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFPARASTYLE_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "xfglobal.hxx"
 #include "xfstyle.hxx"
 #include "xfcolor.hxx"
@@ -110,12 +114,12 @@ public:
      * @param   font font object to be setted.Font object are deleted by font-factory,so
      *          dont't delete it in the destructure function of para style.
      */
-    void    SetFont(XFFont *font);
+    void    SetFont(rtl::Reference<XFFont> const & font);
 
     /**
      * @descr   get the font object.
      */
-    XFFont* GetFont(){ return m_pFont; }
+    rtl::Reference<XFFont> GetFont(){ return m_pFont; }
 
     /**
      * @descr   Set the indent of the paragraph.This is the indent for
@@ -252,7 +256,7 @@ protected:
     XFMargins   m_aMargin;
     XFPadding   m_aPadding;
     XFStyleContainer m_aTabs;
-    XFFont      *m_pFont;
+    rtl::Reference<XFFont> m_pFont;
     XFShadow    m_aShadow;
     XFBorders   *m_pBorders;
     XFBGImage   *m_pBGImage;
diff --git a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
index 1266538..d4f3ecb 100644
--- a/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
+++ b/lotuswordpro/source/filter/xfilter/xfstylecont.cxx
@@ -209,8 +209,8 @@ void    XFStyleContainer::ToXml(IXFStream *pStrm)
 
 void    XFStyleContainer::ManageStyleFont(IXFStyle *pStyle)
 {
-    XFFont *pStyleFont = NULL;
-    XFFont *pFactoryFont = NULL;
+    rtl::Reference<XFFont> pStyleFont;
+    rtl::Reference<XFFont> pFactoryFont;
 
     if( !pStyle )
         return;
@@ -219,17 +219,15 @@ void    XFStyleContainer::ManageStyleFont(IXFStyle *pStyle)
     {
         XFTextStyle *pTS = (XFTextStyle*)pStyle;
         pStyleFont = pTS->GetFont();
-        if( !pStyleFont )
+        if( !pStyleFont.is() )
             return;
         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
         XFFontFactory* pFontFactory = pGlobal->GetXFFontFactory();
         pFactoryFont = pFontFactory->FindSameFont(pStyleFont);
         //this font has been exists in the factory:
-        if( pFactoryFont )
+        if( pFactoryFont.is() )
         {
             pTS->SetFont(pFactoryFont);
-            if( pStyleFont != pFactoryFont )
-                delete pStyleFont;
         }
         else
         {
@@ -240,17 +238,15 @@ void    XFStyleContainer::ManageStyleFont(IXFStyle *pStyle)
     {
         XFParaStyle *pPS = (XFParaStyle*)pStyle;
         pStyleFont = pPS->GetFont();
-        if( !pStyleFont )
+        if( !pStyleFont.is() )
             return;
         LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance();
         XFFontFactory* pFontFactory = pGlobal->GetXFFontFactory();
         pFactoryFont = pFontFactory->FindSameFont(pStyleFont);
         //this font has been exists in the factory:
-        if( pFactoryFont )
+        if( pFactoryFont.is() )
         {
             pPS->SetFont(pFactoryFont);
-            if( pFactoryFont != pStyleFont )
-                delete pStyleFont;
         }
         else
         {
diff --git a/lotuswordpro/source/filter/xfilter/xftextstyle.cxx b/lotuswordpro/source/filter/xfilter/xftextstyle.cxx
index aa623b9..cf4f6cc 100644
--- a/lotuswordpro/source/filter/xfilter/xftextstyle.cxx
+++ b/lotuswordpro/source/filter/xfilter/xftextstyle.cxx
@@ -66,14 +66,13 @@
 
 XFTextStyle::XFTextStyle()
 {
-    m_pFont = NULL;
 }
 
 XFTextStyle::~XFTextStyle()
 {
 }
 
-void    XFTextStyle::SetFont(XFFont *font)
+void    XFTextStyle::SetFont(rtl::Reference<XFFont> const & font)
 {
     m_pFont = font;
 }
@@ -91,14 +90,14 @@ bool    XFTextStyle::Equal(IXFStyle *pStyle)
         return false;
     }
 
-    if( m_pFont )
+    if( m_pFont.is() )
     {
-        if( !pOther->m_pFont )
+        if( !pOther->m_pFont.is() )
             return false;
         if( *m_pFont != *pOther->m_pFont )
             return false;
     }
-    else if( pOther->m_pFont )
+    else if( pOther->m_pFont.is() )
         return false;
 
     return true;
@@ -126,7 +125,7 @@ void    XFTextStyle::ToXml(IXFStream *strm)
     //Font properties:
     pAttrList->Clear();
     //font name:
-    if( m_pFont )
+    if( m_pFont.is() )
         m_pFont->ToXml(strm);
 
     strm->StartElement("style:properties");
diff --git a/lotuswordpro/source/filter/xfilter/xftextstyle.hxx b/lotuswordpro/source/filter/xfilter/xftextstyle.hxx
index f047536..30d73e8 100644
--- a/lotuswordpro/source/filter/xfilter/xftextstyle.hxx
+++ b/lotuswordpro/source/filter/xfilter/xftextstyle.hxx
@@ -61,6 +61,10 @@
 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFTEXTSTYLE_HXX
 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_XFILTER_XFTEXTSTYLE_HXX
 
+#include <sal/config.h>
+
+#include <rtl/ref.hxx>
+
 #include "xfglobal.hxx"
 #include "xfstyle.hxx"
 
@@ -78,9 +82,9 @@ public:
     /**
      * @descr:  set the font for the text span.
      */
-    void    SetFont(XFFont *font);
+    void    SetFont(rtl::Reference<XFFont> const & font);
 
-    XFFont* GetFont(){ return m_pFont; }
+    rtl::Reference<XFFont> GetFont(){ return m_pFont; }
 
     virtual enumXFStyle GetStyleFamily() SAL_OVERRIDE;
 
@@ -89,7 +93,7 @@ public:
     virtual void        ToXml(IXFStream *strm) SAL_OVERRIDE;
 
 private:
-    XFFont              *m_pFont;
+    rtl::Reference<XFFont> m_pFont;
 };
 
 #endif


More information about the Libreoffice-commits mailing list