diff options
-rw-r--r-- | svx/source/inc/StylesPreviewWindow.hxx | 24 | ||||
-rw-r--r-- | svx/source/tbxctrls/StylesPreviewWindow.cxx | 20 |
2 files changed, 37 insertions, 7 deletions
diff --git a/svx/source/inc/StylesPreviewWindow.hxx b/svx/source/inc/StylesPreviewWindow.hxx index 73c688fc9498..21f46a5e81b9 100644 --- a/svx/source/inc/StylesPreviewWindow.hxx +++ b/svx/source/inc/StylesPreviewWindow.hxx @@ -74,8 +74,25 @@ private: const tools::Rectangle& aContentRect, const Color& aColor); }; +class StylesListUpdateTask : public Idle +{ + StylesPreviewWindow_Base& m_rStylesList; + +public: + StylesListUpdateTask(StylesPreviewWindow_Base& rStylesList) + : Idle("StylesListUpdateTask") + , m_rStylesList(rStylesList) + { + SetPriority(TaskPriority::HIGH_IDLE); + } + + virtual void Invoke() override; +}; + class StylesPreviewWindow_Base { + friend class StylesListUpdateTask; + protected: static constexpr unsigned STYLES_COUNT = 6; @@ -83,6 +100,8 @@ protected: std::unique_ptr<weld::IconView> m_xStylesView; + StylesListUpdateTask m_aUpdateTask; + rtl::Reference<StyleStatusListener> m_xStatusListener; std::unique_ptr<StylePoolChangeListener> m_pStylePoolChangeListener; @@ -102,10 +121,11 @@ public: ~StylesPreviewWindow_Base(); void Select(const OUString& rStyleName); - void UpdateStylesList(); + void RequestStylesListUpdate(); private: - void Update(); + void UpdateStylesList(); + void UpdateSelection(); bool Command(const CommandEvent& rEvent); }; diff --git a/svx/source/tbxctrls/StylesPreviewWindow.cxx b/svx/source/tbxctrls/StylesPreviewWindow.cxx index 228e322be50a..2c27c2fb834f 100644 --- a/svx/source/tbxctrls/StylesPreviewWindow.cxx +++ b/svx/source/tbxctrls/StylesPreviewWindow.cxx @@ -100,7 +100,7 @@ StylePoolChangeListener::~StylePoolChangeListener() void StylePoolChangeListener::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& /*rHint*/) { - m_pPreviewControl->UpdateStylesList(); + m_pPreviewControl->RequestStylesListUpdate(); } StyleItemController::StyleItemController(const std::pair<OUString, OUString>& aStyleName) @@ -358,6 +358,7 @@ StylesPreviewWindow_Base::StylesPreviewWindow_Base( const css::uno::Reference<css::frame::XDispatchProvider>& xDispatchProvider) : m_xDispatchProvider(xDispatchProvider) , m_xStylesView(xBuilder.weld_icon_view("stylesview")) + , m_aUpdateTask(*this) , m_aDefaultStyles(std::move(aDefaultStyles)) { m_xStylesView->connect_selection_changed(LINK(this, StylesPreviewWindow_Base, Selected)); @@ -368,8 +369,7 @@ StylesPreviewWindow_Base::StylesPreviewWindow_Base( m_pStylePoolChangeListener.reset(new StylePoolChangeListener(this)); - UpdateStylesList(); - Update(); + RequestStylesListUpdate(); } IMPL_LINK(StylesPreviewWindow_Base, Selected, weld::IconView&, rIconView, void) @@ -405,6 +405,8 @@ StylesPreviewWindow_Base::~StylesPreviewWindow_Base() { m_xStatusListener->UnBind(); + m_aUpdateTask.Stop(); + try { m_xStatusListener->dispose(); @@ -420,10 +422,10 @@ void StylesPreviewWindow_Base::Select(const OUString& rStyleName) { m_sSelectedStyle = rStyleName; - Update(); + UpdateSelection(); } -void StylesPreviewWindow_Base::Update() +void StylesPreviewWindow_Base::UpdateSelection() { for (std::vector<std::pair<OUString, OUString>>::size_type i = 0; i < m_aAllStyles.size(); ++i) { @@ -435,6 +437,14 @@ void StylesPreviewWindow_Base::Update() } } +void StylesPreviewWindow_Base::RequestStylesListUpdate() { m_aUpdateTask.Start(); } + +void StylesListUpdateTask::Invoke() +{ + m_rStylesList.UpdateStylesList(); + m_rStylesList.UpdateSelection(); +} + void StylesPreviewWindow_Base::UpdateStylesList() { m_aAllStyles = m_aDefaultStyles; |