[Libreoffice-commits] core.git: 2 commits - svx/source
Takeshi Abe
tabe at fixedpoint.jp
Wed Jul 2 08:20:58 PDT 2014
svx/source/tbxctrls/extrusioncontrols.cxx | 2 +-
svx/source/tbxctrls/fillctrl.cxx | 16 +++++++---------
svx/source/tbxctrls/fontworkgallery.cxx | 7 +++----
svx/source/tbxctrls/linectrl.cxx | 16 +++++++---------
svx/source/unodraw/UnoGraphicExporter.cxx | 8 +++-----
svx/source/unodraw/UnoNameItemTable.cxx | 4 ++--
svx/source/unodraw/unoshape.cxx | 4 ++--
7 files changed, 25 insertions(+), 32 deletions(-)
New commits:
commit 8374bbe589511721cbca6adacf15380c5f2dc0f5
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Wed Jul 2 22:05:18 2014 +0900
Avoid possible memory leaks in case of exceptions
Change-Id: I7878d425cea773338799fb784c25039e6b923e47
diff --git a/svx/source/tbxctrls/fillctrl.cxx b/svx/source/tbxctrls/fillctrl.cxx
index 4a26ac4..097d475 100644
--- a/svx/source/tbxctrls/fillctrl.cxx
+++ b/svx/source/tbxctrls/fillctrl.cxx
@@ -36,6 +36,7 @@
#include <svx/itemwin.hxx>
#include <svx/dialmgr.hxx>
#include "helpid.hrc"
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
@@ -317,9 +318,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
- XGradientEntry* pEntry = new XGradientEntry(mpGradientItem->GetGradientValue(), aTmpStr);
+ boost::scoped_ptr<XGradientEntry> pEntry(new XGradientEntry(mpGradientItem->GetGradientValue(), aTmpStr));
XGradientList aGradientList( "", ""/*TODO?*/ );
- aGradientList.Insert( pEntry );
+ aGradientList.Insert( pEntry.get() );
aGradientList.SetDirty( false );
const Bitmap aBmp = aGradientList.GetUiBitmap( 0 );
@@ -330,7 +331,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aGradientList.Remove( 0 );
- delete pEntry;
}
}
else
@@ -363,9 +363,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
- XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr);
+ boost::scoped_ptr<XHatchEntry> pEntry(new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr));
XHatchList aHatchList( "", ""/*TODO?*/ );
- aHatchList.Insert( pEntry );
+ aHatchList.Insert( pEntry.get() );
aHatchList.SetDirty( false );
const Bitmap aBmp = aHatchList.GetUiBitmap( 0 );
@@ -376,7 +376,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aHatchList.Remove( 0 );
- delete pEntry;
}
}
else
@@ -409,16 +408,15 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
- XBitmapEntry* pEntry = new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr);
+ boost::scoped_ptr<XBitmapEntry> pEntry(new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr));
XBitmapListRef xBitmapList =
XPropertyList::CreatePropertyList(XBITMAP_LIST,
OUString("TmpList"), ""/*TODO?*/)->AsBitmapList();
- xBitmapList->Insert( pEntry );
+ xBitmapList->Insert( pEntry.get() );
xBitmapList->SetDirty( false );
mpFillAttrLB->Fill( xBitmapList );
mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
xBitmapList->Remove( 0 );
- delete pEntry;
}
}
else
diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx
index 1f7281d..270c83c 100644
--- a/svx/source/tbxctrls/fontworkgallery.cxx
+++ b/svx/source/tbxctrls/fontworkgallery.cxx
@@ -52,6 +52,7 @@
#include "fontworkgallery.hrc"
#include <algorithm>
+#include <boost/scoped_ptr.hpp>
#include "helpid.hrc"
@@ -202,10 +203,10 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
if( nItemId > 0 )
{
- FmFormModel* pModel = new FmFormModel();
+ boost::scoped_ptr<FmFormModel> pModel(new FmFormModel());
pModel->GetItemPool().FreezeIdRanges();
- if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel ) )
+ if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel.get() ) )
{
SdrPage* pPage = pModel->GetPage(0);
if( pPage && pPage->GetObjCount() )
@@ -237,8 +238,6 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
}
}
}
-
- delete pModel;
}
}
diff --git a/svx/source/tbxctrls/linectrl.cxx b/svx/source/tbxctrls/linectrl.cxx
index 65563c0..d556fca 100644
--- a/svx/source/tbxctrls/linectrl.cxx
+++ b/svx/source/tbxctrls/linectrl.cxx
@@ -34,6 +34,7 @@
#include <svx/itemwin.hxx>
#include <svx/dialmgr.hxx>
#include <svx/unoapi.hxx>
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
@@ -356,27 +357,27 @@ SvxLineEndWindow::~SvxLineEndWindow()
IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl)
{
- XLineEndItem* pLineEndItem = NULL;
- XLineStartItem* pLineStartItem = NULL;
+ boost::scoped_ptr<XLineEndItem> pLineEndItem;
+ boost::scoped_ptr<XLineStartItem> pLineStartItem;
sal_uInt16 nId = aLineEndSet.GetSelectItemId();
if( nId == 1 )
{
- pLineStartItem = new XLineStartItem();
+ pLineStartItem.reset(new XLineStartItem());
}
else if( nId == 2 )
{
- pLineEndItem = new XLineEndItem();
+ pLineEndItem.reset(new XLineEndItem());
}
else if( nId % 2 ) // beginning of line
{
XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 );
- pLineStartItem = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() );
+ pLineStartItem.reset(new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ));
}
else // end of line
{
XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 );
- pLineEndItem = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() );
+ pLineEndItem.reset(new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ));
}
if ( IsInPopupMode() )
@@ -407,9 +408,6 @@ IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl)
OUString( ".uno:LineEndStyle" ),
aArgs );
- delete pLineEndItem;
- delete pLineStartItem;
-
return 0;
}
diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx
index 6034d5e..71a2f82 100644
--- a/svx/source/unodraw/UnoGraphicExporter.cxx
+++ b/svx/source/unodraw/UnoGraphicExporter.cxx
@@ -66,7 +66,7 @@
#include <svx/svdoutl.hxx>
#include <editeng/flditem.hxx>
-#include "boost/scoped_ptr.hpp"
+#include <boost/scoped_ptr.hpp>
#include <UnoGraphicExporter.hxx>
@@ -439,7 +439,7 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid
if(bSuccess)
{
- SdrView* pView = new SdrView(mpDoc, pVDev);
+ boost::scoped_ptr<SdrView> pView(new SdrView(mpDoc, pVDev));
pView->SetPageVisible( false );
pView->SetBordVisible( false );
pView->SetGridVisible( false );
@@ -451,7 +451,6 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid
ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
pView->CompleteRedraw(pVDev, aRegion, &aRedirector);
- delete pView;
}
else
{
@@ -713,14 +712,13 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
}
- VirtualDevice* pVDev = CreatePageVDev( pPage, nWidthPix, nHeightPix );
+ boost::scoped_ptr<VirtualDevice> pVDev(CreatePageVDev( pPage, nWidthPix, nHeightPix ));
if( pVDev )
{
aGraphic = pVDev->GetBitmap( Point(), pVDev->GetOutputSize() );
aGraphic.SetPrefMapMode( aMap );
aGraphic.SetPrefSize( aSize );
- delete pVDev;
}
}
// create a metafile to export a vector format
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx
index 58ce21c..345ec9c 100644
--- a/svx/source/unodraw/UnoNameItemTable.cxx
+++ b/svx/source/unodraw/UnoNameItemTable.cxx
@@ -30,6 +30,7 @@
#include <vcl/svapp.hxx>
#include "svx/unoapi.hxx"
+#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::rtl;
@@ -87,11 +88,10 @@ void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, cons
SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, mnWhich, mnWhich );
maItemSetVector.push_back( mpInSet );
- NameOrIndex* pNewItem = createItem();
+ boost::scoped_ptr<NameOrIndex> pNewItem(createItem());
pNewItem->SetName( aName );
pNewItem->PutValue( aElement, mnMemberId );
mpInSet->Put( *pNewItem, mnWhich );
- delete pNewItem;
}
// XNameContainer
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx
index 6d344f6..bae3f7d 100644
--- a/svx/source/unodraw/unoshape.cxx
+++ b/svx/source/unodraw/unoshape.cxx
@@ -94,6 +94,7 @@
#include "svx/extrud3d.hxx"
#include <boost/bind.hpp>
+#include <boost/scoped_ptr.hpp>
#include <vcl/wmf.hxx>
using namespace ::osl;
@@ -685,7 +686,7 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
SdrModel* pModel = mpObj->GetModel();
SdrPage* pPage = mpObj->GetPage();
- E3dView* pView = new E3dView( pModel, &aVDev );
+ boost::scoped_ptr<E3dView> pView(new E3dView( pModel, &aVDev ));
pView->hideMarkHandles();
SdrPageView* pPageView = pView->ShowSdrPage(pPage);
@@ -717,7 +718,6 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
}
pView->UnmarkAll();
- delete pView;
return aAny;
}
commit 7a85ec95b0efcf7fb9b5db0037bb1de2aadfc4fd
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Wed Jul 2 22:02:20 2014 +0900
Mark as const
Change-Id: Id0b0f77d88f593975dec4e024ca6ef5c45946128
diff --git a/svx/source/tbxctrls/extrusioncontrols.cxx b/svx/source/tbxctrls/extrusioncontrols.cxx
index 30fd7b4..ab0459b 100644
--- a/svx/source/tbxctrls/extrusioncontrols.cxx
+++ b/svx/source/tbxctrls/extrusioncontrols.cxx
@@ -64,7 +64,7 @@ namespace svx
|*
\************************************************************************/
-static sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
+static const sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
ExtrusionDirectionWindow::ExtrusionDirectionWindow(
svt::ToolboxController& rController,
More information about the Libreoffice-commits
mailing list