diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-02 17:06:29 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-03-02 17:26:39 +0100 |
commit | 8ba5369032202fd727cbf1af61284fdb5e3f4ec7 (patch) | |
tree | 630d1dbbc2b81657c56e794edeba9ac65e13d256 /sfx2/source/view/classificationcontroller.cxx | |
parent | 5582f0596876c82df343dd0e5d354cd4403e9594 (diff) |
sfx2 classification: add config listener to avoid restarts
So that when SvxPathTabPage sets a custom classification path (or resets
it back to the default), then no restart is needed, the toolbar will be
updated instantly.
ClassificationCategoriesController::statusChanged() was called already,
all that was necessary is to remove old entries, to trigger a re-read of
the policy.
Change-Id: I98edea19fedfb5c1197981085193f959c19647a1
Diffstat (limited to 'sfx2/source/view/classificationcontroller.cxx')
-rw-r--r-- | sfx2/source/view/classificationcontroller.cxx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx index fa54a9b86fbe..1dc8134e1cf5 100644 --- a/sfx2/source/view/classificationcontroller.cxx +++ b/sfx2/source/view/classificationcontroller.cxx @@ -24,18 +24,34 @@ #include <cppuhelper/supportsservice.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/dispatchcommand.hxx> +#include <comphelper/configurationlistener.hxx> using namespace com::sun::star; namespace sfx2 { +class ClassificationCategoriesController; +using ClassificationPropertyListenerBase = comphelper::ConfigurationListenerProperty<OUString>; + +/// Listens to configuration changes, so no restart is needed after setting the classification path. +class ClassificationPropertyListener : public ClassificationPropertyListenerBase +{ + ClassificationCategoriesController& m_rController; + +public: + ClassificationPropertyListener(const rtl::Reference<comphelper::ConfigurationListener>& xListener, ClassificationCategoriesController& rController); + virtual void setProperty(const uno::Any& rProperty) override; +}; + using ClassificationCategoriesControllerBase = cppu::ImplInheritanceHelper<svt::ToolboxController, lang::XServiceInfo>; /// Controller for .uno:ClassificationApply. class ClassificationCategoriesController : public ClassificationCategoriesControllerBase { VclPtr<ListBox> m_pCategories; + rtl::Reference<comphelper::ConfigurationListener> m_xListener; + ClassificationPropertyListener m_aPropertyListener; DECL_LINK_TYPED(SelectHdl, ListBox&, void); @@ -56,12 +72,29 @@ public: // XStatusListener virtual void SAL_CALL statusChanged(const frame::FeatureStateEvent& rEvent) throw (uno::RuntimeException, std::exception) override; + + void removeEntries(); }; +ClassificationPropertyListener::ClassificationPropertyListener(const rtl::Reference<comphelper::ConfigurationListener>& xListener, ClassificationCategoriesController& rController) + : ClassificationPropertyListenerBase(xListener, "WritePath") + , m_rController(rController) +{ +} + +void ClassificationPropertyListener::setProperty(const uno::Any& /*rProperty*/) +{ + // So that its gets re-filled with entries from the new policy. + m_rController.removeEntries(); +} + ClassificationCategoriesController::ClassificationCategoriesController(const uno::Reference<uno::XComponentContext>& rContext) : ClassificationCategoriesControllerBase(rContext, uno::Reference<frame::XFrame>(), OUString(".uno:ClassificationApply")) , m_pCategories(nullptr) + , m_xListener(new comphelper::ConfigurationListener("/org.openoffice.Office.Paths/Paths/Classification")) + , m_aPropertyListener(m_xListener, *this) { + } ClassificationCategoriesController::~ClassificationCategoriesController() @@ -93,6 +126,8 @@ void ClassificationCategoriesController::dispose() throw (uno::RuntimeException, svt::ToolboxController::dispose(); m_pCategories.disposeAndClear(); + m_aPropertyListener.dispose(); + m_xListener->dispose(); } uno::Reference<awt::XWindow> ClassificationCategoriesController::createItemWindow(const uno::Reference<awt::XWindow>& rParent) throw (uno::RuntimeException, std::exception) @@ -146,6 +181,12 @@ void ClassificationCategoriesController::statusChanged(const frame::FeatureState m_pCategories->SelectEntry(rCategoryName); } +void ClassificationCategoriesController::removeEntries() +{ + if (m_pCategories) + m_pCategories->Clear(); +} + } // namespace sfx2 extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL com_sun_star_sfx2_ClassificationCategoriesController_get_implementation(uno::XComponentContext* pContext, const uno::Sequence<uno::Any>&) |