diff options
-rw-r--r-- | include/vcl/toolkit/ivctrl.hxx | 1 | ||||
-rw-r--r-- | vcl/source/control/imivctl.hxx | 6 | ||||
-rw-r--r-- | vcl/source/control/imivctl1.cxx | 29 | ||||
-rw-r--r-- | vcl/source/control/ivctrl.cxx | 1 |
4 files changed, 8 insertions, 29 deletions
diff --git a/include/vcl/toolkit/ivctrl.hxx b/include/vcl/toolkit/ivctrl.hxx index a51751ace40d..9f5e73a0e30e 100644 --- a/include/vcl/toolkit/ivctrl.hxx +++ b/include/vcl/toolkit/ivctrl.hxx @@ -71,7 +71,6 @@ class SvxIconChoiceCtrlEntry tools::Rectangle aRect; // Bounding-Rectangle of the entry tools::Rectangle aGridRect; // Only valid in Grid-mode - sal_Int32 nPos; SvxIconChoiceCtrlTextMode eTextMode; sal_uInt16 nX,nY; // for keyboard control diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx index 1df0c7309e02..6bce8738e17c 100644 --- a/vcl/source/control/imivctl.hxx +++ b/vcl/source/control/imivctl.hxx @@ -52,9 +52,8 @@ class IcnGridMap_Impl; enum class IconChoiceFlags { NONE = 0x0000, AddMode = 0x0001, - EntryListPosValid = 0x0002, - ClearingSelection = 0x0004, - Arranging = 0x0008, + ClearingSelection = 0x0002, + Arranging = 0x0004, }; namespace o3tl { template<> struct typed_flags<IconChoiceFlags> : is_typed_flags<IconChoiceFlags, 0x007f> {}; @@ -181,7 +180,6 @@ class SvxIconChoiceCtrl_Impl bool bSelect ); void RepaintSelectedEntries(); - void SetListPositions(); void SetDefaultTextSize(); bool IsAutoArrange() const { diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx index 6a58742996fb..d30b42b1d80e 100644 --- a/vcl/source/control/imivctl1.cxx +++ b/vcl/source/control/imivctl1.cxx @@ -171,11 +171,6 @@ void SvxIconChoiceCtrl_Impl::InsertEntry( std::unique_ptr<SvxIconChoiceCtrlEntry maEntries.push_back( std::move(pEntry1) ); } - if( (nFlags & IconChoiceFlags::EntryListPosValid) && nPos >= maEntries.size() - 1 ) - pEntry->nPos = maEntries.size() - 1; - else - nFlags &= ~IconChoiceFlags::EntryListPosValid; - maZOrderList.push_back( pEntry ); pImpCursor->Clear(); @@ -195,8 +190,6 @@ void SvxIconChoiceCtrl_Impl::RemoveEntry(size_t nPos) { pImpCursor->Clear(); maEntries.erase(maEntries.begin() + nPos); - // Recalculate list positions - nFlags &= ~IconChoiceFlags::EntryListPosValid; RecalcAllBoundingRectsSmart(); } @@ -207,19 +200,6 @@ tools::Rectangle SvxIconChoiceCtrl_Impl::GetOutputRect() const return tools::Rectangle( aOrigin, aOutputSize ); } -void SvxIconChoiceCtrl_Impl::SetListPositions() -{ - if( nFlags & IconChoiceFlags::EntryListPosValid ) - return; - - size_t nCount = maEntries.size(); - for( size_t nCur = 0; nCur < nCount; nCur++ ) - { - maEntries[ nCur ]->nPos = nCur; - } - nFlags |= IconChoiceFlags::EntryListPosValid; -} - void SvxIconChoiceCtrl_Impl::SelectEntry( SvxIconChoiceCtrlEntry* pEntry, bool bSelect, bool bAdd ) { @@ -1882,9 +1862,12 @@ SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetFirstSelectedEntry() const sal_Int32 SvxIconChoiceCtrl_Impl::GetEntryListPos( SvxIconChoiceCtrlEntry const * pEntry ) const { - if( !(nFlags & IconChoiceFlags::EntryListPosValid )) - const_cast<SvxIconChoiceCtrl_Impl*>(this)->SetListPositions(); - return pEntry->nPos; + auto it = std::find_if(maEntries.begin(), maEntries.end(), + [pEntry](auto& rIt) { return rIt.get() == pEntry; }); + if (it != maEntries.end()) + return std::distance(maEntries.begin(), it); + + return -1; } void SvxIconChoiceCtrl_Impl::InitSettings() diff --git a/vcl/source/control/ivctrl.cxx b/vcl/source/control/ivctrl.cxx index 8e1c03a45e25..ca8785651624 100644 --- a/vcl/source/control/ivctrl.cxx +++ b/vcl/source/control/ivctrl.cxx @@ -58,7 +58,6 @@ SvxIconChoiceCtrlEntry::SvxIconChoiceCtrlEntry( OUString _aText, Image _aImage ) : aImage(std::move(_aImage)) , aText(std::move(_aText)) - , nPos(0) , eTextMode(SvxIconChoiceCtrlTextMode::Short) , nX(0) , nY(0) |