summaryrefslogtreecommitdiff
path: root/sw
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
parentb1a5aedb74d623709c4448b75c250e9fe17b9c28 (diff)
Avoid possible memory leaks in case of exceptions
Change-Id: I45929aae52fa106b5f5c0199f8ce8b60c0ac5438
Diffstat (limited to 'sw')
-rw-r--r--sw/source/ui/envelp/envfmt.cxx6
-rw-r--r--sw/source/ui/envelp/envprt.cxx5
-rw-r--r--sw/source/ui/envelp/labfmt.cxx4
-rw-r--r--sw/source/ui/envelp/labprt.cxx5
-rw-r--r--sw/source/ui/fldui/fldedt.cxx6
-rw-r--r--sw/source/ui/frmdlg/frmpage.cxx11
-rw-r--r--sw/source/ui/index/cnttab.cxx12
-rw-r--r--sw/source/ui/index/swuiidxmrk.cxx4
-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
11 files changed, 41 insertions, 45 deletions
diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx
index 760c9c278d59..c816fe933972 100644
--- a/sw/source/ui/envelp/envfmt.cxx
+++ b/sw/source/ui/envelp/envfmt.cxx
@@ -44,6 +44,7 @@
#include <vector>
#include <algorithm>
+#include <boost/scoped_array.hpp>
#include <boost/scoped_ptr.hpp>
#include "swabstdlg.hxx"
@@ -352,12 +353,11 @@ SfxItemSet *SwEnvFmtPage::GetCollItemSet(SwTxtFmtColl* pColl, bool bSender)
std::vector<sal_uInt16> pVec = ::lcl_convertRangesToList(pRanges);
std::vector<sal_uInt16> aVec = ::lcl_convertRangesToList(aRanges);
pVec.insert(pVec.end(), aVec.begin(), aVec.end());
- sal_uInt16 *pNewRanges = ::lcl_convertListToRanges(pVec);
+ boost::scoped_array<sal_uInt16> pNewRanges(::lcl_convertListToRanges(pVec));
pAddrSet = new SfxItemSet(GetParentSwEnvDlg()->pSh->GetView().GetCurShell()->GetPool(),
- pNewRanges);
+ pNewRanges.get());
pAddrSet->Put(pColl->GetAttrSet());
- delete[] pNewRanges;
}
return pAddrSet;
diff --git a/sw/source/ui/envelp/envprt.cxx b/sw/source/ui/envelp/envprt.cxx
index 6978b0454b36..252cf04ac0d9 100644
--- a/sw/source/ui/envelp/envprt.cxx
+++ b/sw/source/ui/envelp/envprt.cxx
@@ -27,6 +27,7 @@
#include "uitool.hxx"
#include "envprt.hrc"
+#include <boost/scoped_ptr.hpp>
SwEnvPrtPage::SwEnvPrtPage(Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "EnvPrinterPage",
@@ -98,10 +99,10 @@ IMPL_LINK( SwEnvPrtPage, ButtonHdl, Button *, pBtn )
// Call printer setup
if (pPrt)
{
- PrinterSetupDialog* pDlg = new PrinterSetupDialog(this );
+ boost::scoped_ptr<PrinterSetupDialog> pDlg(new PrinterSetupDialog(this));
pDlg->SetPrinter(pPrt);
pDlg->Execute();
- delete pDlg;
+ pDlg.reset();
GrabFocus();
m_pPrinterInfo->SetText(pPrt->GetName());
}
diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx
index ae27b717766f..49593db120b8 100644
--- a/sw/source/ui/envelp/labfmt.cxx
+++ b/sw/source/ui/envelp/labfmt.cxx
@@ -34,6 +34,7 @@
#include "../../uibase/envelp/label.hrc"
#include "labfmt.hrc"
#include <unomid.h>
+#include <boost/scoped_ptr.hpp>
using namespace utl;
using namespace ::com::sun::star::uno;
@@ -557,7 +558,7 @@ IMPL_LINK_NOARG(SwLabFmtPage, SaveHdl)
aRec.lPWidth = static_cast< long >(GETFLDVAL(*m_pPWidthField ));
aRec.lPHeight = static_cast< long >(GETFLDVAL(*m_pPHeightField));
aRec.bCont = aItem.bCont;
- SwSaveLabelDlg* pSaveDlg = new SwSaveLabelDlg(this, aRec);
+ boost::scoped_ptr<SwSaveLabelDlg> pSaveDlg(new SwSaveLabelDlg(this, aRec));
pSaveDlg->SetLabel(aItem.aLstMake, aItem.aLstType);
pSaveDlg->Execute();
if(pSaveDlg->GetLabel(aItem))
@@ -572,7 +573,6 @@ IMPL_LINK_NOARG(SwLabFmtPage, SaveHdl)
m_pMakeFI->SetText(aItem.aMake);
m_pTypeFI->SetText(aItem.aType);
}
- delete pSaveDlg;
return 0;
}
diff --git a/sw/source/ui/envelp/labprt.cxx b/sw/source/ui/envelp/labprt.cxx
index 454660df265e..cc5a9e3c152a 100644
--- a/sw/source/ui/envelp/labprt.cxx
+++ b/sw/source/ui/envelp/labprt.cxx
@@ -27,6 +27,7 @@
#include "swuilabimp.hxx"
#include <cmdid.h>
+#include <boost/scoped_ptr.hpp>
SwLabPrtPage::SwLabPrtPage(Window* pParent, const SfxItemSet& rSet)
: SfxTabPage(pParent, "LabelOptionsPage",
@@ -73,10 +74,10 @@ IMPL_LINK( SwLabPrtPage, CountHdl, Button *, pButton )
if (!pPrinter)
pPrinter = new Printer;
- PrinterSetupDialog* pDlg = new PrinterSetupDialog(this );
+ boost::scoped_ptr<PrinterSetupDialog> pDlg(new PrinterSetupDialog(this));
pDlg->SetPrinter(pPrinter);
pDlg->Execute();
- delete pDlg;
+ pDlg.reset();
GrabFocus();
m_pPrinterInfo->SetText(pPrinter->GetName());
return 0;
diff --git a/sw/source/ui/fldui/fldedt.cxx b/sw/source/ui/fldui/fldedt.cxx
index 45bf150b9f0f..54b938b48f7c 100644
--- a/sw/source/ui/fldui/fldedt.cxx
+++ b/sw/source/ui/fldui/fldedt.cxx
@@ -46,6 +46,7 @@
#include <com/sun/star/document/XDocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
+#include <boost/scoped_ptr.hpp>
namespace swui
{
@@ -312,15 +313,14 @@ IMPL_LINK_NOARG(SwFldEditDlg, AddressHdl)
SwAbstractDialogFactory* pFact = swui::GetFactory();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( this, aSet,
+ boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact->CreateSfxDialog( this, aSet,
pSh->GetView().GetViewFrame()->GetFrame().GetFrameInterface(),
- RC_DLG_ADDR );
+ RC_DLG_ADDR ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if(RET_OK == pDlg->Execute())
{
pSh->UpdateFlds( *pCurFld );
}
- delete pDlg;
return 0;
}
diff --git a/sw/source/ui/frmdlg/frmpage.cxx b/sw/source/ui/frmdlg/frmpage.cxx
index 9a9cc62cc57b..b96ed9ad5fe5 100644
--- a/sw/source/ui/frmdlg/frmpage.cxx
+++ b/sw/source/ui/frmdlg/frmpage.cxx
@@ -68,6 +68,7 @@
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
#include <vcl/graphicfilter.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::sfx2;
@@ -2716,7 +2717,7 @@ void SwFrmURLPage::Reset( const SfxItemSet &rSet )
const SfxPoolItem* pItem;
if ( SFX_ITEM_SET == rSet.GetItemState( SID_DOCFRAME, true, &pItem))
{
- TargetList* pList = new TargetList;
+ boost::scoped_ptr<TargetList> pList(new TargetList);
((const SfxFrameItem*)pItem)->GetFrame()->GetTargetList(*pList);
if( !pList->empty() )
{
@@ -2726,7 +2727,6 @@ void SwFrmURLPage::Reset( const SfxItemSet &rSet )
pFrameCB->InsertEntry( pList->at( i ) );
}
}
- delete pList;
}
if ( SFX_ITEM_SET == rSet.GetItemState( RES_URL, true, &pItem ) )
@@ -2756,11 +2756,11 @@ bool SwFrmURLPage::FillItemSet(SfxItemSet &rSet)
{
bool bModified = false;
const SwFmtURL* pOldURL = (SwFmtURL*)GetOldItem(rSet, RES_URL);
- SwFmtURL* pFmtURL;
+ boost::scoped_ptr<SwFmtURL> pFmtURL;
if(pOldURL)
- pFmtURL = (SwFmtURL*)pOldURL->Clone();
+ pFmtURL.reset((SwFmtURL*)pOldURL->Clone());
else
- pFmtURL = new SwFmtURL();
+ pFmtURL.reset(new SwFmtURL());
{
const OUString sText = pURLED->GetText();
@@ -2787,7 +2787,6 @@ bool SwFrmURLPage::FillItemSet(SfxItemSet &rSet)
bModified = true;
}
rSet.Put(*pFmtURL);
- delete pFmtURL;
return bModified;
}
diff --git a/sw/source/ui/index/cnttab.cxx b/sw/source/ui/index/cnttab.cxx
index 9934fb5f01c5..0589d6b470b7 100644
--- a/sw/source/ui/index/cnttab.cxx
+++ b/sw/source/ui/index/cnttab.cxx
@@ -83,6 +83,7 @@ using namespace ::com::sun::star::uno;
using namespace com::sun::star::ui::dialogs;
using namespace ::sfx2;
#include <svtools/editbrowsebox.hxx>
+#include <boost/scoped_ptr.hpp>
static const sal_Unicode aDeliStart = '['; // for the form
static const sal_Unicode aDeliEnd = ']'; // for the form
@@ -1409,11 +1410,11 @@ IMPL_LINK(SwTOXSelectTabPage, LanguageHdl, ListBox*, pBox)
IMPL_LINK(SwTOXSelectTabPage, AddStylesHdl, PushButton*, pButton)
{
- SwAddStylesDlg_Impl* pDlg = new SwAddStylesDlg_Impl(pButton,
+ boost::scoped_ptr<SwAddStylesDlg_Impl> pDlg(new SwAddStylesDlg_Impl(pButton,
((SwMultiTOXTabDialog*)GetTabDialog())->GetWrtShell(),
- aStyleArr);
+ aStyleArr));
pDlg->Execute();
- delete pDlg;
+ pDlg.reset();
ModifyHdl(0);
return 0;
}
@@ -1445,12 +1446,11 @@ IMPL_LINK(SwTOXSelectTabPage, MenuExecuteHdl, Menu*, pMenu)
return 0;
}
- SwAutoMarkDlg_Impl* pAutoMarkDlg = new SwAutoMarkDlg_Impl(
- m_pAutoMarkPB, sAutoMarkURL, sAutoMarkType, bNew );
+ boost::scoped_ptr<SwAutoMarkDlg_Impl> pAutoMarkDlg(new SwAutoMarkDlg_Impl(
+ m_pAutoMarkPB, sAutoMarkURL, sAutoMarkType, bNew ));
if( RET_OK != pAutoMarkDlg->Execute() && bNew )
sAutoMarkURL = sSaveAutoMarkURL;
- delete pAutoMarkDlg;
}
return 0;
}
diff --git a/sw/source/ui/index/swuiidxmrk.cxx b/sw/source/ui/index/swuiidxmrk.cxx
index 94b0c0ac1730..12cabb4ea082 100644
--- a/sw/source/ui/index/swuiidxmrk.cxx
+++ b/sw/source/ui/index/swuiidxmrk.cxx
@@ -60,6 +60,7 @@
#include <SwRewriter.hxx>
#include <unomid.h>
+#include <boost/scoped_ptr.hpp>
#define POS_CONTENT 0
#define POS_INDEX 1
@@ -581,14 +582,13 @@ IMPL_LINK( SwNewUserIdxDlg, ModifyHdl, Edit*, pEdit)
IMPL_LINK_NOARG(SwIndexMarkPane, NewUserIdxHdl)
{
- SwNewUserIdxDlg* pDlg = new SwNewUserIdxDlg(this);
+ boost::scoped_ptr<SwNewUserIdxDlg> pDlg(new SwNewUserIdxDlg(this));
if(RET_OK == pDlg->Execute())
{
OUString sNewName(pDlg->GetName());
m_pTypeDCB->InsertEntry(sNewName);
m_pTypeDCB->SelectEntry(sNewName);
}
- delete pDlg;
return 0;
}
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()