framework/source/uielement/newmenucontroller.cxx |   57 ++++++++++++++++++++---
 idl/inc/globals.hxx                              |    2 
 idl/inc/slot.hxx                                 |    2 
 idl/source/objects/slot.cxx                      |   11 ++++
 idl/source/prj/globals.cxx                       |    1 
 include/sfx2/msg.hxx                             |    5 +-
 sc/sdi/scalc.sdi                                 |   52 ++++++++++----------
 sfx2/sdi/sfx.sdi                                 |   35 ++++++++++++++
 sfx2/source/control/dispatch.cxx                 |   14 +++++
 svx/sdi/svx.sdi                                  |    6 ++
 sw/sdi/swriter.sdi                               |    3 +
 11 files changed, 152 insertions(+), 36 deletions(-)

New commits:
commit 5d25fc928846a0914954b71f52636f0232ac2618
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Dec 6 23:14:57 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:42:58 2024 +0100

    Check if the slot is active in NewMenuController::fillPopupMenu
    
    Otherwise, the popup menu gets filled, even when the respective slot
    is disabled.
    
    Change-Id: I74ff3692500ca76e6e15bf3725dd295f0213403c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178002
    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 9f773ff869d7..e3988b1ef19b 100644
--- a/framework/source/uielement/newmenucontroller.cxx
+++ b/framework/source/uielement/newmenucontroller.cxx
@@ -46,7 +46,7 @@
 
 //  Defines
 constexpr OUString aSlotNewDocDirect = u".uno:AddDirect"_ustr;
-constexpr OUStringLiteral aSlotAutoPilot = u".uno:AutoPilotMenu";
+constexpr OUString aSlotAutoPilot = u".uno:AutoPilotMenu"_ustr;
 
 using namespace com::sun::star::uno;
 using namespace com::sun::star::lang;
@@ -55,6 +55,54 @@ using namespace com::sun::star::beans;
 using namespace com::sun::star::util;
 using namespace com::sun::star::ui;
 
+namespace
+{
+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:
+    // XStatusListener
+    void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& state) 
override
+    {
+        m_bEnabled = state.IsEnabled;
+    }
+
+    // XEventListener
+    void SAL_CALL disposing(const css::lang::EventObject&) override {} // 
unused
+
+    bool m_bEnabled = false;
+};
+
+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();
+}
+}
+
 namespace framework
 {
 
@@ -296,12 +344,7 @@ void NewMenuController::fillPopupMenu( Reference< 
css::awt::XPopupMenu > const &
     if ( !pVCLPopupMenu )
         return;
 
-    Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
-    URL aTargetURL;
-    aTargetURL.Complete = m_bNewMenu ? aSlotNewDocDirect : 
OUString(aSlotAutoPilot);
-    m_xURLTransformer->parseStrict( aTargetURL );
-    Reference< XDispatch > xMenuItemDispatch = 
xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
-    if(xMenuItemDispatch == nullptr)
+    if (!isSlotActive(m_bNewMenu ? aSlotNewDocDirect : aSlotAutoPilot, 
m_xFrame, m_xURLTransformer))
         return;
 
     const std::vector< SvtDynMenuEntry > aDynamicMenuEntries =
commit f3e81c95b148dbab5ce56764f5534b5e6de53204
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Dec 6 16:20:25 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:42:54 2024 +0100

    tdf#62845: Introduce ViewerApp flag for slots, to hide in Viewer app mode
    
    Some slots make sense in read-only files, when the application runs in
    normal mode; but they make no sense in Viewer app mode. So this new flag
    is orthogonal to the existing ReadOnlyDoc flag.
    
    When it is FALSE, the respective command should not be active in the
    viewer mode. The default is TRUE.
    
    Change-Id: I5b5c75487fdf5a647aeab80129b6e84b42c00745
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177965
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Jenkins

diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx
index b72d53fafae2..ff7068113fb5 100644
--- a/idl/inc/globals.hxx
+++ b/idl/inc/globals.hxx
@@ -58,6 +58,7 @@ struct SvGlobalHashNames
     SvStringHashEntry* MM_SbxObject;
     SvStringHashEntry* MM_Container;
     SvStringHashEntry* MM_ReadOnlyDoc;
+    SvStringHashEntry* MM_ViewerApp;
     SvStringHashEntry* MM_struct;
     SvStringHashEntry* MM_DisableFlags;
 
@@ -118,6 +119,7 @@ HASH_INLINE(FastCall)
 HASH_INLINE(SbxObject)
 HASH_INLINE(Container)
 HASH_INLINE(ReadOnlyDoc)
+HASH_INLINE(ViewerApp)
 HASH_INLINE(struct)
 HASH_INLINE(DisableFlags)
 
diff --git a/idl/inc/slot.hxx b/idl/inc/slot.hxx
index 34d60f1831af..00654144db35 100644
--- a/idl/inc/slot.hxx
+++ b/idl/inc/slot.hxx
@@ -48,6 +48,7 @@ public:
     SvMetaSlot*      pNextSlot;
     sal_uInt32       nListPos;
     SvBOOL           aReadOnlyDoc;
+    SvBOOL           aViewerApp;
 
     void            WriteSlot( std::string_view rShellName,
                             sal_uInt16 nCount, std::string_view rSlotId,
@@ -101,6 +102,7 @@ public:
     bool                GetFastCall() const;
     bool                GetContainer() const;
     bool                GetReadOnlyDoc() const;
+    bool                GetViewerApp() const;
 
     sal_uInt32           GetListPos() const
                         { return nListPos; }
diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx
index 8edff3a63efd..33279a5290d2 100644
--- a/idl/source/objects/slot.cxx
+++ b/idl/source/objects/slot.cxx
@@ -30,6 +30,7 @@ SvMetaSlot::SvMetaSlot()
     , pNextSlot(nullptr)
     , nListPos(0)
     , aReadOnlyDoc ( true )
+    , aViewerApp ( true )
 {
 }
 
@@ -40,6 +41,7 @@ SvMetaSlot::SvMetaSlot( SvMetaType * pType )
     , pNextSlot(nullptr)
     , nListPos(0)
     , aReadOnlyDoc ( true )
+    , aViewerApp ( true )
 {
 }
 
@@ -49,6 +51,12 @@ bool SvMetaSlot::GetReadOnlyDoc() const
     return static_cast<SvMetaSlot *>(GetRef())->GetReadOnlyDoc();
 }
 
+bool SvMetaSlot::GetViewerApp() const
+{
+    if( aViewerApp.IsSet() || !GetRef() ) return aViewerApp;
+    return static_cast<SvMetaSlot*>(GetRef())->GetViewerApp();
+}
+
 bool SvMetaSlot::IsVariable() const
 {
     SvMetaType * pType = GetType();
@@ -171,6 +179,7 @@ void SvMetaSlot::ReadAttributesSvIdl( SvIdlDataBase & rBase,
     aStateMethod.ReadSvIdl( SvHash_StateMethod(), rInStm );
     ReadStringSvIdl( SvHash_DisableFlags(), rInStm, aDisableFlags );
     aReadOnlyDoc.ReadSvIdl( SvHash_ReadOnlyDoc(), rInStm );
+    aViewerApp.ReadSvIdl( SvHash_ViewerApp(), rInStm );
     aToggle.ReadSvIdl( SvHash_Toggle(), rInStm );
     aAutoUpdate.ReadSvIdl( SvHash_AutoUpdate(), rInStm );
     aAsynchron.ReadSvIdl( SvHash_Asynchron(), rInStm );
@@ -501,6 +510,8 @@ void SvMetaSlot::WriteSlot( std::string_view rShellName, 
sal_uInt16 nCount,
         rOutStm.WriteOString( MakeSlotName( SvHash_Container() ) ).WriteChar( 
'|' );
     if ( GetReadOnlyDoc() )
         rOutStm.WriteOString( MakeSlotName( SvHash_ReadOnlyDoc() ) 
).WriteChar( '|' );
+    if ( GetViewerApp() )
+        rOutStm.WriteOString( MakeSlotName( SvHash_ViewerApp() ) ).WriteChar( 
'|' );
     rOutStm.WriteOString( "SfxSlotMode::NONE" );
 
     rOutStm.WriteChar( ',' ) << endl;
diff --git a/idl/source/prj/globals.cxx b/idl/source/prj/globals.cxx
index c4ac9ff20a25..a4d7af15d930 100644
--- a/idl/source/prj/globals.cxx
+++ b/idl/source/prj/globals.cxx
@@ -77,6 +77,7 @@ SvGlobalHashNames::SvGlobalHashNames()
     A_ENTRY(SbxObject)
     A_ENTRY(Container)
     A_ENTRY(ReadOnlyDoc)
+    A_ENTRY(ViewerApp)
     A_ENTRY(struct)
     A_ENTRY(DisableFlags)
 {}
diff --git a/include/sfx2/msg.hxx b/include/sfx2/msg.hxx
index 88d9f68cf6ca..9b84bb62b27e 100644
--- a/include/sfx2/msg.hxx
+++ b/include/sfx2/msg.hxx
@@ -51,12 +51,13 @@ enum class SfxSlotMode {
     ACCELCONFIG     =   0x80000, // configurable keys
 
     CONTAINER       =  0x100000, // Operated by the container at InPlace
-    READONLYDOC     =  0x200000  // also available for read-only Documents
+    READONLYDOC     =  0x200000, // also available for read-only Documents
+    VIEWERAPP       =  0x400000, // also available in Viewer app mode
 };
 
 namespace o3tl
 {
-    template<> struct typed_flags<SfxSlotMode> : is_typed_flags<SfxSlotMode, 
0x13ec72cL> {};
+    template<> struct typed_flags<SfxSlotMode> : is_typed_flags<SfxSlotMode, 
0x17ec72cL> {};
 }
 
 #define SFX_EXEC_STUB( aShellClass, aExecMethod) \
diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi
index aa09ee044235..c07d4bbf7a83 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -196,6 +196,7 @@ SfxStringItem NewDoc SID_NEWDOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -233,6 +234,7 @@ SfxStringItem AddDirect SID_NEWDOCDIRECT
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -326,6 +328,7 @@ SfxStringItem AutoPilotMenu SID_AUTOPILOTMENU
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -383,6 +386,7 @@ SfxVoidItem BasicIDEAppear SID_BASICIDE_APPEAR
     AutoUpdate = FALSE,
     FastCall = TRUE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -2346,6 +2350,7 @@ SfxScriptOrganizerItem ScriptOrganizer SID_SCRIPTORGANIZER
     AutoUpdate = FALSE,
     FastCall = TRUE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -2364,6 +2369,7 @@ SfxScriptOrganizerItem MacroOrganizer SID_MACROORGANIZER
     AutoUpdate = FALSE,
     FastCall = TRUE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -2416,6 +2422,7 @@ SfxVoidItem RunMacro SID_RUNMACRO
     AutoUpdate = FALSE,
     FastCall = TRUE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -2433,6 +2440,7 @@ SfxVoidItem MacroManager SID_MACROMANAGER
     AutoUpdate = FALSE,
     FastCall = TRUE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -2982,6 +2990,7 @@ SfxVoidItem OpenTemplate SID_OPENTEMPLATE
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3697,6 +3706,7 @@ SfxVoidItem SaveSimple SID_SAVESIMPLE
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = FALSE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3714,6 +3724,7 @@ SfxStringItem Save SID_SAVEDOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = FALSE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3733,6 +3744,7 @@ SfxVoidItem SaveAll SID_SAVEDOCS
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = FALSE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3751,6 +3763,7 @@ SfxStringItem SaveAs SID_SAVEASDOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3768,6 +3781,7 @@ SfxStringItem SaveAsRemote SID_SAVEASREMOTE
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3786,6 +3800,7 @@ SfxVoidItem SaveAsTemplate SID_DOCTEMPLATE
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3805,6 +3820,7 @@ SfxVoidItem SaveACopy SID_SAVEACOPY
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3822,6 +3838,7 @@ SfxVoidItem SaveBasicAs SID_BASICSAVEAS
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -3841,6 +3858,7 @@ SfxVoidItem ExportDialog SID_EXPORT_DIALOG
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4096,6 +4114,7 @@ SfxStringItem SendMailDocAsPDF SID_MAIL_SENDDOCASPDF
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4133,6 +4152,7 @@ SfxStringItem SendMailDocAsFormat SID_MAIL_SENDDOCASFORMAT
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4151,6 +4171,7 @@ SfxStringItem SendMailDocAsMS SID_MAIL_SENDDOCASMS
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4169,6 +4190,7 @@ SfxStringItem SendMailDocAsOOo SID_MAIL_SENDDOCASOOO
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4939,6 +4961,7 @@ SfxVoidItem ExportTo SID_EXPORTDOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4957,6 +4980,7 @@ SfxVoidItem ExportToPDF SID_EXPORTDOCASPDF
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4975,6 +4999,7 @@ SfxVoidItem ExportDirectToPDF SID_DIRECTEXPORTDOCASPDF
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -4992,6 +5017,7 @@ SfxVoidItem ExportToEPUB SID_EXPORTDOCASEPUB
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -5009,6 +5035,7 @@ SfxVoidItem ExportDirectToEPUB SID_DIRECTEXPORTDOCASEPUB
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -5026,6 +5053,7 @@ SfxVoidItem RedactDoc SID_REDACTDOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -5043,6 +5071,7 @@ SfxVoidItem AutoRedactDoc SID_AUTOREDACTDOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -5274,6 +5303,7 @@ SfxVoidItem InsertBusinessCard FN_BUSINESS_CARD
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = FALSE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5293,6 +5323,7 @@ SfxVoidItem InsertLabels FN_LABEL
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = FALSE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5312,6 +5343,7 @@ SfxVoidItem NewXForms FN_XFORMS_INIT
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = FALSE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5331,6 +5363,7 @@ SfxVoidItem NewPresentation SID_NEWSD
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = TRUE,
     RecordAbsolute = FALSE,
@@ -5366,6 +5399,7 @@ SfxVoidItem AutoCorrectDlg SID_AUTO_CORRECT_DLG
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5837,6 +5871,7 @@ SfxBoolItem DevelopmentToolsDockingWindow 
SID_DEVELOPMENT_TOOLS_DOCKING_WINDOW
     AutoUpdate = TRUE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = TRUE,
     Container = FALSE,
     RecordAbsolute = FALSE,
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 87dc47d8c976..cb0f26e3c4b6 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -40,6 +40,7 @@
 #include <comphelper/lok.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/propertyvalue.hxx>
+#include <officecfg/Office/Common.hxx>
 #include <rtl/strbuf.hxx>
 #include <sal/log.hxx>
 #include <sfx2/app.hxx>
@@ -1156,6 +1157,7 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool 
bIsMDIApp, bool bIsIPOwne
         return;
 
     StatusBarId eStatBarId = StatusBarId::None;
+    const bool isViewerAppMode = 
officecfg::Office::Common::Misc::ViewerAppMode::get();
 
     SfxSlotPool* pSlotPool = &SfxSlotPool::GetSlotPool( GetFrame() );
     sal_uInt16 nTotCount = xImp->aStack.size();
@@ -1217,6 +1219,14 @@ void SfxDispatcher::Update_Impl_( bool bUIActive, bool 
bIsMDIApp, bool bIsIPOwne
             sal_uInt32 nId = pIFace->GetChildWindowId(nNo);
             const SfxSlot *pSlot = pSlotPool->GetSlot( 
static_cast<sal_uInt16>(nId) );
             SAL_INFO_IF( !pSlot, "sfx.control", "Childwindow slot missing: " 
<< nId );
+
+            if (isViewerAppMode)
+            {
+                // Skip if the slot is not allowed in viewer app mode
+                if (pSlot && !pSlot->IsMode(SfxSlotMode::VIEWERAPP))
+                    continue;
+            }
+
             if ( bReadOnlyShell )
             {
                 // only show ChildWindows if their slot is allowed for 
readonly documents
@@ -1609,6 +1619,7 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, 
SfxSlotServer& rServer)
         return false;
     }
 
+    const bool isViewerAppMode = 
officecfg::Office::Common::Misc::ViewerAppMode::get();
     bool bReadOnly = ( SfxSlotFilterState::ENABLED_READONLY != nSlotEnableMode 
&& xImp->bReadOnly );
     bool bCheckForCommentCommands = false;
 
@@ -1641,6 +1652,9 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, 
SfxSlotServer& rServer)
              ( static_cast<int>(pSlot->nDisableFlags) & 
static_cast<int>(pObjShell->GetDisableFlags()) ) != 0 )
             return false;
 
+        if (pSlot && !(pSlot->nFlags & SfxSlotMode::VIEWERAPP) && 
isViewerAppMode)
+            return false;
+
         if ( pSlot && !( pSlot->nFlags & SfxSlotMode::READONLYDOC ) && 
bReadOnly )
             return false;
 
diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 8563b1376f60..4b067f001f07 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -4465,6 +4465,7 @@ SfxVoidItem ExternalEdit SID_EXTERNAL_EDIT
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -4565,6 +4566,7 @@ SfxVoidItem ChangePicture SID_CHANGE_PICTURE
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -4599,6 +4601,7 @@ SfxVoidItem CompressGraphic SID_COMPRESS_GRAPHIC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -6071,6 +6074,7 @@ SfxBoolItem OpenReadOnly SID_FM_OPEN_READONLY
     AutoUpdate = TRUE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = TRUE,
     Container = FALSE,
     RecordAbsolute = FALSE,
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index dd123e29f6cf..bba5111a7077 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -1043,6 +1043,7 @@ SfxVoidItem EditGlossary FN_GLOSSARY_DLG
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -4672,6 +4673,7 @@ SfxVoidItem NewGlobalDoc FN_NEW_GLOBAL_DOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -4689,6 +4691,7 @@ SfxVoidItem NewHtmlDoc FN_NEW_HTML_DOC
     AutoUpdate = FALSE,
     FastCall = FALSE,
     ReadOnlyDoc = TRUE,
+    ViewerApp = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
commit c49b966d54d004d1fcb9b94e8ca34a86759a85c7
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Dec 6 16:19:00 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:42:49 2024 +0100

    Mark an svx slot as inactive in readonly mode
    
    Change-Id: I4e508c2492025bd7e39a1c67cc68016977843de3
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177964
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi
index 53f531866276..8563b1376f60 100644
--- a/svx/sdi/svx.sdi
+++ b/svx/sdi/svx.sdi
@@ -12623,7 +12623,7 @@ SfxVoidItem ThemeDialog SID_THEME_DIALOG
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
commit 62f5310fd1aa2cd6c2c2a63d69fb4a39ff7dfb93
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Fri Dec 6 16:17:43 2024 +0500
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Dec 11 11:42:45 2024 +0100

    Mark some Calc slots as inactive in readonly mode
    
    Change-Id: If1874a3d85b90e5671abdb026549ac913f990a8a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177963
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/sdi/scalc.sdi b/sc/sdi/scalc.sdi
index b8f8aa2dd505..f8a179a8d3e9 100644
--- a/sc/sdi/scalc.sdi
+++ b/sc/sdi/scalc.sdi
@@ -917,7 +917,7 @@ SfxVoidItem CreateNames FID_USE_NAME
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -1021,7 +1021,7 @@ SfxVoidItem DataFilterAutoFilter SID_AUTO_FILTER
 [
     AutoUpdate = TRUE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -1039,7 +1039,7 @@ SfxVoidItem DataFilterHideAutoFilter SID_AUTOFILTER_HIDE
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -1057,7 +1057,7 @@ SfxVoidItem DataFilterRemoveFilter SID_UNFILTER
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -1075,7 +1075,7 @@ SfxVoidItem DataFilterSpecialFilter SID_SPECIAL_FILTER
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -1093,7 +1093,7 @@ SfxVoidItem DataFilterStandardFilter SID_FILTER
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -1255,7 +1255,7 @@ SfxVoidItem DefineLabelRange SID_DEFINE_COLROWNAMERANGES
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -1543,7 +1543,7 @@ SfxVoidItem EditHeaderAndFooter SID_HFEDIT
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3240,7 +3240,7 @@ SfxVoidItem AddName FID_ADD_NAME
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3258,7 +3258,7 @@ SfxVoidItem InsertName FID_INSERT_NAME
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3820,7 +3820,7 @@ SfxStringItem NumberFormat SID_NUMBER_FORMAT
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3839,7 +3839,7 @@ SfxBoolItem NumberFormatCurrency SID_NUMBER_CURRENCY
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3857,7 +3857,7 @@ SfxVoidItem NumberFormatDate SID_NUMBER_DATE
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3875,7 +3875,7 @@ SfxVoidItem NumberFormatDecDecimals SID_NUMBER_DECDEC
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3893,7 +3893,7 @@ SfxVoidItem NumberFormatDecimal SID_NUMBER_TWODEC
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3911,7 +3911,7 @@ SfxVoidItem NumberFormatIncDecimals SID_NUMBER_INCDEC
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3929,7 +3929,7 @@ SfxVoidItem NumberFormatPercent SID_NUMBER_PERCENT
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3947,7 +3947,7 @@ SfxVoidItem NumberFormatScientific SID_NUMBER_SCIENTIFIC
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3965,7 +3965,7 @@ SfxVoidItem NumberFormatStandard SID_NUMBER_STANDARD
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -3983,7 +3983,7 @@ SfxVoidItem NumberFormatTime SID_NUMBER_TIME
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -4001,7 +4001,7 @@ SfxVoidItem NumberFormatThousands SID_NUMBER_THOUSANDS
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5649,7 +5649,7 @@ SfxVoidItem TableEvents FID_TAB_EVENTS
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5759,7 +5759,7 @@ SfxVoidItem ToggleRelative SID_TOGGLE_REL
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -5795,7 +5795,7 @@ SfxBoolItem TraceChangeMode FID_CHG_RECORD
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -6140,7 +6140,7 @@ SfxBoolItem WrapText SID_ATTR_ALIGN_LINEBREAK
 [
     AutoUpdate = FALSE,
     FastCall = FALSE,
-    ReadOnlyDoc = TRUE,
+    ReadOnlyDoc = FALSE,
     Toggle = FALSE,
     Container = FALSE,
     RecordAbsolute = FALSE,
@@ -6742,4 +6742,4 @@ SfxVoidItem CopyDelete SID_COPYDELETE
     MenuConfig = TRUE,
     ToolBoxConfig = TRUE,
     GroupId = SfxGroupId::Edit;
-]
\ No newline at end of file
+]

Reply via email to