summaryrefslogtreecommitdiffstats
path: root/sw/source/uibase
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2014-06-10 17:31:26 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2014-06-10 18:25:54 +0900
commited9d32908dca5740109f0d9f3233721aa3a49775 (patch)
tree601a6f988c2e4824241d0b80bc7f18bbb21b9a74 /sw/source/uibase
parent-Werror,-Wundefined-bool-conversion (diff)
downloadcore-ed9d32908dca5740109f0d9f3233721aa3a49775.tar.gz
core-ed9d32908dca5740109f0d9f3233721aa3a49775.zip
Avoid possible memory leaks in case of exceptions
Change-Id: I0cb10efaa3ab08d2cf1338963917d89bdab15289
Diffstat (limited to 'sw/source/uibase')
-rw-r--r--sw/source/uibase/shells/drwbassh.cxx20
-rw-r--r--sw/source/uibase/shells/drwtxtex.cxx16
-rw-r--r--sw/source/uibase/shells/drwtxtsh.cxx13
-rw-r--r--sw/source/uibase/shells/frmsh.cxx27
-rw-r--r--sw/source/uibase/shells/grfsh.cxx6
-rw-r--r--sw/source/uibase/shells/langhelper.cxx4
6 files changed, 35 insertions, 51 deletions
diff --git a/sw/source/uibase/shells/drwbassh.cxx b/sw/source/uibase/shells/drwbassh.cxx
index a03492dae262..b17d41b8ba3d 100644
--- a/sw/source/uibase/shells/drwbassh.cxx
+++ b/sw/source/uibase/shells/drwbassh.cxx
@@ -64,6 +64,7 @@
#include <com/sun/star/text/RelOrientation.hpp>
#include <IDocumentDrawModelAccess.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
@@ -152,7 +153,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- SfxAbstractDialog* pDlg = pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, true, RC_DLG_SWWRAPDLG );
+ boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact->CreateSwWrapDlg( GetView().GetWindow(), aSet, pSh, true, RC_DLG_SWWRAPDLG ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if (pDlg->Execute() == RET_OK)
@@ -170,7 +171,6 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
pSh->SetObjAttr(*pOutSet);
}
- delete pDlg;
}
}
}
@@ -187,7 +187,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
if( rMarkList.GetMark(0) != 0 )
{
SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
- SfxAbstractTabDialog *pDlg=NULL;
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg;
bool bCaption = false;
// Allowed anchorages:
@@ -207,7 +207,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
AbstractSvxCaptionDialog* pCaptionDlg =
pFact->CreateCaptionDialog( NULL, pSdrView, nAllowedAnchors );
pCaptionDlg->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
- pDlg = pCaptionDlg;
+ pDlg.reset(pCaptionDlg);
}
else
{
@@ -215,7 +215,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
AbstractSvxTransformTabDialog* pTransform =
pFact->CreateSvxTransformTabDialog( NULL, NULL, pSdrView, nAllowedAnchors );
pTransform->SetValidateFramePosLink( LINK(this, SwDrawBaseShell, ValidatePosition) );
- pDlg = pTransform;
+ pDlg.reset(pTransform);
}
SfxItemSet aNewAttr(pSdrView->GetGeoAttrFromMarked());
@@ -347,8 +347,6 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
pSh->EndAllAction();
}
- delete pDlg;
-
}
}
else
@@ -529,7 +527,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- AbstractSvxObjectNameDialog* pDlg = pFact->CreateSvxObjectNameDialog(NULL, aName);
+ boost::scoped_ptr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(NULL, aName));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->SetCheckNameHdl(LINK(this, SwDrawBaseShell, CheckGroupShapeNameHdl));
@@ -540,8 +538,6 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
pSelected->SetName(aName);
pSh->SetModified();
}
-
- delete pDlg;
}
break;
@@ -561,7 +557,7 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- AbstractSvxObjectTitleDescDialog* pDlg = pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription);
+ boost::scoped_ptr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog(NULL, aTitle, aDescription));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if(RET_OK == pDlg->Execute())
@@ -574,8 +570,6 @@ void SwDrawBaseShell::Execute(SfxRequest &rReq)
pSh->SetModified();
}
-
- delete pDlg;
}
break;
diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx
index 775e2bf81885..e2f5990f629a 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -99,6 +99,7 @@
#include "swabstdlg.hxx"
#include "chrdlg.hrc"
#include "misc.hrc"
+#include <boost/scoped_ptr.hpp>
const sal_uInt32 nFontInc = 40; // 2pt
const sal_uInt32 nFontMaxSz = 19998; // 999.9pt
@@ -323,7 +324,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg(pView->GetWindow(), *pView, aDlgAttr, DLG_CHAR_DRAW);
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg(pView->GetWindow(), *pView, aDlgAttr, DLG_CHAR_DRAW));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if (nSlot == SID_CHAR_DLG_EFFECT)
{
@@ -335,7 +336,6 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
rReq.Done( *( pDlg->GetOutputItemSet() ) );
aNewAttr.Put(*pDlg->GetOutputItemSet());
}
- delete( pDlg );
if(RET_OK != nRet)
return ;
}
@@ -348,10 +348,9 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), rView.GetWrtShell());
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), rView.GetWrtShell()));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
break;
}
case FN_NUMBERING_OUTLINE_DLG:
@@ -359,11 +358,11 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
- GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ GetView().GetWindow(), &aTmp, GetView().GetWrtShell()));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
+ pDlg.reset();
rReq.Done();
}
break;
@@ -422,7 +421,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr,DLG_STD, 0, true );
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwParaDlg( GetView().GetWindow(), GetView(), aDlgAttr,DLG_STD, 0, true ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
sal_uInt16 nRet = pDlg->Execute();
if(RET_OK == nRet)
@@ -430,7 +429,6 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
rReq.Done( *( pDlg->GetOutputItemSet() ) );
aNewAttr.Put(*pDlg->GetOutputItemSet());
}
- delete( pDlg );
if(RET_OK != nRet)
return;
}
diff --git a/sw/source/uibase/shells/drwtxtsh.cxx b/sw/source/uibase/shells/drwtxtsh.cxx
index 69bae229721d..f362e30377f1 100644
--- a/sw/source/uibase/shells/drwtxtsh.cxx
+++ b/sw/source/uibase/shells/drwtxtsh.cxx
@@ -73,6 +73,7 @@
#include <cppuhelper/bootstrap.hxx>
#include "swabstdlg.hxx"
#include "misc.hrc"
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -459,9 +460,9 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq)
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
if ( pFact )
{
- SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog(
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog(
&(GetView().GetViewFrame()->GetWindow()),
- &aNewAttr, pSdrView );
+ &aNewAttr, pSdrView ));
sal_uInt16 nResult = pDlg->Execute();
if (nResult == RET_OK)
@@ -472,8 +473,6 @@ void SwDrawTextShell::ExecDraw(SfxRequest &rReq)
rReq.Done(*(pDlg->GetOutputItemSet()));
}
}
-
- delete( pDlg );
}
}
break;
@@ -741,8 +740,8 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
// If character is selected, it can be shown
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
- rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP );
+ boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact->CreateSfxDialog( rView.GetWindow(), aAllSet,
+ rView.GetViewFrame()->GetFrame().GetFrameInterface(), RID_SVXDLG_CHARMAP ));
sal_uInt16 nResult = pDlg->Execute();
if( nResult == RET_OK )
{
@@ -763,8 +762,6 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
SW_MOD()->ApplyUsrPref(aOpt, &rView);
}
}
-
- delete( pDlg );
}
if( !sSym.isEmpty() )
diff --git a/sw/source/uibase/shells/frmsh.cxx b/sw/source/uibase/shells/frmsh.cxx
index a420e800e4e8..e1c59e68d0b7 100644
--- a/sw/source/uibase/shells/frmsh.cxx
+++ b/sw/source/uibase/shells/frmsh.cxx
@@ -82,6 +82,7 @@
#include <docsh.hxx>
#include <svx/drawitem.hxx>
+#include <boost/scoped_ptr.hpp>
using ::editeng::SvxBorderLine;
using namespace ::com::sun::star;
@@ -240,10 +241,9 @@ void SwFrameShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
- VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), GetView().GetWrtShell());
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwFootNoteOptionDlg(GetView().GetWindow(), GetView().GetWrtShell()));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
break;
}
case FN_NUMBERING_OUTLINE_DLG:
@@ -251,11 +251,11 @@ void SwFrameShell::Execute(SfxRequest &rReq)
SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1);
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
- GetView().GetWindow(), &aTmp, GetView().GetWrtShell());
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTabDialog( DLG_TAB_OUTLINE,
+ GetView().GetWindow(), &aTmp, GetView().GetWrtShell()));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
pDlg->Execute();
- delete pDlg;
+ pDlg.reset();
rReq.Done();
break;
}
@@ -497,7 +497,7 @@ void SwFrameShell::Execute(SfxRequest &rReq)
SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric) ));
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog(
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateFrmTabDialog(
nSel & nsSelectionType::SEL_GRF ? "PictureDialog" :
nSel & nsSelectionType::SEL_OLE ? "ObjectDialog":
"FrameDialog",
@@ -505,7 +505,7 @@ void SwFrameShell::Execute(SfxRequest &rReq)
GetView().GetWindow(),
aSet, false,
false,
- sDefPage);
+ sDefPage));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if ( nSlot == FN_DRAW_WRAP_DLG )
@@ -627,7 +627,6 @@ void SwFrameShell::Execute(SfxRequest &rReq)
}
else
bUpdateMgr = false;
- delete pDlg;
}
}
break;
@@ -656,10 +655,10 @@ void SwFrameShell::Execute(SfxRequest &rReq)
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "Dialogdiet fail!");
- AbstractSvxObjectTitleDescDialog* pDlg =
+ boost::scoped_ptr<AbstractSvxObjectTitleDescDialog> pDlg(
pFact->CreateSvxObjectTitleDescDialog( NULL,
aTitle,
- aDescription );
+ aDescription ));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if ( pDlg->Execute() == RET_OK )
@@ -670,8 +669,6 @@ void SwFrameShell::Execute(SfxRequest &rReq)
rSh.SetObjDescription(aDescription);
rSh.SetObjTitle(aTitle);
}
-
- delete pDlg;
}
}
break;
@@ -1291,11 +1288,11 @@ void SwFrameShell::ExecDrawDlgTextFrame(SfxRequest& rReq)
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
DBG_ASSERT(pFact, "Dialogdiet Factory fail!");
- AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog(
+ boost::scoped_ptr<AbstractSvxAreaTabDialog> pDlg(pFact->CreateSvxAreaTabDialog(
NULL,
&aNewAttr,
pDoc,
- false);
+ false));
DBG_ASSERT(pDlg, "Dialogdiet fail!");
if(RET_OK == pDlg->Execute())
@@ -1320,8 +1317,6 @@ void SwFrameShell::ExecDrawDlgTextFrame(SfxRequest& rReq)
rBnd.Update(SID_ATTR_FILL_TRANSPARENCE);
rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE);
}
-
- delete pDlg;
}
break;
diff --git a/sw/source/uibase/shells/grfsh.cxx b/sw/source/uibase/shells/grfsh.cxx
index 23cc9bcf0fb9..f60b2d494278 100644
--- a/sw/source/uibase/shells/grfsh.cxx
+++ b/sw/source/uibase/shells/grfsh.cxx
@@ -79,6 +79,7 @@
#include "swslots.hxx"
#include "swabstdlg.hxx"
+#include <boost/scoped_ptr.hpp>
#define TOOLBOX_NAME "colorbar"
@@ -339,10 +340,10 @@ void SwGrfShell::Execute(SfxRequest &rReq)
SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "no dialog factory!");
- SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog("PictureDialog",
+ boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateFrmTabDialog("PictureDialog",
GetView().GetViewFrame(),
GetView().GetWindow(),
- aSet, false);
+ aSet, false));
OSL_ENSURE(pDlg, "no tab dialog!");
if (nSlot == FN_DRAW_WRAP_DLG)
@@ -456,7 +457,6 @@ void SwGrfShell::Execute(SfxRequest &rReq)
rSh.EndUndo(UNDO_END);
rSh.EndAllAction();
}
- delete pDlg;
}
break;
diff --git a/sw/source/uibase/shells/langhelper.cxx b/sw/source/uibase/shells/langhelper.cxx
index d7fa3f583b50..62474b422739 100644
--- a/sw/source/uibase/shells/langhelper.cxx
+++ b/sw/source/uibase/shells/langhelper.cxx
@@ -52,6 +52,7 @@
#include <vcl/msgbox.hxx>
#include <langhelper.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
@@ -125,9 +126,8 @@ namespace SwLangHelper
SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
if (pFact)
{
- VclAbstractDialog* pDlg = pFact->CreateVclDialog( rView.GetWindow(), SID_LANGUAGE_OPTIONS );
+ boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateVclDialog( rView.GetWindow(), SID_LANGUAGE_OPTIONS ));
pDlg->Execute();
- delete pDlg;
}
}
else