Kaydet (Commit) 5db48971 authored tarafından David Tardon's avatar David Tardon

use unique_ptr

Change-Id: I047a2436ce5603a8642aa621694560aca669b2f1
üst 07a641b1
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#include <set> #include <set>
#include <o3tl/make_unique.hxx>
#include <svl/itempool.hxx> #include <svl/itempool.hxx>
#include <svl/itemset.hxx> #include <svl/itemset.hxx>
#include <svl/style.hxx> #include <svl/style.hxx>
...@@ -59,14 +62,6 @@ bool SvxUnoNameItemTable::isValid( const NameOrIndex* pItem ) const ...@@ -59,14 +62,6 @@ bool SvxUnoNameItemTable::isValid( const NameOrIndex* pItem ) const
void SvxUnoNameItemTable::dispose() void SvxUnoNameItemTable::dispose()
{ {
ItemPoolVector::iterator aIter = maItemSetVector.begin();
const ItemPoolVector::iterator aEnd = maItemSetVector.end();
while( aIter != aEnd )
{
delete (*aIter++);
}
maItemSetVector.clear(); maItemSetVector.clear();
} }
...@@ -85,13 +80,12 @@ sal_Bool SAL_CALL SvxUnoNameItemTable::supportsService( const OUString& Service ...@@ -85,13 +80,12 @@ sal_Bool SAL_CALL SvxUnoNameItemTable::supportsService( const OUString& Service
void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement ) void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, const uno::Any& aElement )
{ {
SfxItemSet* pInSet = new SfxItemSet( *mpModelPool, mnWhich, mnWhich ); maItemSetVector.push_back( o3tl::make_unique< SfxItemSet >( *mpModelPool, mnWhich, mnWhich ) );
maItemSetVector.push_back( pInSet );
std::unique_ptr<NameOrIndex> pNewItem(createItem()); std::unique_ptr<NameOrIndex> pNewItem(createItem());
pNewItem->SetName( aName ); pNewItem->SetName( aName );
pNewItem->PutValue( aElement, mnMemberId ); pNewItem->PutValue( aElement, mnMemberId );
pInSet->Put( *pNewItem, mnWhich ); maItemSetVector.back()->Put( *pNewItem, mnWhich );
} }
// XNameContainer // XNameContainer
...@@ -133,7 +127,6 @@ void SAL_CALL SvxUnoNameItemTable::removeByName( const OUString& aApiName ) ...@@ -133,7 +127,6 @@ void SAL_CALL SvxUnoNameItemTable::removeByName( const OUString& aApiName )
const NameOrIndex *pItem = static_cast<const NameOrIndex *>(&((*aIter)->Get( mnWhich ) )); const NameOrIndex *pItem = static_cast<const NameOrIndex *>(&((*aIter)->Get( mnWhich ) ));
if (sName.equals(pItem->GetName())) if (sName.equals(pItem->GetName()))
{ {
delete (*aIter);
maItemSetVector.erase( aIter ); maItemSetVector.erase( aIter );
return; return;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase.hxx>
#include <memory>
#include <vector> #include <vector>
#include <svl/lstner.hxx> #include <svl/lstner.hxx>
#include <svx/xit.hxx> #include <svx/xit.hxx>
...@@ -35,7 +36,7 @@ class SdrModel; ...@@ -35,7 +36,7 @@ class SdrModel;
class SfxItemPool; class SfxItemPool;
class SfxItemSet; class SfxItemSet;
typedef std::vector< SfxItemSet* > ItemPoolVector; typedef std::vector< std::unique_ptr< SfxItemSet > > ItemPoolVector;
class SvxUnoNameItemTable : public cppu::WeakImplHelper< css::container::XNameContainer, css::lang::XServiceInfo >, class SvxUnoNameItemTable : public cppu::WeakImplHelper< css::container::XNameContainer, css::lang::XServiceInfo >,
public SfxListener public SfxListener
{ {
......
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