From 8f4ff4c601c7480479c97b274e577cf074a9a2ef Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Tue, 19 Dec 2023 23:48:20 +0300 Subject: [PATCH] tdf#158375: add expert option DisableOLEAutomation Add a disable option for OLE Automation interface that is used only on Windows. Change-Id: I86f212977bb604fbae6ac2603bee037b32b5036c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161035 Tested-by: Thorsten Behrens Reviewed-by: Thorsten Behrens --- extensions/Library_oleautobridge.mk | 4 ++++ extensions/source/ole/servprov.cxx | 7 ++++++- officecfg/registry/schema/org/openoffice/Office/Common.xcs | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/extensions/Library_oleautobridge.mk b/extensions/Library_oleautobridge.mk index aa6c6d0cf2a6..38bd19eb8f06 100644 --- a/extensions/Library_oleautobridge.mk +++ b/extensions/Library_oleautobridge.mk @@ -11,6 +11,10 @@ $(eval $(call gb_Library_Library,oleautobridge)) +$(eval $(call gb_Library_use_custom_headers,oleautobridge,\ + officecfg/registry \ +)) + $(eval $(call gb_Library_set_componentfile,oleautobridge,extensions/source/ole/oleautobridge,services)) $(eval $(call gb_Library_use_api,oleautobridge,\ diff --git a/extensions/source/ole/servprov.cxx b/extensions/source/ole/servprov.cxx index f5a9323d361d..0c3920ccca11 100644 --- a/extensions/source/ole/servprov.cxx +++ b/extensions/source/ole/servprov.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -144,8 +145,12 @@ COM_DECLSPEC_NOTHROW STDMETHODIMP OneInstanceOleWrapper::CreateInstance(IUnknown SAL_INFO("extensions.olebridge", "OneInstanceOleWrapper::CreateInstance(" << riid << ")"); - HRESULT ret = ResultFromScode(E_UNEXPECTED); + if (officecfg::Office::Common::Security::Scripting::DisableOLEAutomation::get()) + { + return ResultFromScode(E_NOINTERFACE); + } + HRESULT ret = ResultFromScode(E_UNEXPECTED); const Reference& xInst = m_xInstFunction(); if (xInst.is()) { diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index ecd6a05b927b..73de7af3a267 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -2524,6 +2524,13 @@ false + + + Specifies whether or not to disable OLE Automation interface. + + + false + Warn on load when a document binds an event to a macro