basctl/source/basicide/baside2.cxx                  |    3 ++-
 framework/source/uielement/macrosmenucontroller.cxx |    4 ++--
 scripting/Library_protocolhandler.mk                |    1 +
 scripting/source/protocolhandler/scripthandler.cxx  |    3 ++-
 sfx2/source/appl/appserv.cxx                        |    5 ++---
 sfx2/source/view/viewfrm.cxx                        |    3 +--
 6 files changed, 10 insertions(+), 9 deletions(-)

New commits:
commit a049c6ef426affe9ab347b4cec589919d687673e
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Dec 11 11:42:46 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:43:20 2024 +0100

    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.kagan...@collabora.com>

diff --git a/basctl/source/basicide/baside2.cxx 
b/basctl/source/basicide/baside2.cxx
index dd75a88b06fc..4d805f65113a 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -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(
diff --git a/framework/source/uielement/macrosmenucontroller.cxx 
b/framework/source/uielement/macrosmenucontroller.cxx
index 9899b9fa6ac2..1e78355d7738 100644
--- a/framework/source/uielement/macrosmenucontroller.cxx
+++ b/framework/source/uielement/macrosmenucontroller.cxx
@@ -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;
diff --git a/scripting/Library_protocolhandler.mk 
b/scripting/Library_protocolhandler.mk
index 31599c3d865b..d0fb4169625a 100644
--- a/scripting/Library_protocolhandler.mk
+++ b/scripting/Library_protocolhandler.mk
@@ -32,6 +32,7 @@ $(eval $(call gb_Library_use_libraries,protocolhandler,\
        sal \
        sfx \
        tl \
+       utl \
        vcl \
 ))
 
diff --git a/scripting/source/protocolhandler/scripthandler.cxx 
b/scripting/source/protocolhandler/scripthandler.cxx
index bcf53854ebf6..5e87f1623e7d 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -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;
diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index fdc4a8e0b3ee..ad24a1ec6092 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -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);
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index da03b23e6cf9..2d150615bf2a 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -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" ) )
                     {

Reply via email to