diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2014-06-06 15:19:50 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2014-06-06 15:19:50 +0200 |
commit | fa49b57806e1215f156a525cf9123078a32841cb (patch) | |
tree | 5887b9b50ca9734ed708bf22df0cff1187b70a2c /lotuswordpro | |
parent | c50c800f9c183f12aa75d64a386c3b9f20731d70 (diff) |
Fix memory leaks, by refcounting XFFont
Change-Id: Iecfddf21f19313f46ee2544fad9c4df1e399e0f5
Diffstat (limited to 'lotuswordpro')
23 files changed, 101 insertions, 87 deletions
diff --git a/lotuswordpro/Library_lwpft.mk b/lotuswordpro/Library_lwpft.mk index 8cc8b9628b92..1ed04839310e 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 5c4de3f9e8d5..1cb925baa7c6 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 d3ac87db2bb8..6ef548bd3654 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 33dad651c6e0..457a1fbccc5c 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 b7e72f6cb400..3ee7e1b5ecb1 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 f8e057802719..cda119dd5eae 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 173bb7eca38c..948a35f21483 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 f753ece9c430..4543c9607787 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 21252aa54ed0..de50c6d21ba8 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 ac118a38f8d1..141cf1f2ef47 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 ba5d40cd8b9e..073031cca84b 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 70b8e93ea622..04e25dd77696 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 0fe5952518da..3a98f79f9732 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 f5b8d1980d0b..42bf24512ffa 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 f9f51bd749f4..85a267b73ce0 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 999daa236d03..676f08aa7efb 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 841d5382a1f8..7bdaf8f5ed0c 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 7cc979fa2e0f..59f95f89ac3d 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 17703462f4f1..1b73242b4390 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 29a13b38db36..9f3c4aff275e 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 1266538ac12a..d4f3ecb03cde 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 aa623b90d248..cf4f6cc86527 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 f047536921f8..30d73e8e8812 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 |