Kaydet (Commit) 8ba53690 authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 5582f059
......@@ -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>&)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment