From cb685f603e15d73fc518b8d4e896f96f21bab4ea Mon Sep 17 00:00:00 2001 From: Sarper Akdemir Date: Mon, 29 Jan 2024 18:40:26 +0300 Subject: tdf#158375: make it possible to hot disable embedded objects Do not require a reload of the current document for the embedded objects to be disabled. Also make sure the existing active embedded objects are disabled when DisableActiveContent is enabled via options dialog. Change-Id: I5a8f302af0cac64575c3e5ec6dbe71ec50a15442 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164367 Tested-by: Jenkins Reviewed-by: Sarper Akdemir --- embeddedobj/source/commonembedding/embedobj.cxx | 4 ++++ embeddedobj/source/commonembedding/specialobject.cxx | 5 +++++ embeddedobj/source/msole/oleembed.cxx | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'embeddedobj') diff --git a/embeddedobj/source/commonembedding/embedobj.cxx b/embeddedobj/source/commonembedding/embedobj.cxx index 0b3843852e58..61e5d1f39ef4 100644 --- a/embeddedobj/source/commonembedding/embedobj.cxx +++ b/embeddedobj/source/commonembedding/embedobj.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -475,6 +476,9 @@ uno::Sequence< sal_Int32 > const & OCommonEmbeddedObject::GetIntermediateStatesS void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState ) { + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() + && nNewState != embed::EmbedStates::LOADED ) + throw embed::UnreachableStateException(); ::osl::ResettableMutexGuard aGuard( m_aMutex ); if ( m_bDisposed ) throw lang::DisposedException(); // TODO diff --git a/embeddedobj/source/commonembedding/specialobject.cxx b/embeddedobj/source/commonembedding/specialobject.cxx index 3dc1eb7e47ef..a2f282ed1aae 100644 --- a/embeddedobj/source/commonembedding/specialobject.cxx +++ b/embeddedobj/source/commonembedding/specialobject.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -137,6 +138,10 @@ sal_Int32 SAL_CALL OSpecialEmbeddedObject::getMapUnit( sal_Int64 nAspect ) void SAL_CALL OSpecialEmbeddedObject::changeState( sal_Int32 nNewState ) { + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() + && nNewState != embed::EmbedStates::LOADED ) + throw embed::UnreachableStateException(); + if ( nNewState == embed::EmbedStates::UI_ACTIVE ) nNewState = embed::EmbedStates::INPLACE_ACTIVE; OCommonEmbeddedObject::changeState( nNewState ); diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx index 8379a78693f1..69b3ca8d239e 100644 --- a/embeddedobj/source/msole/oleembed.cxx +++ b/embeddedobj/source/msole/oleembed.cxx @@ -52,7 +52,7 @@ #include #include #include - +#include #include @@ -438,6 +438,9 @@ bool OleEmbeddedObject::TryToConvertToOOo( const uno::Reference< io::XStream >& void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState ) { + if ( officecfg::Office::Common::Security::Scripting::DisableActiveContent::get() + && nNewState != embed::EmbedStates::LOADED ) + throw embed::UnreachableStateException(); // begin wrapping related part ==================== uno::Reference< embed::XEmbeddedObject > xWrappedObject = m_xWrappedObject; if ( xWrappedObject.is() ) -- cgit