Use SvtSecurityOptions::IsMacroDisabled() instead of officecfg check

The change is most important for Viewer app mode, which also disables
macros

Change-Id: Ie305649dafbb3717e7986a4b437c38b09ffc1802
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178275
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2024-12-11 11:42:46 +05:00
parent 1c32970c0d
commit a049c6ef42
6 changed files with 10 additions and 9 deletions

View File

@@ -58,6 +58,7 @@
#include <svl/whiter.hxx>
#include <svx/svxids.hrc>
#include <tools/debug.hxx>
#include <unotools/securityoptions.hxx>
#include <utility>
#include <vcl/locktoplevels.hxx>
#include <vcl/errinf.hxx>
@@ -318,7 +319,7 @@ void ModulWindow::BasicExecute()
{
// #116444# check security settings before macro execution
ScriptDocument aDocument( GetDocument() );
bool bMacrosDisabled = officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
bool bMacrosDisabled = SvtSecurityOptions::IsMacroDisabled();
if (bMacrosDisabled || (aDocument.isDocument() && !aDocument.allowMacros()))
{
std::unique_ptr<weld::MessageDialog> xBox(

View File

@@ -28,6 +28,7 @@
#include <osl/mutex.hxx>
#include <toolkit/awt/vclxmenu.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/securityoptions.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
@@ -67,8 +68,7 @@ MacrosMenuController::~MacrosMenuController()
// private function
void MacrosMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > const & rPopupMenu )
{
bool bMacrosDisabled = officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
if (bMacrosDisabled)
if (SvtSecurityOptions::IsMacroDisabled())
return;
SolarMutexGuard aSolarMutexGuard;

View File

@@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_libraries,protocolhandler,\
sal \
sfx \
tl \
utl \
vcl \
))

View File

@@ -43,6 +43,7 @@
#include <cppuhelper/supportsservice.hxx>
#include <framework/documentundoguard.hxx>
#include <officecfg/Office/Common.hxx>
#include <unotools/securityoptions.hxx>
#include <com/sun/star/uri/XUriReference.hpp>
#include <com/sun/star/uri/XVndSunStarScriptUrlReference.hpp>
@@ -117,7 +118,7 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
const URL& aURL, const Sequence < PropertyValue >& lArgs,
const Reference< XDispatchResultListener >& xListener )
{
if (officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get())
if (SvtSecurityOptions::IsMacroDisabled())
return;
sal_Int16 aState = css::frame::DispatchResultState::FAILURE;

View File

@@ -72,6 +72,7 @@
#include <vcl/toolbox.hxx>
#include <unotools/moduleoptions.hxx>
#include <unotools/securityoptions.hxx>
#include <rtl/bootstrap.hxx>
#include <com/sun/star/frame/ModuleManager.hpp>
@@ -2057,9 +2058,7 @@ void SfxApplication::OfaState_Impl(SfxItemSet &rSet)
if ( comphelper::LibreOfficeKit::isActive() )
rSet.DisableItem( SID_AUTO_CORRECT_DLG );
bool bMacrosDisabled
= officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
if (bMacrosDisabled)
if (SvtSecurityOptions::IsMacroDisabled())
{
rSet.DisableItem(SID_RUNMACRO);
rSet.DisableItem(SID_MACROORGANIZER);

View File

@@ -3401,8 +3401,7 @@ void SfxViewFrame::MiscState_Impl(SfxItemSet &rSet)
case SID_RECORDMACRO :
{
const OUString& sName{GetObjectShell()->GetFactory().GetFactoryName()};
bool bMacrosDisabled = officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
if (bMacrosDisabled ||
if (SvtSecurityOptions::IsMacroDisabled() ||
!officecfg::Office::Common::Misc::MacroRecorderMode::get() ||
( sName!="swriter" && sName!="scalc" ) )
{