sfx2/source/view/viewfrm.cxx |   63 ++++++++++++++++++++++++-------------------
 1 file changed, 36 insertions(+), 27 deletions(-)

New commits:
commit 64a5509d9aef88c04dbaad7f553c2b83b23c045a
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Wed Mar 27 16:42:48 2024 +0000
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Thu Mar 28 09:54:58 2024 +0100

    show this infobar regardless of the exact reason for presenting it
    
    Change-Id: I8af248efe8f9dda868e2f126beead875e391b563
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165402
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
    Tested-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>

diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 222eb0ff96ec..71ea0e92d4dc 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -1344,6 +1344,32 @@ void SfxViewFrame::AppendContainsMacrosInfobar()
 {
     SfxObjectShell_Impl* pObjImpl = m_xObjSh->Get_Impl();
 
+    auto aResId = STR_CONTAINS_MACROS;
+    if (SvtSecurityOptions::IsMacroDisabled())
+        aResId = STR_MACROS_DISABLED;
+    else if (pObjImpl->aMacroMode.hasUnsignedContentError())
+        aResId = STR_MACROS_DISABLED_CONTENT_UNSIGNED;
+    // The idea here is to always present an infobar is there was some
+    // macro/script related potential hazard disabled in the source document
+    auto pInfoBar = AppendInfoBar("macro", SfxResId(STR_MACROS_DISABLED_TITLE),
+                                  SfxResId(aResId), InfobarType::WARNING);
+    if (!pInfoBar)
+        return;
+
+    // Then show buttons to help navigate to whatever that hazard is.  Whether
+    // that is included macros, so the user could delete them.  Or events bound
+    // to scripts which could be cleared.  But there are likely other cases not
+    // captured here, which could be added, various blocked features where its
+    // likely still worth displaying the infobar that they have been disabled,
+    // even if we don't currently provide a way to indicate what exactly those
+    // are and how to remove them.
+
+    // No access to macro dialog when macros are disabled globally, so return
+    // early without adding buttons to help explore what the 
macros/script/events
+    // might be.
+    if (SvtSecurityOptions::IsMacroDisabled())
+        return;
+
     // what's the difference between pObjImpl->documentStorageHasMacros() and 
pObjImpl->aMacroMode.hasMacroLibrary() ?
     bool bHasDocumentMacros = pObjImpl->aMacroMode.hasMacroLibrary();
 
@@ -1380,35 +1406,18 @@ void SfxViewFrame::AppendContainsMacrosInfobar()
         }
     }
 
-    if (bHasDocumentMacros || bHasBoundConfigEvents)
+    if (bHasDocumentMacros)
     {
-        auto aResId = STR_CONTAINS_MACROS;
-        if (SvtSecurityOptions::IsMacroDisabled())
-            aResId = STR_MACROS_DISABLED;
-        else if (pObjImpl->aMacroMode.hasUnsignedContentError())
-            aResId = STR_MACROS_DISABLED_CONTENT_UNSIGNED;
-        auto pInfoBar = AppendInfoBar("macro", 
SfxResId(STR_MACROS_DISABLED_TITLE),
-                                      SfxResId(aResId), InfobarType::WARNING);
-        if (!pInfoBar)
-            return;
-
-        // No access to macro dialog when macros are disabled globally.
-        if (SvtSecurityOptions::IsMacroDisabled())
-            return;
-
-        if (bHasDocumentMacros)
-        {
-            weld::Button& rMacroButton = pInfoBar->addButton();
-            rMacroButton.set_label(SfxResId(STR_MACROS));
-            rMacroButton.connect_clicked(LINK(this, SfxViewFrame, 
MacroButtonHandler));
-        }
+        weld::Button& rMacroButton = pInfoBar->addButton();
+        rMacroButton.set_label(SfxResId(STR_MACROS));
+        rMacroButton.connect_clicked(LINK(this, SfxViewFrame, 
MacroButtonHandler));
+    }
 
-        if (bHasBoundConfigEvents)
-        {
-            weld::Button& rEventButton = pInfoBar->addButton();
-            rEventButton.set_label(SfxResId(STR_EVENTS));
-            rEventButton.connect_clicked(LINK(this, SfxViewFrame, 
EventButtonHandler));
-        }
+    if (bHasBoundConfigEvents)
+    {
+        weld::Button& rEventButton = pInfoBar->addButton();
+        rEventButton.set_label(SfxResId(STR_EVENTS));
+        rEventButton.connect_clicked(LINK(this, SfxViewFrame, 
EventButtonHandler));
     }
 }
 

Reply via email to