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

Avoid possible memory leaks in case of exceptions

Change-Id: Icc1e11e173329fd88898a3d13270406fd651eb2b
üst 558618e0
......@@ -76,6 +76,8 @@
#define ScDrawTextObjectBar
#include "scslots.hxx"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
SFX_IMPL_INTERFACE(ScDrawTextObjectBar, SfxShell, ScResId(SCSTR_DRAWTEXTSHELL))
......@@ -833,14 +835,14 @@ void ScDrawTextObjectBar::ExecuteAttr( SfxRequest &rReq )
case SID_DRAWTEXT_ATTR_DLG:
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView );
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog( pViewData->GetDialogParent(), &aEditAttr, pView ));
bDone = ( RET_OK == pDlg->Execute() );
if ( bDone )
aNewAttr.Put( *pDlg->GetOutputItemSet() );
delete pDlg;
pDlg.reset();
SfxBindings& rBindings = pViewData->GetBindings();
rBindings.Invalidate( SID_TABLE_VERT_NONE );
......
......@@ -38,6 +38,7 @@
#include "scresid.hxx"
#include "scabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
bool ScDrawTextObjectBar::ExecuteCharDlg( const SfxItemSet& rArgs,
......@@ -46,9 +47,9 @@ bool ScDrawTextObjectBar::ExecuteCharDlg( const SfxItemSet& rArgs,
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg(
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateScCharDlg(
pViewData->GetDialogParent(), &rArgs,
pViewData->GetSfxDocShell());
pViewData->GetSfxDocShell()));
OSL_ENSURE(pDlg, "Dialog create fail!");
if (nSlot == SID_CHAR_DLG_EFFECT)
{
......@@ -62,7 +63,6 @@ bool ScDrawTextObjectBar::ExecuteCharDlg( const SfxItemSet& rArgs,
if ( pNewAttrs )
rOutSet.Put( *pNewAttrs );
}
delete pDlg;
return bRet;
}
......@@ -94,8 +94,8 @@ bool ScDrawTextObjectBar::ExecuteParaDlg( const SfxItemSet& rArgs,
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
SfxAbstractTabDialog* pDlg = pFact->CreateScParagraphDlg(
pViewData->GetDialogParent(), &aNewAttr);
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateScParagraphDlg(
pViewData->GetDialogParent(), &aNewAttr));
OSL_ENSURE(pDlg, "Dialog create fail!");
bool bRet = ( pDlg->Execute() == RET_OK );
......@@ -105,7 +105,6 @@ bool ScDrawTextObjectBar::ExecuteParaDlg( const SfxItemSet& rArgs,
if ( pNewAttrs )
rOutSet.Put( *pNewAttrs );
}
delete pDlg;
return bRet;
}
......@@ -115,7 +114,7 @@ void ScDrawTextObjectBar::ExecutePasteContents( SfxRequest & /* rReq */ )
SdrView* pView = pViewData->GetScDrawView();
OutlinerView* pOutView = pView->GetTextEditOutlinerView();
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
boost::scoped_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( pViewData->GetDialogParent() ));
pDlg->Insert( SOT_FORMAT_STRING, EMPTY_OUSTRING );
pDlg->Insert( SOT_FORMAT_RTF, EMPTY_OUSTRING );
......@@ -133,7 +132,6 @@ void ScDrawTextObjectBar::ExecutePasteContents( SfxRequest & /* rReq */ )
else
pOutView->PasteSpecial();
}
delete pDlg;
}
......
......@@ -83,6 +83,7 @@ using namespace ::com::sun::star;
#include "drawview.hxx"
#include "markdata.hxx"
#include "gridwin.hxx"
#include <boost/scoped_ptr.hpp>
namespace {
......@@ -245,9 +246,9 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pVie
case SID_INSERT_FLOATINGFRAME :
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractInsertObjectDialog* pDlg =
boost::scoped_ptr<SfxAbstractInsertObjectDialog> pDlg(
pFact->CreateInsertObjectDialog( pViewShell->GetWindow(), SC_MOD()->GetSlotPool()->GetSlot(nSlot)->GetCommandString(),
xStorage, &aServerLst );
xStorage, &aServerLst ));
if ( pDlg )
{
pDlg->Execute();
......@@ -261,7 +262,6 @@ FuInsertOLE::FuInsertOLE(ScTabViewShell* pViewSh, Window* pWin, ScDrawView* pVie
pViewSh->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
// damit DrawShell eingeschaltet wird (Objekt aktivieren ist unnoetig):
bIsFromFile = !pDlg->IsCreateNew();
DELETEZ( pDlg );
}
break;
......
......@@ -50,6 +50,7 @@
#include "scuiautofmt.hxx"
#include "scresid.hxx"
#include "document.hxx"
#include <boost/scoped_ptr.hpp>
// AutoFormat-Dialog:
......@@ -203,16 +204,15 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl)
{
OUString aStrStandard( SfxResId(STR_STANDARD) );
OUString aFormatName;
ScStringInputDlg* pDlg;
bool bOk = false;
while ( !bOk )
{
pDlg = new ScStringInputDlg( this,
boost::scoped_ptr<ScStringInputDlg> pDlg(new ScStringInputDlg( this,
aStrTitle,
aStrLabel,
aFormatName,
HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME );
HID_SC_ADD_AUTOFMT, HID_SC_AUTOFMT_NAME ));
if ( pDlg->Execute() == RET_OK )
{
......@@ -261,8 +261,6 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, AddHdl)
}
else
bOk = true;
delete pDlg;
}
}
......@@ -316,11 +314,11 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl)
OUString aFormatName = m_pLbFormat->GetSelectEntry();
OUString aEntry;
ScStringInputDlg* pDlg = new ScStringInputDlg( this,
boost::scoped_ptr<ScStringInputDlg> pDlg(new ScStringInputDlg( this,
aStrRename,
aStrLabel,
aFormatName,
HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME );
HID_SC_REN_AFMT_DLG, HID_SC_REN_AFMT_NAME ));
if( pDlg->Execute() == RET_OK )
{
bool bFmtRenamed = false;
......@@ -386,7 +384,6 @@ IMPL_LINK_NOARG(ScAutoFormatDlg, RenameHdl)
}
else
bOk = true;
delete pDlg;
}
return 0;
......
......@@ -41,6 +41,7 @@
#include "scresid.hxx"
#include "scuitphfedit.hxx"
#undef _TPHF_CXX
#include <boost/scoped_ptr.hpp>
// class ScHFPage
......@@ -191,21 +192,19 @@ IMPL_LINK_NOARG(ScHFPage, HFEditHdl)
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
SfxAbstractTabDialog* pDlg = pFact->CreateScHFEditDlg(
pViewSh->GetViewFrame(), this, aDataSet, aStrPageStyle, nResId);
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateScHFEditDlg(
pViewSh->GetViewFrame(), this, aDataSet, aStrPageStyle, nResId));
OSL_ENSURE(pDlg, "Dialog create fail!");
if ( pDlg->Execute() == RET_OK )
{
aDataSet.Put( *pDlg->GetOutputItemSet() );
}
delete pDlg;
}
else
{
OUString aText;
SfxSingleTabDialog* pDlg = new SfxSingleTabDialog(this, aDataSet);
boost::scoped_ptr<SfxSingleTabDialog> pDlg(new SfxSingleTabDialog(this, aDataSet));
const int nSettingsId = 42;
bool bRightPage = m_pCntSharedBox->IsChecked()
|| ( SVX_PAGE_LEFT != SvxPageUsage(nPageUsage) );
......@@ -239,8 +238,6 @@ IMPL_LINK_NOARG(ScHFPage, HFEditHdl)
{
aDataSet.Put( *pDlg->GetOutputItemSet() );
}
delete pDlg;
}
return 0;
......
......@@ -45,6 +45,7 @@
#include "AccessibleEditObject.hxx"
#include "scabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
// STATIC DATA -----------------------------------------------------------
......@@ -201,8 +202,8 @@ void ScEditWindow::SetCharAttriutes()
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
SfxAbstractTabDialog* pDlg = pFact->CreateScCharDlg(
GetParent(), &aSet, pDocSh);
boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateScCharDlg(
GetParent(), &aSet, pDocSh));
OSL_ENSURE(pDlg, "Dialog create fail!");
pDlg->SetText( ScGlobal::GetRscString( STR_TEXTATTRS ) );
if ( pDlg->Execute() == RET_OK )
......@@ -213,7 +214,6 @@ void ScEditWindow::SetCharAttriutes()
}
if(pTabViewSh!=NULL) pTabViewSh->SetInFormatDialog(false);
delete pDlg;
}
}
......
......@@ -40,6 +40,7 @@
#include <optutil.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
......@@ -194,11 +195,11 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException, st
INetURLObject aURL( aFileName );
OUString aPrivDatName(aURL.getName());
SvStream* pInStream = NULL;
boost::scoped_ptr<SvStream> pInStream;
if ( xInputStream.is() )
pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
pInStream.reset(utl::UcbStreamHelper::CreateStream( xInputStream ));
AbstractScImportAsciiDlg* pDlg = pFact->CreateScImportAsciiDlg( NULL, aPrivDatName, pInStream, SC_IMPORTFILE);
boost::scoped_ptr<AbstractScImportAsciiDlg> pDlg(pFact->CreateScImportAsciiDlg( NULL, aPrivDatName, pInStream.get(), SC_IMPORTFILE));
OSL_ENSURE(pDlg, "Dialog create fail!");
if ( pDlg->Execute() == RET_OK )
{
......@@ -208,8 +209,6 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException, st
aFilterOptions = aOptions.WriteToString();
nRet = ui::dialogs::ExecutableDialogResults::OK;
}
delete pDlg;
delete pInStream;
}
else if ( aFilterString == ScDocShell::GetWebQueryFilterName() || aFilterString == ScDocShell::GetHtmlFilterName() )
{
......@@ -301,9 +300,9 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException, st
ScImportOptions aOptions( cAsciiDel, cStrDel, eEncoding);
AbstractScImportOptionsDlg* pDlg = pFact->CreateScImportOptionsDlg(NULL,
boost::scoped_ptr<AbstractScImportOptionsDlg> pDlg(pFact->CreateScImportOptionsDlg(NULL,
bAscii, &aOptions, &aTitle, bMultiByte, bDBEnc,
!bExport);
!bExport));
OSL_ENSURE(pDlg, "Dialog create fail!");
if ( pDlg->Execute() == RET_OK )
{
......@@ -315,7 +314,6 @@ sal_Int16 SAL_CALL ScFilterOptionsObj::execute() throw(uno::RuntimeException, st
aFilterOptions = aOptions.aStrFont;
nRet = ui::dialogs::ExecutableDialogResults::OK;
}
delete pDlg;
}
xInputStream.clear(); // don't hold the stream longer than necessary
......
......@@ -272,7 +272,7 @@ void ScEditShell::Execute( SfxRequest& rReq )
case SID_PASTE_SPECIAL:
{
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( pViewData->GetDialogParent() );
boost::scoped_ptr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( pViewData->GetDialogParent() ));
sal_uLong nFormat = 0;
if ( pDlg )
{
......@@ -283,8 +283,8 @@ void ScEditShell::Execute( SfxRequest& rReq )
TransferableDataHelper::CreateFromSystemClipboard( pViewData->GetActiveWin() ) );
nFormat = pDlg->GetFormat( aDataHelper.GetTransferable() );
DELETEZ(pDlg);
}
pDlg.reset();
// while the dialog was open, edit mode may have been stopped
if (!SC_MOD()->IsInputMode())
......
......@@ -790,7 +790,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
AbstractScShowTabDlg* pDlg = pFact->CreateScShowTabDlg(GetDialogParent());
boost::scoped_ptr<AbstractScShowTabDlg> pDlg(pFact->CreateScShowTabDlg(GetDialogParent()));
OSL_ENSURE(pDlg, "Dialog create fail!");
pDlg->SetDescription(
OUString( ScResId( STR_DLG_SELECTTABLES_TITLE ) ),
......@@ -811,7 +811,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq )
sal_uInt16 nSelIx;
for( nSelIx = 0; nSelIx < nSelCount; ++nSelIx )
aIndexList.insert( aIndexList.begin()+nSelIx, pDlg->GetSelectEntryPos( nSelIx ) );
delete pDlg;
pDlg.reset();
rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, aIndexList ) );
}
else
......
......@@ -698,12 +698,12 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
aTabBgColor = pDoc->GetTabBgColor( nCurrentTab );
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
AbstractScTabBgColorDlg* pDlg = pFact->CreateScTabBgColorDlg(
boost::scoped_ptr<AbstractScTabBgColorDlg> pDlg(pFact->CreateScTabBgColorDlg(
GetDialogParent(),
OUString(ScResId(SCSTR_SET_TAB_BG_COLOR)),
OUString(ScResId(SCSTR_NO_TAB_BG_COLOR)),
aTabBgColor,
CMD_FID_TAB_SET_TAB_BG_COLOR);
CMD_FID_TAB_SET_TAB_BG_COLOR));
while ( !bDone && nRet == RET_OK )
{
nRet = pDlg->Execute();
......@@ -747,7 +747,6 @@ void ScTabViewShell::ExecuteTable( SfxRequest& rReq )
}
}
}
delete( pDlg );
}
}
break;
......
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