diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-12 08:58:30 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-02-12 18:05:03 +0100 |
commit | 3a3c54659876aa07be1e38bce5d7f54d343f228a (patch) | |
tree | fe869a162ec31e9e88568af0e5674013e7a2018a /lotuswordpro | |
parent | e5ace62c32191a2ae4183102c21e37575add39d8 (diff) |
potential leaks
Change-Id: I06bb0791a8598fab847853083fc3b767a904df0e
Reviewed-on: https://gerrit.libreoffice.org/49593
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'lotuswordpro')
-rw-r--r-- | lotuswordpro/source/filter/lwpdoc.cxx | 13 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpdoc.hxx | 10 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpframelayout.cxx | 8 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwpfribptr.cxx | 41 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwppara.cxx | 74 | ||||
-rw-r--r-- | lotuswordpro/source/filter/lwppara.hxx | 2 |
6 files changed, 56 insertions, 92 deletions
diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx index 779a98a31855..cd86f4bf6819 100644 --- a/lotuswordpro/source/filter/lwpdoc.cxx +++ b/lotuswordpro/source/filter/lwpdoc.cxx @@ -72,20 +72,16 @@ LwpDocument::LwpDocument(LwpObjectHeader const & objHdr, LwpSvStream* pStrm) : LwpDLNFPVList(objHdr, pStrm) - , m_pOwnedFoundry(nullptr) , m_bGettingFirstDivisionWithContentsThatIsNotOLE(false) , m_bGettingPreviousDivisionWithContents(false) , m_bGettingGetLastDivisionWithContents(false) , m_nFlags(0) , m_nPersistentFlags(0) - , m_pLnOpts(nullptr) { } LwpDocument::~LwpDocument() { - delete m_pLnOpts; - delete m_pOwnedFoundry; } /** * @descr Read VO_Document from object stream @@ -104,7 +100,7 @@ void LwpDocument::Read() LwpUIDocument aUIDoc( m_pObjStrm.get() ); } - m_pLnOpts = new LwpLineNumberOptions(m_pObjStrm.get()); + m_xLnOpts.reset(new LwpLineNumberOptions(m_pObjStrm.get())); //Skip LwpUserDictFiles { @@ -117,7 +113,8 @@ void LwpDocument::Read() LwpPrinterInfo aPrtInfo( m_pObjStrm.get() ); } - m_pFoundry = m_pOwnedFoundry = new LwpFoundry(m_pObjStrm.get(), this); + m_xOwnedFoundry.reset(new LwpFoundry(m_pObjStrm.get(), this)); + m_pFoundry = m_xOwnedFoundry.get(); m_DivOpts.ReadIndexed(m_pObjStrm.get()); @@ -348,9 +345,9 @@ void LwpDocument::RegisterGraphicsStyles() */ void LwpDocument::RegisterLinenumberStyles() { - if (!m_pLnOpts) + if (!m_xLnOpts) return; - m_pLnOpts->RegisterStyle(); + m_xLnOpts->RegisterStyle(); } /** diff --git a/lotuswordpro/source/filter/lwpdoc.hxx b/lotuswordpro/source/filter/lwpdoc.hxx index e8551dcd466e..a2537a5abe2f 100644 --- a/lotuswordpro/source/filter/lwpdoc.hxx +++ b/lotuswordpro/source/filter/lwpdoc.hxx @@ -83,7 +83,7 @@ public: virtual ~LwpDocument() override; private: - LwpFoundry* m_pOwnedFoundry; + std::unique_ptr<LwpFoundry> m_xOwnedFoundry; bool m_bGettingFirstDivisionWithContentsThatIsNotOLE; bool m_bGettingPreviousDivisionWithContents; bool m_bGettingGetLastDivisionWithContents; @@ -98,13 +98,7 @@ private: DOC_CHILDDOC = 0x00000800UL }; - //Code cleaning by change some members to local variables in Read() - //Reserve the comments for future use - //LwpSortOption* m_pDocSort; - //LwpUIDocument* m_pUIDoc; - LwpLineNumberOptions* m_pLnOpts; - //LwpUserDictFiles* m_pUsrDicts; - //LwpPrinterInfo* m_pPrtInfo; + std::unique_ptr<LwpLineNumberOptions> m_xLnOpts; LwpObjectID m_DivOpts; LwpObjectID m_FootnoteOpts; diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx index df851fd8d4f2..ab51c1527d6c 100644 --- a/lotuswordpro/source/filter/lwpframelayout.cxx +++ b/lotuswordpro/source/filter/lwpframelayout.cxx @@ -1242,7 +1242,7 @@ void LwpRubyLayout::RegisterStyle() if (!pMarker) throw std::runtime_error("missing Ruby Marker"); - XFRubyStyle* pRubyStyle = new XFRubyStyle; + std::unique_ptr<XFRubyStyle> xRubyStyle(new XFRubyStyle); enumXFRubyPosition eType = enumXFRubyLeft; if (m_nAlignment == LEFT) @@ -1257,7 +1257,7 @@ void LwpRubyLayout::RegisterStyle() { eType = enumXFRubyCenter; } - pRubyStyle->SetAlignment(eType); + xRubyStyle->SetAlignment(eType); eType = enumXFRubyTop; if (m_nPlacement == TOP) @@ -1268,10 +1268,10 @@ void LwpRubyLayout::RegisterStyle() { eType = enumXFRubyBottom; } - pRubyStyle->SetPosition(eType); + xRubyStyle->SetPosition(eType); XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - OUString rubyStyle = pXFStyleManager->AddStyle(pRubyStyle).m_pStyle->GetStyleName(); + OUString rubyStyle = pXFStyleManager->AddStyle(xRubyStyle.release()).m_pStyle->GetStyleName(); pMarker->SetRubyStyleName(rubyStyle); LwpStory* pStory = GetContentStory(); diff --git a/lotuswordpro/source/filter/lwpfribptr.cxx b/lotuswordpro/source/filter/lwpfribptr.cxx index a899458bca4e..902727aef38c 100644 --- a/lotuswordpro/source/filter/lwpfribptr.cxx +++ b/lotuswordpro/source/filter/lwpfribptr.cxx @@ -162,20 +162,9 @@ void LwpFribPtr::XFConvert() sChangeID = pChangeMgr->GetChangeID(pFrib); if (!sChangeID.isEmpty()) { - /// if (nRevisionType == LwpFrib::REV_INSERT) - /// { - XFChangeStart* pChangeStart = new XFChangeStart; - pChangeStart->SetChangeID(sChangeID); - m_pXFPara->Add(pChangeStart); - /// } - /// else if (nRevisionType == LwpFrib::REV_DELETE) - /// { - /// XFChange* pChange = new XFChange; - /// pChange->SetChangeID(sChangeID); - /// m_pXFPara->Add(pChange); - /// pFrib = pFrib->GetNext(); - /// continue; - /// } + rtl::Reference<XFChangeStart> xChangeStart(new XFChangeStart); + xChangeStart->SetChangeID(sChangeID); + m_pXFPara->Add(xChangeStart.get()); } } } @@ -193,16 +182,16 @@ void LwpFribPtr::XFConvert() LwpFribTab* tabFrib = static_cast<LwpFribTab*>(pFrib); if (pFrib->m_ModFlag) { - XFTextSpan *pSpan = new XFTextSpan(); - pSpan->SetStyleName(tabFrib->GetStyleName()); - XFTabStop *pTab = new XFTabStop; - pSpan->Add(pTab); - m_pXFPara->Add(pSpan); + rtl::Reference<XFTextSpan> xSpan(new XFTextSpan); + xSpan->SetStyleName(tabFrib->GetStyleName()); + rtl::Reference<XFTabStop> xTab(new XFTabStop); + xSpan->Add(xTab.get()); + m_pXFPara->Add(xSpan.get()); } else { - XFTabStop *pTab = new XFTabStop; - m_pXFPara->Add(pTab); + rtl::Reference<XFTabStop> xTab(new XFTabStop); + m_pXFPara->Add(xTab.get()); } break; } @@ -248,8 +237,8 @@ void LwpFribPtr::XFConvert() } case FRIB_TAG_LINEBREAK: { - XFLineBreak *pLineBreak = new XFLineBreak; - m_pXFPara->Add(pLineBreak); + rtl::Reference<XFLineBreak> xLineBreak(new XFLineBreak); + m_pXFPara->Add(xLineBreak.get()); break; } case FRIB_TAG_UNICODE: //fall through @@ -363,9 +352,9 @@ void LwpFribPtr::XFConvert() { if (!sChangeID.isEmpty()) { - XFChangeEnd* pChangeEnd = new XFChangeEnd; - pChangeEnd->SetChangeID(sChangeID); - m_pXFPara->Add(pChangeEnd); + rtl::Reference<XFChangeEnd> xChangeEnd(new XFChangeEnd); + xChangeEnd->SetChangeID(sChangeID); + m_pXFPara->Add(xChangeEnd.get()); } } } diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx index b078e3a054d0..54f1246749a6 100644 --- a/lotuswordpro/source/filter/lwppara.cxx +++ b/lotuswordpro/source/filter/lwppara.cxx @@ -164,16 +164,7 @@ void LwpPara::Read() m_nOrdinal = m_pObjStrm->QuickReaduInt32(); if(LwpFileHeader::m_nFileRevision<0x000B) { - // TODO: to process assert(false); - /*pCForked3NotifyList Notify = new CForked3NotifyList(this); - Notify->GetExtraList()->QuickRead(pFile); - Notify->QuickRead(pFile); - if(Notify->GetExtraList()->IsEmpty() && - Notify->IsEmpty()) - delete Notify; - else - cNotifyList = Notify;*/ } else { @@ -203,13 +194,6 @@ void LwpPara::Read() { // TODO: to process assert(false); - /*PropList = new CParaPropListProperty(this); - PropList->GetList()->QuickRead(pFile); - if(PropList->GetList()->IsEmpty()) - { - delete PropList; - PropList = LNULL; - }*/ } m_nLevel = m_pObjStrm->QuickReaduInt16(); @@ -260,10 +244,10 @@ void LwpPara::XFConvert(XFContentContainer* pCont) if(!m_SectionStyleName.isEmpty()) { - XFSection* pSection = CreateXFSection(); + rtl::Reference<XFSection> xSection(CreateXFSection()); if (pStory) - pStory->AddXFContent(pSection); - m_xXFContainer.set(pSection); + pStory->AddXFContent(xSection.get()); + m_xXFContainer.set(xSection.get()); } if (m_bHasBullet && m_pSilverBullet) @@ -674,8 +658,8 @@ void LwpPara::RegisterStyle() XFListStyle* pOldStyle = static_cast<XFListStyle*>(pXFStyleManager->FindStyle(m_aBulletStyleName)); if (pOldStyle) { - XFListStyle* pNewStyle = new XFListStyle(*pOldStyle); - m_aBulletStyleName = pXFStyleManager->AddStyle(pNewStyle).m_pStyle->GetStyleName(); + std::unique_ptr<XFListStyle> xNewStyle(new XFListStyle(*pOldStyle)); + m_aBulletStyleName = pXFStyleManager->AddStyle(xNewStyle.release()).m_pStyle->GetStyleName(); } } } @@ -736,12 +720,12 @@ void LwpPara::RegisterStyle() if (m_bHasDropcap) { GatherDropcapInfo(); - XFParaStyle* pStyle = new XFParaStyle; - *pStyle = *GetXFParaStyle(); - pStyle->SetDropCap(m_nChars-1,m_nLines); + std::unique_ptr<XFParaStyle> xStyle(new XFParaStyle); + *xStyle = *GetXFParaStyle(); + xStyle->SetDropCap(m_nChars-1,m_nLines); if (!m_ParentStyleName.isEmpty()) - pStyle->SetParentStyleName(m_ParentStyleName); - m_StyleName = pXFStyleManager->AddStyle(pStyle).m_pStyle->GetStyleName(); + xStyle->SetParentStyleName(m_ParentStyleName); + m_StyleName = pXFStyleManager->AddStyle(xStyle.release()).m_pStyle->GetStyleName(); } // maybe useful for further version // deleted because Leader of Table is not supported in this version @@ -753,22 +737,22 @@ void LwpPara::RegisterNewSectionStyle(LwpPageLayout *pLayout) if( !pLayout ) return; - XFSectionStyle* pSectStyle= new XFSectionStyle(); + std::unique_ptr<XFSectionStyle> xSectStyle(new XFSectionStyle); XFColumns* pColumns = pLayout->GetXFColumns(); if(pColumns) { - pSectStyle->SetColumns(pColumns); + xSectStyle->SetColumns(pColumns); } XFStyleManager* pXFStyleManager = LwpGlobalMgr::GetInstance()->GetXFStyleManager(); - m_SectionStyleName = pXFStyleManager->AddStyle(pSectStyle).m_pStyle->GetStyleName(); + m_SectionStyleName = pXFStyleManager->AddStyle(xSectStyle.release()).m_pStyle->GetStyleName(); } -XFSection* LwpPara::CreateXFSection() +rtl::Reference<XFSection> LwpPara::CreateXFSection() { - XFSection* pXFSection = new XFSection(); - pXFSection->SetStyleName(m_SectionStyleName); + rtl::Reference<XFSection> xXFSection(new XFSection); + xXFSection->SetStyleName(m_SectionStyleName); m_SectionStyleName.clear(); - return pXFSection; + return xXFSection; } /************************************************************************** @@ -829,15 +813,15 @@ void LwpPara::AddBreakBefore(XFContentContainer* pCont) return; if (m_pBreaks->IsPageBreakBefore()) { - XFParagraph *pPara = new XFParagraph(); - pPara->SetStyleName(m_BefPageBreakName); - pCont->Add(pPara); + rtl::Reference<XFParagraph> xPara(new XFParagraph); + xPara->SetStyleName(m_BefPageBreakName); + pCont->Add(xPara.get()); } else if (m_pBreaks->IsColumnBreakBefore()) { - XFParagraph *pPara = new XFParagraph(); - pPara->SetStyleName(m_BefColumnBreakName); - pCont->Add(pPara); + rtl::Reference<XFParagraph> xPara(new XFParagraph); + xPara->SetStyleName(m_BefColumnBreakName); + pCont->Add(xPara.get()); } } @@ -847,15 +831,15 @@ void LwpPara::AddBreakAfter(XFContentContainer* pCont) return; if (m_pBreaks->IsPageBreakAfter()) { - XFParagraph *pPara = new XFParagraph(); - pPara->SetStyleName(m_AftPageBreakName); - pCont->Add(pPara); + rtl::Reference<XFParagraph> xPara(new XFParagraph); + xPara->SetStyleName(m_AftPageBreakName); + pCont->Add(xPara.get()); } else if (m_pBreaks->IsColumnBreakAfter()) { - XFParagraph *pPara = new XFParagraph(); - pPara->SetStyleName(m_AftColumnBreakName); - pCont->Add(pPara); + rtl::Reference<XFParagraph> xPara(new XFParagraph); + xPara->SetStyleName(m_AftColumnBreakName); + pCont->Add(xPara.get()); } } diff --git a/lotuswordpro/source/filter/lwppara.hxx b/lotuswordpro/source/filter/lwppara.hxx index 701cb7daeb59..ef44a214d1dd 100644 --- a/lotuswordpro/source/filter/lwppara.hxx +++ b/lotuswordpro/source/filter/lwppara.hxx @@ -274,7 +274,7 @@ private: rtl::Reference<XFContentContainer> AddBulletList(XFContentContainer* pCont); void AddBreakAfter(XFContentContainer* pCont); void AddBreakBefore(XFContentContainer* pCont); - XFSection* CreateXFSection(); + rtl::Reference<XFSection> CreateXFSection(); void ReadPropertyList(LwpObjectStream* pFile); }; |