summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2012-06-28 08:21:54 +0200
committerMichael Stahl <mstahl@redhat.com>2012-07-04 23:23:21 +0200
commit2c09f1c0a7747a625c375028d02a30c0c0e1a893 (patch)
treebc46147200bf2259f9b36f50fd4cafb5d6757cd0 /svtools
parenta6edbee5f827c8b8f1dde87933f54aae18dc2863 (diff)
Convert SvPtrarr to std::vector<SvxIconChoiceCtrlEntry*>
Change-Id: I70a3907f659f26817bca5c7049a0f301ae5f10ed
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/contnr/imivctl.hxx27
-rw-r--r--svtools/source/contnr/imivctl1.cxx14
-rw-r--r--svtools/source/contnr/imivctl2.cxx127
3 files changed, 80 insertions, 88 deletions
diff --git a/svtools/source/contnr/imivctl.hxx b/svtools/source/contnr/imivctl.hxx
index 96512aab5880..19f7bdb4e9da 100644
--- a/svtools/source/contnr/imivctl.hxx
+++ b/svtools/source/contnr/imivctl.hxx
@@ -39,7 +39,6 @@
#include <limits.h>
#include <svtools/ivctrl.hxx>
-#include <svl/svarray.hxx>
#include <boost/ptr_container/ptr_map.hpp>
class IcnCursor_Impl;
@@ -159,6 +158,7 @@ public:
//
typedef boost::ptr_map<sal_uInt16, SvxIconChoiceCtrlColumnInfo> SvxIconChoiceCtrlColumnInfoMap;
+typedef std::vector<SvxIconChoiceCtrlEntry*> SvxIconChoiceCtrlEntryPtrVec;
class SvxIconChoiceCtrl_Impl
{
@@ -288,7 +288,7 @@ class SvxIconChoiceCtrl_Impl
Rectangle CalcMaxTextRect( const SvxIconChoiceCtrlEntry* pEntry ) const;
void ClipAtVirtOutRect( Rectangle& rRect ) const;
- void AdjustAtGrid( const SvPtrarr& rRow, SvxIconChoiceCtrlEntry* pStart=0 );
+ void AdjustAtGrid( const SvxIconChoiceCtrlEntryPtrVec& rRow, SvxIconChoiceCtrlEntry* pStart=0 );
Point AdjustAtGrid(
const Rectangle& rCenterRect, // balance point of object (typically Bmp-Rect)
const Rectangle& rBoundRect
@@ -571,11 +571,13 @@ public:
// ----------------------------------------------------------------------------------------------
+typedef std::map<sal_uInt16, SvxIconChoiceCtrlEntryPtrVec> IconChoiceMap;
+
class IcnCursor_Impl
{
SvxIconChoiceCtrl_Impl* pView;
- SvPtrarr* pColumns;
- SvPtrarr* pRows;
+ IconChoiceMap* pColumns;
+ IconChoiceMap* pRows;
long nCols;
long nRows;
short nDeltaWidth;
@@ -585,14 +587,17 @@ class IcnCursor_Impl
void ImplCreate();
void Create() { if( !pColumns ) ImplCreate(); }
- sal_uInt16 GetSortListPos( SvPtrarr* pList, long nValue, int bVertical);
+ sal_uInt16 GetSortListPos(
+ SvxIconChoiceCtrlEntryPtrVec& rList,
+ long nValue,
+ int bVertical);
SvxIconChoiceCtrlEntry* SearchCol(
sal_uInt16 nCol,
sal_uInt16 nTop,
sal_uInt16 nBottom,
sal_uInt16 nPref,
- sal_Bool bDown,
- sal_Bool bSimple
+ bool bDown,
+ bool bSimple
);
SvxIconChoiceCtrlEntry* SearchRow(
@@ -600,8 +605,8 @@ class IcnCursor_Impl
sal_uInt16 nRight,
sal_uInt16 nLeft,
sal_uInt16 nPref,
- sal_Bool bRight,
- sal_Bool bSimple
+ bool bRight,
+ bool bSimple
);
public:
@@ -617,8 +622,8 @@ public:
// Creates a list of entries for every row (height = nGridDY) sorted by
// BoundRect.Left(). A list may be empty. The lists become the property of
// the caller and have to be deleted with DestroyGridAdjustData.
- void CreateGridAjustData( SvPtrarr& pLists, SvxIconChoiceCtrlEntry* pRow=0);
- static void DestroyGridAdjustData( SvPtrarr& rLists );
+ void CreateGridAjustData( IconChoiceMap& pLists, SvxIconChoiceCtrlEntry* pRow=0);
+ static void DestroyGridAdjustData( IconChoiceMap& rLists );
};
// ----------------------------------------------------------------------------------------------
diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx
index e7622537a2e8..b52607fa2bcf 100644
--- a/svtools/source/contnr/imivctl1.cxx
+++ b/svtools/source/contnr/imivctl1.cxx
@@ -2983,19 +2983,19 @@ IMPL_LINK_NOARG(SvxIconChoiceCtrl_Impl, EditTimeoutHdl)
// else: align all entries of the row from pStart on (including pStart)
void SvxIconChoiceCtrl_Impl::AdjustEntryAtGrid( SvxIconChoiceCtrlEntry* pStart )
{
- SvPtrarr aLists;
+ IconChoiceMap aLists;
pImpCursor->CreateGridAjustData( aLists, pStart );
- const sal_uInt16 nCount = aLists.Count();
+ const sal_uInt16 nCount = aLists.size();
for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
- AdjustAtGrid( *(SvPtrarr*)aLists[ nCur ], pStart );
+ AdjustAtGrid( aLists[ nCur ], pStart );
IcnCursor_Impl::DestroyGridAdjustData( aLists );
CheckScrollBars();
}
// align a row, might expand width, doesn't break the line
-void SvxIconChoiceCtrl_Impl::AdjustAtGrid( const SvPtrarr& rRow, SvxIconChoiceCtrlEntry* pStart )
+void SvxIconChoiceCtrl_Impl::AdjustAtGrid( const SvxIconChoiceCtrlEntryPtrVec& rRow, SvxIconChoiceCtrlEntry* pStart )
{
- if( !rRow.Count() )
+ if( rRow.empty() )
return;
sal_Bool bGo;
@@ -3005,9 +3005,9 @@ void SvxIconChoiceCtrl_Impl::AdjustAtGrid( const SvPtrarr& rRow, SvxIconChoiceCt
bGo = sal_False;
long nCurRight = 0;
- for( sal_uInt16 nCur = 0; nCur < rRow.Count(); nCur++ )
+ for( sal_uInt16 nCur = 0; nCur < rRow.size(); nCur++ )
{
- SvxIconChoiceCtrlEntry* pCur = (SvxIconChoiceCtrlEntry*)rRow[ nCur ];
+ SvxIconChoiceCtrlEntry* pCur = rRow[ nCur ];
if( !bGo && pCur == pStart )
bGo = sal_True;
diff --git a/svtools/source/contnr/imivctl2.cxx b/svtools/source/contnr/imivctl2.cxx
index 0bb77a951ba0..0b381c613c47 100644
--- a/svtools/source/contnr/imivctl2.cxx
+++ b/svtools/source/contnr/imivctl2.cxx
@@ -46,10 +46,10 @@ IcnCursor_Impl::~IcnCursor_Impl()
delete[] pRows;
}
-sal_uInt16 IcnCursor_Impl::GetSortListPos( SvPtrarr* pList, long nValue,
+sal_uInt16 IcnCursor_Impl::GetSortListPos( SvxIconChoiceCtrlEntryPtrVec& rList, long nValue,
int bVertical )
{
- sal_uInt16 nCount = (sal_uInt16)pList->Count();
+ sal_uInt16 nCount = rList.size();
if( !nCount )
return 0;
@@ -57,8 +57,7 @@ sal_uInt16 IcnCursor_Impl::GetSortListPos( SvPtrarr* pList, long nValue,
long nPrevValue = LONG_MIN;
while( nCount )
{
- const Rectangle& rRect=
- pView->GetEntryBoundRect((SvxIconChoiceCtrlEntry*)(pList->GetObject(nCurPos)));
+ const Rectangle& rRect = pView->GetEntryBoundRect( rList[nCurPos] );
long nCurValue;
if( bVertical )
nCurValue = rRect.Top();
@@ -70,7 +69,7 @@ sal_uInt16 IcnCursor_Impl::GetSortListPos( SvPtrarr* pList, long nValue,
nCount--;
nCurPos++;
}
- return pList->Count();
+ return rList.size();
}
void IcnCursor_Impl::ImplCreate()
@@ -80,8 +79,8 @@ void IcnCursor_Impl::ImplCreate()
SetDeltas();
- pColumns = new SvPtrarr[ nCols ];
- pRows = new SvPtrarr[ nRows ];
+ pColumns = new IconChoiceMap;
+ pRows = new IconChoiceMap;
size_t nCount = pView->aEntries.size();
for( size_t nCur = 0; nCur < nCount; nCur++ )
@@ -98,11 +97,13 @@ void IcnCursor_Impl::ImplCreate()
if( nX >= nCols )
nX = sal::static_int_cast< short >(nCols - 1);
- sal_uInt16 nIns = GetSortListPos( &pColumns[nX], rRect.Top(), sal_True );
- pColumns[ nX ].Insert( pEntry, nIns );
+ SvxIconChoiceCtrlEntryPtrVec& rColEntry = (*pColumns)[nX];
+ sal_uInt16 nIns = GetSortListPos( rColEntry, rRect.Top(), sal_True );
+ rColEntry.insert( rColEntry.begin() + nIns, pEntry );
- nIns = GetSortListPos( &pRows[nY], rRect.Left(), sal_False );
- pRows[ nY ].Insert( pEntry, nIns );
+ SvxIconChoiceCtrlEntryPtrVec& rRowEntry = (*pRows)[nY];
+ nIns = GetSortListPos( rRowEntry, rRect.Left(), sal_False );
+ rRowEntry.insert( rRowEntry.begin() + nIns, pEntry );
pEntry->nX = nX;
pEntry->nY = nY;
@@ -126,12 +127,15 @@ void IcnCursor_Impl::Clear()
}
}
-SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchCol(sal_uInt16 nCol,sal_uInt16 nTop,sal_uInt16 nBottom,
- sal_uInt16, sal_Bool bDown, sal_Bool bSimple )
+SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchCol(sal_uInt16 nCol, sal_uInt16 nTop, sal_uInt16 nBottom,
+ sal_uInt16, bool bDown, bool bSimple )
{
- DBG_ASSERT(pCurEntry,"SearchCol: No reference entry");
- SvPtrarr* pList = &(pColumns[ nCol ]);
- const sal_uInt16 nCount = pList->Count();
+ DBG_ASSERT(pCurEntry, "SearchCol: No reference entry");
+ IconChoiceMap::iterator mapIt = pColumns->find( nCol );
+ if ( mapIt == pColumns->end() )
+ return 0;
+ SvxIconChoiceCtrlEntryPtrVec& rList = mapIt->second;
+ const sal_uInt16 nCount = rList.size();
if( !nCount )
return 0;
@@ -139,14 +143,13 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchCol(sal_uInt16 nCol,sal_uInt16 nTo
if( bSimple )
{
- sal_uInt16 nListPos = pList->GetPos( pCurEntry );
- DBG_ASSERT(nListPos!=0xffff,"Entry not in Col-List");
+ SvxIconChoiceCtrlEntryPtrVec::const_iterator it = std::find( rList.begin(), rList.end(), pCurEntry );
+ DBG_ASSERT( it != rList.end(), "Entry not in Col-List" );
if( bDown )
{
- while( nListPos < nCount-1 )
+ while( ++it != rList.end() )
{
- nListPos++;
- SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)pList->GetObject( nListPos );
+ SvxIconChoiceCtrlEntry* pEntry = *it;
const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
if( rRect.Top() > rRefRect.Top() )
return pEntry;
@@ -155,16 +158,13 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchCol(sal_uInt16 nCol,sal_uInt16 nTo
}
else
{
- while( nListPos )
+ SvxIconChoiceCtrlEntryPtrVec::const_reverse_iterator it2(it);
+ while( ++it2 != rList.rend() )
{
- nListPos--;
- if( nListPos < nCount )
- {
- SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)pList->GetObject( nListPos );
- const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
- if( rRect.Top() < rRefRect.Top() )
- return pEntry;
- }
+ SvxIconChoiceCtrlEntry* pEntry = *it2;
+ const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
+ if( rRect.Top() < rRefRect.Top() )
+ return pEntry;
}
return 0;
}
@@ -180,7 +180,7 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchCol(sal_uInt16 nCol,sal_uInt16 nTo
SvxIconChoiceCtrlEntry* pResult = 0;
for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
{
- SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pList->GetObject( nCur ));
+ SvxIconChoiceCtrlEntry* pEntry = rList[ nCur ];
if( pEntry != pCurEntry )
{
sal_uInt16 nY = pEntry->nY;
@@ -201,12 +201,15 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchCol(sal_uInt16 nCol,sal_uInt16 nTo
return pResult;
}
-SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchRow(sal_uInt16 nRow,sal_uInt16 nLeft,sal_uInt16 nRight,
- sal_uInt16, sal_Bool bRight, sal_Bool bSimple )
+SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchRow(sal_uInt16 nRow, sal_uInt16 nLeft, sal_uInt16 nRight,
+ sal_uInt16, bool bRight, bool bSimple )
{
DBG_ASSERT(pCurEntry,"SearchRow: No reference entry");
- SvPtrarr* pList = &(pRows[ nRow ]);
- const sal_uInt16 nCount = pList->Count();
+ IconChoiceMap::iterator mapIt = pRows->find( nRow );
+ if ( mapIt == pRows->end() )
+ return 0;
+ SvxIconChoiceCtrlEntryPtrVec& rList = mapIt->second;
+ const sal_uInt16 nCount = rList.size();
if( !nCount )
return 0;
@@ -214,14 +217,13 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchRow(sal_uInt16 nRow,sal_uInt16 nLe
if( bSimple )
{
- sal_uInt16 nListPos = pList->GetPos( pCurEntry );
- DBG_ASSERT(nListPos!=0xffff,"Entry not in Row-List");
+ SvxIconChoiceCtrlEntryPtrVec::const_iterator it = std::find( rList.begin(), rList.end(), pCurEntry );
+ DBG_ASSERT( it != rList.end(), "Entry not in Row-List" );
if( bRight )
{
- while( nListPos < nCount-1 )
+ while( ++it != rList.end() )
{
- nListPos++;
- SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)pList->GetObject( nListPos );
+ SvxIconChoiceCtrlEntry* pEntry = *it;
const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
if( rRect.Left() > rRefRect.Left() )
return pEntry;
@@ -230,16 +232,13 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchRow(sal_uInt16 nRow,sal_uInt16 nLe
}
else
{
- while( nListPos )
+ SvxIconChoiceCtrlEntryPtrVec::const_reverse_iterator it2(it);
+ while( ++it2 != rList.rend() )
{
- nListPos--;
- if( nListPos < nCount )
- {
- SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)pList->GetObject( nListPos );
- const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
- if( rRect.Left() < rRefRect.Left() )
- return pEntry;
- }
+ SvxIconChoiceCtrlEntry* pEntry = *it;
+ const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
+ if( rRect.Left() < rRefRect.Left() )
+ return pEntry;
}
return 0;
}
@@ -255,7 +254,7 @@ SvxIconChoiceCtrlEntry* IcnCursor_Impl::SearchRow(sal_uInt16 nRow,sal_uInt16 nLe
SvxIconChoiceCtrlEntry* pResult = 0;
for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
{
- SvxIconChoiceCtrlEntry* pEntry = (SvxIconChoiceCtrlEntry*)(pList->GetObject( nCur ));
+ SvxIconChoiceCtrlEntry* pEntry = rList[ nCur ];
if( pEntry != pCurEntry )
{
sal_uInt16 nX = pEntry->nX;
@@ -488,7 +487,7 @@ void IcnCursor_Impl::SetDeltas()
}
}
-void IcnCursor_Impl::CreateGridAjustData( SvPtrarr& rLists, SvxIconChoiceCtrlEntry* pRefEntry)
+void IcnCursor_Impl::CreateGridAjustData( IconChoiceMap& rLists, SvxIconChoiceCtrlEntry* pRefEntry)
{
if( !pRefEntry )
{
@@ -497,19 +496,14 @@ void IcnCursor_Impl::CreateGridAjustData( SvPtrarr& rLists, SvxIconChoiceCtrlEnt
if( !nGridRows )
return;
- for( sal_uInt16 nCurList = 0; nCurList < nGridRows; nCurList++ )
- {
- SvPtrarr* pRow = new SvPtrarr;
- rLists.Insert( (void*)pRow, nCurList );
- }
const size_t nCount = pView->aEntries.size();
for( size_t nCur = 0; nCur < nCount; nCur++ )
{
SvxIconChoiceCtrlEntry* pEntry = pView->aEntries[ nCur ];
const Rectangle& rRect = pView->GetEntryBoundRect( pEntry );
short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / pView->nGridDY );
- sal_uInt16 nIns = GetSortListPos((SvPtrarr*)rLists[nY],rRect.Left(),sal_False);
- ((SvPtrarr*)rLists[ nY ])->Insert( pEntry, nIns );
+ sal_uInt16 nIns = GetSortListPos( rLists[nY], rRect.Left(), sal_False );
+ rLists[ nY ].insert( rLists[ nY ].begin() + nIns, pEntry );
}
}
else
@@ -519,8 +513,7 @@ void IcnCursor_Impl::CreateGridAjustData( SvPtrarr& rLists, SvxIconChoiceCtrlEnt
Rectangle rRefRect( pView->CalcBmpRect( pRefEntry ) );
//const Rectangle& rRefRect = pView->GetEntryBoundRect( pRefEntry );
short nRefRow = (short)( ((rRefRect.Top()+rRefRect.Bottom())/2) / pView->nGridDY );
- SvPtrarr* pRow = new SvPtrarr;
- rLists.Insert( (void*)pRow, 0 );
+ SvxIconChoiceCtrlEntryPtrVec& rRow = rLists[0];
size_t nCount = pView->aEntries.size();
for( size_t nCur = 0; nCur < nCount; nCur++ )
{
@@ -530,23 +523,17 @@ void IcnCursor_Impl::CreateGridAjustData( SvPtrarr& rLists, SvxIconChoiceCtrlEnt
short nY = (short)( ((rRect.Top()+rRect.Bottom())/2) / pView->nGridDY );
if( nY == nRefRow )
{
- sal_uInt16 nIns = GetSortListPos( pRow, rRect.Left(), sal_False );
- pRow->Insert( pEntry, nIns );
+ sal_uInt16 nIns = GetSortListPos( rRow, rRect.Left(), sal_False );
+ rRow.insert( rRow.begin() + nIns, pEntry );
}
}
}
}
//static
-void IcnCursor_Impl::DestroyGridAdjustData( SvPtrarr& rLists )
+void IcnCursor_Impl::DestroyGridAdjustData( IconChoiceMap& rLists )
{
- const sal_uInt16 nCount = rLists.Count();
- for( sal_uInt16 nCur = 0; nCur < nCount; nCur++ )
- {
- SvPtrarr* pArr = (SvPtrarr*)rLists[ nCur ];
- delete pArr;
- }
- rLists.Remove( 0, rLists.Count() );
+ rLists.clear();
}
IcnGridMap_Impl::IcnGridMap_Impl(SvxIconChoiceCtrl_Impl* pView)