sw/source/uibase/misc/glshell.cxx | 8 ++-- sw/source/uibase/misc/redlndlg.cxx | 5 +- sw/source/uibase/shells/annotsh.cxx | 25 +++++--------- sw/source/uibase/shells/basesh.cxx | 63 ++++++++++++++---------------------- sw/source/uibase/shells/drawdlg.cxx | 15 +++----- sw/source/uibase/shells/drawsh.cxx | 10 ++--- 6 files changed, 54 insertions(+), 72 deletions(-)
New commits: commit cb28c59ff262cfc03dbd893dfe281ed41958b2c0 Author: Takeshi Abe <t...@fixedpoint.jp> Date: Mon Jun 9 12:26:02 2014 +0900 Avoid possible memory leaks in case of exceptions Change-Id: Id24acc128cf345a660e552f64c857906229f59c0 diff --git a/sw/source/uibase/misc/glshell.cxx b/sw/source/uibase/misc/glshell.cxx index 6149584..48d33c0 100644 --- a/sw/source/uibase/misc/glshell.cxx +++ b/sw/source/uibase/misc/glshell.cxx @@ -51,6 +51,7 @@ #include <sfx2/msg.hxx> #include <swslots.hxx> +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star; @@ -103,14 +104,14 @@ static bool lcl_Save( SwWrtShell& rSh, const OUString& rGroupName, const OUString& rShortNm, const OUString& rLongNm ) { const SvxAutoCorrCfg& rCfg = SvxAutoCorrCfg::Get(); - SwTextBlocks * pBlock = ::GetGlossaries()->GetGroupDoc( rGroupName ); + boost::scoped_ptr<SwTextBlocks> pBlock(::GetGlossaries()->GetGroupDoc( rGroupName )); SvxMacro aStart(aEmptyOUStr, aEmptyOUStr); SvxMacro aEnd(aEmptyOUStr, aEmptyOUStr); SwGlossaryHdl* pGlosHdl; pGlosHdl = rSh.GetView().GetGlosHdl(); - pGlosHdl->GetMacros( rShortNm, aStart, aEnd, pBlock ); + pGlosHdl->GetMacros( rShortNm, aStart, aEnd, pBlock.get() ); sal_uInt16 nRet = rSh.SaveGlossaryDoc( *pBlock, rLongNm, rShortNm, rCfg.IsSaveRelFile(), @@ -120,13 +121,12 @@ static bool lcl_Save( SwWrtShell& rSh, const OUString& rGroupName, { SvxMacro* pStart = aStart.HasMacro() ? &aStart : 0; SvxMacro* pEnd = aEnd.HasMacro() ? &aEnd : 0; - pGlosHdl->SetMacros( rShortNm, pStart, pEnd, pBlock ); + pGlosHdl->SetMacros( rShortNm, pStart, pEnd, pBlock.get() ); } rSh.EnterStdMode(); if( USHRT_MAX != nRet ) rSh.ResetModified(); - delete pBlock; return nRet != USHRT_MAX; } diff --git a/sw/source/uibase/misc/redlndlg.cxx b/sw/source/uibase/misc/redlndlg.cxx index 53aebdc..8f5968d 100644 --- a/sw/source/uibase/misc/redlndlg.cxx +++ b/sw/source/uibase/misc/redlndlg.cxx @@ -54,6 +54,7 @@ #include <docsh.hxx> #include <IDocumentRedlineAccess.hxx> +#include <boost/scoped_ptr.hpp> SFX_IMPL_MODELESSDIALOG_WITHID( SwRedlineAcceptChild, FN_REDLINE_ACCEPT ) @@ -1073,7 +1074,7 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl) rRedline.GetRedlineData().GetTimeStamp() ), SID_ATTR_POSTIT_DATE )); - AbstractSvxPostItDialog* pDlg = pFact->CreateSvxPostItDialog( pParentDlg, aSet, false ); + boost::scoped_ptr<AbstractSvxPostItDialog> pDlg(pFact->CreateSvxPostItDialog( pParentDlg, aSet, false )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); pDlg->HideAuthor(); @@ -1112,7 +1113,7 @@ IMPL_LINK_NOARG(SwRedlineAcceptDlg, CommandHdl) pTable->SetEntryText(sMsg.replace('\n', ' '), pEntry, 3); } - delete pDlg; + pDlg.reset(); pSh->SetCareWin(NULL); } diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx index 47d32a9..2b6158d 100644 --- a/sw/source/uibase/shells/annotsh.cxx +++ b/sw/source/uibase/shells/annotsh.cxx @@ -125,6 +125,7 @@ #include <wordcountdialog.hxx> #include <tools/diagnose_ex.h> +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -417,10 +418,9 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg(rView.GetWindow(), rView.GetWrtShell()); + boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwFootNoteOptionDlg(rView.GetWindow(), rView.GetWrtShell())); OSL_ENSURE(pDlg, "Dialogdiet fail!"); pDlg->Execute(); - delete pDlg; break; } case FN_NUMBERING_OUTLINE_DLG: @@ -428,11 +428,11 @@ void SwAnnotationShell::Exec( 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, - rView.GetWindow(), &aTmp, rView.GetWrtShell()); + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, + rView.GetWindow(), &aTmp, rView.GetWrtShell())); OSL_ENSURE(pDlg, "Dialogdiet fail!"); pDlg->Execute(); - delete pDlg; + pDlg.reset(); rReq.Done(); } break; @@ -485,7 +485,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - SfxAbstractTabDialog* pDlg = pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, DLG_CHAR_ANN); + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwCharDlg( rView.GetWindow(), rView, aDlgAttr, DLG_CHAR_ANN)); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if (nSlot == SID_CHAR_DLG_EFFECT) { @@ -497,7 +497,6 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) rReq.Done( *( pDlg->GetOutputItemSet() ) ); aNewAttr.Put(*pDlg->GetOutputItemSet()); } - delete( pDlg ); if(RET_OK != nRet) return ; } @@ -535,7 +534,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - SfxAbstractTabDialog* pDlg = pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, 0, true ); + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSwParaDlg( rView.GetWindow(), rView, aDlgAttr,DLG_STD, 0, true )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); sal_uInt16 nRet = pDlg->Execute(); if(RET_OK == nRet) @@ -543,7 +542,6 @@ void SwAnnotationShell::Exec( SfxRequest &rReq ) rReq.Done( *( pDlg->GetOutputItemSet() ) ); aNewAttr.Put(*pDlg->GetOutputItemSet()); } - delete( pDlg ); if(RET_OK != nRet) return; } @@ -891,7 +889,7 @@ void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq) if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()!=SwPostItHelper::DELETED) { SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( &rView.GetEditWin() ); + boost::scoped_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( &rView.GetEditWin() )); pDlg->Insert( SOT_FORMAT_STRING, OUString() ); pDlg->Insert( SOT_FORMAT_RTF, OUString() ); @@ -907,7 +905,6 @@ void SwAnnotationShell::ExecClpbrd(SfxRequest &rReq) else pOLV->PasteSpecial(); } - delete pDlg; } break; } @@ -1685,8 +1682,8 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq) aAllSet.Put( SfxStringItem( SID_FONT_NAME, aSetDlgFont.GetFamilyName() ) ); // If character is selected then it can be shown. - 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 ) @@ -1708,8 +1705,6 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq) SW_MOD()->ApplyUsrPref(aOpt, &rView); } } - - delete( pDlg ); } if( !sSym.isEmpty() ) diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 0bd7d8f..6d544b4b 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -109,6 +109,7 @@ #include <unomid.h> #include <svx/galleryitem.hxx> #include <com/sun/star/gallery/GalleryItemType.hpp> +#include <boost/scoped_ptr.hpp> FlyMode SwBaseShell::eFrameMode = FLY_DRAG_END; @@ -159,16 +160,14 @@ static void lcl_UpdateIMapDlg( SwWrtShell& rSh ) GraphicType nGrfType = aGrf.GetType(); void* pEditObj = GRAPHIC_NONE != nGrfType && GRAPHIC_DEFAULT != nGrfType ? rSh.GetIMapInventor() : 0; - TargetList* pList = new TargetList; + boost::scoped_ptr<TargetList> pList(new TargetList); rSh.GetView().GetViewFrame()->GetTopFrame().GetTargetList(*pList); SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL ); rSh.GetFlyFrmAttr( aSet ); const SwFmtURL &rURL = (SwFmtURL&)aSet.Get( RES_URL ); SvxIMapDlgChildWindow::UpdateIMapDlg( - aGrf, rURL.GetMap(), pList, pEditObj ); - - delete pList; + aGrf, rURL.GetMap(), pList.get(), pEditObj ); } static bool lcl_UpdateContourDlg( SwWrtShell &rSh, int nSel ) @@ -772,7 +771,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) bToTable = true; SwInsertTableOptions aInsTblOpts( tabopts::ALL_TBL_INS_ATTR, 1 ); SwTableAutoFmt const* pTAFmt = 0; - SwTableAutoFmtTbl* pAutoFmtTbl = 0; + boost::scoped_ptr<SwTableAutoFmtTbl> pAutoFmtTbl; bool bDeleteFormat = true; if(pArgs && SFX_ITEM_SET == pArgs->GetItemState( FN_PARAM_1, true, &pItem)) { @@ -786,7 +785,7 @@ void SwBaseShell::Execute(SfxRequest &rReq) { OUString sAutoFmt = static_cast< const SfxStringItem* >(pItem)->GetValue(); - pAutoFmtTbl = new SwTableAutoFmtTbl; + pAutoFmtTbl.reset(new SwTableAutoFmtTbl); pAutoFmtTbl->Load(); for( sal_uInt16 i = 0, nCount = pAutoFmtTbl->size(); i < nCount; i++ ) @@ -822,14 +821,13 @@ void SwBaseShell::Execute(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - AbstractSwConvertTableDlg* pDlg = pFact->CreateSwConvertTableDlg(GetView(), bToTable); + boost::scoped_ptr<AbstractSwConvertTableDlg> pDlg(pFact->CreateSwConvertTableDlg(GetView(), bToTable)); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if( RET_OK == pDlg->Execute() ) { pDlg->GetValues( cDelim, aInsTblOpts, pTAFmt ); } - delete pDlg; } if( cDelim ) @@ -868,7 +866,6 @@ void SwBaseShell::Execute(SfxRequest &rReq) } if(bDeleteFormat) delete pTAFmt; - delete pAutoFmtTbl; } break; case SID_STYLE_WATERCAN: @@ -1931,7 +1928,7 @@ void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq ) if( pArgs) { SwWrtShell &rSh = GetShell(); - SvxScriptSetItem* pSSetItem = 0; + boost::scoped_ptr<SvxScriptSetItem> pSSetItem; sal_uInt16 nSlot = rReq.GetSlot(); SfxItemPool& rPool = rSh.GetAttrPool(); sal_uInt16 nWhich = rPool.GetWhich( nSlot ); @@ -1959,7 +1956,7 @@ void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq ) case SID_ATTR_CHAR_POSTURE: case SID_ATTR_CHAR_WEIGHT: { - pSSetItem = new SvxScriptSetItem( nSlot, rPool ); + pSSetItem.reset(new SvxScriptSetItem( nSlot, rPool )); pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); pArgs = &pSSetItem->GetItemSet(); } @@ -1968,7 +1965,7 @@ void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq ) { if(rSh.HasSelection()) { - pSSetItem = new SvxScriptSetItem( nSlot, rPool ); + pSSetItem.reset(new SvxScriptSetItem( nSlot, rPool )); pSSetItem->PutItemForScriptType( nScripts, pArgs->Get( nWhich )); pArgs = &pSSetItem->GetItemSet(); } @@ -2043,7 +2040,6 @@ void SwBaseShell::ExecTxtCtrl( SfxRequest& rReq ) rSh.SetAttrSet( *pArgs ); } } - delete pSSetItem; } else GetView().GetViewFrame()->GetDispatcher()->Execute( SID_CHAR_DLG, sal_False); @@ -2060,7 +2056,7 @@ void SwBaseShell::GetTxtFontCtrlState( SfxItemSet& rSet ) { SwWrtShell &rSh = GetShell(); bool bFirst = true; - SfxItemSet* pFntCoreSet = 0; + boost::scoped_ptr<SfxItemSet> pFntCoreSet; sal_uInt16 nScriptType = SCRIPTTYPE_LATIN; SfxWhichIter aIter( rSet ); sal_uInt16 nWhich = aIter.FirstWhich(); @@ -2075,8 +2071,8 @@ void SwBaseShell::GetTxtFontCtrlState( SfxItemSet& rSet ) { if( !pFntCoreSet ) { - pFntCoreSet = new SfxItemSet( *rSet.GetPool(), - RES_CHRATR_BEGIN, RES_CHRATR_END-1 ); + pFntCoreSet.reset(new SfxItemSet( *rSet.GetPool(), + RES_CHRATR_BEGIN, RES_CHRATR_END-1 )); rSh.GetCurAttr( *pFntCoreSet ); nScriptType = rSh.GetScriptType(); // #i42732# input language should be preferred over @@ -2133,7 +2129,6 @@ void SwBaseShell::GetTxtFontCtrlState( SfxItemSet& rSet ) } nWhich = aIter.NextWhich(); } - delete pFntCoreSet; } void SwBaseShell::GetBckColState(SfxItemSet &rSet) @@ -2414,9 +2409,8 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) case FN_FORMAT_TITLEPAGE_DLG: { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); - VclAbstractDialog* pDlg = pFact->CreateTitlePageDlg( pMDI ); + boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateTitlePageDlg( pMDI )); pDlg->Execute(); - delete pDlg; } break; case FN_FORMAT_PAGE_DLG: @@ -2454,7 +2448,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) RES_BOX , RES_SHADOW, SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 ); - SfxAbstractDialog * pDlg = 0; + boost::scoped_ptr<SfxAbstractDialog> pDlg; // Table cell(s) selected? if ( rSh.IsTableMode() ) { @@ -2464,7 +2458,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_TABLE, RC_DLG_SWBORDERDLG ); + pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_TABLE, RC_DLG_SWBORDERDLG )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if ( pDlg->Execute() == RET_OK ) { @@ -2481,7 +2475,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_FRAME, RC_DLG_SWBORDERDLG ); + pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_FRAME, RC_DLG_SWBORDERDLG )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if ( pDlg->Execute() == RET_OK ) { @@ -2499,7 +2493,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - pDlg = pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_PARA, RC_DLG_SWBORDERDLG ); + pDlg.reset(pFact->CreateSwBorderDlg( pMDI, aSet, SW_BORDER_MODE_PARA, RC_DLG_SWBORDERDLG )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if ( pDlg->Execute() == RET_OK ) { @@ -2512,7 +2506,6 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) rReq.Done(*pOutSet); bDone = true; } - delete pDlg; } break; case FN_FORMAT_BACKGROUND_DLG: @@ -2520,7 +2513,7 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) SfxItemSet aSet( rSh.GetAttrPool(), RES_BACKGROUND, RES_BACKGROUND ); - SfxAbstractDialog * pDlg = 0; + boost::scoped_ptr<SfxAbstractDialog> pDlg; SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); @@ -2530,9 +2523,9 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) // Get background attributes of the table and put it in the set SvxBrushItem aBrush(RES_BACKGROUND); rSh.GetBoxBackground( aBrush ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg.reset(pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame().GetFrameInterface(), - RC_SWDLG_BACKGROUND ); + RC_SWDLG_BACKGROUND )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); aSet.Put( aBrush ); if ( pDlg->Execute() == RET_OK ) @@ -2548,9 +2541,9 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) rSh.GetFlyFrmAttr( aSet ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg.reset(pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame().GetFrameInterface(), - RC_SWDLG_BACKGROUND ); + RC_SWDLG_BACKGROUND )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if ( pDlg->Execute() == RET_OK ) { @@ -2563,9 +2556,9 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) // Set border attributes Umrandungsattribute with the shell quite normal. rSh.GetCurAttr( aSet ); - pDlg = pFact->CreateSfxDialog( pMDI, aSet, + pDlg.reset(pFact->CreateSfxDialog( pMDI, aSet, rView.GetViewFrame()->GetFrame().GetFrameInterface(), - RC_SWDLG_BACKGROUND ); + RC_SWDLG_BACKGROUND )); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if ( pDlg->Execute() == RET_OK ) { @@ -2578,8 +2571,6 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) rReq.Done(*pOutSet); bDone = true; } - delete pDlg; - } break; default:OSL_FAIL("wrong Dispatcher (basesh.cxx)"); @@ -2678,7 +2669,7 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest ) { SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialogdiet fail!"); - AbstractInsTableDlg* pDlg = pFact->CreateInsTableDlg(rTempView); + boost::scoped_ptr<AbstractInsTableDlg> pDlg(pFact->CreateInsTableDlg(rTempView)); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if( RET_OK == pDlg->Execute() ) { @@ -2686,7 +2677,6 @@ void SwBaseShell::InsertTable( SfxRequest& _rRequest ) } else _rRequest.Ignore(); - delete pDlg; } if( nCols && nRows ) @@ -2893,10 +2883,9 @@ void SwBaseShell::ExecField( SfxRequest& rReq ) SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!"); - VclAbstractDialog* pDlg = pFact->CreateSwChangeDBDlg(GetView()); + boost::scoped_ptr<VclAbstractDialog> pDlg(pFact->CreateSwChangeDBDlg(GetView())); OSL_ENSURE(pDlg, "Dialogdiet fail!"); pDlg->Execute(); - delete pDlg; } break; default: diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index ce37589..79d5960 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -33,6 +33,7 @@ #include "drawsh.hxx" #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> +#include <boost/scoped_ptr.hpp> void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) { @@ -54,7 +55,7 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { - SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView ); + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog( NULL, &aNewAttr, pView )); sal_uInt16 nResult = pDlg->Execute(); if (nResult == RET_OK) @@ -67,8 +68,6 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) pSh->EndAction(); } } - - delete( pDlg ); } } break; @@ -78,10 +77,10 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) bool bHasMarked = pView->AreObjectsMarked(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL, + boost::scoped_ptr<AbstractSvxAreaTabDialog> pDlg(pFact->CreateSvxAreaTabDialog( NULL, &aNewAttr, pDoc, - true); + true)); if (pDlg->Execute() == RET_OK) { pSh->StartAction(); @@ -106,7 +105,6 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) rBnd.Update(SID_ATTR_FILL_TRANSPARENCE); rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE); } - delete pDlg; } break; @@ -121,11 +119,11 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialogdiet Factory fail!"); - SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL, + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxLineTabDialog( NULL, &aNewAttr, pDoc, pObj, - bHasMarked); + bHasMarked)); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if (pDlg->Execute() == RET_OK) { @@ -152,7 +150,6 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) GetView().GetViewFrame()->GetBindings().Invalidate(aInval); } - delete pDlg; } break; diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx index b4328a6..cf7dba7 100644 --- a/sw/source/uibase/shells/drawsh.cxx +++ b/sw/source/uibase/shells/drawsh.cxx @@ -69,6 +69,7 @@ #include "swabstdlg.hxx" #include <wordcountdialog.hxx> #include "misc.hrc" +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -303,10 +304,9 @@ void SwDrawShell::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: @@ -314,11 +314,11 @@ void SwDrawShell::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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits