vcl/source/treelist/iconviewimpl.cxx | 17 +++++++++++------ vcl/source/treelist/iconviewimpl.hxx | 5 ++++- 2 files changed, 15 insertions(+), 7 deletions(-)
New commits: commit 06e8ba52b5ffcc03bbc0d4f96c4c40c3c1507d2d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 25 18:58:36 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 25 20:52:20 2025 +0200 vcl: Move casting to new IconViewImpl::GetIconView Instead of casting SvImpLBox::m_pView to IconView in multiple places in the IconViewImpl subclass, introduce a new helper method IconViewImpl::GetIconView that does this. Change-Id: I2f053362774d2a3ad4d4848b55b6f633c9e49db6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188361 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/source/treelist/iconviewimpl.cxx b/vcl/source/treelist/iconviewimpl.cxx index 224b35031c27..fbf25844f2c5 100644 --- a/vcl/source/treelist/iconviewimpl.cxx +++ b/vcl/source/treelist/iconviewimpl.cxx @@ -32,9 +32,15 @@ static bool IsSeparator(const SvTreeListEntry* entry) return entry && entry->GetFlags() & SvTLEntryFlags::IS_SEPARATOR; } +IconView& IconViewImpl::GetIconView() const +{ + assert(m_pView); + return static_cast<IconView&>(*m_pView); +} + Size IconViewImpl::GetEntrySize(const SvTreeListEntry& entry) const { - return static_cast<const IconView*>(m_pView.get())->GetEntrySize(entry); + return GetIconView().GetEntrySize(entry); } void IconViewImpl::IterateVisibleEntryAreas(const IterateEntriesFunc& f, bool fromStartEntry) const @@ -511,12 +517,12 @@ void IconViewImpl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectan SetCursor(m_pStartEntry, bNotSelect); } - auto PaintEntry = [iconView = static_cast<IconView*>(m_pView.get()), &rRect, + auto PaintEntry = [&rIconView = GetIconView(), &rRect, &rRenderContext](const EntryAreaInfo& info) { if (!info.area.GetIntersection(rRect).IsEmpty()) { - iconView->PaintEntry(*info.entry, info.area.Left(), info.area.Top(), rRenderContext); + rIconView.PaintEntry(*info.entry, info.area.Left(), info.area.Top(), rRenderContext); } else if (info.area.Top() > rRect.Bottom()) { diff --git a/vcl/source/treelist/iconviewimpl.hxx b/vcl/source/treelist/iconviewimpl.hxx index d1fe108ae73a..8f53413e981b 100644 --- a/vcl/source/treelist/iconviewimpl.hxx +++ b/vcl/source/treelist/iconviewimpl.hxx @@ -77,6 +77,8 @@ private: void IterateVisibleEntryAreas(const IterateEntriesFunc& f, bool fromStartEntry = false) const; + IconView& GetIconView() const; + Size GetEntrySize(const SvTreeListEntry& entry) const; // Get first entry at most n rows above; nullptr if no rows above SvTreeListEntry* GoToPrevRow(SvTreeListEntry* pEntry, int n) const; commit e9fa78a1e440a7e2f6d55100f1f124468b9cddbc Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Jul 25 18:51:11 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Jul 25 20:52:12 2025 +0200 vcl: Take IconView* param in IconViewImpl ctor This must be an IconView and e.g. IconViewImpl::GetEntrySize casts the SvTreeListBox to that, so make that requirement explicit in the ctor. Change-Id: I030a2f3781392399bf70c406ce30f376bc87dcd2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188360 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/treelist/iconviewimpl.cxx b/vcl/source/treelist/iconviewimpl.cxx index 35025d1c81f4..224b35031c27 100644 --- a/vcl/source/treelist/iconviewimpl.cxx +++ b/vcl/source/treelist/iconviewimpl.cxx @@ -20,11 +20,10 @@ #include <vcl/svapp.hxx> #include <vcl/toolkit/treelistentry.hxx> #include <tools/debug.hxx> -#include <iconview.hxx> #include "iconviewimpl.hxx" -IconViewImpl::IconViewImpl( SvTreeListBox* pTreeListBox, SvTreeList* pTreeList, WinBits nWinStyle ) -: SvImpLBox( pTreeListBox, pTreeList, nWinStyle ) +IconViewImpl::IconViewImpl(IconView* pIconView, SvTreeList* pTreeList, WinBits nWinStyle) + : SvImpLBox(pIconView, pTreeList, nWinStyle) { } diff --git a/vcl/source/treelist/iconviewimpl.hxx b/vcl/source/treelist/iconviewimpl.hxx index 6e969e810c6d..d1fe108ae73a 100644 --- a/vcl/source/treelist/iconviewimpl.hxx +++ b/vcl/source/treelist/iconviewimpl.hxx @@ -19,6 +19,7 @@ #pragma once +#include <iconview.hxx> #include <svimpbox.hxx> class SvTreeListBox; @@ -26,7 +27,7 @@ class SvTreeListBox; class IconViewImpl : public SvImpLBox { public: - IconViewImpl(SvTreeListBox* pTreeListBox, SvTreeList* pTreeList, WinBits nWinStyle); + IconViewImpl(IconView* pIconView, SvTreeList* pTreeList, WinBits nWinStyle); void KeyDown(bool bPageDown) override;