summaryrefslogtreecommitdiffstats
path: root/comphelper/source/misc/configuration.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/source/misc/configuration.cxx')
-rw-r--r--comphelper/source/misc/configuration.cxx52
1 files changed, 35 insertions, 17 deletions
diff --git a/comphelper/source/misc/configuration.cxx b/comphelper/source/misc/configuration.cxx
index 67009cd9f864..b7d97bbb6533 100644
--- a/comphelper/source/misc/configuration.cxx
+++ b/comphelper/source/misc/configuration.cxx
@@ -38,12 +38,6 @@ namespace com::sun::star::uno { class XComponentContext; }
namespace {
-comphelper::detail::ConfigurationWrapper& GetTheConfigurationWrapper(const css::uno::Reference< css::uno::XComponentContext >& xContext)
-{
- static comphelper::detail::ConfigurationWrapper WRAPPER(xContext);
- return WRAPPER;
-}
-
OUString getDefaultLocale(
css::uno::Reference< css::uno::XComponentContext > const & context)
{
@@ -68,9 +62,9 @@ OUString extendLocalizedPath(std::u16string_view path, OUString const & locale)
std::shared_ptr< comphelper::ConfigurationChanges >
comphelper::ConfigurationChanges::create(
- css::uno::Reference< css::uno::XComponentContext > const & context)
+ css::uno::Reference<css::uno::XComponentContext> const & context)
{
- return GetTheConfigurationWrapper(context).createChanges();
+ return detail::ConfigurationWrapper::get(context).createChanges();
}
comphelper::ConfigurationChanges::~ConfigurationChanges() {}
@@ -108,15 +102,16 @@ comphelper::ConfigurationChanges::getSet(OUString const & path) const
comphelper::detail::ConfigurationWrapper const &
comphelper::detail::ConfigurationWrapper::get(
- css::uno::Reference< css::uno::XComponentContext > const & context)
+ css::uno::Reference<css::uno::XComponentContext> const & context)
{
- return GetTheConfigurationWrapper(context);
+ static comphelper::detail::ConfigurationWrapper WRAPPER(context);
+ return WRAPPER;
}
comphelper::detail::ConfigurationWrapper::ConfigurationWrapper(
- css::uno::Reference< css::uno::XComponentContext > const & context):
- context_(context),
- access_(css::configuration::ReadWriteAccess::create(context, "*"))
+ css::uno::Reference<css::uno::XComponentContext> const & context):
+ context_(context.is() ? context : comphelper::getProcessComponentContext()),
+ access_(css::configuration::ReadWriteAccess::create(context_, "*"))
{}
comphelper::detail::ConfigurationWrapper::~ConfigurationWrapper() {}
@@ -130,18 +125,21 @@ bool comphelper::detail::ConfigurationWrapper::isReadOnly(OUString const & path)
!= 0;
}
-css::uno::Any comphelper::detail::ConfigurationWrapper::getPropertyValue(OUString const& path) const
+css::uno::Any comphelper::detail::ConfigurationWrapper::getPropertyValue(std::u16string_view path) const
{
+ // should be short-circuited in ConfigurationProperty::get()
+ assert(!comphelper::IsFuzzing());
+
// Cache the configuration access, since some of the keys are used in hot code.
// Note that this cache is only used by the officecfg:: auto-generated code, using it for anything
// else would be unwise because the cache could end up containing stale entries.
static std::mutex gMutex;
static std::map<OUString, css::uno::Reference< css::container::XNameAccess >> gAccessMap;
- sal_Int32 idx = path.lastIndexOf("/");
+ sal_Int32 idx = path.rfind('/');
assert(idx!=-1);
- OUString parentPath = path.copy(0, idx);
- OUString childName = path.copy(idx+1);
+ OUString parentPath(path.substr(0, idx));
+ OUString childName(path.substr(idx+1));
std::scoped_lock aGuard(gMutex);
@@ -252,6 +250,7 @@ void comphelper::ConfigurationListener::dispose()
listener->dispose();
}
maListeners.clear();
+ mxConfig.clear();
mbDisposed = true;
}
@@ -284,4 +283,23 @@ void SAL_CALL comphelper::ConfigurationListener::propertyChange(
}
}
+namespace comphelper {
+
+static bool bIsFuzzing = false;
+
+#if !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
+bool IsFuzzing()
+{
+ return bIsFuzzing;
+}
+#endif
+
+void EnableFuzzing()
+{
+ bIsFuzzing = true;
+ LanguageTag::disable_lt_tag_parse();
+}
+
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */