include/vcl/toolkit/ivctrl.hxx | 1 - vcl/source/control/imivctl.hxx | 2 -- vcl/source/control/imivctl1.cxx | 24 ++++-------------------- 3 files changed, 4 insertions(+), 23 deletions(-)
New commits: commit 7b645998e691c3a6279f5e5a7452981d77d29e20 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 23 11:29:40 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 24 05:45:13 2024 +0200 tdf#161501 icon choice ctrl: Use a single member for entry rect `SvxIconChoiceCtrlEntry` has two members for maintaining the bound rect: * `aRect`, used almost everywhere * `aGridRect`, used very rarely `SvxIconChoiceCtrl_Impl::FindBoundingRect` calculates a new bounding rect and assigns it to `pEntry->aGridRect`, then calls `SvxIconChoiceCtrl_Impl::Center`, which at first assigns the same value to `pEntry->aRect`, so both are the same there. The other place using the `aGridRect` member is `SvxIconChoiceCtrl_Impl::CalcMaxTextRect` where it's used as a fallback if `aRect` has not been assigned a proper value yet. However, since `aGridRect` is never assigned a useful value apart from `aRect`, there doesn't seem to be much value in doing that, so use `aRect` there, too, and drop the `aGridRect` member altogether and assign directly to `aRect` in `SvxIconChoiceCtrl_Impl::FindBoundingRect` instead. Instead of falling back to `aGridRect` in `SvxIconChoiceCtrl_Impl::CalcMaxTextRect`, add an assert that `aRect` is valid instead, which never triggered in my tests with the "Insert" -> "Hyperlink" and "Format" -> "Page Style" dialogs, so should presumably be fine already. Change-Id: I99f368672523279f530b937a73c3afb655f7853e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170894 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/include/vcl/toolkit/ivctrl.hxx b/include/vcl/toolkit/ivctrl.hxx index 0944ce5001a8..9d0822fa4d6c 100644 --- a/include/vcl/toolkit/ivctrl.hxx +++ b/include/vcl/toolkit/ivctrl.hxx @@ -64,7 +64,6 @@ class SvxIconChoiceCtrlEntry friend class IcnGridMap_Impl; tools::Rectangle aRect; // Bounding-Rectangle of the entry - tools::Rectangle aGridRect; // Only valid in Grid-mode SvxIconChoiceCtrlTextMode eTextMode; sal_uInt16 nX,nY; // for keyboard control diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx index 8046dc54caf8..f5f1767ba019 100644 --- a/vcl/source/control/imivctl1.cxx +++ b/vcl/source/control/imivctl1.cxx @@ -1264,7 +1264,7 @@ void SvxIconChoiceCtrl_Impl::FindBoundingRect( SvxIconChoiceCtrlEntry* pEntry ) Point aPos(pGridMap->GetGridRect(pGridMap->GetUnoccupiedGrid()).TopLeft()); tools::Rectangle aGridRect(aPos, Size(nGridDX, nGridDY)); - pEntry->aGridRect = aGridRect; + pEntry->aRect = aGridRect; Center( pEntry ); AdjustVirtSize( pEntry->aRect ); pGridMap->OccupyGrids( pEntry ); @@ -1574,12 +1574,8 @@ void SvxIconChoiceCtrl_Impl::SetGrid( const Size& rSize ) tools::Rectangle SvxIconChoiceCtrl_Impl::CalcMaxTextRect( const SvxIconChoiceCtrlEntry* pEntry ) const { - tools::Rectangle aBoundRect; - // avoid infinite recursion: don't calculate the bounding rectangle here - if( IsBoundingRectValid( pEntry->aRect ) ) - aBoundRect = pEntry->aRect; - else - aBoundRect = pEntry->aGridRect; + assert(IsBoundingRectValid(pEntry->aRect) && "Bounding rect for entry hasn't been calculated yet."); + tools::Rectangle aBoundRect = pEntry->aRect; tools::Rectangle aBmpRect( const_cast<SvxIconChoiceCtrl_Impl*>(this)->CalcBmpRect( const_cast<SvxIconChoiceCtrlEntry*>(pEntry) ) ); @@ -1641,12 +1637,11 @@ void SvxIconChoiceCtrl_Impl::SetDefaultTextSize() void SvxIconChoiceCtrl_Impl::Center( SvxIconChoiceCtrlEntry* pEntry ) const { - pEntry->aRect = pEntry->aGridRect; Size aSize( CalcBoundingSize() ); if( nWinBits & WB_ICON ) { // center horizontally - tools::Long nBorder = pEntry->aGridRect.GetWidth() - aSize.Width(); + tools::Long nBorder = pEntry->aRect.GetWidth() - aSize.Width(); pEntry->aRect.AdjustLeft(nBorder / 2 ); pEntry->aRect.AdjustRight( -(nBorder / 2) ); } commit 14e1f10793d1ec994ab70f928feeecdb384a307e Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jul 23 11:09:21 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jul 24 05:45:04 2024 +0200 tdf#161501 Drop unused SvxIconChoiceCtrl_Impl::InvalidateEntry Unused since: Change-Id: If309f84fcd9a99337bc5896ce5c3238333427da5 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Tue Jul 23 11:00:42 2024 +0200 tdf#161501 icon choice ctrl: Drop debug-only mode switch feature Drop code that allows switching the text mode of the currently selected tab item in a vertical tab bar using Shift+F10 or Ctrl+F10, which is only available in dbgutil builds, and was therefore likely meant to be used for debugging purposes only. As related code will be changed in a follow-up commit, this would have to be adjusted to keep it working. Instead of spending time on that, just drop it. Testing how using another mode is still possible e.g. by locally changing the value assigned to `SvxIconChoiceCtrlEntry::eTextMode` in the `SvxIconChoiceCtrlEntry` ctor instead. Change-Id: If309f84fcd9a99337bc5896ce5c3238333427da5 Change-Id: I418fbf862ec94b04dbcfa4e7ff30cd5a8f9100e9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170893 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx index 505f32d3e960..ae767baf4e50 100644 --- a/vcl/source/control/imivctl.hxx +++ b/vcl/source/control/imivctl.hxx @@ -225,8 +225,6 @@ public: void LoseFocus(); void PaintEntry(SvxIconChoiceCtrlEntry*, const Point&, vcl::RenderContext& rRenderContext); - void InvalidateEntry( SvxIconChoiceCtrlEntry* ); - SvxIconChoiceCtrlEntry* GetCurEntry() const { return pCursor; } void SetCursor( SvxIconChoiceCtrlEntry* ); diff --git a/vcl/source/control/imivctl1.cxx b/vcl/source/control/imivctl1.cxx index eb1b576e044f..8046dc54caf8 100644 --- a/vcl/source/control/imivctl1.cxx +++ b/vcl/source/control/imivctl1.cxx @@ -1777,17 +1777,6 @@ void SvxIconChoiceCtrl_Impl::CancelUserEvents() } } -void SvxIconChoiceCtrl_Impl::InvalidateEntry( SvxIconChoiceCtrlEntry* pEntry ) -{ - if( pEntry == pCursor ) - ShowCursor( false ); - pView->Invalidate( pEntry->aRect ); - Center( pEntry ); - pView->Invalidate( pEntry->aRect ); - if( pEntry == pCursor ) - ShowCursor( true ); -} - SvxIconChoiceCtrlEntry* SvxIconChoiceCtrl_Impl::GetFirstSelectedEntry() const { size_t nCount = maEntries.size();