From 8d18b5af883bb6b56e758801ee730a08bb88a8f5 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 13 Jun 2023 10:11:08 +0200 Subject: speed up rendering annotatins, cache meta height MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit shaves 2% off scrolling profile on a large word doc Change-Id: I283e3f99c1c385f3d20ea573d15ca59b4629c14d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152978 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- sw/source/uibase/docvw/AnnotationWin2.cxx | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'sw/source/uibase/docvw/AnnotationWin2.cxx') diff --git a/sw/source/uibase/docvw/AnnotationWin2.cxx b/sw/source/uibase/docvw/AnnotationWin2.cxx index 06efbfdb581f..2c4bc7ce3d5e 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 -- cgit