diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-12-23 16:07:24 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2023-12-30 12:45:45 +0100 |
commit | f0a8b5b81d6be08de6e0d504616a1f09830f7c38 (patch) | |
tree | c13bfc5e50c8e1852bf50531d6fcdff6e59e718c /unotools/source | |
parent | 2c8e9ed3cbe3aed5520ce8f5888dd083f8ee50c3 (diff) |
move IsFuzzing to comphelper
and try something a bit more generic
Change-Id: I1d8256576cd02f0a589df350ba7b53059dd586a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161250
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Diffstat (limited to 'unotools/source')
-rw-r--r-- | unotools/source/config/configitem.cxx | 5 | ||||
-rw-r--r-- | unotools/source/config/configmgr.cxx | 15 | ||||
-rw-r--r-- | unotools/source/config/eventcfg.cxx | 3 | ||||
-rw-r--r-- | unotools/source/config/fontcfg.cxx | 7 | ||||
-rw-r--r-- | unotools/source/config/securityoptions.cxx | 10 | ||||
-rw-r--r-- | unotools/source/config/syslocaleoptions.cxx | 3 | ||||
-rw-r--r-- | unotools/source/config/viewoptions.cxx | 3 | ||||
-rw-r--r-- | unotools/source/misc/defaultencoding.cxx | 2 | ||||
-rw-r--r-- | unotools/source/misc/mediadescriptor.cxx | 2 |
9 files changed, 20 insertions, 30 deletions
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx index d0b6a04a697d..80a644b400f6 100644 --- a/unotools/source/config/configitem.cxx +++ b/unotools/source/config/configitem.cxx @@ -36,6 +36,7 @@ #include <com/sun/star/util/XChangesBatch.hpp> #include <o3tl/deleter.hxx> #include <osl/diagnose.h> +#include <comphelper/configuration.hxx> #include <comphelper/sequence.hxx> #include <comphelper/solarmutex.hxx> #include <comphelper/diagnose_ex.hxx> @@ -144,7 +145,7 @@ ConfigItem::ConfigItem(OUString aSubTree, ConfigItemMode nSetMode ) : m_bEnableInternalNotification(false), m_nInValueChange(0) { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return; if (nSetMode & ConfigItemMode::ReleaseTree) @@ -1172,7 +1173,7 @@ void ConfigItem::ClearModified() Reference< XHierarchicalNameAccess> ConfigItem::GetTree() { Reference< XHierarchicalNameAccess> xRet; - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return xRet; if(!m_xHierarchyAccess.is()) xRet = ConfigManager::acquireTree(*this); diff --git a/unotools/source/config/configmgr.cxx b/unotools/source/config/configmgr.cxx index e19c7c694a6a..52c48b02adf9 100644 --- a/unotools/source/config/configmgr.cxx +++ b/unotools/source/config/configmgr.cxx @@ -175,19 +175,4 @@ void utl::ConfigManager::doStoreConfigItems() { } } -static bool bIsFuzzing = false; - -#if !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) -bool utl::ConfigManager::IsFuzzing() -{ - return bIsFuzzing; -} -#endif - -void utl::ConfigManager::EnableFuzzing() -{ - bIsFuzzing = true; - LanguageTag::disable_lt_tag_parse(); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx index 62f854c003c5..b4e879265b14 100644 --- a/unotools/source/config/eventcfg.cxx +++ b/unotools/source/config/eventcfg.cxx @@ -19,6 +19,7 @@ #include <sal/config.h> +#include <comphelper/configuration.hxx> #include <comphelper/propertyvalue.hxx> #include <unotools/eventcfg.hxx> #include <unotools/configmgr.hxx> @@ -371,7 +372,7 @@ sal_Bool SAL_CALL GlobalEventConfig::hasElements( ) OUString GlobalEventConfig::GetEventName( GlobalEventId nIndex ) { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return OUString(); static rtl::Reference<GlobalEventConfig> createImpl(new GlobalEventConfig); return GlobalEventConfig::m_pImpl->GetEventName( nIndex ); diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx index 26ceda82d5fa..aad44c9ef0c9 100644 --- a/unotools/source/config/fontcfg.cxx +++ b/unotools/source/config/fontcfg.cxx @@ -23,12 +23,13 @@ #include <unotools/configmgr.hxx> #include <unotools/fontcfg.hxx> #include <unotools/fontdefs.hxx> +#include <comphelper/configuration.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/propertysequence.hxx> #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/configuration/theDefaultProvider.hpp> #include <com/sun/star/container/XNameAccess.hpp> -#include <comphelper/propertysequence.hxx> #include <unotools/syslocale.hxx> #include <rtl/ustrbuf.hxx> #include <osl/diagnose.h> @@ -89,7 +90,7 @@ DefaultFontConfiguration& DefaultFontConfiguration::get() DefaultFontConfiguration::DefaultFontConfiguration() { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return; // create configuration hierarchical access name try @@ -301,7 +302,7 @@ FontSubstConfiguration::FontSubstConfiguration() : maSubstHash( 300 ), maLanguageTag("en") { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return; try { diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx index 1c2070ab95fc..5c1c3dbe0a56 100644 --- a/unotools/source/config/securityoptions.cxx +++ b/unotools/source/config/securityoptions.cxx @@ -111,7 +111,7 @@ bool IsReadOnly( EOption eOption ) std::vector< OUString > GetSecureURLs() { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return {}; std::vector<OUString> aRet = comphelper::sequenceToContainer<std::vector<OUString>>( officecfg::Office::Common::Security::Scripting::SecureURL::get()); @@ -182,12 +182,12 @@ bool isTrustedLocationUriForUpdatingLinks(OUString const & uri) sal_Int32 GetMacroSecurityLevel() { - return utl::ConfigManager::IsFuzzing() ? 3 : officecfg::Office::Common::Security::Scripting::MacroSecurityLevel::get(); + return comphelper::IsFuzzing() ? 3 : officecfg::Office::Common::Security::Scripting::MacroSecurityLevel::get(); } void SetMacroSecurityLevel( sal_Int32 _nLevel ) { - if (utl::ConfigManager::IsFuzzing() || officecfg::Office::Common::Security::Scripting::MacroSecurityLevel::isReadOnly()) + if (comphelper::IsFuzzing() || officecfg::Office::Common::Security::Scripting::MacroSecurityLevel::isReadOnly()) return; if( _nLevel > 3 || _nLevel < 0 ) @@ -200,7 +200,7 @@ void SetMacroSecurityLevel( sal_Int32 _nLevel ) bool IsMacroDisabled() { - return utl::ConfigManager::IsFuzzing() || officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get(); + return comphelper::IsFuzzing() || officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get(); } std::vector< SvtSecurityOptions::Certificate > GetTrustedAuthors() @@ -293,7 +293,7 @@ void SetTrustedAuthors( const std::vector< Certificate >& rAuthors ) bool IsOptionSet( EOption eOption ) { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return false; bool bSet = false; switch(eOption) diff --git a/unotools/source/config/syslocaleoptions.cxx b/unotools/source/config/syslocaleoptions.cxx index 70177c5c0593..52760b87c673 100644 --- a/unotools/source/config/syslocaleoptions.cxx +++ b/unotools/source/config/syslocaleoptions.cxx @@ -18,6 +18,7 @@ */ #include <com/sun/star/uno/Sequence.hxx> +#include <comphelper/configuration.hxx> #include <sal/log.hxx> #include <i18nlangtag/mslangid.hxx> #include <i18nlangtag/languagetag.hxx> @@ -550,7 +551,7 @@ SvtSysLocaleOptions::SvtSysLocaleOptions() { pImpl = std::make_shared<SvtSysLocaleOptions_Impl>(); g_pSysLocaleOptions = pImpl; - if (!utl::ConfigManager::IsFuzzing()) + if (!comphelper::IsFuzzing()) ItemHolder1::holdConfigItem(EItem::SysLocaleOptions); } pImpl->AddListener(this); diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx index 382af97b2c8b..a17d3c48df2d 100644 --- a/unotools/source/config/viewoptions.cxx +++ b/unotools/source/config/viewoptions.cxx @@ -25,6 +25,7 @@ #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <unotools/configmgr.hxx> +#include <comphelper/configuration.hxx> #include <comphelper/configurationhelper.hxx> #include <comphelper/processfactory.hxx> #include <utility> @@ -51,7 +52,7 @@ SvtViewOptions::SvtViewOptions( EViewType eType, OUString sViewName ) case EViewType::Window: m_sListName = "Windows"; break; default: assert(false); } - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return; try diff --git a/unotools/source/misc/defaultencoding.cxx b/unotools/source/misc/defaultencoding.cxx index 552f3b8c40d7..b5a7ce2316a1 100644 --- a/unotools/source/misc/defaultencoding.cxx +++ b/unotools/source/misc/defaultencoding.cxx @@ -17,7 +17,7 @@ OUString utl_getLocaleForGlobalDefaultEncoding() { - if (utl::ConfigManager::IsFuzzing()) + if (comphelper::IsFuzzing()) return "en-US"; // First try document default language OUString result(officecfg::Office::Linguistic::General::DefaultLocale::get()); diff --git a/unotools/source/misc/mediadescriptor.cxx b/unotools/source/misc/mediadescriptor.cxx index f797728f7b3f..c846a365ec31 100644 --- a/unotools/source/misc/mediadescriptor.cxx +++ b/unotools/source/misc/mediadescriptor.cxx @@ -223,7 +223,7 @@ bool MediaDescriptor::addInputStream() /*-----------------------------------------------*/ bool MediaDescriptor::addInputStreamOwnLock() { - const bool bLock = !utl::ConfigManager::IsFuzzing() + const bool bLock = !comphelper::IsFuzzing() && officecfg::Office::Common::Misc::UseDocumentSystemFileLocking::get(); return impl_addInputStream(bLock); } |