Avoid possible memory leaks in case of exceptions
Change-Id: I9a92edd7886db484f1333585545f6f63a233a6dd
This commit is contained in:
parent
d4feafb064
commit
b20e6acea2
@ -86,6 +86,7 @@
|
||||
#include <svl/itemset.hxx>
|
||||
#include <vcl/settings.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <boost/scoped_array.hpp>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
@ -1538,7 +1539,7 @@ void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
|
||||
// at first, save the pointers of the affected pages in an array
|
||||
sal_uInt16 nPageNum=nFirstPageNum;
|
||||
sal_uInt16 nCopyAnz=((!bReverse)?(nLastPageNum-nFirstPageNum):(nFirstPageNum-nLastPageNum))+1;
|
||||
SdrPage** pPagePtrs=new SdrPage*[nCopyAnz];
|
||||
boost::scoped_array<SdrPage*> pPagePtrs(new SdrPage*[nCopyAnz]);
|
||||
sal_uInt16 nCopyNum;
|
||||
for(nCopyNum=0; nCopyNum<nCopyAnz; nCopyNum++)
|
||||
{
|
||||
@ -1584,7 +1585,7 @@ void SdrModel::CopyPages(sal_uInt16 nFirstPageNum, sal_uInt16 nLastPageNum,
|
||||
nPageNum2++;
|
||||
}
|
||||
|
||||
delete[] pPagePtrs;
|
||||
pPagePtrs.reset();
|
||||
if(bUndo)
|
||||
EndUndo();
|
||||
}
|
||||
@ -1616,18 +1617,18 @@ void SdrModel::Merge(SdrModel& rSourceModel,
|
||||
if (nLastPageNum>nMaxSrcPage) nLastPageNum =nMaxSrcPage;
|
||||
bool bReverse=nLastPageNum<nFirstPageNum;
|
||||
|
||||
sal_uInt16* pMasterMap=NULL;
|
||||
bool* pMasterNeed=NULL;
|
||||
boost::scoped_array<sal_uInt16> pMasterMap;
|
||||
boost::scoped_array<bool> pMasterNeed;
|
||||
sal_uInt16 nMasterNeed=0;
|
||||
if (bMergeMasterPages && nSrcMasterPageAnz!=0) {
|
||||
// determine which MasterPages from rSrcModel we need
|
||||
pMasterMap=new sal_uInt16[nSrcMasterPageAnz];
|
||||
pMasterNeed=new bool[nSrcMasterPageAnz];
|
||||
memset(pMasterMap,0xFF,nSrcMasterPageAnz*sizeof(sal_uInt16));
|
||||
pMasterMap.reset(new sal_uInt16[nSrcMasterPageAnz]);
|
||||
pMasterNeed.reset(new bool[nSrcMasterPageAnz]);
|
||||
memset(pMasterMap.get(),0xFF,nSrcMasterPageAnz*sizeof(sal_uInt16));
|
||||
if (bAllMasterPages) {
|
||||
memset(pMasterNeed, true, nSrcMasterPageAnz * sizeof(bool));
|
||||
memset(pMasterNeed.get(), true, nSrcMasterPageAnz * sizeof(bool));
|
||||
} else {
|
||||
memset(pMasterNeed, false, nSrcMasterPageAnz * sizeof(bool));
|
||||
memset(pMasterNeed.get(), false, nSrcMasterPageAnz * sizeof(bool));
|
||||
sal_uInt16 nAnf= bReverse ? nLastPageNum : nFirstPageNum;
|
||||
sal_uInt16 nEnd= bReverse ? nFirstPageNum : nLastPageNum;
|
||||
for (sal_uInt16 i=nAnf; i<=nEnd; i++) {
|
||||
@ -1656,7 +1657,7 @@ void SdrModel::Merge(SdrModel& rSourceModel,
|
||||
}
|
||||
|
||||
// get the MasterPages
|
||||
if (pMasterMap!=NULL && pMasterNeed!=NULL && nMasterNeed!=0) {
|
||||
if (pMasterMap && pMasterNeed && nMasterNeed!=0) {
|
||||
for (sal_uInt16 i=nSrcMasterPageAnz; i>0;) {
|
||||
i--;
|
||||
if (pMasterNeed[i]) {
|
||||
@ -1743,8 +1744,8 @@ void SdrModel::Merge(SdrModel& rSourceModel,
|
||||
}
|
||||
}
|
||||
|
||||
delete [] pMasterMap;
|
||||
delete [] pMasterNeed;
|
||||
pMasterMap.reset();
|
||||
pMasterNeed.reset();
|
||||
|
||||
bMPgNumsDirty=true;
|
||||
bPagNumsDirty=true;
|
||||
|
@ -129,6 +129,7 @@
|
||||
#include <svx/xpoly.hxx>
|
||||
#include <rtl/strbuf.hxx>
|
||||
#include <svdoopengl.hxx>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
|
||||
@ -3315,16 +3316,15 @@ SdrObject* SdrObjFactory::MakeNewObject(sal_uInt32 nInvent, sal_uInt16 nIdent, S
|
||||
|
||||
if(pObj == NULL)
|
||||
{
|
||||
SdrObjFactory* pFact=new SdrObjFactory(nInvent,nIdent,pPage,pModel);
|
||||
boost::scoped_ptr<SdrObjFactory> pFact(new SdrObjFactory(nInvent,nIdent,pPage,pModel));
|
||||
SdrLinkList& rLL=ImpGetUserMakeObjHdl();
|
||||
unsigned nAnz=rLL.GetLinkCount();
|
||||
unsigned i=0;
|
||||
while (i<nAnz && pObj==NULL) {
|
||||
rLL.GetLink(i).Call((void*)pFact);
|
||||
rLL.GetLink(i).Call((void*)pFact.get());
|
||||
pObj=pFact->pNewObj;
|
||||
i++;
|
||||
}
|
||||
delete pFact;
|
||||
}
|
||||
|
||||
if(pObj == NULL)
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include <osl/thread.hxx>
|
||||
#include <drawinglayer/processor2d/objectinfoextractor2d.hxx>
|
||||
#include <drawinglayer/primitive2d/objectinfoprimitive2d.hxx>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
@ -1334,11 +1335,11 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
|
||||
{
|
||||
Graphic aGraphic;
|
||||
|
||||
com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >* pFilterData = NULL;
|
||||
boost::scoped_ptr<com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > > pFilterData;
|
||||
|
||||
if(mbInsidePaint && !GetViewContact().HasViewObjectContacts(true))
|
||||
{
|
||||
pFilterData = new com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >( 3 );
|
||||
pFilterData.reset(new com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >( 3 ));
|
||||
|
||||
const com::sun::star::awt::Size aPreviewSizeHint( 64, 64 );
|
||||
const bool bAllowPartialStreamRead = true;
|
||||
@ -1357,7 +1358,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
|
||||
|
||||
if(!GraphicFilter::GetGraphicFilter().ImportGraphic(
|
||||
aGraphic, aUserData, *pStream,
|
||||
GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData))
|
||||
GRFILTER_FORMAT_DONTKNOW, NULL, 0, pFilterData.get()))
|
||||
{
|
||||
const OUString aNewUserData( pGraphic->GetUserData() );
|
||||
|
||||
@ -1367,7 +1368,7 @@ IMPL_LINK( SdrGrafObj, ImpSwapHdl, GraphicObject*, pO )
|
||||
// Graphic successfully swapped in.
|
||||
pRet = GRFMGR_AUTOSWAPSTREAM_LOADED;
|
||||
}
|
||||
delete pFilterData;
|
||||
pFilterData.reset();
|
||||
|
||||
pStream->ResetError();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <tools/urlobj.hxx>
|
||||
#include <svl/urihelper.hxx>
|
||||
#include <tools/tenccvt.hxx>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
class ImpSdrObjTextLink: public ::sfx2::SvBaseLink
|
||||
{
|
||||
@ -222,7 +222,7 @@ bool SdrTextObj::LoadText(const OUString& rFileName, const OUString& /*rFilterNa
|
||||
|
||||
DBG_ASSERT( aFileURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
|
||||
|
||||
SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ );
|
||||
boost::scoped_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( aFileURL.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ ));
|
||||
|
||||
if( pIStm )
|
||||
{
|
||||
@ -241,8 +241,6 @@ bool SdrTextObj::LoadText(const OUString& rFileName, const OUString& /*rFilterNa
|
||||
SetText( *pIStm, aFileURL.GetMainURL( INetURLObject::NO_DECODE ), sal::static_int_cast< sal_uInt16 >( bRTF ? EE_FORMAT_RTF : EE_FORMAT_TEXT ) );
|
||||
bRet = true;
|
||||
}
|
||||
|
||||
delete pIStm;
|
||||
}
|
||||
|
||||
return bRet;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "editeng/fhgtitem.hxx"
|
||||
#include <editeng/eeitem.hxx>
|
||||
#include <svl/itemset.hxx>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
SdrText::SdrText( SdrTextObj& rObject, OutlinerParaObject* pOutlinerParaObject /* = 0 */ )
|
||||
: mpOutlinerParaObject( pOutlinerParaObject )
|
||||
@ -172,7 +173,7 @@ void SdrText::ForceOutlinerParaObject( sal_uInt16 nOutlMode )
|
||||
{
|
||||
if( mpModel && !mpOutlinerParaObject )
|
||||
{
|
||||
Outliner* pOutliner = SdrMakeOutliner( nOutlMode, mpModel );
|
||||
boost::scoped_ptr<Outliner> pOutliner(SdrMakeOutliner( nOutlMode, mpModel ));
|
||||
if( pOutliner )
|
||||
{
|
||||
Outliner& aDrawOutliner = mpModel->GetDrawOutliner();
|
||||
@ -181,8 +182,6 @@ void SdrText::ForceOutlinerParaObject( sal_uInt16 nOutlMode )
|
||||
pOutliner->SetStyleSheet( 0, GetStyleSheet());
|
||||
OutlinerParaObject* pOutlinerParaObject = pOutliner->CreateParaObject();
|
||||
SetOutlinerParaObject( pOutlinerParaObject );
|
||||
|
||||
delete pOutliner;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ void SvxTableController::GetState( SfxItemSet& rSet )
|
||||
if( !mxTable.is() || !mxTableObj.is() || !mxTableObj->GetModel() )
|
||||
return;
|
||||
|
||||
SfxItemSet* pSet = 0;
|
||||
boost::scoped_ptr<SfxItemSet> pSet;
|
||||
|
||||
bool bVertDone = false;
|
||||
|
||||
@ -420,7 +420,7 @@ void SvxTableController::GetState( SfxItemSet& rSet )
|
||||
{
|
||||
if( !pSet )
|
||||
{
|
||||
pSet = new SfxItemSet( mxTableObj->GetModel()->GetItemPool() );
|
||||
pSet.reset(new SfxItemSet( mxTableObj->GetModel()->GetItemPool() ));
|
||||
MergeAttrFromSelectedCells(*pSet, false);
|
||||
}
|
||||
|
||||
@ -487,7 +487,6 @@ void SvxTableController::GetState( SfxItemSet& rSet )
|
||||
}
|
||||
nWhich = aIter.NextWhich();
|
||||
}
|
||||
delete pSet;
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <com/sun/star/table/XTable.hpp>
|
||||
@ -272,14 +273,13 @@ void SdrTableRTFParser::FillTable()
|
||||
if( xCellInfo->maItemSet.GetItemState(SDRATTR_TABLE_BORDER,false,&pPoolItem)==SFX_ITEM_SET)
|
||||
xCell->SetMergedItem( *pPoolItem );
|
||||
|
||||
OutlinerParaObject* pTextObject = mpOutliner->CreateParaObject( xCellInfo->mnStartPara, xCellInfo->mnParaCount );
|
||||
boost::scoped_ptr<OutlinerParaObject> pTextObject(mpOutliner->CreateParaObject( xCellInfo->mnStartPara, xCellInfo->mnParaCount ));
|
||||
if( pTextObject )
|
||||
{
|
||||
SdrOutliner& rOutliner=mrTableObj.ImpGetDrawOutliner();
|
||||
rOutliner.SetUpdateMode(true);
|
||||
rOutliner.SetText( *pTextObject );
|
||||
mrTableObj.NbcSetOutlinerParaObjectForText( rOutliner.CreateParaObject(), xCell.get() );
|
||||
delete pTextObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user