loplugin:useuniqueptr in StylePool::createIterator

Change-Id: I1a7bdfc00352c25f5d2db9ef195000d16f909537
Reviewed-on: https://gerrit.libreoffice.org/60263
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2018-09-11 08:17:42 +02:00
parent 9a9d407977
commit 1476d95b6e
3 changed files with 8 additions and 9 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ public:
@postcond the iterator "points before the first" SfxItemSet of the pool.
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 );
~StylePool();
+5 -4
View File
@@ -20,6 +20,7 @@
#include <svl/stylepool.hxx>
#include <svl/itemiter.hxx>
#include <svl/itempool.hxx>
#include <o3tl/make_unique.hxx>
#include <algorithm>
#include <map>
#include <memory>
@@ -357,7 +358,7 @@ public:
std::shared_ptr<SfxItemSet> insertItemSet( const SfxItemSet& rSet );
// #i86923#
IStylePoolIteratorAccess* createIterator( bool bSkipUnusedItemSets,
std::unique_ptr<IStylePoolIteratorAccess> createIterator( bool bSkipUnusedItemSets,
bool bSkipIgnorableItems );
};
@@ -432,10 +433,10 @@ std::shared_ptr<SfxItemSet> StylePoolImpl::insertItemSet( const SfxItemSet& rSet
}
// #i86923#
IStylePoolIteratorAccess* StylePoolImpl::createIterator( bool bSkipUnusedItemSets,
std::unique_ptr<IStylePoolIteratorAccess> StylePoolImpl::createIterator( bool bSkipUnusedItemSets,
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 ;-)
@@ -448,7 +449,7 @@ std::shared_ptr<SfxItemSet> StylePool::insertItemSet( const SfxItemSet& rSet )
{ return pImpl->insertItemSet( rSet ); }
// #i86923#
IStylePoolIteratorAccess* StylePool::createIterator( const bool bSkipUnusedItemSets,
std::unique_ptr<IStylePoolIteratorAccess> StylePool::createIterator( const bool bSkipUnusedItemSets,
const bool bSkipIgnorableItems )
{
return pImpl->createIterator( bSkipUnusedItemSets, bSkipIgnorableItems );
+2 -4
View File
@@ -43,7 +43,7 @@ public:
void SwStyleCache::addCompletePool( StylePool& rPool )
{
IStylePoolIteratorAccess *pIter = rPool.createIterator();
std::unique_ptr<IStylePoolIteratorAccess> pIter = rPool.createIterator();
std::shared_ptr<SfxItemSet> pStyle = pIter->getNext();
while( pStyle.get() )
{
@@ -51,7 +51,6 @@ void SwStyleCache::addCompletePool( StylePool& rPool )
mMap[ aName ] = pStyle;
pStyle = pIter->getNext();
}
delete pIter;
}
class SwStyleManager : public IStyleAccess
@@ -140,7 +139,7 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt
{
StylePool& rAutoPool = eFamily == IStyleAccess::AUTO_STYLE_CHAR ? aAutoCharPool : aAutoParaPool;
// 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();
while( pStyle.get() )
{
@@ -148,7 +147,6 @@ void SwStyleManager::getAllStyles( std::vector<std::shared_ptr<SfxItemSet>> &rSt
pStyle = pIter->getNext();
}
delete pIter;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */