summaryrefslogtreecommitdiff
path: root/sw/source/ui/misc
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-06-04 04:11:15 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-06-04 04:17:18 +0900
commit7883992dd5f8561b6eb192fce864b76c3034b1c5 (patch)
tree7025fcae30913753f8ec86e502bec5d33bb436f3 /sw/source/ui/misc
parentb1a5aedb74d623709c4448b75c250e9fe17b9c28 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I45929aae52fa106b5f5c0199f8ce8b60c0ac5438
Diffstat (limited to 'sw/source/ui/misc')
-rw-r--r--sw/source/ui/misc/docfnote.cxx11
-rw-r--r--sw/source/ui/misc/glossary.cxx11
-rw-r--r--sw/source/ui/misc/outline.cxx11
3 files changed, 14 insertions, 19 deletions
diff --git a/sw/source/ui/misc/docfnote.cxx b/sw/source/ui/misc/docfnote.cxx
index 1f5c0f9d2174..7b9f5d246513 100644
--- a/sw/source/ui/misc/docfnote.cxx
+++ b/sw/source/ui/misc/docfnote.cxx
@@ -36,6 +36,7 @@
#include <misc.hrc>
#include <frmui.hrc>
#include <SwStyleNameMapper.hxx>
+#include <boost/scoped_ptr.hpp>
SwFootNoteOptionDlg::SwFootNoteOptionDlg(Window *pParent, SwWrtShell &rS)
: SfxTabDialog(pParent, "FootEndnoteDialog", "modules/swriter/ui/footendnotedialog.ui")
@@ -118,8 +119,8 @@ SwEndNoteOptionPage::SwEndNoteOptionPage(Window *pParent, bool bEN,
void SwEndNoteOptionPage::Reset( const SfxItemSet& )
{
- SwEndNoteInfo *pInf = bEndNote ? new SwEndNoteInfo( pSh->GetEndNoteInfo() )
- : new SwFtnInfo( pSh->GetFtnInfo() );
+ boost::scoped_ptr<SwEndNoteInfo> pInf(bEndNote ? new SwEndNoteInfo( pSh->GetEndNoteInfo() )
+ : new SwFtnInfo( pSh->GetFtnInfo() ));
SfxObjectShell * pDocSh = SfxObjectShell::Current();
if (PTR_CAST(SwWebDocShell, pDocSh))
@@ -216,7 +217,6 @@ void SwEndNoteOptionPage::Reset( const SfxItemSet& )
}
m_pPageTemplBox->SelectEntry( pInf->GetPageDesc( *pSh->GetDoc() )->GetName());
- delete pInf;
}
SwEndNoteOptionPage::~SwEndNoteOptionPage()
@@ -346,7 +346,7 @@ static SwCharFmt* lcl_GetCharFormat( SwWrtShell* pSh, const OUString& rCharFmtNa
bool SwEndNoteOptionPage::FillItemSet( SfxItemSet & )
{
- SwEndNoteInfo *pInf = bEndNote ? new SwEndNoteInfo() : new SwFtnInfo();
+ boost::scoped_ptr<SwEndNoteInfo> pInf(bEndNote ? new SwEndNoteInfo() : new SwFtnInfo());
pInf->nFtnOffset = static_cast< sal_uInt16 >(m_pOffsetFld->GetValue() -1);
pInf->aFmt.SetNumberingType(m_pNumViewBox->GetSelectedNumberingType() );
@@ -379,7 +379,7 @@ bool SwEndNoteOptionPage::FillItemSet( SfxItemSet & )
}
else
{
- SwFtnInfo *pI = (SwFtnInfo*)pInf;
+ SwFtnInfo *pI = (SwFtnInfo*)pInf.get();
pI->ePos = m_pPosPageBox->IsChecked() ? FTNPOS_PAGE : FTNPOS_CHAPTER;
pI->eNum = (SwFtnNum)GetNumbering();
pI->aQuoVadis = m_pContEdit->GetText();
@@ -387,7 +387,6 @@ bool SwEndNoteOptionPage::FillItemSet( SfxItemSet & )
if ( !(*pI == pSh->GetFtnInfo()) )
pSh->SetFtnInfo( *pI );
}
- delete pInf;
return true;
}
diff --git a/sw/source/ui/misc/glossary.cxx b/sw/source/ui/misc/glossary.cxx
index e989d124cd9f..677dc2b2d2ae 100644
--- a/sw/source/ui/misc/glossary.cxx
+++ b/sw/source/ui/misc/glossary.cxx
@@ -465,8 +465,8 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
else if (sItemIdent == "rename")
{
m_pShortNameEdit->SetText(pGlossaryHdl->GetGlossaryShortName(m_pNameED->GetText()));
- SwNewGlosNameDlg* pNewNameDlg = new SwNewGlosNameDlg(this, m_pNameED->GetText(),
- m_pShortNameEdit->GetText() );
+ boost::scoped_ptr<SwNewGlosNameDlg> pNewNameDlg(new SwNewGlosNameDlg(this, m_pNameED->GetText(),
+ m_pShortNameEdit->GetText() ));
if( RET_OK == pNewNameDlg->Execute() &&
pGlossaryHdl->Rename( m_pShortNameEdit->GetText(),
pNewNameDlg->GetNewShort(),
@@ -482,7 +482,6 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
m_pCategoryBox->MakeVisible(pNewEntry);
}
GrpSelect(m_pCategoryBox);
- delete pNewNameDlg;
}
else if (sItemIdent == "delete")
{
@@ -523,8 +522,8 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
const SfxPoolItem* pItem;
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- SfxAbstractDialog* pMacroDlg = pFact->CreateSfxDialog( this, aSet,
- pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), SID_EVENTCONFIG );
+ boost::scoped_ptr<SfxAbstractDialog> pMacroDlg(pFact->CreateSfxDialog( this, aSet,
+ pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(), SID_EVENTCONFIG ));
if ( pMacroDlg && pMacroDlg->Execute() == RET_OK &&
SFX_ITEM_SET == pMacroDlg->GetOutputItemSet()->GetItemState( RES_FRMMACRO, false, &pItem ) )
{
@@ -533,8 +532,6 @@ IMPL_LINK( SwGlossaryDlg, MenuHdl, Menu *, pMn )
rTbl.Get( SW_EVENT_START_INS_GLOSSARY ),
rTbl.Get( SW_EVENT_END_INS_GLOSSARY ) );
}
-
- delete pMacroDlg;
}
else if (sItemIdent == "import")
{
diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx
index c4b1901208fa..50ccf9ea16be 100644
--- a/sw/source/ui/misc/outline.cxx
+++ b/sw/source/ui/misc/outline.cxx
@@ -893,7 +893,7 @@ void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
{
const Size aSize(PixelToLogic(GetOutputSizePixel()));
- VirtualDevice* pVDev = new VirtualDevice(*this);
+ boost::scoped_ptr<VirtualDevice> pVDev(new VirtualDevice(*this));
pVDev->SetMapMode(GetMapMode());
pVDev->SetOutputSize( aSize );
@@ -973,12 +973,12 @@ void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
long nBulletWidth = 0;
if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
{
- nBulletWidth = lcl_DrawGraphic(pVDev, rFmt, nNumberXPos,
+ nBulletWidth = lcl_DrawGraphic(pVDev.get(), rFmt, nNumberXPos,
nYStart, nWidthRelation);
}
else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
{
- nBulletWidth = lcl_DrawBullet(pVDev, rFmt, nNumberXPos,
+ nBulletWidth = lcl_DrawBullet(pVDev.get(), rFmt, nNumberXPos,
nYStart, aStdFont.GetSize());
}
else
@@ -1069,12 +1069,12 @@ void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
long nTextOffset = 2 * nXStep;
if( SVX_NUM_BITMAP == rFmt.GetNumberingType() )
{
- lcl_DrawGraphic(pVDev, rFmt, nXStart, nYStart, nWidthRelation);
+ lcl_DrawGraphic(pVDev.get(), rFmt, nXStart, nYStart, nWidthRelation);
nTextOffset = nLineHeight + nXStep;
}
else if( SVX_NUM_CHAR_SPECIAL == rFmt.GetNumberingType() )
{
- nTextOffset = lcl_DrawBullet(pVDev, rFmt, nXStart, nYStart, aStdFont.GetSize());
+ nTextOffset = lcl_DrawBullet(pVDev.get(), rFmt, nXStart, nYStart, aStdFont.GetSize());
nTextOffset += nXStep;
}
else
@@ -1100,7 +1100,6 @@ void NumberingPreview::Paint( const Rectangle& /*rRect*/ )
DrawOutDev( Point(0,0), aSize,
Point(0,0), aSize,
*pVDev );
- delete pVDev;
}
NumberingPreview::~NumberingPreview()