Kaydet (Commit) e8c2bb2e authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

tabbar: convert ItemList* to ItemList and clean-up

Change-Id: Ibd4364f7d30f098df49537c6a6a01915bfa31b8d
üst 36f1dec2
...@@ -25,16 +25,6 @@ ...@@ -25,16 +25,6 @@
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <vector> #include <vector>
class MouseEvent;
class TrackingEvent;
class DataChangedEvent;
class ImplTabButton;
class ImplTabSizer;
class TabBarEdit;
struct ImplTabBarItem;
typedef std::vector<ImplTabBarItem*> ImplTabBarList;
/* /*
Allowed StylbeBits Allowed StylbeBits
...@@ -306,6 +296,14 @@ enum TabBarAllowRenamingReturnCode { ...@@ -306,6 +296,14 @@ enum TabBarAllowRenamingReturnCode {
// - TabBar - // - TabBar -
class MouseEvent;
class TrackingEvent;
class DataChangedEvent;
class ImplTabButton;
class ImplTabSizer;
class TabBarEdit;
struct ImplTabBarItem;
struct TabBar_Impl; struct TabBar_Impl;
typedef std::vector<ImplTabBarItem*> ImplTabBarList; typedef std::vector<ImplTabBarItem*> ImplTabBarList;
......
...@@ -358,7 +358,7 @@ struct TabBar_Impl ...@@ -358,7 +358,7 @@ struct TabBar_Impl
std::unique_ptr<ImplTabButton> mpNextButton; std::unique_ptr<ImplTabButton> mpNextButton;
std::unique_ptr<ImplTabButton> mpLastButton; std::unique_ptr<ImplTabButton> mpLastButton;
std::unique_ptr<TabBarEdit> mpEdit; std::unique_ptr<TabBarEdit> mpEdit;
ImplTabBarList* mpItemList; ImplTabBarList mpItemList;
svt::AccessibleFactoryAccess maAccessibleFactory; svt::AccessibleFactoryAccess maAccessibleFactory;
...@@ -369,15 +369,21 @@ struct TabBar_Impl ...@@ -369,15 +369,21 @@ struct TabBar_Impl
, mpNextButton() , mpNextButton()
, mpLastButton() , mpLastButton()
, mpEdit() , mpEdit()
, mpItemList(new ImplTabBarList) , mpItemList()
{} {}
~TabBar_Impl() ~TabBar_Impl()
{ {
for ( size_t i = 0, n = mpItemList->size(); i < n; ++i ) { for (size_t i = 0; i < mpItemList.size(); ++i)
delete (*mpItemList)[ i ]; {
delete mpItemList[i];
}
mpItemList.clear();
} }
delete mpItemList;
sal_uInt16 getItemSize()
{
return static_cast<sal_uInt16>(mpItemList.size());
} }
}; };
...@@ -455,26 +461,28 @@ TabBar::~TabBar() ...@@ -455,26 +461,28 @@ TabBar::~TabBar()
ImplTabBarItem* TabBar::seek( size_t i ) ImplTabBarItem* TabBar::seek( size_t i )
{ {
if ( i < mpImpl->mpItemList->size() ) if ( i < mpImpl->mpItemList.size() )
{ {
maCurrentItemList = i; maCurrentItemList = i;
return (*mpImpl->mpItemList)[ maCurrentItemList ]; return mpImpl->mpItemList[maCurrentItemList];
} }
return NULL; return NULL;
} }
ImplTabBarItem* TabBar::prev() ImplTabBarItem* TabBar::prev()
{ {
if ( maCurrentItemList > 0 ) { if ( maCurrentItemList > 0 )
return (*mpImpl->mpItemList)[ --maCurrentItemList ]; {
return mpImpl->mpItemList[--maCurrentItemList];
} }
return NULL; return NULL;
} }
ImplTabBarItem* TabBar::next() ImplTabBarItem* TabBar::next()
{ {
if ( maCurrentItemList + 1 < mpImpl->mpItemList->size() ) { if ( maCurrentItemList + 1 < mpImpl->mpItemList.size() )
return (*mpImpl->mpItemList)[ ++maCurrentItemList ]; {
return mpImpl->mpItemList[++maCurrentItemList];
} }
return NULL; return NULL;
} }
...@@ -578,9 +586,9 @@ bool TabBar::ImplCalcWidth() ...@@ -578,9 +586,9 @@ bool TabBar::ImplCalcWidth()
mnCurMaxWidth = 0; mnCurMaxWidth = 0;
bool bChanged = false; bool bChanged = false;
for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ i ]; ImplTabBarItem* pItem = mpImpl->mpItemList[i];
long nNewWidth = GetTextWidth( pItem->maText ); long nNewWidth = GetTextWidth( pItem->maText );
if ( mnCurMaxWidth && (nNewWidth > mnCurMaxWidth) ) if ( mnCurMaxWidth && (nNewWidth > mnCurMaxWidth) )
{ {
...@@ -619,9 +627,9 @@ void TabBar::ImplFormat() ...@@ -619,9 +627,9 @@ void TabBar::ImplFormat()
sal_uInt16 n = 0; sal_uInt16 n = 0;
long x = mnOffX; long x = mnOffX;
for ( size_t i = 0, nL = mpImpl->mpItemList->size(); i < nL; ++i ) for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ i ]; ImplTabBarItem* pItem = mpImpl->mpItemList[i];
// At all non-visible tabs an empty rectangle is set // At all non-visible tabs an empty rectangle is set
if ( (n+1 < mnFirstPos) || (x > mnLastOffX) ) if ( (n+1 < mnFirstPos) || (x > mnLastOffX) )
pItem->maRect.SetEmpty(); pItem->maRect.SetEmpty();
...@@ -660,20 +668,19 @@ void TabBar::ImplFormat() ...@@ -660,20 +668,19 @@ void TabBar::ImplFormat()
sal_uInt16 TabBar::ImplGetLastFirstPos() sal_uInt16 TabBar::ImplGetLastFirstPos()
{ {
sal_uInt16 nCount = (sal_uInt16)(mpImpl->mpItemList->size()); sal_uInt16 nCount = mpImpl->getItemSize();
if ( !nCount || mbSizeFormat || mbFormat ) if ( !nCount || mbSizeFormat || mbFormat )
return 0; return 0;
sal_uInt16 nLastFirstPos = nCount-1; sal_uInt16 nLastFirstPos = nCount-1;
long nWinWidth = mnLastOffX - mnOffX - ADDNEWPAGE_AREAWIDTH; long nWinWidth = mnLastOffX - mnOffX - ADDNEWPAGE_AREAWIDTH;
long nWidth = (*mpImpl->mpItemList)[ nLastFirstPos ]->mnWidth; long nWidth = mpImpl->mpItemList[nLastFirstPos]->mnWidth;
while ( nLastFirstPos && (nWidth < nWinWidth) ) while ( nLastFirstPos && (nWidth < nWinWidth) )
{ {
nLastFirstPos--; nLastFirstPos--;
nWidth += (*mpImpl->mpItemList)[ nLastFirstPos ]->mnWidth; nWidth += mpImpl->mpItemList[nLastFirstPos]->mnWidth;
} }
if ( (nLastFirstPos != (sal_uInt16)(mpImpl->mpItemList->size()-1)) && if ( (nLastFirstPos != static_cast<sal_uInt16>(mpImpl->mpItemList.size() - 1)) && (nWidth > nWinWidth) )
(nWidth > nWinWidth) )
nLastFirstPos++; nLastFirstPos++;
return nLastFirstPos; return nLastFirstPos;
} }
...@@ -777,13 +784,13 @@ void TabBar::SetScrollAlwaysEnabled(bool bScrollAlwaysEnabled) ...@@ -777,13 +784,13 @@ void TabBar::SetScrollAlwaysEnabled(bool bScrollAlwaysEnabled)
void TabBar::ImplShowPage( sal_uInt16 nPos ) void TabBar::ImplShowPage( sal_uInt16 nPos )
{ {
if (nPos >= mpImpl->mpItemList->size()) if (nPos >= mpImpl->getItemSize())
return; return;
// calculate width // calculate width
long nWidth = GetOutputSizePixel().Width(); long nWidth = GetOutputSizePixel().Width();
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
if ( nPos < mnFirstPos ) if ( nPos < mnFirstPos )
SetFirstPageId( pItem->mnId ); SetFirstPageId( pItem->mnId );
else if ( pItem->maRect.Right() > nWidth ) else if ( pItem->maRect.Right() > nWidth )
...@@ -868,7 +875,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -868,7 +875,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt )
if ( (nSelId > 0) && (nSelId != mnCurPageId) ) if ( (nSelId > 0) && (nSelId != mnCurPageId) )
{ {
sal_uInt16 nPos = GetPagePos( nSelId ); sal_uInt16 nPos = GetPagePos( nSelId );
pItem = (*mpImpl->mpItemList)[ nPos ]; pItem = mpImpl->mpItemList[nPos];
if ( pItem->mbEnable ) if ( pItem->mbEnable )
{ {
...@@ -896,7 +903,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -896,7 +903,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt )
if ( nSelId ) if ( nSelId )
{ {
sal_uInt16 nPos = GetPagePos( nSelId ); sal_uInt16 nPos = GetPagePos( nSelId );
pItem = (*mpImpl->mpItemList)[ nPos ]; pItem = mpImpl->mpItemList[nPos];
if ( pItem->mbEnable ) if ( pItem->mbEnable )
{ {
...@@ -924,7 +931,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -924,7 +931,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt )
n = 0; n = 0;
while ( n < nCurPos ) while ( n < nCurPos )
{ {
pItem = (*mpImpl->mpItemList)[ n ]; pItem = mpImpl->mpItemList[n];
if ( n < nPos ) if ( n < nPos )
bSelect = false; bSelect = false;
else else
...@@ -946,11 +953,11 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -946,11 +953,11 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt )
// Select all tabs from the actual position till the clicked tab // Select all tabs from the actual position till the clicked tab
// and deselect all tabs from the actual position // and deselect all tabs from the actual position
// till the last tab // till the last tab
sal_uInt16 nCount = (sal_uInt16) mpImpl->mpItemList->size(); sal_uInt16 nCount = mpImpl->getItemSize();
n = nCurPos; n = nCurPos;
while ( n < nCount ) while ( n < nCount )
{ {
pItem = (*mpImpl->mpItemList)[ n ]; pItem = mpImpl->mpItemList[n];
if ( n <= nPos ) if ( n <= nPos )
bSelect = true; bSelect = true;
...@@ -1008,7 +1015,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -1008,7 +1015,7 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt )
if ( nSelId != mnCurPageId ) if ( nSelId != mnCurPageId )
{ {
sal_uInt16 nPos = GetPagePos( nSelId ); sal_uInt16 nPos = GetPagePos( nSelId );
pItem = (*mpImpl->mpItemList)[ nPos ]; pItem = mpImpl->mpItemList[nPos];
if ( pItem->mbEnable ) if ( pItem->mbEnable )
{ {
...@@ -1020,9 +1027,9 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt ) ...@@ -1020,9 +1027,9 @@ void TabBar::MouseButtonDown( const MouseEvent& rMEvt )
bUpdate = true; bUpdate = true;
// deselect all selected items // deselect all selected items
for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
{ {
pItem = (*mpImpl->mpItemList)[ i ]; pItem = mpImpl->mpItemList[i];
if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) ) if ( pItem->mbSelect || (pItem->mnId == mnCurPageId) )
{ {
pItem->mbSelect = false; pItem->mbSelect = false;
...@@ -1271,7 +1278,7 @@ void TabBar::Paint( const Rectangle& rect ) ...@@ -1271,7 +1278,7 @@ void TabBar::Paint( const Rectangle& rect )
ControlState::ENABLED,ImplControlValue(0),OUString()); ControlState::ENABLED,ImplControlValue(0),OUString());
// calculate items and emit // calculate items and emit
sal_uInt16 nItemCount = (sal_uInt16)mpImpl->mpItemList->size(); sal_uInt16 nItemCount = mpImpl->getItemSize();
if (!nItemCount) if (!nItemCount)
return; return;
...@@ -1548,7 +1555,7 @@ void TabBar::RequestHelp( const HelpEvent& rHEvt ) ...@@ -1548,7 +1555,7 @@ void TabBar::RequestHelp( const HelpEvent& rHEvt )
if ( rHEvt.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON) ) if ( rHEvt.GetMode() & (HelpEventMode::QUICK | HelpEventMode::BALLOON) )
{ {
sal_uInt16 nPos = GetPagePos( nItemId ); sal_uInt16 nPos = GetPagePos( nItemId );
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
if ( pItem->mbShort || (pItem->maRect.Right() - 5 > mnLastOffX) ) if ( pItem->mbShort || (pItem->maRect.Right() - 5 > mnLastOffX) )
{ {
Rectangle aItemRect = GetPageRect( nItemId ); Rectangle aItemRect = GetPageRect( nItemId );
...@@ -1558,7 +1565,7 @@ void TabBar::RequestHelp( const HelpEvent& rHEvt ) ...@@ -1558,7 +1565,7 @@ void TabBar::RequestHelp( const HelpEvent& rHEvt )
aPt = OutputToScreenPixel( aItemRect.BottomRight() ); aPt = OutputToScreenPixel( aItemRect.BottomRight() );
aItemRect.Right() = aPt.X(); aItemRect.Right() = aPt.X();
aItemRect.Bottom() = aPt.Y(); aItemRect.Bottom() = aPt.Y();
OUString aStr = (*mpImpl->mpItemList)[ nPos ]->maText; OUString aStr = mpImpl->mpItemList[nPos]->maText;
if (!aStr.isEmpty()) if (!aStr.isEmpty())
{ {
if ( rHEvt.GetMode() & HelpEventMode::BALLOON ) if ( rHEvt.GetMode() & HelpEventMode::BALLOON )
...@@ -1582,7 +1589,7 @@ void TabBar::StateChanged( StateChangedType nType ) ...@@ -1582,7 +1589,7 @@ void TabBar::StateChanged( StateChangedType nType )
if ( nType == StateChangedType::INITSHOW ) if ( nType == StateChangedType::INITSHOW )
{ {
if ( (mbSizeFormat || mbFormat) && !mpImpl->mpItemList->empty() ) if ( (mbSizeFormat || mbFormat) && !mpImpl->mpItemList.empty() )
ImplFormat(); ImplFormat();
} }
else if ( (nType == StateChangedType::ZOOM) || else if ( (nType == StateChangedType::ZOOM) ||
...@@ -1689,7 +1696,7 @@ bool TabBar::ImplDeactivatePage() ...@@ -1689,7 +1696,7 @@ bool TabBar::ImplDeactivatePage()
void TabBar::ImplPrePaint() void TabBar::ImplPrePaint()
{ {
sal_uInt16 nItemCount = (sal_uInt16) mpImpl->mpItemList->size(); sal_uInt16 nItemCount = mpImpl->getItemSize();
if (!nItemCount) if (!nItemCount)
return; return;
...@@ -1704,7 +1711,7 @@ void TabBar::ImplPrePaint() ...@@ -1704,7 +1711,7 @@ void TabBar::ImplPrePaint()
if ( mnCurPageId && (mnFirstPos == 0) && !mbDropPos ) if ( mnCurPageId && (mnFirstPos == 0) && !mbDropPos )
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ GetPagePos( mnCurPageId ) ]; ImplTabBarItem* pItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)];
if ( pItem->maRect.IsEmpty() ) if ( pItem->maRect.IsEmpty() )
{ {
// set mbDropPos (or misuse) to prevent Invalidate() // set mbDropPos (or misuse) to prevent Invalidate()
...@@ -1808,12 +1815,15 @@ void TabBar::InsertPage( sal_uInt16 nPageId, const OUString& rText, ...@@ -1808,12 +1815,15 @@ void TabBar::InsertPage( sal_uInt16 nPageId, const OUString& rText,
// create PageItem and insert in the item list // create PageItem and insert in the item list
ImplTabBarItem* pItem = new ImplTabBarItem( nPageId, rText, nBits ); ImplTabBarItem* pItem = new ImplTabBarItem( nPageId, rText, nBits );
if ( nPos < mpImpl->mpItemList->size() ) { if (nPos < mpImpl->mpItemList.size())
ImplTabBarList::iterator it = mpImpl->mpItemList->begin(); {
std::advance( it, nPos ); ImplTabBarList::iterator it = mpImpl->mpItemList.begin();
mpImpl->mpItemList->insert( it, pItem ); std::advance(it, nPos);
} else { mpImpl->mpItemList.insert(it, pItem);
mpImpl->mpItemList->push_back( pItem ); }
else
{
mpImpl->mpItemList.push_back(pItem);
} }
mbSizeFormat = true; mbSizeFormat = true;
...@@ -1835,7 +1845,7 @@ Color TabBar::GetTabBgColor( sal_uInt16 nPageId ) const ...@@ -1835,7 +1845,7 @@ Color TabBar::GetTabBgColor( sal_uInt16 nPageId ) const
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
return (*mpImpl->mpItemList)[ nPos ]->maTabBgColor; return mpImpl->mpItemList[nPos]->maTabBgColor;
else else
return Color( COL_AUTO ); return Color( COL_AUTO );
} }
...@@ -1845,7 +1855,7 @@ void TabBar::SetTabBgColor( sal_uInt16 nPageId, const Color& aTabBgColor ) ...@@ -1845,7 +1855,7 @@ void TabBar::SetTabBgColor( sal_uInt16 nPageId, const Color& aTabBgColor )
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
if ( aTabBgColor != Color( COL_AUTO ) ) if ( aTabBgColor != Color( COL_AUTO ) )
{ {
pItem->maTabBgColor = aTabBgColor; pItem->maTabBgColor = aTabBgColor;
...@@ -1879,10 +1889,10 @@ void TabBar::RemovePage( sal_uInt16 nPageId ) ...@@ -1879,10 +1889,10 @@ void TabBar::RemovePage( sal_uInt16 nPageId )
mnFirstPos--; mnFirstPos--;
// delete item data // delete item data
ImplTabBarList::iterator it = mpImpl->mpItemList->begin(); ImplTabBarList::iterator it = mpImpl->mpItemList.begin();
std::advance( it, nPos ); std::advance(it, nPos);
delete *it; delete *it;
mpImpl->mpItemList->erase( it ); mpImpl->mpItemList.erase(it);
// redraw bar // redraw bar
if ( IsReallyVisible() && IsUpdateMode() ) if ( IsReallyVisible() && IsUpdateMode() )
...@@ -1909,16 +1919,17 @@ void TabBar::MovePage( sal_uInt16 nPageId, sal_uInt16 nNewPos ) ...@@ -1909,16 +1919,17 @@ void TabBar::MovePage( sal_uInt16 nPageId, sal_uInt16 nNewPos )
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
{ {
// move tabbar item in the list // move tabbar item in the list
ImplTabBarList::iterator it = mpImpl->mpItemList->begin(); ImplTabBarList::iterator it = mpImpl->mpItemList.begin();
std::advance( it, nPos ); std::advance(it, nPos);
ImplTabBarItem* pItem = *it; ImplTabBarItem* pItem = *it;
mpImpl->mpItemList->erase( it ); mpImpl->mpItemList.erase(it);
if ( nNewPos < mpImpl->mpItemList->size() ) { if (nNewPos < mpImpl->mpItemList.size())
it = mpImpl->mpItemList->begin(); {
std::advance( it, nNewPos ); it = mpImpl->mpItemList.begin();
mpImpl->mpItemList->insert( it, pItem ); std::advance(it, nNewPos);
mpImpl->mpItemList.insert(it, pItem);
} else { } else {
mpImpl->mpItemList->push_back( pItem ); mpImpl->mpItemList.push_back(pItem);
} }
// redraw bar // redraw bar
...@@ -1934,10 +1945,11 @@ void TabBar::MovePage( sal_uInt16 nPageId, sal_uInt16 nNewPos ) ...@@ -1934,10 +1945,11 @@ void TabBar::MovePage( sal_uInt16 nPageId, sal_uInt16 nNewPos )
void TabBar::Clear() void TabBar::Clear()
{ {
// delete all items // delete all items
for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) { for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
delete (*mpImpl->mpItemList)[ i ]; {
delete mpImpl->mpItemList[i];
} }
mpImpl->mpItemList->clear(); mpImpl->mpItemList.clear();
// remove items from the list // remove items from the list
mbSizeFormat = true; mbSizeFormat = true;
...@@ -1959,7 +1971,7 @@ bool TabBar::IsPageEnabled( sal_uInt16 nPageId ) const ...@@ -1959,7 +1971,7 @@ bool TabBar::IsPageEnabled( sal_uInt16 nPageId ) const
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
return (*mpImpl->mpItemList)[ nPos ]->mbEnable; return mpImpl->mpItemList[nPos]->mbEnable;
else else
return false; return false;
} }
...@@ -1972,7 +1984,7 @@ void TabBar::SetPageBits( sal_uInt16 nPageId, TabBarPageBits nBits ) ...@@ -1972,7 +1984,7 @@ void TabBar::SetPageBits( sal_uInt16 nPageId, TabBarPageBits nBits )
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
if ( pItem->mnBits != nBits ) if ( pItem->mnBits != nBits )
{ {
...@@ -1992,7 +2004,7 @@ TabBarPageBits TabBar::GetPageBits( sal_uInt16 nPageId ) const ...@@ -1992,7 +2004,7 @@ TabBarPageBits TabBar::GetPageBits( sal_uInt16 nPageId ) const
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
return (*mpImpl->mpItemList)[ nPos ]->mnBits; return mpImpl->mpItemList[nPos]->mnBits;
else else
return sal_False; return sal_False;
} }
...@@ -2001,23 +2013,24 @@ TabBarPageBits TabBar::GetPageBits( sal_uInt16 nPageId ) const ...@@ -2001,23 +2013,24 @@ TabBarPageBits TabBar::GetPageBits( sal_uInt16 nPageId ) const
sal_uInt16 TabBar::GetPageCount() const sal_uInt16 TabBar::GetPageCount() const
{ {
return (sal_uInt16) mpImpl->mpItemList->size(); return mpImpl->getItemSize();
} }
sal_uInt16 TabBar::GetPageId( sal_uInt16 nPos ) const sal_uInt16 TabBar::GetPageId( sal_uInt16 nPos ) const
{ {
return ( nPos < mpImpl->mpItemList->size() ) ? (*mpImpl->mpItemList)[ nPos ]->mnId : 0; return nPos < mpImpl->mpItemList.size() ? mpImpl->mpItemList[nPos]->mnId : 0;
} }
sal_uInt16 TabBar::GetPagePos( sal_uInt16 nPageId ) const sal_uInt16 TabBar::GetPagePos( sal_uInt16 nPageId ) const
{ {
for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) { for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
if ( (*mpImpl->mpItemList)[ i ]->mnId == nPageId ) { {
return sal_uInt16( i ); if (mpImpl->mpItemList[i]->mnId == nPageId) {
return static_cast<sal_uInt16>(i);
} }
} }
return PAGE_NOT_FOUND; return PAGE_NOT_FOUND;
...@@ -2027,16 +2040,16 @@ sal_uInt16 TabBar::GetPagePos( sal_uInt16 nPageId ) const ...@@ -2027,16 +2040,16 @@ sal_uInt16 TabBar::GetPagePos( sal_uInt16 nPageId ) const
sal_uInt16 TabBar::GetPageId( const Point& rPos, bool bCheckInsTab ) const sal_uInt16 TabBar::GetPageId( const Point& rPos, bool bCheckInsTab ) const
{ {
for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ i ]; ImplTabBarItem* pItem = mpImpl->mpItemList[i];
if ( pItem->maRect.IsInside( rPos ) ) if (pItem->maRect.IsInside(rPos))
return pItem->mnId; return pItem->mnId;
} }
if (bCheckInsTab && mbHasInsertTab && !mpImpl->mpItemList->empty()) if (bCheckInsTab && mbHasInsertTab && !mpImpl->mpItemList.empty())
{ {
ImplTabBarItem* pItem = mpImpl->mpItemList->back(); ImplTabBarItem* pItem = mpImpl->mpItemList.back();
if (ImplGetInsertTabRect(pItem).IsInside(rPos)) if (ImplGetInsertTabRect(pItem).IsInside(rPos))
return INSERT_TAB_POS; return INSERT_TAB_POS;
} }
...@@ -2051,7 +2064,7 @@ Rectangle TabBar::GetPageRect( sal_uInt16 nPageId ) const ...@@ -2051,7 +2064,7 @@ Rectangle TabBar::GetPageRect( sal_uInt16 nPageId ) const
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
return (*mpImpl->mpItemList)[ nPos ]->maRect; return mpImpl->mpItemList[nPos]->maRect;
else else
return Rectangle(); return Rectangle();
} }
...@@ -2074,11 +2087,11 @@ void TabBar::SetCurPageId( sal_uInt16 nPageId ) ...@@ -2074,11 +2087,11 @@ void TabBar::SetCurPageId( sal_uInt16 nPageId )
if ( IsReallyVisible() && IsUpdateMode() ) if ( IsReallyVisible() && IsUpdateMode() )
bUpdate = true; bUpdate = true;
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
ImplTabBarItem* pOldItem; ImplTabBarItem* pOldItem;
if ( mnCurPageId ) if ( mnCurPageId )
pOldItem = (*mpImpl->mpItemList)[ GetPagePos( mnCurPageId ) ]; pOldItem = mpImpl->mpItemList[GetPagePos(mnCurPageId)];
else else
pOldItem = NULL; pOldItem = NULL;
...@@ -2156,7 +2169,7 @@ void TabBar::MakeVisible( sal_uInt16 nPageId ) ...@@ -2156,7 +2169,7 @@ void TabBar::MakeVisible( sal_uInt16 nPageId )
SetFirstPageId( nPageId ); SetFirstPageId( nPageId );
else else
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
// calculate visible area // calculate visible area
long nWidth = mnLastOffX; long nWidth = mnLastOffX;
...@@ -2230,7 +2243,7 @@ void TabBar::SelectPage( sal_uInt16 nPageId, bool bSelect ) ...@@ -2230,7 +2243,7 @@ void TabBar::SelectPage( sal_uInt16 nPageId, bool bSelect )
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
if ( pItem->mbSelect != bSelect ) if ( pItem->mbSelect != bSelect )
{ {
...@@ -2248,10 +2261,10 @@ void TabBar::SelectPage( sal_uInt16 nPageId, bool bSelect ) ...@@ -2248,10 +2261,10 @@ void TabBar::SelectPage( sal_uInt16 nPageId, bool bSelect )
sal_uInt16 TabBar::GetSelectPageCount() const sal_uInt16 TabBar::GetSelectPageCount() const
{ {
sal_uInt16 nSelected = 0; sal_uInt16 nSelected = 0;
for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ i ]; ImplTabBarItem* pItem = mpImpl->mpItemList[i];
if ( pItem->mbSelect ) if (pItem->mbSelect)
nSelected++; nSelected++;
} }
...@@ -2264,7 +2277,7 @@ bool TabBar::IsPageSelected( sal_uInt16 nPageId ) const ...@@ -2264,7 +2277,7 @@ bool TabBar::IsPageSelected( sal_uInt16 nPageId ) const
{ {
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
return (*mpImpl->mpItemList)[ nPos ]->mbSelect; return mpImpl->mpItemList[nPos]->mbSelect;
else else
return false; return false;
} }
...@@ -2427,7 +2440,7 @@ void TabBar::SetPageText( sal_uInt16 nPageId, const OUString& rText ) ...@@ -2427,7 +2440,7 @@ void TabBar::SetPageText( sal_uInt16 nPageId, const OUString& rText )
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
{ {
(*mpImpl->mpItemList)[ nPos ]->maText = rText; mpImpl->mpItemList[nPos]->maText = rText;
mbSizeFormat = true; mbSizeFormat = true;
// redraw bar // redraw bar
...@@ -2444,7 +2457,7 @@ OUString TabBar::GetPageText( sal_uInt16 nPageId ) const ...@@ -2444,7 +2457,7 @@ OUString TabBar::GetPageText( sal_uInt16 nPageId ) const
{ {
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
return (*mpImpl->mpItemList)[ nPos ]->maText; return mpImpl->mpItemList[nPos]->maText;
return OUString(); return OUString();
} }
...@@ -2455,7 +2468,7 @@ OUString TabBar::GetHelpText( sal_uInt16 nPageId ) const ...@@ -2455,7 +2468,7 @@ OUString TabBar::GetHelpText( sal_uInt16 nPageId ) const
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ nPos ]; ImplTabBarItem* pItem = mpImpl->mpItemList[nPos];
if (pItem->maHelpText.isEmpty() && !pItem->maHelpId.isEmpty()) if (pItem->maHelpText.isEmpty() && !pItem->maHelpId.isEmpty())
{ {
Help* pHelp = Application::GetHelp(); Help* pHelp = Application::GetHelp();
...@@ -2475,7 +2488,7 @@ OString TabBar::GetHelpId( sal_uInt16 nPageId ) const ...@@ -2475,7 +2488,7 @@ OString TabBar::GetHelpId( sal_uInt16 nPageId ) const
sal_uInt16 nPos = GetPagePos( nPageId ); sal_uInt16 nPos = GetPagePos( nPageId );
OString aRet; OString aRet;
if ( nPos != PAGE_NOT_FOUND ) if ( nPos != PAGE_NOT_FOUND )
return (*mpImpl->mpItemList)[ nPos ]->maHelpId; return mpImpl->mpItemList[nPos]->maHelpId;
return aRet; return aRet;
} }
...@@ -2531,14 +2544,14 @@ sal_uInt16 TabBar::ShowDropPos( const Point& rPos ) ...@@ -2531,14 +2544,14 @@ sal_uInt16 TabBar::ShowDropPos( const Point& rPos )
ImplTabBarItem* pItem; ImplTabBarItem* pItem;
sal_uInt16 nDropId; sal_uInt16 nDropId;
sal_uInt16 nNewDropPos; sal_uInt16 nNewDropPos;
sal_uInt16 nItemCount = (sal_uInt16) mpImpl->mpItemList->size(); sal_uInt16 nItemCount = mpImpl->getItemSize();
short nScroll = 0; short nScroll = 0;
if ( rPos.X() > mnLastOffX-TABBAR_DRAG_SCROLLOFF ) if ( rPos.X() > mnLastOffX-TABBAR_DRAG_SCROLLOFF )
{ {
pItem = (*mpImpl->mpItemList)[ mpImpl->mpItemList->size()-1 ]; pItem = mpImpl->mpItemList[mpImpl->mpItemList.size() - 1];
if ( !pItem->maRect.IsEmpty() && (rPos.X() > pItem->maRect.Right()) ) if ( !pItem->maRect.IsEmpty() && (rPos.X() > pItem->maRect.Right()) )
nNewDropPos = (sal_uInt16) mpImpl->mpItemList->size(); nNewDropPos = mpImpl->getItemSize();
else else
{ {
nNewDropPos = mnFirstPos+1; nNewDropPos = mnFirstPos+1;
...@@ -2605,7 +2618,7 @@ sal_uInt16 TabBar::ShowDropPos( const Point& rPos ) ...@@ -2605,7 +2618,7 @@ sal_uInt16 TabBar::ShowDropPos( const Point& rPos )
SetLineColor(aBlackColor); SetLineColor(aBlackColor);
SetFillColor(aBlackColor); SetFillColor(aBlackColor);
pItem = (*mpImpl->mpItemList)[ mnDropPos ]; pItem = mpImpl->mpItemList[mnDropPos];
nX = pItem->maRect.Left(); nX = pItem->maRect.Left();
if ( mnDropPos == nCurPos ) if ( mnDropPos == nCurPos )
nX--; nX--;
...@@ -2628,7 +2641,7 @@ sal_uInt16 TabBar::ShowDropPos( const Point& rPos ) ...@@ -2628,7 +2641,7 @@ sal_uInt16 TabBar::ShowDropPos( const Point& rPos )
SetLineColor(aBlackColor); SetLineColor(aBlackColor);
SetFillColor(aBlackColor); SetFillColor(aBlackColor);
pItem = (*mpImpl->mpItemList)[ mnDropPos-1 ]; pItem = mpImpl->mpItemList[mnDropPos - 1];
nX = pItem->maRect.Right(); nX = pItem->maRect.Right();
if ( mnDropPos == nCurPos ) if ( mnDropPos == nCurPos )
nX++; nX++;
...@@ -2657,11 +2670,11 @@ void TabBar::HideDropPos() ...@@ -2657,11 +2670,11 @@ void TabBar::HideDropPos()
long nX; long nX;
long nY1 = (maWinSize.Height()/2)-3; long nY1 = (maWinSize.Height()/2)-3;
long nY2 = nY1 + 5; long nY2 = nY1 + 5;
sal_uInt16 nItemCount = (sal_uInt16) mpImpl->mpItemList->size(); sal_uInt16 nItemCount = mpImpl->getItemSize();
if ( mnDropPos < nItemCount ) if ( mnDropPos < nItemCount )
{ {
pItem = (*mpImpl->mpItemList)[ mnDropPos ]; pItem = mpImpl->mpItemList[mnDropPos];
nX = pItem->maRect.Left(); nX = pItem->maRect.Left();
// immediately call Paint, as it is not possible during drag and drop // immediately call Paint, as it is not possible during drag and drop
Rectangle aRect( nX-1, nY1, nX+3, nY2 ); Rectangle aRect( nX-1, nY1, nX+3, nY2 );
...@@ -2672,7 +2685,7 @@ void TabBar::HideDropPos() ...@@ -2672,7 +2685,7 @@ void TabBar::HideDropPos()
} }
if ( (mnDropPos > 0) && (mnDropPos < nItemCount+1) ) if ( (mnDropPos > 0) && (mnDropPos < nItemCount+1) )
{ {
pItem = (*mpImpl->mpItemList)[ mnDropPos-1 ]; pItem = mpImpl->mpItemList[mnDropPos - 1];
nX = pItem->maRect.Right(); nX = pItem->maRect.Right();
// immediately call Paint, as it is not possible during drag and drop // immediately call Paint, as it is not possible during drag and drop
Rectangle aRect( nX-2, nY1, nX+1, nY2 ); Rectangle aRect( nX-2, nY1, nX+1, nY2 );
...@@ -2752,12 +2765,12 @@ Size TabBar::CalcWindowSizePixel() const ...@@ -2752,12 +2765,12 @@ Size TabBar::CalcWindowSizePixel() const
{ {
long nWidth = 0; long nWidth = 0;
if ( mpImpl->mpItemList->size() ) if (mpImpl->mpItemList.size() > 0)
{ {
((TabBar*)this)->ImplCalcWidth(); ((TabBar*)this)->ImplCalcWidth();
for ( size_t i = 0, n = mpImpl->mpItemList->size(); i < n; ++i ) for (size_t i = 0; i < mpImpl->mpItemList.size(); ++i)
{ {
ImplTabBarItem* pItem = (*mpImpl->mpItemList)[ i ]; ImplTabBarItem* pItem = mpImpl->mpItemList[i];
nWidth += pItem->mnWidth; nWidth += pItem->mnWidth;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment