From a87c24fcfe1d8842d892185d6f9f2e07c52c3804 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 28 Jun 2012 10:06:59 +0200 Subject: [PATCH] Convert aTabs field in SvTreeListBox from SvPtrarr to std::vector Change-Id: I901c6df67fc95cfb2ac3ea15e69a47c5fc3161b6 --- basctl/source/basicide/baside2b.cxx | 4 +- cui/source/options/fontsubs.cxx | 4 +- cui/source/options/optfltr.cxx | 8 ++-- cui/source/tabpages/autocdlg.cxx | 8 ++-- svtools/inc/svtools/svtreebx.hxx | 4 +- svtools/source/contnr/svimpbox.cxx | 6 +-- svtools/source/contnr/svtabbx.cxx | 2 +- svtools/source/contnr/svtreebx.cxx | 66 ++++++++++++++--------------- 8 files changed, 50 insertions(+), 52 deletions(-) diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index d674fd1f719c..331399505b28 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -1769,10 +1769,10 @@ WatchTreeListBox::~WatchTreeListBox() void WatchTreeListBox::SetTabs() { SvHeaderTabListBox::SetTabs(); - sal_uInt16 nTabCount_ = aTabs.Count(); + sal_uInt16 nTabCount_ = aTabs.size(); for( sal_uInt16 i = 0 ; i < nTabCount_ ; i++ ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(i); + SvLBoxTab* pTab = aTabs[i]; if( i == 2 ) pTab->nFlags |= SV_LBOXTAB_EDITABLE; else diff --git a/cui/source/options/fontsubs.cxx b/cui/source/options/fontsubs.cxx index 191799f8b855..7f65c50307e1 100644 --- a/cui/source/options/fontsubs.cxx +++ b/cui/source/options/fontsubs.cxx @@ -468,11 +468,11 @@ void SvxFontSubstCheckListBox::SetTabs() SvxSimpleTable::SetTabs(); sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT|SV_LBOXTAB_ADJUST_LEFT|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_ADJUST_NUMERIC|SV_LBOXTAB_FORCE; - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(1); + SvLBoxTab* pTab = aTabs[1]; pTab->nFlags &= ~nAdjust; pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; - pTab = (SvLBoxTab*)aTabs.GetObject(2); + pTab = aTabs[2]; pTab->nFlags &= ~nAdjust; pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; } diff --git a/cui/source/options/optfltr.cxx b/cui/source/options/optfltr.cxx index 5300a844acb6..5a6474ec645c 100644 --- a/cui/source/options/optfltr.cxx +++ b/cui/source/options/optfltr.cxx @@ -322,15 +322,15 @@ void OfaMSFilterTabPage2::MSFltrSimpleTable::SetTabs() SvxSimpleTable::SetTabs(); sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT|SV_LBOXTAB_ADJUST_LEFT|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_ADJUST_NUMERIC|SV_LBOXTAB_FORCE; - if( aTabs.Count() > 1 ) + if( aTabs.size() > 1 ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(1); + SvLBoxTab* pTab = aTabs[1]; pTab->nFlags &= ~nAdjust; pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; } - if( aTabs.Count() > 2 ) + if( aTabs.size() > 2 ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(2); + SvLBoxTab* pTab = aTabs[2]; pTab->nFlags &= ~nAdjust; pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; } diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index c459791cffea..2643aa44be48 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -808,15 +808,15 @@ void OfaACorrCheckListBox::SetTabs() SvxSimpleTable::SetTabs(); sal_uInt16 nAdjust = SV_LBOXTAB_ADJUST_RIGHT|SV_LBOXTAB_ADJUST_LEFT|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_ADJUST_NUMERIC|SV_LBOXTAB_FORCE; - if( aTabs.Count() > 1 ) + if( aTabs.size() > 1 ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(1); + SvLBoxTab* pTab = aTabs[1]; pTab->nFlags &= ~nAdjust; pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; } - if( aTabs.Count() > 2 ) + if( aTabs.size() > 2 ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(2); + SvLBoxTab* pTab = aTabs[2]; pTab->nFlags &= ~nAdjust; pTab->nFlags |= SV_LBOXTAB_PUSHABLE|SV_LBOXTAB_ADJUST_CENTER|SV_LBOXTAB_FORCE; } diff --git a/svtools/inc/svtools/svtreebx.hxx b/svtools/inc/svtools/svtreebx.hxx index b6f1bab4d07a..b656bdb37b95 100644 --- a/svtools/inc/svtools/svtreebx.hxx +++ b/svtools/inc/svtools/svtreebx.hxx @@ -115,7 +115,7 @@ protected: void EditingRequest( SvLBoxEntry* pEntry, SvLBoxItem* pItem, const Point& rMousePos ); - SvPtrarr aTabs; + std::vector aTabs; // berechnet abhaengig von TreeList-Style & Bitmap-Groessen // alle Tabulatoren neu; wird beim Einfuegen/Austauschen von @@ -124,7 +124,7 @@ protected: void SetTabs_Impl(); void AddTab( long nPos,sal_uInt16 nFlags=SV_LBOXTAB_ADJUST_LEFT, void* pUserData = 0 ); - sal_uInt16 TabCount() const { return aTabs.Count(); } + sal_uInt16 TabCount() const { return aTabs.size(); } SvLBoxTab* GetFirstDynamicTab() const; SvLBoxTab* GetFirstDynamicTab( sal_uInt16& rTabPos ) const; SvLBoxTab* GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos ); diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index 9b0baec5954e..21a0e4a92b14 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -3285,14 +3285,14 @@ sal_Bool SvImpLBox::SetMostRight( SvLBoxEntry* pEntry ) nFlags &= ~F_IGNORE_CHANGED_TABS; } - sal_uInt16 nLastTab = pView->aTabs.Count() - 1; + sal_uInt16 nLastTab = pView->aTabs.size() - 1; sal_uInt16 nLastItem = pEntry->ItemCount() - 1; - if( nLastTab != USHRT_MAX && nLastItem != USHRT_MAX ) + if( !pView->aTabs.empty() && nLastItem != USHRT_MAX ) { if( nLastItem < nLastTab ) nLastTab = nLastItem; - SvLBoxTab* pTab = (SvLBoxTab*)pView->aTabs[ nLastTab ]; + SvLBoxTab* pTab = pView->aTabs[ nLastTab ]; SvLBoxItem* pItem = pEntry->GetItem( nLastTab ); long nTabPos = pView->GetTabPos( pEntry, pTab ); diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx index ad14ca314194..ad019f4c9202 100644 --- a/svtools/source/contnr/svtabbx.cxx +++ b/svtools/source/contnr/svtabbx.cxx @@ -543,7 +543,7 @@ long SvTabListBox::GetLogicTab( sal_uInt16 nTab ) ((SvTabListBox*)this)->SetTabs(); DBG_ASSERT(nTabGetPos(); + return aTabs[ nTab ]->GetPos(); } // class SvHeaderTabListBoxImpl ------------------------------------------ diff --git a/svtools/source/contnr/svtreebx.cxx b/svtools/source/contnr/svtreebx.cxx index d57f8b6225a6..fe513db90113 100644 --- a/svtools/source/contnr/svtreebx.cxx +++ b/svtools/source/contnr/svtreebx.cxx @@ -1255,10 +1255,10 @@ void SvTreeListBox::EditItemText( SvLBoxEntry* pEntry, SvLBoxString* pItem, aPos.X() = GetTabPos( pEntry, pTab ); long nOutputWidth = pImp->GetOutputSize().Width(); Size aSize( nOutputWidth - aPos.X(), aItemSize.Height() ); - sal_uInt16 nPos = aTabs.GetPos( pTab ); - if( nPos+1 < aTabs.Count() ) + sal_uInt16 nPos = std::find( aTabs.begin(), aTabs.end(), pTab ) - aTabs.begin(); + if( nPos+1 < (sal_uInt16)aTabs.size() ) { - SvLBoxTab* pRightTab = (SvLBoxTab*)aTabs.GetObject( nPos + 1 ); + SvLBoxTab* pRightTab = aTabs[ nPos + 1 ]; long nRight = GetTabPos( pEntry, pRightTab ); if( nRight <= nOutputWidth ) aSize.Width() = nRight - aPos.X(); @@ -1525,16 +1525,16 @@ long SvTreeListBox::PaintEntry1(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFl SvViewDataEntry* pViewDataEntry = GetViewDataEntry( pEntry ); - sal_uInt16 nTabCount = aTabs.Count(); + sal_uInt16 nTabCount = aTabs.size(); sal_uInt16 nItemCount = pEntry->ItemCount(); sal_uInt16 nCurTab = 0; sal_uInt16 nCurItem = 0; while( nCurTab < nTabCount && nCurItem < nItemCount ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nCurTab ); + SvLBoxTab* pTab = aTabs[ nCurTab ]; sal_uInt16 nNextTab = nCurTab + 1; - SvLBoxTab* pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0; + SvLBoxTab* pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : 0; SvLBoxItem* pItem = nCurItem < nItemCount ? pEntry->GetItem(nCurItem) : 0; sal_uInt16 nFlags = pTab->nFlags; @@ -1704,7 +1704,7 @@ long SvTreeListBox::PaintEntry1(SvLBoxEntry* pEntry,long nLine,sal_uInt16 nTabFl do { nNextTab++; - pNextTab = nNextTab < nTabCount ? (SvLBoxTab*)aTabs.GetObject(nNextTab) : 0; + pNextTab = nNextTab < nTabCount ? aTabs[nNextTab] : 0; } while( pNextTab && pNextTab->IsDynamic() ); if( !pNextTab || (GetTabPos( pEntry, pNextTab ) > nDynTabPos) ) @@ -1795,9 +1795,9 @@ Rectangle SvTreeListBox::GetFocusRect( SvLBoxEntry* pEntry, long nLine ) if( pTab ) nTabPos = GetTabPos( pEntry, pTab ); long nNextTabPos; - if( pTab && nCurTab < aTabs.Count() - 1 ) + if( pTab && nCurTab < aTabs.size() - 1 ) { - SvLBoxTab* pNextTab = (SvLBoxTab*)aTabs.GetObject( nCurTab + 1 ); + SvLBoxTab* pNextTab = aTabs[ nCurTab + 1 ]; nNextTabPos = GetTabPos( pEntry, pNextTab ); } else @@ -1835,8 +1835,8 @@ Rectangle SvTreeListBox::GetFocusRect( SvLBoxEntry* pEntry, long nLine ) sal_uInt16 nLastTab; SvLBoxTab* pLastTab = GetLastTab(SV_LBOXTAB_SHOW_SELECTION,nLastTab); nLastTab++; - if( nLastTab < aTabs.Count() ) // is there another one? - pLastTab = (SvLBoxTab*)aTabs.GetObject( nLastTab ); + if( nLastTab < aTabs.size() ) // is there another one? + pLastTab = aTabs[ nLastTab ]; else pLastTab = 0; // select whole width aSize.Width() = pLastTab ? pLastTab->GetPos() : 0x0fffffff; @@ -1892,9 +1892,9 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvLBoxEntry* pEntry, long nX, { DBG_CHKTHIS(SvTreeListBox,0); SvLBoxItem* pItemClicked = 0; - sal_uInt16 nTabCount = aTabs.Count(); + sal_uInt16 nTabCount = aTabs.size(); sal_uInt16 nItemCount = pEntry->ItemCount(); - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(0); + SvLBoxTab* pTab = aTabs.front(); SvLBoxItem* pItem = pEntry->GetItem(0); sal_uInt16 nNextItem = 1; nX -= GetMapMode().GetOrigin().X(); @@ -1903,7 +1903,7 @@ SvLBoxItem* SvTreeListBox::GetItem_Impl( SvLBoxEntry* pEntry, long nX, while( 1 ) { - SvLBoxTab* pNextTab=nNextItem= nItemCount || nNextItem >= nTabCount) break; - pTab = (SvLBoxTab*)aTabs.GetObject( nNextItem ); + pTab = aTabs[ nNextItem ]; pItem = pEntry->GetItem( nNextItem ); nNextItem++; } @@ -1965,10 +1965,10 @@ void SvTreeListBox::AddTab(long nTabPos,sal_uInt16 nFlags,void* pUserData ) nFocusWidth = -1; SvLBoxTab* pTab = new SvLBoxTab( nTabPos, nFlags ); pTab->SetUserData( pUserData ); - aTabs.Insert( pTab, aTabs.Count() ); + aTabs.push_back( pTab ); if( nTreeFlags & TREEFLAG_USESEL ) { - sal_uInt16 nPos = aTabs.Count() - 1; + sal_uInt16 nPos = aTabs.size() - 1; if( nPos >= nFirstSelTab && nPos <= nLastSelTab ) pTab->nFlags |= SV_LBOXTAB_SHOW_SELECTION; else @@ -1984,10 +1984,10 @@ SvLBoxTab* SvTreeListBox::GetFirstDynamicTab( sal_uInt16& rPos ) const { DBG_CHKTHIS(SvTreeListBox,0); sal_uInt16 nCurTab = 0; - sal_uInt16 nTabCount = aTabs.Count(); + sal_uInt16 nTabCount = aTabs.size(); while( nCurTab < nTabCount ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject(nCurTab); + SvLBoxTab* pTab = aTabs[nCurTab]; if( pTab->nFlags & SV_LBOXTAB_DYNAMIC ) { rPos = nCurTab; @@ -2008,20 +2008,20 @@ SvLBoxTab* SvTreeListBox::GetTab( SvLBoxEntry* pEntry, SvLBoxItem* pItem) const { DBG_CHKTHIS(SvTreeListBox,0); sal_uInt16 nPos = pEntry->GetPos( pItem ); - return (SvLBoxTab*)aTabs.GetObject( nPos ); + return aTabs[ nPos ]; } void SvTreeListBox::ClearTabList() { DBG_CHKTHIS(SvTreeListBox,0); - sal_uInt16 nTabCount = aTabs.Count(); + sal_uInt16 nTabCount = aTabs.size(); while( nTabCount ) { nTabCount--; - SvLBoxTab* pDelTab = (SvLBoxTab*)aTabs.GetObject( nTabCount ); + SvLBoxTab* pDelTab = aTabs[ nTabCount ]; delete pDelTab; } - aTabs.Remove(0,aTabs.Count()); + aTabs.clear(); } @@ -2154,10 +2154,10 @@ void SvTreeListBox::RemoveParentKeepChildren( SvLBoxEntry* pParent ) SvLBoxTab* SvTreeListBox::GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rPos ) { - sal_uInt16 nTabCount = aTabs.Count(); + sal_uInt16 nTabCount = aTabs.size(); for( sal_uInt16 nPos = 0; nPos < nTabCount; nPos++ ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( nPos ); + SvLBoxTab* pTab = aTabs[ nPos ]; if( (pTab->nFlags & nFlagMask) ) { rPos = nPos; @@ -2170,17 +2170,15 @@ SvLBoxTab* SvTreeListBox::GetFirstTab( sal_uInt16 nFlagMask, sal_uInt16& rPos ) SvLBoxTab* SvTreeListBox::GetLastTab( sal_uInt16 nFlagMask, sal_uInt16& rTabPos ) { - short nTabCount = (short)aTabs.Count(); - if( nTabCount ) + sal_uInt16 nPos = (sal_uInt16)aTabs.size(); + while( nPos ) { - for( short nPos = nTabCount-1; nPos >= 0; nPos-- ) + --nPos; + SvLBoxTab* pTab = aTabs[ nPos ]; + if( (pTab->nFlags & nFlagMask) ) { - SvLBoxTab* pTab = (SvLBoxTab*)aTabs.GetObject( (sal_uInt16)nPos ); - if( (pTab->nFlags & nFlagMask) ) - { - rTabPos = (sal_uInt16)nPos; - return pTab; - } + rTabPos = nPos; + return pTab; } } rTabPos = 0xffff;