From 37183595bb3b4d58682f90fd9f6713bedcb852a2 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Fri, 6 Jun 2014 16:49:17 +0200 Subject: Fix memory leaks, by refcounting LwpObject Change-Id: I1539597cd5bcabcbf0295d1acc320c503ad53604 --- lotuswordpro/source/filter/lwppagelayout.cxx | 44 ++++++++++++++-------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'lotuswordpro/source/filter/lwppagelayout.cxx') diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx index ec388047bcdc..631a1ad033a6 100644 --- a/lotuswordpro/source/filter/lwppagelayout.cxx +++ b/lotuswordpro/source/filter/lwppagelayout.cxx @@ -123,8 +123,8 @@ void LwpPageLayout::Read() void LwpPageLayout::Parse(IXFStream* pOutputStream) { //Only parse this layout - LwpObject* pStory = m_Content.obj(); - if(pStory) + rtl::Reference pStory = m_Content.obj(); + if(pStory.is()) { pStory->SetFoundry(m_pFoundry); pStory->Parse(pOutputStream); //Do not parse the next story @@ -272,7 +272,7 @@ void LwpPageLayout::ParseFootNoteSeparator(XFPageMaster * pm1) { LwpObjectID* pFontnodeId = pDocument->GetValidFootnoteOpts(); - LwpFootnoteOptions* pFootnoteOpts = pFontnodeId ? dynamic_cast(pFontnodeId->obj()) : NULL; + LwpFootnoteOptions* pFootnoteOpts = pFontnodeId ? dynamic_cast(pFontnodeId->obj().get()) : NULL; if(pFootnoteOpts) { LwpFootnoteSeparatorOptions* pFootnoteSep = pFootnoteOpts->GetFootnoteSeparator(); @@ -482,8 +482,8 @@ void LwpPageLayout::ConvertFillerPageText(XFContentContainer* pCont) { //get filerpage story from division info LwpDocument* pDoc = m_pFoundry->GetDocument(); - LwpDivInfo* pDivInfo = dynamic_cast(pDoc->GetDivInfoID()->obj()); - LwpStory* pStory = dynamic_cast(pDivInfo->GetFillerPageTextID()->obj()); + LwpDivInfo* pDivInfo = dynamic_cast(pDoc->GetDivInfoID()->obj().get()); + LwpStory* pStory = dynamic_cast(pDivInfo->GetFillerPageTextID()->obj().get()); //parse fillerpage story if(pStory) @@ -506,24 +506,24 @@ void LwpPageLayout::ResetXFColumns() LwpHeaderLayout* LwpPageLayout::GetHeaderLayout() { - LwpVirtualLayout* pLay = dynamic_cast(GetChildHead()->obj()); + LwpVirtualLayout* pLay = dynamic_cast(GetChildHead()->obj().get()); while(pLay) { if( pLay->GetLayoutType() == LWP_HEADER_LAYOUT ) return ( static_cast (pLay) ); - pLay = dynamic_cast (pLay->GetNext()->obj()); + pLay = dynamic_cast (pLay->GetNext()->obj().get()); } return NULL; } LwpFooterLayout* LwpPageLayout::GetFooterLayout() { - LwpVirtualLayout* pLay = dynamic_cast(GetChildHead()->obj()); + LwpVirtualLayout* pLay = dynamic_cast(GetChildHead()->obj().get()); while(pLay) { if( pLay->GetLayoutType() == LWP_FOOTER_LAYOUT ) return ( static_cast (pLay) ); - pLay = dynamic_cast (pLay->GetNext()->obj()); + pLay = dynamic_cast (pLay->GetNext()->obj().get()); } return NULL; } @@ -536,7 +536,7 @@ LwpPageLayout* LwpPageLayout::GetOddChildLayout() { if(IsComplex()) { - LwpVirtualLayout* pLay = dynamic_cast(GetChildHead()->obj()); + LwpVirtualLayout* pLay = dynamic_cast(GetChildHead()->obj().get()); while(pLay) { if( pLay->GetLayoutType() == LWP_PAGE_LAYOUT ) @@ -548,7 +548,7 @@ LwpPageLayout* LwpPageLayout::GetOddChildLayout() return pPageLayout; } } - pLay = dynamic_cast (pLay->GetNext()->obj()); + pLay = dynamic_cast (pLay->GetNext()->obj().get()); } } return NULL; @@ -580,11 +580,11 @@ sal_Int32 LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber) sal_Int16 nPageNumber = -1; LwpFoundry* pFoundry = this->GetFoundry(); LwpDocument* pDoc = pFoundry->GetDocument(); - LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast(pDoc->GetPageHintsID()->obj()); + LwpDLVListHeadTailHolder* pHeadTail = dynamic_cast(pDoc->GetPageHintsID()->obj().get()); if(!pHeadTail) return nPageNumber; //get first pagehint - LwpPageHint* pPageHint = dynamic_cast(pHeadTail->GetHead()->obj()); + LwpPageHint* pPageHint = dynamic_cast(pHeadTail->GetHead()->obj().get()); while(pPageHint) { if(*(this->GetObjectID()) == *(pPageHint->GetPageLayoutID())) @@ -614,7 +614,7 @@ sal_Int32 LwpPageLayout::GetPageNumber(sal_uInt16 nLayoutNumber) } } - pPageHint = dynamic_cast(pPageHint->GetNext()->obj()); + pPageHint = dynamic_cast(pPageHint->GetNext()->obj().get()); } if(nPageNumber>=0) { @@ -715,7 +715,7 @@ bool LwpPageLayout::operator<(LwpPageLayout& Other) */ LwpPara* LwpPageLayout::GetPagePosition() { - LwpPara* pPara = dynamic_cast(GetPosition()->obj()); + LwpPara* pPara = dynamic_cast(GetPosition()->obj().get()); if(pPara) return pPara; //Get the position from its related section @@ -726,7 +726,7 @@ LwpPara* LwpPageLayout::GetPagePosition() while( (pSection = pFoundry->EnumSections(pSection)) ) { if(pSection->GetPageLayout() == this) - return dynamic_cast(pSection->GetPosition()->obj()); + return dynamic_cast(pSection->GetPosition()->obj().get()); } } @@ -788,7 +788,7 @@ void LwpHeaderLayout::ParseMargins(XFHeaderStyle* ph1) } //Set left,right,bottom margins - LwpMiddleLayout* parent = dynamic_cast (GetParent()->obj()); + LwpMiddleLayout* parent = dynamic_cast (GetParent()->obj().get()); //left margin in SODC: the space from the left edge of body to the left edge of header double left = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0); if(left<=0) //The left margin in SODC can not be minus value @@ -875,8 +875,8 @@ void LwpHeaderLayout::ParseWaterMark(XFHeaderStyle * pHeaderStyle) void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1) { XFHeader* pHeader = new XFHeader(); - LwpObject* pStory = m_Content.obj(); - if(pStory) + rtl::Reference pStory = m_Content.obj(); + if(pStory.is()) { LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance(); LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr(); @@ -954,7 +954,7 @@ void LwpFooterLayout::ParseMargins(XFFooterStyle* pFooterStyle) } //Set left,right,top margins - LwpMiddleLayout* parent = dynamic_cast (GetParent()->obj()); + LwpMiddleLayout* parent = dynamic_cast (GetParent()->obj().get()); double left = GetMarginsValue(MARGIN_LEFT) - (parent ? parent->GetMarginsValue(MARGIN_LEFT) : 0); if(left<=0) //The left margin in SODC can not be minus value { @@ -1028,9 +1028,9 @@ void LwpFooterLayout::ParseBackColor(XFFooterStyle* pFooterStyle) void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1) { XFFooter* pFooter = new XFFooter(); - LwpObject* pStory = m_Content.obj(VO_STORY); + rtl::Reference pStory = m_Content.obj(VO_STORY); //Call the RegisterStyle first to register the styles in footer paras, and then XFConvert() - if(pStory) + if(pStory.is()) { LwpGlobalMgr* pGlobal = LwpGlobalMgr::GetInstance(); LwpChangeMgr* pChangeMgr = pGlobal->GetLwpChangeMgr(); -- cgit