Simplify ConfigurationWrapper singleton construction a bit
Change-Id: I8b0dd0e049ebeb3304673df3bdb9fe7c755b7750 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131335 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -41,12 +41,6 @@ namespace com::sun::star::uno { class XComponentContext; }
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
comphelper::detail::ConfigurationWrapper& GetTheConfigurationWrapper()
|
|
||||||
{
|
|
||||||
static comphelper::detail::ConfigurationWrapper WRAPPER(comphelper::getProcessComponentContext());
|
|
||||||
return WRAPPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
OUString getDefaultLocale(
|
OUString getDefaultLocale(
|
||||||
css::uno::Reference< css::uno::XComponentContext > const & context)
|
css::uno::Reference< css::uno::XComponentContext > const & context)
|
||||||
{
|
{
|
||||||
@@ -72,7 +66,7 @@ OUString extendLocalizedPath(std::u16string_view path, OUString const & locale)
|
|||||||
std::shared_ptr< comphelper::ConfigurationChanges >
|
std::shared_ptr< comphelper::ConfigurationChanges >
|
||||||
comphelper::ConfigurationChanges::create()
|
comphelper::ConfigurationChanges::create()
|
||||||
{
|
{
|
||||||
return GetTheConfigurationWrapper().createChanges();
|
return detail::ConfigurationWrapper::get().createChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
comphelper::ConfigurationChanges::~ConfigurationChanges() {}
|
comphelper::ConfigurationChanges::~ConfigurationChanges() {}
|
||||||
@@ -111,7 +105,8 @@ comphelper::ConfigurationChanges::getSet(OUString const & path) const
|
|||||||
comphelper::detail::ConfigurationWrapper const &
|
comphelper::detail::ConfigurationWrapper const &
|
||||||
comphelper::detail::ConfigurationWrapper::get()
|
comphelper::detail::ConfigurationWrapper::get()
|
||||||
{
|
{
|
||||||
return GetTheConfigurationWrapper();
|
static comphelper::detail::ConfigurationWrapper WRAPPER;
|
||||||
|
return WRAPPER;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -138,16 +133,15 @@ public:
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
comphelper::detail::ConfigurationWrapper::ConfigurationWrapper(
|
comphelper::detail::ConfigurationWrapper::ConfigurationWrapper():
|
||||||
css::uno::Reference< css::uno::XComponentContext > const & context):
|
context_(comphelper::getProcessComponentContext()),
|
||||||
context_(context),
|
access_(css::configuration::ReadWriteAccess::create(context_, "*"))
|
||||||
access_(css::configuration::ReadWriteAccess::create(context, "*"))
|
|
||||||
{
|
{
|
||||||
// Set up a configuration notifier to invalidate the cache as needed.
|
// Set up a configuration notifier to invalidate the cache as needed.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
|
css::uno::Reference< css::lang::XMultiServiceFactory > xConfigProvider(
|
||||||
css::configuration::theDefaultProvider::get( context ) );
|
css::configuration::theDefaultProvider::get( context_ ) );
|
||||||
|
|
||||||
// set root path
|
// set root path
|
||||||
css::uno::Sequence< css::uno::Any > params {
|
css::uno::Sequence< css::uno::Any > params {
|
||||||
|
@@ -85,12 +85,6 @@ class COMPHELPER_DLLPUBLIC ConfigurationWrapper {
|
|||||||
public:
|
public:
|
||||||
static ConfigurationWrapper const & get();
|
static ConfigurationWrapper const & get();
|
||||||
|
|
||||||
SAL_DLLPRIVATE explicit ConfigurationWrapper(
|
|
||||||
css::uno::Reference< css::uno::XComponentContext >
|
|
||||||
const & context);
|
|
||||||
|
|
||||||
SAL_DLLPRIVATE ~ConfigurationWrapper();
|
|
||||||
|
|
||||||
bool isReadOnly(OUString const & path) const;
|
bool isReadOnly(OUString const & path) const;
|
||||||
|
|
||||||
css::uno::Any getPropertyValue(OUString const & path) const;
|
css::uno::Any getPropertyValue(OUString const & path) const;
|
||||||
@@ -127,6 +121,10 @@ public:
|
|||||||
std::shared_ptr< ConfigurationChanges > createChanges() const;
|
std::shared_ptr< ConfigurationChanges > createChanges() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SAL_DLLPRIVATE explicit ConfigurationWrapper();
|
||||||
|
|
||||||
|
SAL_DLLPRIVATE ~ConfigurationWrapper();
|
||||||
|
|
||||||
ConfigurationWrapper(const ConfigurationWrapper&) = delete;
|
ConfigurationWrapper(const ConfigurationWrapper&) = delete;
|
||||||
ConfigurationWrapper& operator=(const ConfigurationWrapper&) = delete;
|
ConfigurationWrapper& operator=(const ConfigurationWrapper&) = delete;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user