sw/inc/AnnotationWin.hxx | 3 +++ sw/source/uibase/docvw/AnnotationWin2.cxx | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-)
New commits: commit 253fd3d519a271a41ba717da48fa86975267dcf9 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jun 13 10:11:08 2023 +0200 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Tue Aug 8 12:35:57 2023 +0200 speed up rendering annotatins, cache meta height shaves 2% off scrolling profile on a large word doc Change-Id: I283e3f99c1c385f3d20ea573d15ca59b4629c14d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152952 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/inc/AnnotationWin.hxx b/sw/inc/AnnotationWin.hxx index 2aa641361ebf..fb7741543f4a 100644 --- a/sw/inc/AnnotationWin.hxx +++ b/sw/inc/AnnotationWin.hxx @@ -29,6 +29,7 @@ #include "postithelper.hxx" #include "swrect.hxx" #include "SidebarWindowsTypes.hxx" +#include <optional> class EditView; class PopupMenu; @@ -212,6 +213,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow virtual void LoseFocus() override; virtual void GetFocus() override; + virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; void SetSizePixel( const Size& rNewSize ) override; SfxItemSet DefaultItem(); @@ -280,6 +282,7 @@ class SAL_DLLPUBLIC_RTTI SwAnnotationWin final : public InterimItemWindow SwPostItField* mpField; rtl::Reference<sw::sidebarwindows::SidebarWinAccessible> mxSidebarWinAccessible; + mutable std::optional<sal_Int32> moMetaHeight; }; } // end of namespace sw::annotation diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index cfc42e0a5a84..9deb292da6ab 100644 --- a/sw/source/uibase/docvw/AnnotationWin2.cxx +++ b/sw/source/uibase/docvw/AnnotationWin2.cxx @@ -1262,14 +1262,25 @@ int SwAnnotationWin::GetPrefScrollbarWidth() const sal_Int32 SwAnnotationWin::GetMetaHeight() const { - const int fields = GetNumFields(); + if (!moMetaHeight) + { + const int fields = GetNumFields(); - sal_Int32 nRequiredHeight = 0; - weld::Label* aLabels[3] = { mxMetadataAuthor.get(), mxMetadataDate.get(), mxMetadataResolved.get() }; - for (int i = 0; i < fields; ++i) - nRequiredHeight += aLabels[i]->get_preferred_size().Height(); + sal_Int32 nRequiredHeight = 0; + weld::Label* aLabels[3] = { mxMetadataAuthor.get(), mxMetadataDate.get(), mxMetadataResolved.get() }; + for (int i = 0; i < fields; ++i) + nRequiredHeight += aLabels[i]->get_preferred_size().Height(); + moMetaHeight = nRequiredHeight; + } + return *moMetaHeight; +} - return nRequiredHeight; +void SwAnnotationWin::DataChanged(const DataChangedEvent& rDCEvt) +{ + if ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) + { + moMetaHeight.reset(); + } } sal_Int32 SwAnnotationWin::GetNumFields() const