diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-27 14:11:30 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-28 10:01:32 -0500 |
commit | 8369a21642c3f7abd3b3784ee1a27b5cc02562e0 (patch) | |
tree | ecf5d692d9132945c2e66b5877f90dfe6d59f3a3 /svtools | |
parent | Make SvViewDataItem a struct, with only one public data member... (diff) | |
download | core-8369a21642c3f7abd3b3784ee1a27b5cc02562e0.tar.gz core-8369a21642c3f7abd3b3784ee1a27b5cc02562e0.zip |
Use std::vector over c-style pointer array.
Change-Id: I91ab1fb269070deb8389cf4e8473a223c1bbca1d
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/inc/svtools/treelistbox.hxx | 2 | ||||
-rw-r--r-- | svtools/inc/svtools/viewdataentry.hxx | 11 | ||||
-rw-r--r-- | svtools/source/contnr/treelistbox.cxx | 8 | ||||
-rw-r--r-- | svtools/source/contnr/viewdataentry.cxx | 17 |
4 files changed, 27 insertions, 11 deletions
diff --git a/svtools/inc/svtools/treelistbox.hxx b/svtools/inc/svtools/treelistbox.hxx index 0aa4177bbd30..1a591fd5ad76 100644 --- a/svtools/inc/svtools/treelistbox.hxx +++ b/svtools/inc/svtools/treelistbox.hxx @@ -145,7 +145,7 @@ public: const Size& GetSize(const SvTreeListBox* pView, const SvTreeListEntry* pEntry) const; const Size& GetSize(const SvViewDataEntry* pData, sal_uInt16 nItemPos) const { - const SvViewDataItem* pIData = pData->pItemData + nItemPos; + const SvViewDataItem* pIData = pData->GetItem(nItemPos); return pIData->maSize; } diff --git a/svtools/inc/svtools/viewdataentry.hxx b/svtools/inc/svtools/viewdataentry.hxx index 4e14bc50faab..fa1969e1c24d 100644 --- a/svtools/inc/svtools/viewdataentry.hxx +++ b/svtools/inc/svtools/viewdataentry.hxx @@ -24,6 +24,8 @@ #include "tools/solar.h" #include "tools/gen.hxx" +#include <vector> + // Entryflags that are attached to the View #define SVLISTENTRYFLAG_SELECTED 0x0001 #define SVLISTENTRYFLAG_EXPANDED 0x0002 @@ -65,12 +67,15 @@ public: // changed (because it's an array) class SvViewDataEntry : public SvViewData { + std::vector<SvViewDataItem> maItems; public: - SvViewDataItem* pItemData; // An array of SvViewDataItems - sal_uInt16 nItmCnt; // Item count for delete operator - SvViewDataEntry(); virtual ~SvViewDataEntry(); + + void Init(size_t nSize); + + const SvViewDataItem* GetItem(size_t nPos) const; + SvViewDataItem* GetItem(size_t nPos); }; #endif diff --git a/svtools/source/contnr/treelistbox.cxx b/svtools/source/contnr/treelistbox.cxx index f7fe4d8f42bc..296a036c2009 100644 --- a/svtools/source/contnr/treelistbox.cxx +++ b/svtools/source/contnr/treelistbox.cxx @@ -947,9 +947,8 @@ const SvViewDataItem* SvTreeListBox::GetViewDataItem(const SvTreeListEntry* pEnt { const SvViewDataEntry* pEntryData = (const SvViewDataEntry*)SvListView::GetViewData(pEntry); DBG_ASSERT(pEntryData,"Entry not in View"); - DBG_ASSERT(pEntryData->pItemData,"No ItemData"); sal_uInt16 nItemPos = pEntry->GetPos(pItem); - return (pEntryData->pItemData + nItemPos); + return pEntryData->GetItem(nItemPos); } SvViewData* SvTreeListBox::CreateViewData( SvTreeListEntry* ) @@ -965,14 +964,13 @@ void SvTreeListBox::InitViewData( SvViewData* pData, SvTreeListEntry* pEntry ) SvTreeListEntry* pInhEntry = (SvTreeListEntry*)pEntry; SvViewDataEntry* pEntryData = (SvViewDataEntry*)pData; - pEntryData->pItemData = new SvViewDataItem[ pInhEntry->ItemCount() ]; - SvViewDataItem* pItemData = pEntryData->pItemData; - pEntryData->nItmCnt = pInhEntry->ItemCount(); // number of items to delete + pEntryData->Init(pInhEntry->ItemCount()); sal_uInt16 nCount = pInhEntry->ItemCount(); sal_uInt16 nCurPos = 0; while( nCurPos < nCount ) { SvLBoxItem* pItem = pInhEntry->GetItem( nCurPos ); + SvViewDataItem* pItemData = pEntryData->GetItem(nCurPos); pItem->InitViewData( this, pInhEntry, pItemData ); pItemData++; nCurPos++; diff --git a/svtools/source/contnr/viewdataentry.cxx b/svtools/source/contnr/viewdataentry.cxx index 3b35c7578d1d..0fda3dd7e594 100644 --- a/svtools/source/contnr/viewdataentry.cxx +++ b/svtools/source/contnr/viewdataentry.cxx @@ -107,13 +107,26 @@ SvViewDataEntry::SvViewDataEntry() : SvViewData() { DBG_CTOR(SvViewDataEntry,0); - pItemData = 0; } SvViewDataEntry::~SvViewDataEntry() { DBG_DTOR(SvViewDataEntry,0); - delete [] pItemData; +} + +void SvViewDataEntry::Init(size_t nSize) +{ + maItems.resize(nSize); +} + +const SvViewDataItem* SvViewDataEntry::GetItem(size_t nPos) const +{ + return &maItems[nPos]; +} + +SvViewDataItem* SvViewDataEntry::GetItem(size_t nPos) +{ + return &maItems[nPos]; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |