From f4a9ba4b484480ddacc62a47f68b02e449d72880 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 9 Feb 2017 13:50:39 +0200 Subject: convert ConfigNameFormat to scoped enum and drop unused constants CONFIG_NAME_PLAINTEXT_NAME CONFIG_NAME_FULL_PATH Change-Id: Ibf7e88da0ae54516cb863b8efa995201f2a95268 --- .../source/fwi/classes/protocolhandlercache.cxx | 2 +- include/unotools/configitem.hxx | 8 ++-- svtools/source/config/fontsubstconfig.cxx | 2 +- unotools/source/config/cmdoptions.cxx | 2 +- unotools/source/config/configitem.cxx | 53 ++-------------------- unotools/source/config/eventcfg.cxx | 2 +- 6 files changed, 10 insertions(+), 59 deletions(-) diff --git a/framework/source/fwi/classes/protocolhandlercache.cxx b/framework/source/fwi/classes/protocolhandlercache.cxx index dc7c3b4966e0..0837083172c4 100644 --- a/framework/source/fwi/classes/protocolhandlercache.cxx +++ b/framework/source/fwi/classes/protocolhandlercache.cxx @@ -201,7 +201,7 @@ void HandlerCFGAccess::read( HandlerHash** ppHandler , PatternHash** ppPattern ) { // list of all uno implementation names without encoding - css::uno::Sequence< OUString > lNames = GetNodeNames( SETNAME_HANDLER, ::utl::CONFIG_NAME_LOCAL_PATH ); + css::uno::Sequence< OUString > lNames = GetNodeNames( SETNAME_HANDLER, ::utl::ConfigNameFormat::LocalPath ); sal_Int32 nSourceCount = lNames.getLength(); sal_Int32 nTargetCount = nSourceCount; // list of all full qualified path names of configuration entries diff --git a/include/unotools/configitem.hxx b/include/unotools/configitem.hxx index 54a57d896f5e..41c8b62a007d 100644 --- a/include/unotools/configitem.hxx +++ b/include/unotools/configitem.hxx @@ -58,12 +58,10 @@ namespace o3tl namespace utl { - enum ConfigNameFormat + enum class ConfigNameFormat { - CONFIG_NAME_PLAINTEXT_NAME, // unescaped local node name, for user display etc. - CONFIG_NAME_LOCAL_NAME, // local node name, for use in XNameAccess etc. ("Item", "Q & A") - CONFIG_NAME_LOCAL_PATH, // one-level relative path, for use when building paths etc. ("Item", "Typ['Q & A']") - CONFIG_NAME_FULL_PATH // full absolute path. ("/org.openoffice.Sample/Group/Item", "/org.openoffice.Sample/Set/Typ['Q & A']") + LocalNode, // local node name, for use in XNameAccess etc. ("Item", "Q & A") + LocalPath, // one-level relative path, for use when building paths etc. ("Item", "Typ['Q & A']") }; class ConfigChangeListener_Impl; diff --git a/svtools/source/config/fontsubstconfig.cxx b/svtools/source/config/fontsubstconfig.cxx index bb4533f0538d..a9b42a6ffc52 100644 --- a/svtools/source/config/fontsubstconfig.cxx +++ b/svtools/source/config/fontsubstconfig.cxx @@ -59,7 +59,7 @@ SvtFontSubstConfig::SvtFontSubstConfig() : bIsEnabled = *o3tl::doAccess(aValues.getConstArray()[0]); OUString sPropPrefix(cFontPairs); - Sequence aNodeNames = GetNodeNames(sPropPrefix, CONFIG_NAME_LOCAL_PATH); + Sequence aNodeNames = GetNodeNames(sPropPrefix, ConfigNameFormat::LocalPath); const OUString* pNodeNames = aNodeNames.getConstArray(); Sequence aPropNames(aNodeNames.getLength() * 4); OUString* pNames = aPropNames.getArray(); diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx index ff2f6445424c..b569e12041a2 100644 --- a/unotools/source/config/cmdoptions.cxx +++ b/unotools/source/config/cmdoptions.cxx @@ -276,7 +276,7 @@ void SvtCommandOptions_Impl::EstablishFrameCallback(const css::uno::Reference< c Sequence< OUString > SvtCommandOptions_Impl::impl_GetPropertyNames() { // First get ALL names of current existing list items in configuration! - Sequence< OUString > lDisabledItems = GetNodeNames( SETNODE_DISABLED, utl::CONFIG_NAME_LOCAL_PATH ); + Sequence< OUString > lDisabledItems = GetNodeNames( SETNODE_DISABLED, utl::ConfigNameFormat::LocalPath ); // Expand all keys for (sal_Int32 i=0; i& _rNames, ConfigNameFor { switch (_eFormat) { - case CONFIG_NAME_LOCAL_NAME: + case ConfigNameFormat::LocalNode: // unaltered - this is our input format break; - case CONFIG_NAME_FULL_PATH: - { - Reference xFormatter(_xParentNode, UNO_QUERY); - if (xFormatter.is()) - { - OUString * pNames = _rNames.getArray(); - for(int i = 0; i<_rNames.getLength(); ++i) - { - try - { - pNames[i] = xFormatter->composeHierarchicalName(pNames[i]); - } - catch (css::uno::Exception & e) - { - SAL_WARN( - "unotools.config", - "Exception from composeHierarchicalName(): " - << e.Message); - } - } - break; - } - } - OSL_FAIL("Cannot create absolute paths: missing interface"); - SAL_FALLTHROUGH; // make local paths instaed - - case CONFIG_NAME_LOCAL_PATH: + case ConfigNameFormat::LocalPath: { Reference xTypeContainer(_xParentNode, UNO_QUERY); if (xTypeContainer.is()) @@ -634,33 +608,12 @@ static void lcl_normalizeLocalNames(Sequence< OUString >& _rNames, ConfigNameFor } break; - case CONFIG_NAME_PLAINTEXT_NAME: - { - Reference xEscaper(_xParentNode, UNO_QUERY); - if (xEscaper.is()) - { - OUString * pNames = _rNames.getArray(); - for(int i = 0; i<_rNames.getLength(); ++i) - try - { - pNames[i] = xEscaper->unescapeString(pNames[i]); - } - catch (css::uno::Exception & e) - { - SAL_WARN( - "unotools.config", - "Exception from unescapeString(): " << e.Message); - } - } - } - break; - } } Sequence< OUString > ConfigItem::GetNodeNames(const OUString& rNode) { - ConfigNameFormat const eDefaultFormat = CONFIG_NAME_LOCAL_NAME; // CONFIG_NAME_DEFAULT; + ConfigNameFormat const eDefaultFormat = ConfigNameFormat::LocalNode; // CONFIG_NAME_DEFAULT; return GetNodeNames(rNode, eDefaultFormat); } diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx index 138df08a62f2..998c4312f837 100644 --- a/unotools/source/config/eventcfg.cxx +++ b/unotools/source/config/eventcfg.cxx @@ -201,7 +201,7 @@ void GlobalEventConfig_Impl::ImplCommit() void GlobalEventConfig_Impl::initBindingInfo() { // Get ALL names of current existing list items in configuration! - Sequence< OUString > lEventNames = GetNodeNames( SETNODE_BINDINGS, utl::CONFIG_NAME_LOCAL_PATH ); + Sequence< OUString > lEventNames = GetNodeNames( SETNODE_BINDINGS, utl::ConfigNameFormat::LocalPath ); OUString aSetNode( SETNODE_BINDINGS ); aSetNode += PATHDELIMITER; -- cgit