From f3e81c95b148dbab5ce56764f5534b5e6de53204 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Fri, 6 Dec 2024 16:20:25 +0500 Subject: [PATCH] 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 Tested-by: Jenkins --- 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 +++-- sfx2/sdi/sfx.sdi | 35 ++++++++++++++++++++++++++++++++ sfx2/source/control/dispatch.cxx | 14 +++++++++++++ svx/sdi/svx.sdi | 4 ++++ sw/sdi/swriter.sdi | 3 +++ 9 files changed, 75 insertions(+), 2 deletions(-) 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(GetRef())->GetReadOnlyDoc(); } +bool SvMetaSlot::GetViewerApp() const +{ + if( aViewerApp.IsSet() || !GetRef() ) return aViewerApp; + return static_cast(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 : is_typed_flags {}; + template<> struct typed_flags : is_typed_flags {}; } #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 #include #include +#include #include #include #include @@ -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(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(pSlot->nDisableFlags) & static_cast(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,