diff options
-rw-r--r-- | compilerplugins/clang/badstatics.cxx | 2 | ||||
-rw-r--r-- | svx/source/inc/StylesPreviewWindow.hxx | 3 | ||||
-rw-r--r-- | svx/source/tbxctrls/StylesPreviewWindow.cxx | 28 |
3 files changed, 27 insertions, 6 deletions
diff --git a/compilerplugins/clang/badstatics.cxx b/compilerplugins/clang/badstatics.cxx index 3b80278a2f4f..7c604bc5ee66 100644 --- a/compilerplugins/clang/badstatics.cxx +++ b/compilerplugins/clang/badstatics.cxx @@ -199,6 +199,8 @@ public: || name == "g_aWindowList" //vcl/unx/gtk3/a11y/atkutil.cxx, asserted empty at exit || name == "gFontPreviewVirDevs" + || (loplugin::DeclCheck(pVarDecl).Var("aPreviewCache") + .Class("StylesPreviewWindow_Base").GlobalNamespace()) // TODO: temp disable //svtools/source/control/ctrlbox.cxx, empty at exit || name == "aLogger" // FormulaLogger& FormulaLogger::get() in sc/source/core/tool/formulalogger.cxx || name == "s_aUncommittedRegistrations" // sw/source/uibase/dbui/dbmgr.cxx diff --git a/svx/source/inc/StylesPreviewWindow.hxx b/svx/source/inc/StylesPreviewWindow.hxx index 0295a0eeea7c..47e21dcb4ca0 100644 --- a/svx/source/inc/StylesPreviewWindow.hxx +++ b/svx/source/inc/StylesPreviewWindow.hxx @@ -121,11 +121,14 @@ public: void Select(const OUString& rStyleName); void RequestStylesListUpdate(); + static VclPtr<VirtualDevice> GetCachedPreview(const std::pair<OUString, OUString>& rStyle); private: void UpdateStylesList(); void UpdateSelection(); bool Command(const CommandEvent& rEvent); + + static std::map<OUString, VclPtr<VirtualDevice>> aPreviewCache; }; class StylesPreviewWindow_Impl final : public InterimItemWindow, public StylesPreviewWindow_Base diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx index ff2f959d3406..c1e3549fb54a 100644 --- a/svx/source/tbxctrls/StylesPreviewWindow.cxx +++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx @@ -60,6 +60,8 @@ #include <vcl/commandevent.hxx> +std::map<OUString, VclPtr<VirtualDevice>> StylesPreviewWindow_Base::aPreviewCache; + StyleStatusListener::StyleStatusListener( StylesPreviewWindow_Base* pPreviewControl, const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider) @@ -460,6 +462,25 @@ void StylesListUpdateTask::Invoke() m_rStylesList.UpdateSelection(); } +VclPtr<VirtualDevice> +StylesPreviewWindow_Base::GetCachedPreview(const std::pair<OUString, OUString>& rStyle) +{ + if (aPreviewCache.find(rStyle.second) != aPreviewCache.end()) + return aPreviewCache[rStyle.second]; + else + { + VclPtr<VirtualDevice> pImg = VclPtr<VirtualDevice>::Create(); + const Size aSize(100, 30); + pImg->SetOutputSizePixel(aSize); + + StyleItemController aStyleController(rStyle); + aStyleController.Paint(*pImg); + aPreviewCache[rStyle.second] = pImg; + + return pImg; + } +} + void StylesPreviewWindow_Base::UpdateStylesList() { m_aAllStyles = m_aDefaultStyles; @@ -487,12 +508,7 @@ void StylesPreviewWindow_Base::UpdateStylesList() m_xStylesView->clear(); for (const auto& rStyle : m_aAllStyles) { - ScopedVclPtr<VirtualDevice> pImg = VclPtr<VirtualDevice>::Create(); - const Size aSize(100, 30); - pImg->SetOutputSizePixel(aSize); - - StyleItemController aStyleController(rStyle); - aStyleController.Paint(*pImg); + VclPtr<VirtualDevice> pImg = GetCachedPreview(rStyle); m_xStylesView->append(rStyle.first, rStyle.second, pImg); } |