desktop/source/deployment/gui/dp_gui_extlistbox.cxx | 45 ++++++++------------ desktop/source/deployment/gui/dp_gui_extlistbox.hxx | 6 +- 2 files changed, 23 insertions(+), 28 deletions(-)
New commits: commit f986f89b1f04e05d8c6522038d15d2ce968dff03 Author: Michael Weghorn <[email protected]> AuthorDate: Tue Oct 28 14:36:44 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Oct 28 19:50:35 2025 +0100 tdf#127201 extension mgr: Extract helper for calculating entry rect Implement a helper method ExtensionBox::GetEntryRect that can be used to calculate the rectangle of any index and use it in two places that were previously duplicating similar logic. The new method could also be used to implement the comphelper::OAccessible::implGetBounds override in case of a future a11y implementation for the entries in the extension manager. Change-Id: I6c6d16564db6f20f3d77b65308d5c07b98a41006 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193107 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index cfec7dc75f46..84ec46bf93e5 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -285,18 +285,21 @@ void ExtensionBox::CalcActiveHeight(const tools::Long nPos) m_nActiveHeight += 2; } -tools::Rectangle ExtensionBox::GetActiveEntryRect() const +tools::Rectangle ExtensionBox::GetEntryRect(tools::Long nIndex) const { - assert(m_nActive >= 0 && "No active entry"); + const ::osl::MutexGuard aGuard(m_entriesMutex); - const ::osl::MutexGuard aGuard( m_entriesMutex ); - - Size aSize( GetOutputSizePixel() ); - aSize.setHeight(m_nActiveHeight); + tools::Long nY = -m_nTopIndex; + if (m_nActive >= 0 && nIndex > m_nActive) + nY += (nIndex - 1) * m_nStdHeight + m_nActiveHeight; + else + nY += nIndex * m_nStdHeight; + Point aStart(0, nY); - Point aPos(0, -m_nTopIndex + m_nActive * m_nStdHeight); + Size aSize(GetOutputSizePixel()); + aSize.setHeight(nIndex == m_nActive ? m_nActiveHeight : m_nStdHeight); - return tools::Rectangle( aPos, aSize ); + return tools::Rectangle(aStart, aSize); } void ExtensionBox::DeleteRemoved() @@ -524,7 +527,7 @@ void ExtensionBox::RecalcAll() if (m_nActive >= 0) { - tools::Rectangle aEntryRect = GetActiveEntryRect(); + tools::Rectangle aEntryRect = GetEntryRect(m_nActive); if ( m_bAdjustActive ) { @@ -617,18 +620,12 @@ void ExtensionBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan if ( m_bNeedsRecalc ) RecalcAll(); - Point aStart( 0, -m_nTopIndex ); - Size aSize(GetOutputSizePixel()); - const ::osl::MutexGuard aGuard( m_entriesMutex ); for (tools::Long i = 0; i < GetEntryCount(); ++i) { const bool bActive = i == m_nActive; - aSize.setHeight(bActive ? m_nActiveHeight : m_nStdHeight); - tools::Rectangle aEntryRect( aStart, aSize ); - DrawRow(rRenderContext, aEntryRect, GetEntryData(i), bActive); - aStart.AdjustY(aSize.Height() ); + DrawRow(rRenderContext, GetEntryRect(i), GetEntryData(i), bActive); } } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index 5c934ecd37f4..fe4b6caa9172 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -170,7 +170,7 @@ public: TEntry_Impl const & GetEntryData( tools::Long nPos ) { return m_vEntries[ nPos ]; } tools::Long GetEntryCount() const { return static_cast<tools::Long>(m_vEntries.size()); } - tools::Rectangle GetActiveEntryRect() const; + tools::Rectangle GetEntryRect(tools::Long nPos) const; bool HasActive() const { return m_nActive >= 0; } tools::Long PointToPos( const Point& rPos ); virtual void RecalcAll(); commit 1396a4fa67f9daa284285a060d58fd70fa463dab Author: Michael Weghorn <[email protected]> AuthorDate: Tue Oct 28 14:01:24 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Tue Oct 28 19:50:28 2025 +0100 extension mgr: Stop double bookkeeping of active entry ExtensionBox::m_nActive is the index of the currently active entry, which is relevant when the entries get drawn. Use that one and stop additionally maintaining the active state in the Entry_Impl representing every single entry. Change-Id: Id474702e31375f676c4bf9f307baceb0e5851629 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193106 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index b73e0a0c7b51..cfec7dc75f46 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -75,7 +75,6 @@ bool FindWeakRef::operator () (uno::WeakReference< deployment::XPackage > const Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage, const PackageState eState, const bool bReadOnly ) : - m_bActive( false ), m_bLocked( bReadOnly ), m_bHasOptions( false ), m_bUser( false ), @@ -333,14 +332,12 @@ void ExtensionBox::selectEntry(const tools::Long nPos) if ( nPos == m_nActive ) return; - m_vEntries[ m_nActive ]->m_bActive = false; m_nActive = -1; } if ( ( nPos >= 0 ) && ( o3tl::make_unsigned(nPos) < m_vEntries.size() ) ) { m_nActive = nPos; - m_vEntries[ nPos ]->m_bActive = true; if ( IsReallyVisible() ) { @@ -363,11 +360,11 @@ void ExtensionBox::selectEntry(const tools::Long nPos) } void ExtensionBox::DrawRow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, - const TEntry_Impl& rEntry) + const TEntry_Impl& rEntry, bool bActive) { const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings(); - if (rEntry->m_bActive) + if (bActive) rRenderContext.SetTextColor(rStyleSettings.GetHighlightTextColor()); else if ((rEntry->m_eState != PackageState::REGISTERED) && (rEntry->m_eState != PackageState::NOT_AVAILABLE)) @@ -375,7 +372,7 @@ void ExtensionBox::DrawRow(vcl::RenderContext& rRenderContext, const tools::Rect else rRenderContext.SetTextColor(rStyleSettings.GetFieldTextColor()); - if (rEntry->m_bActive) + if (bActive) { rRenderContext.SetLineColor(); rRenderContext.SetFillColor(rStyleSettings.GetHighlightColor()); @@ -453,7 +450,7 @@ void ExtensionBox::DrawRow(vcl::RenderContext& rRenderContext, const tools::Rect OUString sDescription; if (!rEntry->m_sErrorText.isEmpty()) { - if (rEntry->m_bActive) + if (bActive) sDescription = rEntry->m_sErrorText + " " + rEntry->m_sDescription; else sDescription = rEntry->m_sErrorText; @@ -462,7 +459,7 @@ void ExtensionBox::DrawRow(vcl::RenderContext& rRenderContext, const tools::Rect sDescription = rEntry->m_sDescription; aPos.AdjustY(aTextHeight ); - if (rEntry->m_bActive) + if (bActive) { tools::Long nExtraHeight = 0; @@ -625,11 +622,12 @@ void ExtensionBox::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan const ::osl::MutexGuard aGuard( m_entriesMutex ); - for (auto const& entry : m_vEntries) + for (tools::Long i = 0; i < GetEntryCount(); ++i) { - aSize.setHeight( entry->m_bActive ? m_nActiveHeight : m_nStdHeight ); + const bool bActive = i == m_nActive; + aSize.setHeight(bActive ? m_nActiveHeight : m_nStdHeight); tools::Rectangle aEntryRect( aStart, aSize ); - DrawRow(rRenderContext, aEntryRect, entry); + DrawRow(rRenderContext, aEntryRect, GetEntryData(i), bActive); aStart.AdjustY(aSize.Height() ); } } diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx index 7b37bfa3ea0b..5c934ecd37f4 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.hxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.hxx @@ -51,7 +51,6 @@ class TheExtensionManager; struct Entry_Impl { - bool m_bActive :1; bool m_bLocked :1; bool m_bHasOptions :1; bool m_bUser :1; @@ -146,7 +145,8 @@ class ExtensionBox : public weld::CustomWidgetController void CalcActiveHeight( const tools::Long nPos ); tools::Long GetTotalHeight() const; void SetupScrollBar(); - void DrawRow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, const TEntry_Impl& rEntry); + void DrawRow(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect, + const TEntry_Impl& rEntry, bool bActive); bool HandleCursorKey( sal_uInt16 nKeyCode ); bool FindEntryPos( const TEntry_Impl& rEntry, tools::Long nStart, tools::Long nEnd, tools::Long &nFound ); void DeleteRemoved();
