summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-07-10 13:57:53 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-07-11 16:01:28 +0200
commit673347af7d37f6789855c17732c9980d91ec6240 (patch)
tree4447a73900c50db2f949755eca64a91ac2d9a385 /sd
parent0bc97adb82f14d6ec22f868422cbfe000afec402 (diff)
loplugin:useuniqueptr in scaddins..svx
Change-Id: I309f98f6b820103a926e9fe94d67d0aff6eb6476 Reviewed-on: https://gerrit.libreoffice.org/39754 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/source/filter/eppt/grouptable.hxx13
-rw-r--r--sd/source/filter/eppt/pptx-grouptable.cxx43
2 files changed, 16 insertions, 40 deletions
diff --git a/sd/source/filter/eppt/grouptable.hxx b/sd/source/filter/eppt/grouptable.hxx
index dd672c240f61..09139fcf1888 100644
--- a/sd/source/filter/eppt/grouptable.hxx
+++ b/sd/source/filter/eppt/grouptable.hxx
@@ -21,6 +21,8 @@
#define INCLUDED_SD_SOURCE_FILTER_EPPT_GROUPTABLE_HXX
#include <com/sun/star/container/XIndexAccess.hpp>
+#include <memory>
+#include <vector>
struct GroupEntry
{
@@ -47,19 +49,16 @@ class GroupTable
protected:
sal_uInt32 mnIndex;
- sal_uInt32 mnCurrentGroupEntry;
- sal_uInt32 mnMaxGroupEntry;
sal_uInt32 mnGroupsClosed;
- GroupEntry** mpGroupEntry;
-
- void ImplResizeGroupTable( sal_uInt32 nEntrys );
+ std::vector<std::unique_ptr<GroupEntry>>
+ mvGroupEntry;
public:
sal_uInt32 GetCurrentGroupIndex() const { return mnIndex; };
- sal_Int32 GetCurrentGroupLevel() const { return mnCurrentGroupEntry - 1; };
+ sal_Int32 GetCurrentGroupLevel() const { return mvGroupEntry.size() - 1; };
css::uno::Reference< css::container::XIndexAccess > &
- GetCurrentGroupAccess() const { return mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mXIndexAccess; };
+ GetCurrentGroupAccess() const { return mvGroupEntry.back()->mXIndexAccess; };
sal_uInt32 GetGroupsClosed();
void ResetGroupTable( sal_uInt32 nCount );
void ClearGroupTable();
diff --git a/sd/source/filter/eppt/pptx-grouptable.cxx b/sd/source/filter/eppt/pptx-grouptable.cxx
index 712de6ac694f..98105a7e6fb6 100644
--- a/sd/source/filter/eppt/pptx-grouptable.cxx
+++ b/sd/source/filter/eppt/pptx-grouptable.cxx
@@ -23,31 +23,13 @@ using ::com::sun::star::container::XIndexAccess;
GroupTable::GroupTable()
: mnIndex(0)
- , mnCurrentGroupEntry(0)
- , mnMaxGroupEntry(0)
, mnGroupsClosed(0)
- , mpGroupEntry(nullptr)
{
- ImplResizeGroupTable( 32 );
+ mvGroupEntry.reserve(32);
}
GroupTable::~GroupTable()
{
- for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; delete mpGroupEntry[ i++ ] ) ;
- delete[] mpGroupEntry;
-}
-
-void GroupTable::ImplResizeGroupTable( sal_uInt32 nEntrys )
-{
- if ( nEntrys > mnMaxGroupEntry )
- {
- mnMaxGroupEntry = nEntrys;
- GroupEntry** pTemp = new GroupEntry*[ nEntrys ];
- for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++ )
- pTemp[ i ] = mpGroupEntry[ i ];
- delete[] mpGroupEntry;
- mpGroupEntry = pTemp;
- }
}
bool GroupTable::EnterGroup( css::uno::Reference< css::container::XIndexAccess >& rXIndexAccessRef )
@@ -55,16 +37,12 @@ bool GroupTable::EnterGroup( css::uno::Reference< css::container::XIndexAccess >
bool bRet = false;
if ( rXIndexAccessRef.is() )
{
- GroupEntry* pNewGroup = new GroupEntry( rXIndexAccessRef );
+ std::unique_ptr<GroupEntry> pNewGroup( new GroupEntry( rXIndexAccessRef ) );
if ( pNewGroup->mnCount )
{
- if ( mnMaxGroupEntry == mnCurrentGroupEntry )
- ImplResizeGroupTable( mnMaxGroupEntry + 8 );
- mpGroupEntry[ mnCurrentGroupEntry++ ] = pNewGroup;
+ mvGroupEntry.push_back( std::move(pNewGroup) );
bRet = true;
}
- else
- delete pNewGroup;
}
return bRet;
}
@@ -78,28 +56,27 @@ sal_uInt32 GroupTable::GetGroupsClosed()
void GroupTable::ClearGroupTable()
{
- for ( sal_uInt32 i = 0; i < mnCurrentGroupEntry; i++, delete mpGroupEntry[ i ] ) ;
- mnCurrentGroupEntry = 0;
+ mvGroupEntry.clear();
}
void GroupTable::ResetGroupTable( sal_uInt32 nCount )
{
ClearGroupTable();
- mpGroupEntry[ mnCurrentGroupEntry++ ] = new GroupEntry( nCount );
+ mvGroupEntry.push_back( std::unique_ptr<GroupEntry>(new GroupEntry( nCount )) );
}
bool GroupTable::GetNextGroupEntry()
{
- while ( mnCurrentGroupEntry )
+ while ( !mvGroupEntry.empty() )
{
- mnIndex = mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mnCurrentPos++;
+ mnIndex = mvGroupEntry.back()->mnCurrentPos++;
- if ( mpGroupEntry[ mnCurrentGroupEntry - 1 ]->mnCount > mnIndex )
+ if ( mvGroupEntry.back()->mnCount > mnIndex )
return true;
- delete ( mpGroupEntry[ --mnCurrentGroupEntry ] );
+ mvGroupEntry.pop_back();
- if ( mnCurrentGroupEntry )
+ if ( !mvGroupEntry.empty() )
mnGroupsClosed++;
}
return false;