diff options
author | Michael Stahl <mstahl@redhat.com> | 2012-07-04 23:03:55 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2012-07-04 23:23:22 +0200 |
commit | 09a61733bf4352edfc7fe341e9342594557ed02f (patch) | |
tree | 5727f68d88a1d73cc857de797c72127e38e361e6 /svtools | |
parent | 2c09f1c0a7747a625c375028d02a30c0c0e1a893 (diff) |
fix previous STL conversion commit:
- the reverse_iterator actually points to the element preceding the
original "it", so on the first iteration it shouldn't be incremented,
as that has happened implicitly already
- it's best to use iterators to iterate over maps
- also fix some pre-existing operator delete[] mismatch
Change-Id: I969d1b79eb970792ee8b0578347ffb59d5a64379
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/contnr/imivctl.hxx | 4 | ||||
-rw-r--r-- | svtools/source/contnr/imivctl1.cxx | 8 | ||||
-rw-r--r-- | svtools/source/contnr/imivctl2.cxx | 22 |
3 files changed, 16 insertions, 18 deletions
diff --git a/svtools/source/contnr/imivctl.hxx b/svtools/source/contnr/imivctl.hxx index 19f7bdb4e9da..a45dafe892ce 100644 --- a/svtools/source/contnr/imivctl.hxx +++ b/svtools/source/contnr/imivctl.hxx @@ -576,8 +576,8 @@ typedef std::map<sal_uInt16, SvxIconChoiceCtrlEntryPtrVec> IconChoiceMap; class IcnCursor_Impl { SvxIconChoiceCtrl_Impl* pView; - IconChoiceMap* pColumns; - IconChoiceMap* pRows; + boost::scoped_ptr<IconChoiceMap> pColumns; + boost::scoped_ptr<IconChoiceMap> pRows; long nCols; long nRows; short nDeltaWidth; diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx index b52607fa2bcf..d4809776ba5b 100644 --- a/svtools/source/contnr/imivctl1.cxx +++ b/svtools/source/contnr/imivctl1.cxx @@ -2985,9 +2985,11 @@ void SvxIconChoiceCtrl_Impl::AdjustEntryAtGrid( SvxIconChoiceCtrlEntry* pStart ) { IconChoiceMap aLists; pImpCursor->CreateGridAjustData( aLists, pStart ); - const sal_uInt16 nCount = aLists.size(); - for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ ) - AdjustAtGrid( aLists[ nCur ], pStart ); + for (IconChoiceMap::const_iterator iter = aLists.begin(); + iter != aLists.end(); ++iter) + { + AdjustAtGrid(iter->second, pStart); + } IcnCursor_Impl::DestroyGridAdjustData( aLists ); CheckScrollBars(); } diff --git a/svtools/source/contnr/imivctl2.cxx b/svtools/source/contnr/imivctl2.cxx index 0b381c613c47..de19b973c45d 100644 --- a/svtools/source/contnr/imivctl2.cxx +++ b/svtools/source/contnr/imivctl2.cxx @@ -31,8 +31,6 @@ IcnCursor_Impl::IcnCursor_Impl( SvxIconChoiceCtrl_Impl* pOwner ) { pView = pOwner; - pColumns = 0; - pRows = 0; pCurEntry = 0; nDeltaWidth = 0; nDeltaHeight= 0; @@ -42,8 +40,6 @@ IcnCursor_Impl::IcnCursor_Impl( SvxIconChoiceCtrl_Impl* pOwner ) IcnCursor_Impl::~IcnCursor_Impl() { - delete[] pColumns; - delete[] pRows; } sal_uInt16 IcnCursor_Impl::GetSortListPos( SvxIconChoiceCtrlEntryPtrVec& rList, long nValue, @@ -79,8 +75,8 @@ void IcnCursor_Impl::ImplCreate() SetDeltas(); - pColumns = new IconChoiceMap; - pRows = new IconChoiceMap; + pColumns.reset(new IconChoiceMap); + pRows.reset(new IconChoiceMap); size_t nCount = pView->aEntries.size(); for( size_t nCur = 0; nCur < nCount; nCur++ ) @@ -117,10 +113,8 @@ void IcnCursor_Impl::Clear() { if( pColumns ) { - delete[] pColumns; - delete[] pRows; - pColumns = 0; - pRows = 0; + pColumns.reset(); + pRows.reset(); pCurEntry = 0; nDeltaWidth = 0; nDeltaHeight = 0; @@ -159,12 +153,13 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchCol(sal_uInt16 nCol, sal_uInt16 nT else { SvxIconChoiceCtrlEntryPtrVec::const_reverse_iterator it2(it); - while( ++it2 != rList.rend() ) + while (it2 != rList.rend()) { SvxIconChoiceCtrlEntry* pEntry = *it2; const Rectangle& rRect = pView->GetEntryBoundRect( pEntry ); if( rRect.Top() < rRefRect.Top() ) return pEntry; + ++it2; } return 0; } @@ -233,12 +228,13 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchRow(sal_uInt16 nRow, sal_uInt16 nL else { SvxIconChoiceCtrlEntryPtrVec::const_reverse_iterator it2(it); - while( ++it2 != rList.rend() ) + while (it2 != rList.rend()) { - SvxIconChoiceCtrlEntry* pEntry = *it; + SvxIconChoiceCtrlEntry* pEntry = *it2; const Rectangle& rRect = pView->GetEntryBoundRect( pEntry ); if( rRect.Left() < rRefRect.Left() ) return pEntry; + ++it2; } return 0; } |