Kaydet (Commit) 1476d95b authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in StylePool::createIterator

Change-Id: I1a7bdfc00352c25f5d2db9ef195000d16f909537
Reviewed-on: https://gerrit.libreoffice.org/60263
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 9a9d4079
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
@postcond the iterator "points before the first" SfxItemSet of the pool. @postcond the iterator "points before the first" SfxItemSet of the pool.
The first StylePoolIterator::getNext() call will deliver the first SfxItemSet. The first StylePoolIterator::getNext() call will deliver the first SfxItemSet.
*/ */
IStylePoolIteratorAccess* createIterator( const bool bSkipUnusedItemSets = false, std::unique_ptr<IStylePoolIteratorAccess> createIterator( const bool bSkipUnusedItemSets = false,
const bool bSkipIgnorableItems = false ); const bool bSkipIgnorableItems = false );
~StylePool(); ~StylePool();
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <svl/stylepool.hxx> #include <svl/stylepool.hxx>
#include <svl/itemiter.hxx> #include <svl/itemiter.hxx>
#include <svl/itempool.hxx> #include <svl/itempool.hxx>
#include <o3tl/make_unique.hxx>
#include <algorithm> #include <algorithm>
#include <map> #include <map>
#include <memory> #include <memory>
...@@ -357,7 +358,7 @@ public: ...@@ -357,7 +358,7 @@ public:
std::shared_ptr<SfxItemSet> insertItemSet( const SfxItemSet& rSet ); std::shared_ptr<SfxItemSet> insertItemSet( const SfxItemSet& rSet );
// #i86923# // #i86923#
IStylePoolIteratorAccess* createIterator( bool bSkipUnusedItemSets, std::unique_ptr<IStylePoolIteratorAccess> createIterator( bool bSkipUnusedItemSets,
bool bSkipIgnorableItems ); bool bSkipIgnorableItems );
}; };
...@@ -432,10 +433,10 @@ std::shared_ptr<SfxItemSet> StylePoolImpl::insertItemSet( const SfxItemSet& rSet ...@@ -432,10 +433,10 @@ std::shared_ptr<SfxItemSet> StylePoolImpl::insertItemSet( const SfxItemSet& rSet
} }
// #i86923# // #i86923#
IStylePoolIteratorAccess* StylePoolImpl::createIterator( bool bSkipUnusedItemSets, std::unique_ptr<IStylePoolIteratorAccess> StylePoolImpl::createIterator( bool bSkipUnusedItemSets,
bool bSkipIgnorableItems ) bool bSkipIgnorableItems )
{ {
return new Iterator( maRoot, bSkipUnusedItemSets, bSkipIgnorableItems ); return o3tl::make_unique<Iterator>( maRoot, bSkipUnusedItemSets, bSkipIgnorableItems );
} }
// Ctor, Dtor and redirected methods of class StylePool, nearly inline ;-) // Ctor, Dtor and redirected methods of class StylePool, nearly inline ;-)
...@@ -448,7 +449,7 @@ std::shared_ptr<SfxItemSet> StylePool::insertItemSet( const SfxItemSet& rSet ) ...@@ -448,7 +449,7 @@ std::shared_ptr<SfxItemSet> StylePool::insertItemSet( const SfxItemSet& rSet )
{ return pImpl->insertItemSet( rSet ); } { return pImpl->insertItemSet( rSet ); }
// #i86923# // #i86923#
IStylePoolIteratorAccess* StylePool::createIterator( const bool bSkipUnusedItemSets, std::unique_ptr<IStylePoolIteratorAccess> StylePool::createIterator( const bool bSkipUnusedItemSets,
const bool bSkipIgnorableItems ) const bool bSkipIgnorableItems )
{ {
return pImpl->createIterator( bSkipUnusedItemSets, bSkipIgnorableItems ); return pImpl->createIterator( bSkipUnusedItemSets, bSkipIgnorableItems );
......
...@@ -43,7 +43,7 @@ public: ...@@ -43,7 +43,7 @@ public:
void SwStyleCache::addCompletePool( StylePool& rPool ) void SwStyleCache::addCompletePool( StylePool& rPool )
{ {
IStylePoolIteratorAccess *pIter = rPool.createIterator(); std::unique_ptr<IStylePoolIteratorAccess> pIter = rPool.createIterator();
std::shared_ptr<SfxItemSet> pStyle = pIter->getNext(); std::shared_ptr<SfxItemSet> pStyle = pIter->getNext();
while( pStyle.get() ) while( pStyle.get() )
{ {
...@@ -51,7 +51,6 @@ void SwStyleCache::addCompletePool( StylePool& rPool ) ...@@ -51,7 +51,6 @@ void SwStyleCache::addCompletePool( StylePool& rPool )
mMap[ aName ] = pStyle; mMap[ aName ] = pStyle;
pStyle = pIter->getNext(); pStyle = pIter->getNext();
} }
delete pIter;
} }
class SwStyleManager : public IStyleAccess class SwStyleManager : public IStyleAccess
...@@ -140,7 +139,7 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt ...@@ -140,7 +139,7 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt
{ {
StylePool& rAutoPool = eFamily == IStyleAccess::AUTO_STYLE_CHAR ? aAutoCharPool : aAutoParaPool; StylePool& rAutoPool = eFamily == IStyleAccess::AUTO_STYLE_CHAR ? aAutoCharPool : aAutoParaPool;
// setup <StylePool> iterator, which skips unused styles and ignorable items // setup <StylePool> iterator, which skips unused styles and ignorable items
IStylePoolIteratorAccess *pIter = rAutoPool.createIterator( true, true ); std::unique_ptr<IStylePoolIteratorAccess> pIter = rAutoPool.createIterator( true, true );
std::shared_ptr<SfxItemSet> pStyle = pIter->getNext(); std::shared_ptr<SfxItemSet> pStyle = pIter->getNext();
while( pStyle.get() ) while( pStyle.get() )
{ {
...@@ -148,7 +147,6 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt ...@@ -148,7 +147,6 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt
pStyle = pIter->getNext(); pStyle = pIter->getNext();
} }
delete pIter;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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