Kaydet (Commit) 2c61edfd authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid possible memory leaks in case of exceptions

Change-Id: Ic88b22895c2eb4144d31f22a0f7bc98971873262
üst 8be75a2d
......@@ -34,6 +34,7 @@
#include "drawdoc.hxx"
#include "sdabstdlg.hxx"
#include "sdattr.hrc"
#include <boost/scoped_ptr.hpp>
namespace sd {
......@@ -90,7 +91,7 @@ void FuParagraph::DoExecute( SfxRequest& rReq )
}
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0;
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdParagraphTabDlg(NULL, &aNewAttr ) : 0);
if (!pDlg)
return;
......@@ -107,12 +108,8 @@ void FuParagraph::DoExecute( SfxRequest& rReq )
break;
default:
{
delete pDlg;
}
return; // Cancel
}
delete( pDlg );
}
mpView->SetAttributes( *pArgs );
......
......@@ -51,6 +51,7 @@
#include <editeng/outliner.hxx>
#include <editeng/editdata.hxx>
#include "sdabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
namespace sd
{
......@@ -148,7 +149,7 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
else
{
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
AbstractSdPresLayoutDlg* pDlg = pFact ? pFact->CreateSdPresLayoutDlg(mpDocSh, NULL, aSet ) : 0;
boost::scoped_ptr<AbstractSdPresLayoutDlg> pDlg(pFact ? pFact->CreateSdPresLayoutDlg(mpDocSh, NULL, aSet ) : 0);
sal_uInt16 nResult = pDlg ? pDlg->Execute() : static_cast<short>(RET_CANCEL);
......@@ -171,7 +172,6 @@ void FuPresentationLayout::DoExecute( SfxRequest& rReq )
default:
bError = true;
}
delete pDlg;
}
if (!bError)
......
......@@ -41,6 +41,8 @@
#include "prlayout.hxx"
#include "unchss.hxx"
#include "sdabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
namespace sd {
TYPEINIT1( FuPresentationObjects, FuPoor );
......@@ -142,7 +144,7 @@ void FuPresentationObjects::DoExecute( SfxRequest& )
SfxStyleSheetBase& rStyleSheet = *pStyleSheet;
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId( nDlgId ), rStyleSheet, ePO, pStyleSheetPool ) : 0;
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId( nDlgId ), rStyleSheet, ePO, pStyleSheetPool ) : 0);
if( pDlg && (pDlg->Execute() == RET_OK) )
{
const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
......@@ -155,7 +157,6 @@ void FuPresentationObjects::DoExecute( SfxRequest& )
pStyleSheet->GetItemSet().Put( *pOutSet );
( (SfxStyleSheet*) pStyleSheet )->Broadcast( SfxSimpleHint( SFX_HINT_DATACHANGED ) );
}
delete( pDlg );
}
}
}
......
......@@ -39,6 +39,7 @@
#include <sfx2/zoomitem.hxx>
#include <sfx2/request.hxx>
#include <svx/svxdlg.hxx>
#include <boost/scoped_ptr.hpp>
namespace sd {
......@@ -70,7 +71,7 @@ void FuScale::DoExecute( SfxRequest& rReq )
if( !pArgs )
{
SfxItemSet aNewAttr( mpDoc->GetPool(), SID_ATTR_ZOOM, SID_ATTR_ZOOM );
SvxZoomItem* pZoomItem;
boost::scoped_ptr<SvxZoomItem> pZoomItem;
sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL;
nValue = (sal_Int16) mpWindow->GetZoom();
......@@ -79,11 +80,11 @@ void FuScale::DoExecute( SfxRequest& rReq )
if( mpViewShell && mpViewShell->ISA( DrawViewShell ) &&
static_cast<DrawViewShell*>(mpViewShell)->IsZoomOnPage() )
{
pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nValue );
pZoomItem.reset(new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nValue ));
}
else
{
pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nValue );
pZoomItem.reset(new SvxZoomItem( SVX_ZOOM_PERCENT, nValue ));
}
// limit range
......@@ -109,11 +110,11 @@ void FuScale::DoExecute( SfxRequest& rReq )
pZoomItem->SetValueSet( nZoomValues );
aNewAttr.Put( *pZoomItem );
AbstractSvxZoomDialog* pDlg=NULL;
boost::scoped_ptr<AbstractSvxZoomDialog> pDlg;
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
if(pFact)
{
pDlg = pFact->CreateSvxZoomDialog(NULL, aNewAttr);
pDlg.reset(pFact->CreateSvxZoomDialog(NULL, aNewAttr));
}
if( pDlg )
......@@ -124,8 +125,6 @@ void FuScale::DoExecute( SfxRequest& rReq )
{
case RET_CANCEL:
{
delete pDlg;
delete pZoomItem;
rReq.Ignore ();
return; // Cancel
}
......@@ -141,7 +140,7 @@ void FuScale::DoExecute( SfxRequest& rReq )
const SfxItemSet aArgs (*(pDlg->GetOutputItemSet ()));
delete pDlg;
pDlg.reset();
switch (((const SvxZoomItem &) aArgs.Get (SID_ATTR_ZOOM)).GetType ())
{
......@@ -177,8 +176,6 @@ void FuScale::DoExecute( SfxRequest& rReq )
break;
}
}
delete pZoomItem;
}
else if(mpViewShell && (pArgs->Count () == 1))
{
......
......@@ -32,6 +32,7 @@
#include "Window.hxx"
#include "optsitem.hxx"
#include "sdabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
namespace sd {
......@@ -110,7 +111,7 @@ void FuSlideShowDlg::DoExecute( SfxRequest& )
aDlgSet.Put( SfxInt32Item( ATTR_PRESENT_DISPLAY, pOptions->GetDisplay() ) );
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
AbstractSdStartPresDlg* pDlg = pFact ? pFact->CreateSdStartPresentationDlg(mpWindow, aDlgSet, aPageNameList, pCustomShowList) : 0;
boost::scoped_ptr<AbstractSdStartPresDlg> pDlg(pFact ? pFact->CreateSdStartPresentationDlg(mpWindow, aDlgSet, aPageNameList, pCustomShowList) : 0);
if( pDlg && (pDlg->Execute() == RET_OK) )
{
OUString aPage;
......@@ -224,7 +225,6 @@ void FuSlideShowDlg::DoExecute( SfxRequest& )
if ( bValuesChanged )
mpDoc->SetChanged( true );
}
delete pDlg;
}
} // end of namespace sd
......
......@@ -36,6 +36,7 @@
#include "sdabstdlg.hxx"
#include "app.hrc"
#include <svx/svdpagv.hxx>
#include <boost/scoped_ptr.hpp>
namespace sd {
......@@ -112,7 +113,7 @@ void FuSnapLine::DoExecute( SfxRequest& rReq )
aNewAttr.Put(SfxUInt32Item(ATTR_SNAPLINE_Y, aLinePos.Y()));
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
AbstractSdSnapLineDlg* pDlg = pFact ? pFact->CreateSdSnapLineDlg( NULL, aNewAttr, mpView ) : 0;
boost::scoped_ptr<AbstractSdSnapLineDlg> pDlg(pFact ? pFact->CreateSdSnapLineDlg( NULL, aNewAttr, mpView ) : 0);
OSL_ASSERT(pDlg);
if (!pDlg)
return;
......@@ -145,7 +146,7 @@ void FuSnapLine::DoExecute( SfxRequest& rReq )
sal_uInt16 nResult = pDlg->Execute();
pDlg->GetAttr(aNewAttr);
delete pDlg;
pDlg.reset();
switch( nResult )
{
......
......@@ -65,6 +65,7 @@
#include "strings.hrc"
#include "helpids.h"
#include "sdabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
using namespace com::sun::star::uno;
using namespace com::sun::star::container;
......@@ -296,8 +297,8 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
if( pStyleSheet )
{
SfxAbstractTabDialog* pStdDlg = NULL;
SfxAbstractTabDialog* pPresDlg = NULL;
boost::scoped_ptr<SfxAbstractTabDialog> pStdDlg;
boost::scoped_ptr<SfxAbstractTabDialog> pPresDlg;
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
bool bOldDocInOtherLanguage = false;
SfxItemSet aOriSet( pStyleSheet->GetItemSet() );
......@@ -306,7 +307,7 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
if (eFamily == SD_STYLE_FAMILY_GRAPHICS)
{
pStdDlg = pFact ? pFact->CreateSdTabTemplateDlg( 0, mpDoc->GetDocSh(), *pStyleSheet, mpDoc, mpView ) : 0;
pStdDlg.reset(pFact ? pFact->CreateSdTabTemplateDlg( 0, mpDoc->GetDocSh(), *pStyleSheet, mpDoc, mpView ) : 0);
}
else if (eFamily == SD_STYLE_FAMILY_PSEUDO)
{
......@@ -370,7 +371,7 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
if( !bOldDocInOtherLanguage )
{
pPresDlg = pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId(nDlgId), *pStyleSheet, ePO, pSSPool ) : 0;
pPresDlg.reset(pFact ? pFact->CreateSdPresLayoutTemplateDlg( mpDocSh, NULL, SdResId(nDlgId), *pStyleSheet, ePO, pSSPool ) : 0);
}
}
else if (eFamily == SD_STYLE_FAMILY_CELL)
......@@ -579,13 +580,9 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
{
if( nSId == SID_STYLE_NEW )
pSSPool->Remove( pStyleSheet );
delete pStdDlg;
delete pPresDlg;
}
return; // Cancel
}
delete pStdDlg;
delete pPresDlg;
}
}
break;
......
......@@ -26,6 +26,7 @@
#include "View.hxx"
#include "ViewShell.hxx"
#include "drawdoc.hxx"
#include <boost/scoped_ptr.hpp>
namespace sd {
......@@ -58,7 +59,7 @@ void FuTextAttrDlg::DoExecute( SfxRequest& rReq )
if( !pArgs )
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, mpView );
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog( NULL, &aNewAttr, mpView ));
sal_uInt16 nResult = pDlg->Execute();
......@@ -73,12 +74,8 @@ void FuTextAttrDlg::DoExecute( SfxRequest& rReq )
break;
default:
{
delete( pDlg );
}
return; // Cancel
}
delete( pDlg );
}
mpView->SetAttributes( *pArgs );
}
......
......@@ -30,6 +30,7 @@
#include "strings.hrc"
#include "sdresid.hxx"
#include "sdabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
namespace sd
{
......@@ -64,7 +65,7 @@ void FuVectorize::DoExecute( SfxRequest& )
if( pObj && pObj->ISA( SdrGrafObj ) )
{
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
AbstractSdVectorizeDlg* pDlg = pFact ? pFact->CreateSdVectorizeDlg( mpWindow, ( (SdrGrafObj*) pObj )->GetGraphic().GetBitmap(), mpDocSh ) : 0;
boost::scoped_ptr<AbstractSdVectorizeDlg> pDlg(pFact ? pFact->CreateSdVectorizeDlg( mpWindow, ( (SdrGrafObj*) pObj )->GetGraphic().GetBitmap(), mpDocSh ) : 0);
if( pDlg && pDlg->Execute() == RET_OK )
{
const GDIMetaFile& rMtf = pDlg->GetGDIMetaFile();
......@@ -81,7 +82,6 @@ void FuVectorize::DoExecute( SfxRequest& )
mpView->EndUndo();
}
}
delete pDlg;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment