framework/source/uielement/popuptoolbarcontroller.cxx |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit 1cc3652c704a0932e91e7ec3b7b3f3cd48a03e23
Author:     Mike Kaganski <[email protected]>
AuthorDate: Mon Dec 9 14:54:47 2024 +0500
Commit:     Miklos Vajna <[email protected]>
CommitDate: Tue Dec 10 15:57:10 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/+/178137
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx 
b/framework/source/uielement/popuptoolbarcontroller.cxx
index b17e8a6bfc60..120c209d5dc9 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -457,6 +457,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 ) )
@@ -539,9 +542,9 @@ void SaveToolbarController::statusChanged( const 
css::frame::FeatureStateEvent&
 
     bool bLastReadOnly = m_bReadOnly;
     m_bReadOnly = m_xStorable.is() && m_xStorable->isReadonly();
+    OUString sCommand = m_bReadOnly ? OUString( ".uno:SaveAs" ) : 
m_aCommandURL;
     if ( bLastReadOnly != m_bReadOnly )
     {
-        OUString sCommand = m_bReadOnly ? OUString( ".uno:SaveAs" ) : 
m_aCommandURL;
         auto aProperties = 
vcl::CommandInfoProvider::GetCommandProperties(sCommand,
             vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
         pToolBox->SetQuickHelpText( nId,
@@ -551,8 +554,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