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 | 34 ++++++++++++++++++++++++++++++++++ sfx2/source/control/dispatch.cxx | 14 ++++++++++++++ svx/sdi/svx.sdi | 4 ++++ sw/sdi/swriter.sdi | 3 +++ 9 files changed, 74 insertions(+), 2 deletions(-)
New commits: commit 18709bd7c837ae8ad8b667d86910ae25068001be Author: Mike Kaganski <[email protected]> AuthorDate: Fri Dec 6 16:20:25 2024 +0500 Commit: Miklos Vajna <[email protected]> CommitDate: Tue Dec 10 14:49:49 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/+/178013 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/idl/inc/globals.hxx b/idl/inc/globals.hxx index 0739d8757b32..35a4d0135a03 100644 --- a/idl/inc/globals.hxx +++ b/idl/inc/globals.hxx @@ -59,6 +59,7 @@ struct SvGlobalHashNames SvStringHashEntry* MM_SbxObject; SvStringHashEntry* MM_Container; SvStringHashEntry* MM_ReadOnlyDoc; + SvStringHashEntry* MM_ViewerApp; SvStringHashEntry* MM_struct; SvStringHashEntry* MM_DisableFlags; @@ -119,6 +120,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 fd8e9c0ad5ce..776d57f50648 100644 --- a/idl/inc/slot.hxx +++ b/idl/inc/slot.hxx @@ -50,6 +50,7 @@ public: SvMetaSlot* pNextSlot; sal_uInt32 nListPos; SvBOOL aReadOnlyDoc; + SvBOOL aViewerApp; void WriteSlot( std::string_view rShellName, sal_uInt16 nCount, std::string_view rSlotId, @@ -103,6 +104,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 58b3faa522b4..d5ce575f7607 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 c8d343b04bcf..005d9b05825e 100644 --- a/include/sfx2/msg.hxx +++ b/include/sfx2/msg.hxx @@ -52,12 +52,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 03a4e25843ea..ad4a5a5b4189 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, @@ -2400,6 +2406,7 @@ SfxVoidItem RunMacro SID_RUNMACRO AutoUpdate = FALSE, FastCall = TRUE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, @@ -2949,6 +2956,7 @@ SfxVoidItem OpenTemplate SID_OPENTEMPLATE AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3664,6 +3672,7 @@ SfxVoidItem SaveSimple SID_SAVESIMPLE AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = FALSE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3681,6 +3690,7 @@ SfxStringItem Save SID_SAVEDOC AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = FALSE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3700,6 +3710,7 @@ SfxVoidItem SaveAll SID_SAVEDOCS AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = FALSE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3718,6 +3729,7 @@ SfxStringItem SaveAs SID_SAVEASDOC AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3735,6 +3747,7 @@ SfxStringItem SaveAsRemote SID_SAVEASREMOTE AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3753,6 +3766,7 @@ SfxVoidItem SaveAsTemplate SID_DOCTEMPLATE AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3772,6 +3786,7 @@ SfxVoidItem SaveACopy SID_SAVEACOPY AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3789,6 +3804,7 @@ SfxVoidItem SaveBasicAs SID_BASICSAVEAS AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -3808,6 +3824,7 @@ SfxVoidItem ExportDialog SID_EXPORT_DIALOG AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4063,6 +4080,7 @@ SfxStringItem SendMailDocAsPDF SID_MAIL_SENDDOCASPDF AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4100,6 +4118,7 @@ SfxStringItem SendMailDocAsFormat SID_MAIL_SENDDOCASFORMAT AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4118,6 +4137,7 @@ SfxStringItem SendMailDocAsMS SID_MAIL_SENDDOCASMS AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4136,6 +4156,7 @@ SfxStringItem SendMailDocAsOOo SID_MAIL_SENDDOCASOOO AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4905,6 +4926,7 @@ SfxVoidItem ExportTo SID_EXPORTDOC AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4923,6 +4945,7 @@ SfxVoidItem ExportToPDF SID_EXPORTDOCASPDF AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4941,6 +4964,7 @@ SfxVoidItem ExportDirectToPDF SID_DIRECTEXPORTDOCASPDF AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4958,6 +4982,7 @@ SfxVoidItem ExportToEPUB SID_EXPORTDOCASEPUB AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4975,6 +5000,7 @@ SfxVoidItem ExportDirectToEPUB SID_DIRECTEXPORTDOCASEPUB AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -4992,6 +5018,7 @@ SfxVoidItem RedactDoc SID_REDACTDOC AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -5009,6 +5036,7 @@ SfxVoidItem AutoRedactDoc SID_AUTOREDACTDOC AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -5240,6 +5268,7 @@ SfxVoidItem InsertBusinessCard FN_BUSINESS_CARD AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = FALSE, + ViewerApp = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, @@ -5259,6 +5288,7 @@ SfxVoidItem InsertLabels FN_LABEL AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = FALSE, + ViewerApp = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, @@ -5278,6 +5308,7 @@ SfxVoidItem NewXForms FN_XFORMS_INIT AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = FALSE, + ViewerApp = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, @@ -5297,6 +5328,7 @@ SfxVoidItem NewPresentation SID_NEWSD AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = TRUE, RecordAbsolute = FALSE, @@ -5332,6 +5364,7 @@ SfxVoidItem AutoCorrectDlg SID_AUTO_CORRECT_DLG AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, @@ -5803,6 +5836,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 d08e02e2f452..d506e6b56bff 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 438f372680fd..492cfc2b07f0 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, @@ -6056,6 +6059,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 f89939b201e0..03d8b8d2c818 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, @@ -4690,6 +4691,7 @@ SfxVoidItem NewGlobalDoc FN_NEW_GLOBAL_DOC AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE, @@ -4707,6 +4709,7 @@ SfxVoidItem NewHtmlDoc FN_NEW_HTML_DOC AutoUpdate = FALSE, FastCall = FALSE, ReadOnlyDoc = TRUE, + ViewerApp = FALSE, Toggle = FALSE, Container = FALSE, RecordAbsolute = FALSE,
