diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-03-20 08:59:05 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-03-20 08:59:47 +0000 |
commit | 91e6638708c3a615f19b9018fd57e5d7a09fd08d (patch) | |
tree | 9ddb294240c4270d50f8ae5c266fd17958a1bfed /filter | |
parent | d66eeb502c4b393229c0b53f72df1b6ef4554490 (diff) |
ofz#912 support avoiding config
Change-Id: I10bef028badc1a3d1d96adaa1757fa7d9c6d2dc8
Diffstat (limited to 'filter')
-rw-r--r-- | filter/source/config/cache/filtercache.cxx | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/filter/source/config/cache/filtercache.cxx b/filter/source/config/cache/filtercache.cxx index 1065eb1bcb73..1b1f53232ccf 100644 --- a/filter/source/config/cache/filtercache.cxx +++ b/filter/source/config/cache/filtercache.cxx @@ -45,6 +45,7 @@ #include <o3tl/make_unique.hxx> +#include <unotools/configmgr.hxx> #include <unotools/configpaths.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/uri.hxx> @@ -902,49 +903,52 @@ css::uno::Reference< css::uno::XInterface > FilterCache::impl_createConfigAccess css::uno::Reference< css::uno::XInterface > xCfg; - try + if (!utl::ConfigManager::IsAvoidConfig()) { - css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( - css::configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() ) ); + try + { + css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider( + css::configuration::theDefaultProvider::get( comphelper::getProcessComponentContext() ) ); - ::std::vector< css::uno::Any > lParams; - css::beans::NamedValue aParam; + ::std::vector< css::uno::Any > lParams; + css::beans::NamedValue aParam; - // set root path - aParam.Name = "nodepath"; - aParam.Value <<= sRoot; - lParams.push_back(css::uno::makeAny(aParam)); + // set root path + aParam.Name = "nodepath"; + aParam.Value <<= sRoot; + lParams.push_back(css::uno::makeAny(aParam)); - // enable "all locales mode" ... if required - if (bLocalesMode) + // enable "all locales mode" ... if required + if (bLocalesMode) + { + aParam.Name = "locale"; + aParam.Value <<= OUString("*"); + lParams.push_back(css::uno::makeAny(aParam)); + } + + // open it + if (bReadOnly) + xCfg = xConfigProvider->createInstanceWithArguments(SERVICE_CONFIGURATIONACCESS, + comphelper::containerToSequence(lParams)); + else + xCfg = xConfigProvider->createInstanceWithArguments(SERVICE_CONFIGURATIONUPDATEACCESS, + comphelper::containerToSequence(lParams)); + + // If configuration could not be opened ... but factory method does not throwed an exception + // trigger throwing of our own CorruptedFilterConfigurationException. + // Let message empty. The normal exception text show enough information to the user. + if (! xCfg.is()) + throw css::uno::Exception( + "Got NULL reference on opening configuration file ... but no exception.", + css::uno::Reference< css::uno::XInterface >()); + } + catch(const css::uno::Exception& ex) { - aParam.Name = "locale"; - aParam.Value <<= OUString("*"); - lParams.push_back(css::uno::makeAny(aParam)); + throw css::document::CorruptedFilterConfigurationException( + "filter configuration, caught: " + ex.Message, + css::uno::Reference< css::uno::XInterface >(), + ex.Message); } - - // open it - if (bReadOnly) - xCfg = xConfigProvider->createInstanceWithArguments(SERVICE_CONFIGURATIONACCESS, - comphelper::containerToSequence(lParams)); - else - xCfg = xConfigProvider->createInstanceWithArguments(SERVICE_CONFIGURATIONUPDATEACCESS, - comphelper::containerToSequence(lParams)); - - // If configuration could not be opened ... but factory method does not throwed an exception - // trigger throwing of our own CorruptedFilterConfigurationException. - // Let message empty. The normal exception text show enough information to the user. - if (! xCfg.is()) - throw css::uno::Exception( - "Got NULL reference on opening configuration file ... but no exception.", - css::uno::Reference< css::uno::XInterface >()); - } - catch(const css::uno::Exception& ex) - { - throw css::document::CorruptedFilterConfigurationException( - "filter configuration, caught: " + ex.Message, - css::uno::Reference< css::uno::XInterface >(), - ex.Message); } return xCfg; |