Kaydet (Commit) 5c829a7d authored tarafından Noel Grandin's avatar Noel Grandin

inline SvxIconChoiceCtrlEntryList_impl typedef

and simplify usage in SvxIconChoiceCtrl_Impl

Change-Id: If72d14be66cdf3135ad4edf5502a478a0857d7dd
Reviewed-on: https://gerrit.libreoffice.org/60951
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst e6852093
...@@ -100,12 +100,10 @@ struct LocalFocus ...@@ -100,12 +100,10 @@ struct LocalFocus
// Entry-List // Entry-List
typedef ::std::vector< SvxIconChoiceCtrlEntry* > SvxIconChoiceCtrlEntryList_impl;
class EntryList_Impl class EntryList_Impl
{ {
private: private:
SvxIconChoiceCtrlEntryList_impl maIconChoiceCtrlEntryList; std::vector< SvxIconChoiceCtrlEntry* > maIconChoiceCtrlEntryList;
SvxIconChoiceCtrl_Impl* _pOwner; SvxIconChoiceCtrl_Impl* _pOwner;
public: public:
...@@ -172,7 +170,7 @@ class SvxIconChoiceCtrl_Impl ...@@ -172,7 +170,7 @@ class SvxIconChoiceCtrl_Impl
std::unique_ptr<IcnGridMap_Impl> pGridMap; std::unique_ptr<IcnGridMap_Impl> pGridMap;
long nMaxVirtWidth; // max. width aVirtOutputSize for ALIGN_TOP long nMaxVirtWidth; // max. width aVirtOutputSize for ALIGN_TOP
long nMaxVirtHeight; // max. height aVirtOutputSize for ALIGN_LEFT long nMaxVirtHeight; // max. height aVirtOutputSize for ALIGN_LEFT
std::unique_ptr<SvxIconChoiceCtrlEntryList_impl> pZOrderList; std::vector< SvxIconChoiceCtrlEntry* > maZOrderList;
std::unique_ptr<SvxIconChoiceCtrlColumnInfoMap> m_pColumns; std::unique_ptr<SvxIconChoiceCtrlColumnInfoMap> m_pColumns;
VclPtr<IcnViewEdit_Impl> pEdit; VclPtr<IcnViewEdit_Impl> pEdit;
WinBits nWinBits; WinBits nWinBits;
......
...@@ -115,7 +115,6 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl( ...@@ -115,7 +115,6 @@ SvxIconChoiceCtrl_Impl::SvxIconChoiceCtrl_Impl(
bHighlightFramePressed = false; bHighlightFramePressed = false;
eSelectionMode = SelectionMode::Multiple; eSelectionMode = SelectionMode::Multiple;
pView = pCurView; pView = pCurView;
pZOrderList.reset( new SvxIconChoiceCtrlEntryList_impl );
ePositionMode = SvxIconChoiceCtrlPositionMode::Free; ePositionMode = SvxIconChoiceCtrlPositionMode::Free;
SetStyle( nWinStyle ); SetStyle( nWinStyle );
nFlags = IconChoiceFlags::NONE; nFlags = IconChoiceFlags::NONE;
...@@ -172,7 +171,6 @@ SvxIconChoiceCtrl_Impl::~SvxIconChoiceCtrl_Impl() ...@@ -172,7 +171,6 @@ SvxIconChoiceCtrl_Impl::~SvxIconChoiceCtrl_Impl()
Clear(false); Clear(false);
StopEditTimer(); StopEditTimer();
CancelUserEvents(); CancelUserEvents();
pZOrderList.reset();
pImpCursor.reset(); pImpCursor.reset();
pGridMap.reset(); pGridMap.reset();
pDDDev.disposeAndClear(); pDDDev.disposeAndClear();
...@@ -211,7 +209,7 @@ void SvxIconChoiceCtrl_Impl::Clear( bool bInCtor ) ...@@ -211,7 +209,7 @@ void SvxIconChoiceCtrl_Impl::Clear( bool bInCtor )
nMaxVirtHeight = aSize.Height() - nHorSBarHeight; nMaxVirtHeight = aSize.Height() - nHorSBarHeight;
if( nMaxVirtHeight <= 0 ) if( nMaxVirtHeight <= 0 )
nMaxVirtHeight = DEFAULT_MAX_VIRT_HEIGHT; nMaxVirtHeight = DEFAULT_MAX_VIRT_HEIGHT;
pZOrderList->clear(); maZOrderList.clear();
SetOrigin( Point() ); SetOrigin( Point() );
if( bUpdateMode ) if( bUpdateMode )
pView->Invalidate(InvalidateFlags::NoChildren); pView->Invalidate(InvalidateFlags::NoChildren);
...@@ -282,7 +280,7 @@ void SvxIconChoiceCtrl_Impl::InsertEntry( SvxIconChoiceCtrlEntry* pEntry, size_t ...@@ -282,7 +280,7 @@ void SvxIconChoiceCtrl_Impl::InsertEntry( SvxIconChoiceCtrlEntry* pEntry, size_t
else else
nFlags &= ~IconChoiceFlags::EntryListPosValid; nFlags &= ~IconChoiceFlags::EntryListPosValid;
pZOrderList->push_back( pEntry ); maZOrderList.push_back( pEntry );
pImpCursor->Clear(); pImpCursor->Clear();
// If the UpdateMode is true, don't set all bounding rectangles to // If the UpdateMode is true, don't set all bounding rectangles to
...@@ -650,55 +648,49 @@ void SvxIconChoiceCtrl_Impl::Paint(vcl::RenderContext& rRenderContext, const too ...@@ -650,55 +648,49 @@ void SvxIconChoiceCtrl_Impl::Paint(vcl::RenderContext& rRenderContext, const too
pCursor = aEntries[ 0 ]; pCursor = aEntries[ 0 ];
} }
size_t nCount = pZOrderList->size(); size_t nCount = maZOrderList.size();
if (!nCount) if (!nCount)
return; return;
rRenderContext.Push(PushFlags::CLIPREGION); rRenderContext.Push(PushFlags::CLIPREGION);
rRenderContext.SetClipRegion(vcl::Region(rRect)); rRenderContext.SetClipRegion(vcl::Region(rRect));
std::unique_ptr<SvxIconChoiceCtrlEntryList_impl> pNewZOrderList( new SvxIconChoiceCtrlEntryList_impl ); std::vector< SvxIconChoiceCtrlEntry* > aNewZOrderList;
std::unique_ptr<SvxIconChoiceCtrlEntryList_impl> pPaintedEntries(new SvxIconChoiceCtrlEntryList_impl); std::vector< SvxIconChoiceCtrlEntry* > aPaintedEntries;
size_t nPos = 0; size_t nPos = 0;
while(nCount) while(nCount)
{ {
SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[nPos]; SvxIconChoiceCtrlEntry* pEntry = maZOrderList[nPos];
const tools::Rectangle& rBoundRect = GetEntryBoundRect(pEntry); const tools::Rectangle& rBoundRect = GetEntryBoundRect(pEntry);
if (rRect.IsOver(rBoundRect)) if (rRect.IsOver(rBoundRect))
{ {
PaintEntry(pEntry, rBoundRect.TopLeft(), rRenderContext); PaintEntry(pEntry, rBoundRect.TopLeft(), rRenderContext);
// set entries to Top if they are being repainted // set entries to Top if they are being repainted
pPaintedEntries->push_back(pEntry); aPaintedEntries.push_back(pEntry);
} }
else else
pNewZOrderList->push_back(pEntry); aNewZOrderList.push_back(pEntry);
nCount--; nCount--;
nPos++; nPos++;
} }
pZOrderList = std::move( pNewZOrderList ); maZOrderList = std::move( aNewZOrderList );
nCount = pPaintedEntries->size(); maZOrderList.insert(maZOrderList.end(), aPaintedEntries.begin(), aPaintedEntries.end());
if (nCount)
{
for (size_t nCur = 0; nCur < nCount; nCur++)
pZOrderList->push_back((*pPaintedEntries)[nCur]);
}
pPaintedEntries.reset();
rRenderContext.Pop(); rRenderContext.Pop();
} }
void SvxIconChoiceCtrl_Impl::RepaintSelectedEntries() void SvxIconChoiceCtrl_Impl::RepaintSelectedEntries()
{ {
const size_t nCount = pZOrderList->size(); const size_t nCount = maZOrderList.size();
if (!nCount) if (!nCount)
return; return;
tools::Rectangle aOutRect(GetOutputRect()); tools::Rectangle aOutRect(GetOutputRect());
for (size_t nCur = 0; nCur < nCount; nCur++) for (size_t nCur = 0; nCur < nCount; nCur++)
{ {
SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[nCur]; SvxIconChoiceCtrlEntry* pEntry = maZOrderList[nCur];
if (pEntry->GetFlags() & SvxIconViewFlags::SELECTED) if (pEntry->GetFlags() & SvxIconViewFlags::SELECTED)
{ {
const tools::Rectangle& rBoundRect = GetEntryBoundRect(pEntry); const tools::Rectangle& rBoundRect = GetEntryBoundRect(pEntry);
...@@ -1377,18 +1369,18 @@ void SvxIconChoiceCtrl_Impl::Resize() ...@@ -1377,18 +1369,18 @@ void SvxIconChoiceCtrl_Impl::Resize()
bool SvxIconChoiceCtrl_Impl::CheckHorScrollBar() bool SvxIconChoiceCtrl_Impl::CheckHorScrollBar()
{ {
if( !pZOrderList || !aHorSBar->IsVisible() ) if( maZOrderList.empty() || !aHorSBar->IsVisible() )
return false; return false;
const MapMode& rMapMode = pView->GetMapMode(); const MapMode& rMapMode = pView->GetMapMode();
Point aOrigin( rMapMode.GetOrigin() ); Point aOrigin( rMapMode.GetOrigin() );
if(!( nWinBits & WB_HSCROLL) && !aOrigin.X() ) if(!( nWinBits & WB_HSCROLL) && !aOrigin.X() )
{ {
long nWidth = aOutputSize.Width(); long nWidth = aOutputSize.Width();
const size_t nCount = pZOrderList->size(); const size_t nCount = maZOrderList.size();
long nMostRight = 0; long nMostRight = 0;
for( size_t nCur = 0; nCur < nCount; nCur++ ) for( size_t nCur = 0; nCur < nCount; nCur++ )
{ {
SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nCur ]; SvxIconChoiceCtrlEntry* pEntry = maZOrderList[ nCur ];
long nRight = GetEntryBoundRect(pEntry).Right(); long nRight = GetEntryBoundRect(pEntry).Right();
if( nRight > nWidth ) if( nRight > nWidth )
return false; return false;
...@@ -1415,7 +1407,7 @@ bool SvxIconChoiceCtrl_Impl::CheckHorScrollBar() ...@@ -1415,7 +1407,7 @@ bool SvxIconChoiceCtrl_Impl::CheckHorScrollBar()
bool SvxIconChoiceCtrl_Impl::CheckVerScrollBar() bool SvxIconChoiceCtrl_Impl::CheckVerScrollBar()
{ {
if( !pZOrderList || !aVerSBar->IsVisible() ) if( maZOrderList.empty() || !aVerSBar->IsVisible() )
return false; return false;
const MapMode& rMapMode = pView->GetMapMode(); const MapMode& rMapMode = pView->GetMapMode();
Point aOrigin( rMapMode.GetOrigin() ); Point aOrigin( rMapMode.GetOrigin() );
...@@ -1423,10 +1415,10 @@ bool SvxIconChoiceCtrl_Impl::CheckVerScrollBar() ...@@ -1423,10 +1415,10 @@ bool SvxIconChoiceCtrl_Impl::CheckVerScrollBar()
{ {
long nDeepest = 0; long nDeepest = 0;
long nHeight = aOutputSize.Height(); long nHeight = aOutputSize.Height();
const size_t nCount = pZOrderList->size(); const size_t nCount = maZOrderList.size();
for( size_t nCur = 0; nCur < nCount; nCur++ ) for( size_t nCur = 0; nCur < nCount; nCur++ )
{ {
SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nCur ]; SvxIconChoiceCtrlEntry* pEntry = maZOrderList[ nCur ];
long nBottom = GetEntryBoundRect(pEntry).Bottom(); long nBottom = GetEntryBoundRect(pEntry).Bottom();
if( nBottom > nHeight ) if( nBottom > nHeight )
return false; return false;
...@@ -1710,11 +1702,11 @@ SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetEntry( const Point& rDocPos, ...@@ -1710,11 +1702,11 @@ SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetEntry( const Point& rDocPos,
{ {
CheckBoundingRects(); CheckBoundingRects();
// search through z-order list from the end // search through z-order list from the end
size_t nCount = pZOrderList->size(); size_t nCount = maZOrderList.size();
while( nCount ) while( nCount )
{ {
nCount--; nCount--;
SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nCount ]; SvxIconChoiceCtrlEntry* pEntry = maZOrderList[ nCount ];
if( pEntry->aRect.IsInside( rDocPos ) ) if( pEntry->aRect.IsInside( rDocPos ) )
{ {
if( bHit ) if( bHit )
...@@ -1906,7 +1898,7 @@ Size SvxIconChoiceCtrl_Impl::CalcBoundingSize() const ...@@ -1906,7 +1898,7 @@ Size SvxIconChoiceCtrl_Impl::CalcBoundingSize() const
void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart() void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart()
{ {
nMaxBoundHeight = 0; nMaxBoundHeight = 0;
pZOrderList->clear(); maZOrderList.clear();
size_t nCur; size_t nCur;
SvxIconChoiceCtrlEntry* pEntry; SvxIconChoiceCtrlEntry* pEntry;
const size_t nCount = aEntries.size(); const size_t nCount = aEntries.size();
...@@ -1924,7 +1916,7 @@ void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart() ...@@ -1924,7 +1916,7 @@ void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart()
} }
else else
FindBoundingRect( pEntry ); FindBoundingRect( pEntry );
pZOrderList->push_back( pEntry ); maZOrderList.push_back( pEntry );
} }
} }
else else
...@@ -1942,7 +1934,7 @@ void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart() ...@@ -1942,7 +1934,7 @@ void SvxIconChoiceCtrl_Impl::RecalcAllBoundingRectsSmart()
} }
else else
FindBoundingRect( pEntry ); FindBoundingRect( pEntry );
pZOrderList->push_back( pEntry ); maZOrderList.push_back( pEntry );
pEntry = pEntry->pflink; pEntry = pEntry->pflink;
nCur++; nCur++;
} }
...@@ -2121,19 +2113,16 @@ void SvxIconChoiceCtrl_Impl::Command( const CommandEvent& rCEvt ) ...@@ -2121,19 +2113,16 @@ void SvxIconChoiceCtrl_Impl::Command( const CommandEvent& rCEvt )
void SvxIconChoiceCtrl_Impl::ToTop( SvxIconChoiceCtrlEntry* pEntry ) void SvxIconChoiceCtrl_Impl::ToTop( SvxIconChoiceCtrlEntry* pEntry )
{ {
if( !(!pZOrderList->empty() if( !(!maZOrderList.empty()
&& pEntry != pZOrderList->back()) && pEntry != maZOrderList.back()))
) return; return;
for( for( auto it = maZOrderList.begin(); it != maZOrderList.end(); ++it)
SvxIconChoiceCtrlEntryList_impl::iterator it = pZOrderList->begin(); {
it != pZOrderList->end();
++it
) {
if ( *it == pEntry ) if ( *it == pEntry )
{ {
pZOrderList->erase( it ); maZOrderList.erase( it );
pZOrderList->push_back( pEntry ); maZOrderList.push_back( pEntry );
break; break;
} }
} }
...@@ -2468,7 +2457,7 @@ void SvxIconChoiceCtrl_Impl::SelectRect( const tools::Rectangle& rRect, bool bAd ...@@ -2468,7 +2457,7 @@ void SvxIconChoiceCtrl_Impl::SelectRect( const tools::Rectangle& rRect, bool bAd
std::vector<tools::Rectangle>* pOtherRects ) std::vector<tools::Rectangle>* pOtherRects )
{ {
aCurSelectionRect = rRect; aCurSelectionRect = rRect;
if( !pZOrderList || !pZOrderList->size() ) if( maZOrderList.empty() )
return; return;
// set flag, so ToTop won't be called in Select // set flag, so ToTop won't be called in Select
...@@ -2477,7 +2466,7 @@ void SvxIconChoiceCtrl_Impl::SelectRect( const tools::Rectangle& rRect, bool bAd ...@@ -2477,7 +2466,7 @@ void SvxIconChoiceCtrl_Impl::SelectRect( const tools::Rectangle& rRect, bool bAd
CheckBoundingRects(); CheckBoundingRects();
pView->Update(); pView->Update();
const size_t nCount = pZOrderList->size(); const size_t nCount = maZOrderList.size();
tools::Rectangle aRect( rRect ); tools::Rectangle aRect( rRect );
aRect.Justify(); aRect.Justify();
...@@ -2492,7 +2481,7 @@ void SvxIconChoiceCtrl_Impl::SelectRect( const tools::Rectangle& rRect, bool bAd ...@@ -2492,7 +2481,7 @@ void SvxIconChoiceCtrl_Impl::SelectRect( const tools::Rectangle& rRect, bool bAd
for( size_t nPos = 0; nPos < nCount; nPos++ ) for( size_t nPos = 0; nPos < nCount; nPos++ )
{ {
SvxIconChoiceCtrlEntry* pEntry = (*pZOrderList)[ nPos ]; SvxIconChoiceCtrlEntry* pEntry = maZOrderList[ nPos ];
if( !IsBoundingRectValid( pEntry->aRect )) if( !IsBoundingRectValid( pEntry->aRect ))
FindBoundingRect( pEntry ); FindBoundingRect( pEntry );
......
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