cui/source/options/optpath.cxx | 25 +++++++ officecfg/registry/schema/org/openoffice/Office/Common.xcs | 6 + sfx2/source/view/classificationcontroller.cxx | 41 +++++++++++++ unotools/source/config/defaultoptions.cxx | 13 ++-- 4 files changed, 80 insertions(+), 5 deletions(-)
New commits: commit 8ba5369032202fd727cbf1af61284fdb5e3f4ec7 Author: Miklos Vajna <[email protected]> Date: Wed Mar 2 17:06:29 2016 +0100 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 diff --git a/sfx2/source/view/classificationcontroller.cxx b/sfx2/source/view/classificationcontroller.cxx index fa54a9b..1dc8134 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>&) commit 5582f0596876c82df343dd0e5d354cd4403e9594 Author: Miklos Vajna <[email protected]> Date: Wed Mar 2 15:09:28 2016 +0100 unotools: handle classification path in SvtDefaultOptions With this, it's possible to reset a custom classification path back to its default value. Change-Id: If0230fa6bb6ab014634dcdface8c470321163097 diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index e06114e..99fc0ef 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -1782,6 +1782,12 @@ </info> <value>$(insturl)/@LIBO_SHARE_FOLDER@/config</value> </prop> + <prop oor:name="Classification" oor:type="xs:string" oor:nillable="false"> + <info> + <desc>Contains the URL of the default TSCP BAF policy file.</desc> + </info> + <value>$(insturl)/@LIBO_SHARE_FOLDER@/classification/example.xml</value> + </prop> <prop oor:name="Dictionary" oor:type="xs:string" oor:nillable="false"> <info> <desc>Specifies the default directory where the provided diff --git a/unotools/source/config/defaultoptions.cxx b/unotools/source/config/defaultoptions.cxx index ee3731b..caccc93 100644 --- a/unotools/source/config/defaultoptions.cxx +++ b/unotools/source/config/defaultoptions.cxx @@ -60,7 +60,8 @@ using namespace com::sun::star::uno; #define DEFAULTPATH__TEMPLATE 18 #define DEFAULTPATH__USERCONFIG 19 #define DEFAULTPATH__WORK 20 -#define DEFAULTPATH__USERDICTIONARY 21 +#define DEFAULTPATH__CLASSIFICATION 21 +#define DEFAULTPATH__USERDICTIONARY 22 // class SvtDefaultOptions_Impl ------------------------------------------ @@ -88,6 +89,7 @@ public: OUString m_aTemplatePath; OUString m_aUserConfigPath; OUString m_aWorkPath; + OUString m_aClassificationPath; OUString m_aUserDictionaryPath; SvtDefaultOptions_Impl(); @@ -134,7 +136,8 @@ static PathToDefaultMapping_Impl const PathMap_Impl[] = { SvtPathOptions::PATH_TEMP, &SvtDefaultOptions_Impl::m_aTempPath }, { SvtPathOptions::PATH_TEMPLATE, &SvtDefaultOptions_Impl::m_aTemplatePath }, { SvtPathOptions::PATH_USERCONFIG, &SvtDefaultOptions_Impl::m_aUserConfigPath }, - { SvtPathOptions::PATH_WORK, &SvtDefaultOptions_Impl::m_aWorkPath } + { SvtPathOptions::PATH_WORK, &SvtDefaultOptions_Impl::m_aWorkPath }, + { SvtPathOptions::PATH_CLASSIFICATION, &SvtDefaultOptions_Impl::m_aClassificationPath } }; // functions ------------------------------------------------------------- @@ -163,7 +166,8 @@ Sequence< OUString > GetDefaultPropertyNames() "Temp", // PATH_TEMP "Template", // PATH_TEMPLATE "UserConfig", // PATH_USERCONFIG - "Work" // PATH_WORK + "Work", // PATH_WORK + "Classification" // PATH_CLASSIFICATION }; const int nCount = sizeof( aPropNames ) / sizeof( const char* ); @@ -192,7 +196,7 @@ OUString SvtDefaultOptions_Impl::GetDefaultPath( sal_uInt16 nId ) const OUString aRet; sal_uInt16 nIdx = 0; - while ( PathMap_Impl[nIdx]._ePath <= SvtPathOptions::PATH_WORK ) + while ( PathMap_Impl[nIdx]._ePath <= SvtPathOptions::PATH_CLASSIFICATION ) { if ( nId == PathMap_Impl[nIdx]._ePath && PathMap_Impl[nIdx]._pDefaultPath ) { @@ -298,6 +302,7 @@ SvtDefaultOptions_Impl::SvtDefaultOptions_Impl() : ConfigItem( "Office.Common/Pa case DEFAULTPATH__TEMPLATE: m_aTemplatePath = aFullPath; break; case DEFAULTPATH__USERCONFIG: m_aUserConfigPath = aFullPath; break; case DEFAULTPATH__WORK: m_aWorkPath = aFullPath; break; + case DEFAULTPATH__CLASSIFICATION: m_aClassificationPath = aFullPath;break; case DEFAULTPATH__USERDICTIONARY: m_aUserDictionaryPath = aFullPath;break; default: commit b4d43cc2152e5cdd274ad76c90532694cc1fb6e2 Author: Miklos Vajna <[email protected]> Date: Wed Mar 2 14:21:37 2016 +0100 cui: classification path is a file, not a directory in SvxPathTabPage So when editing the classification path, open a file picker, not a directory one. Change-Id: I8f7e18f90dc2b5f180e7ddda7157c1e374ed6e4e diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx index d1951f7..03155e4 100644 --- a/cui/source/options/optpath.cxx +++ b/cui/source/options/optpath.cxx @@ -46,11 +46,14 @@ #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/FolderPicker.hpp> +#include <com/sun/star/ui/dialogs/FilePicker.hpp> +#include <com/sun/star/ui/dialogs/TemplateDescription.hpp> #include <com/sun/star/util/thePathSettings.hpp> #include <officecfg/Office/Common.hxx> #include "optHeaderTabListbox.hxx" #include <vcl/help.hxx> +using namespace css; using namespace css::beans; using namespace css::lang; using namespace css::ui::dialogs; @@ -546,6 +549,7 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, PathHdl_Impl, Button*, void) SvTreeListEntry* pEntry = pPathBox->GetCurEntry(); sal_uInt16 nPos = ( pEntry != nullptr ) ? static_cast<PathUserData_Impl*>(pEntry->GetUserData())->nRealId : 0; OUString sInternal, sUser, sWritable; + bool bPickFile = false; if ( pEntry ) { PathUserData_Impl* pPathImpl = static_cast<PathUserData_Impl*>(pEntry->GetUserData()); @@ -553,6 +557,7 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, PathHdl_Impl, Button*, void) GetPathList( pPathImpl->nRealId, sInternal, sUser, sWritable, bReadOnly ); sUser = pPathImpl->sUserPath; sWritable = pPathImpl->sWritablePath; + bPickFile = pPathImpl->nRealId == SvtPathOptions::PATH_CLASSIFICATION; } if(pEntry && !(!SvTreeListBox::GetCollapsedEntryBmp(pEntry))) @@ -614,7 +619,7 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, PathHdl_Impl, Button*, void) } } } - else if ( pEntry ) + else if (pEntry && !bPickFile) { try { @@ -642,6 +647,24 @@ IMPL_LINK_NOARG_TYPED(SvxPathTabPage, PathHdl_Impl, Button*, void) SAL_WARN( "cui.options", "SvxPathTabPage::PathHdl_Impl: exception from folder picker" ); } } + else if (pEntry) + { + try + { + uno::Reference<uno::XComponentContext> xComponentContext(comphelper::getProcessComponentContext()); + uno::Reference<ui::dialogs::XFilePicker3> xFilePicker = ui::dialogs::FilePicker::createWithMode(xComponentContext, ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE); + xFilePicker->appendFilter(OUString(), "*.xml"); + if (xFilePicker->execute() == ui::dialogs::ExecutableDialogResults::OK) + { + uno::Sequence<OUString> aPathSeq(xFilePicker->getSelectedFiles()); + ChangeCurrentEntry(aPathSeq[0]); + } + } + catch (const uno::Exception& rException) + { + SAL_WARN("cui.options", "SvxPathTabPage::PathHdl_Impl: exception from file picker: " << rException.Message); + } + } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
