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.kaganski@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski 2024-12-06 16:20:25 +05:00
parent c49b966d54
commit f3e81c95b1
9 changed files with 75 additions and 2 deletions

View File

@ -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)

View File

@ -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; }

View File

@ -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;

View File

@ -77,6 +77,7 @@ SvGlobalHashNames::SvGlobalHashNames()
A_ENTRY(SbxObject)
A_ENTRY(Container)
A_ENTRY(ReadOnlyDoc)
A_ENTRY(ViewerApp)
A_ENTRY(struct)
A_ENTRY(DisableFlags)
{}

View File

@ -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) \

View File

@ -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,

View File

@ -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;

View File

@ -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,

View File

@ -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,