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