framework/source/uielement/newmenucontroller.cxx      |   42 ++++++++----------
 framework/source/uielement/popuptoolbarcontroller.cxx |    9 ++-
 svx/sdi/svx.sdi                                       |    6 --
 unotools/source/config/securityoptions.cxx            |    4 +
 4 files changed, 31 insertions(+), 30 deletions(-)

New commits:
commit 1c32970c0d9bbe6ba5778416b6d08c57bcffd3ea
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Dec 11 06:24:54 2024 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:43:16 2024 +0100

    Disable macros in Viewer Mode
    
    Prevents "This document contains macros" dialog on file open.
    
    Change-Id: I92cbd6b5f919ccfa5812b4a90ec72ad4378d009a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178273
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/unotools/source/config/securityoptions.cxx 
b/unotools/source/config/securityoptions.cxx
index 263a32808aec..19fa71b3beba 100644
--- a/unotools/source/config/securityoptions.cxx
+++ b/unotools/source/config/securityoptions.cxx
@@ -205,7 +205,9 @@ void SetMacroSecurityLevel( sal_Int32 _nLevel )
 
 bool IsMacroDisabled()
 {
-    return comphelper::IsFuzzing() || 
officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
+    return comphelper::IsFuzzing()
+           || 
officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get()
+           || officecfg::Office::Common::Misc::ViewerAppMode::get();
 }
 
 std::vector< SvtSecurityOptions::Certificate > GetTrustedAuthors()
commit c876e6c4a5dd5fac61dd34f2605116377ab31c0d
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Dec 10 17:23:47 2024 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:43:12 2024 +0100

    These slots don't make sense even in read-only mode
    
    Thanks Miklos for spotting this!
    
    Change-Id: Ic4e85b2357f5cd98ce2932e50e8e84e8bcb25f9f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178261
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 4b067f001f07..e1e00a4b80b2 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -4565,8 +4565,7 @@ SfxVoidItem ChangePicture SID_CHANGE_PICTURE
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
-    ViewerApp = FALSE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -4600,8 +4599,7 @@ SfxVoidItem CompressGraphic SID_COMPRESS_GRAPHIC
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
-    ViewerApp = FALSE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
commit bf77951004d49a0fc9b7d2bd36ce67b8f1902e47
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Tue Dec 10 15:57:20 2024 +0100
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:43:08 2024 +0100

    Simplify the slot status check, and add some comments
    
    Change-Id: Ie2a77f0c5157a03a3461ae54d372382b1e57fe2b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178238
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    (cherry picked from commit 4172ffad04f4a72d9865612530ae4d9117f1eb59)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178245
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/framework/source/uielement/newmenucontroller.cxx 
b/framework/source/uielement/newmenucontroller.cxx
index e3988b1ef19b..9d32ef15dbf7 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -57,26 +57,12 @@ using namespace com::sun::star::ui;
 
 namespace
 {
+/**
+ * A simple status listener, storing the "enabled" status from the last status 
notification
+ */
 class SlotStatusGetter : public 
comphelper::WeakImplHelper<css::frame::XStatusListener>
 {
 public:
-    SlotStatusGetter(const css::util::URL& url,
-                     const css::uno::Reference<css::frame::XFrame>& frame)
-    {
-        if (auto provider = frame.query<css::frame::XDispatchProvider>())
-        {
-            if (auto xDispatch = provider->queryDispatch(url, {}, 0))
-            {
-                // Avoid self-destruction
-                osl_atomic_increment(&m_refCount);
-                // Adding as listener will automatically emit an initial 
notification
-                xDispatch->addStatusListener(this, url);
-                xDispatch->removeStatusListener(this, url);
-                osl_atomic_decrement(&m_refCount);
-            }
-        }
-    }
-
     bool isEnabled() const { return m_bEnabled; }
 
 private:
@@ -95,11 +81,23 @@ private:
 bool isSlotActive(const OUString& slot, const 
css::uno::Reference<css::frame::XFrame>& frame,
     const css::uno::Reference<css::util::XURLTransformer>& transformer)
 {
-    css::util::URL url;
-    url.Complete = slot;
-    transformer->parseStrict(url);
-    rtl::Reference slotStatus(new SlotStatusGetter(url, frame));
-    return slotStatus->isEnabled();
+    if (auto provider = frame.query<css::frame::XDispatchProvider>())
+    {
+        css::util::URL url;
+        url.Complete = slot;
+        transformer->parseStrict(url);
+        if (auto dispatch = provider->queryDispatch(url, {}, 0))
+        {
+            rtl::Reference slotStatus(new SlotStatusGetter);
+            // Adding as listener will automatically emit an initial 
notification. The status
+            // reported in the notification will be stored in the 
SlotStatusGetter instance.
+            dispatch->addStatusListener(slotStatus, url);
+            dispatch->removeStatusListener(slotStatus, url);
+            return slotStatus->isEnabled();
+        }
+    }
+
+    return false;
 }
 }
 
commit d799a66e07ac8d9a4f8162734d66930858b9411b
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Dec 9 14:54:47 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:43:03 2024 +0100

    Check if the correct slot is active in SaveToolbarController::statusChanged
    
    Otherwise, the button may still be active, even with the slot disabled.
    
    Change-Id: Id292b69513a7de8248d33fa813a8b09964f30434
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178124
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx 
b/framework/source/uielement/popuptoolbarcontroller.cxx
index 81424825b2c2..2b3b70da963b 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -459,6 +459,9 @@ void SaveToolbarController::initialize( const 
css::uno::Sequence< css::uno::Any
 {
     PopupMenuToolbarController::initialize( aArguments );
 
+    // Also listen to the status of the slot used for read-only case
+    m_aListenerMap.emplace(u".uno:SaveAs"_ustr, 
css::uno::Reference<css::frame::XDispatch>());
+
     ToolBox* pToolBox = nullptr;
     ToolBoxItemId nId;
     if ( !getToolboxId( nId, &pToolBox ) )
@@ -541,9 +544,9 @@ void SaveToolbarController::statusChanged( const 
css::frame::FeatureStateEvent&
 
     bool bLastReadOnly = m_bReadOnly;
     m_bReadOnly = m_xStorable.is() && m_xStorable->isReadonly();
+    OUString sCommand = m_bReadOnly ? u".uno:SaveAs"_ustr : m_aCommandURL;
     if ( bLastReadOnly != m_bReadOnly )
     {
-        OUString sCommand = m_bReadOnly ? u".uno:SaveAs"_ustr : m_aCommandURL;
         auto aProperties = 
vcl::CommandInfoProvider::GetCommandProperties(sCommand,
             vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
         pToolBox->SetQuickHelpText( nId,
@@ -553,8 +556,8 @@ void SaveToolbarController::statusChanged( const 
css::frame::FeatureStateEvent&
         updateImage();
     }
 
-    if ( !m_bReadOnly )
-        pToolBox->EnableItem( nId, rEvent.IsEnabled );
+    if (rEvent.FeatureURL.Complete == sCommand)
+        pToolBox->EnableItem(nId, rEvent.IsEnabled);
 }
 
 void SaveToolbarController::modified( const css::lang::EventObject& /*rEvent*/ 
)

Reply via email to