impress: restrict presentation in readonly mode
When export is disabled or watermarks are enabled, presentation in readonly mode is disabled. This is checked in the frontend by the WOPI property `DisablePresentation` that is synthesized in the wsd. Also check when calling the presentation command. WOPIFileInfo::getWatermarkText() is stubbed on mobile. Signed-off-by: Hubert Figuière <hub@collabora.com> Change-Id: I4f7aff9f670f7523dfcf396f6009a272df9d5af8pull/8986/head
parent
72bbc375be
commit
22e789a420
|
@ -1324,7 +1324,6 @@ L.Control.Menubar = L.Control.extend({
|
||||||
!window.ThisIsAMobileApp ? 'exportdirectpdf' : 'downloadas-pdf', !window.ThisIsAMobileApp ? 'exportepub' : 'downloadas-epub', // file menu
|
!window.ThisIsAMobileApp ? 'exportdirectpdf' : 'downloadas-pdf', !window.ThisIsAMobileApp ? 'exportepub' : 'downloadas-epub', // file menu
|
||||||
'downloadas-ods', 'downloadas-xls', 'downloadas-xlsx', 'downloadas-csv', 'closedocument', // file menu
|
'downloadas-ods', 'downloadas-xls', 'downloadas-xlsx', 'downloadas-csv', 'closedocument', // file menu
|
||||||
'fullscreen', 'zoomin', 'zoomout', 'zoomreset', 'showstatusbar', 'togglemenubar', 'showresolved', 'toggledarktheme', // view menu
|
'fullscreen', 'zoomin', 'zoomout', 'zoomreset', 'showstatusbar', 'togglemenubar', 'showresolved', 'toggledarktheme', // view menu
|
||||||
'fullscreen-presentation', 'presentation-currentslide', 'present-in-window', // slide menu
|
|
||||||
'about', 'keyboard-shortcuts', 'latestupdates', 'feedback', 'online-help', 'report-an-issue', // help menu
|
'about', 'keyboard-shortcuts', 'latestupdates', 'feedback', 'online-help', 'report-an-issue', // help menu
|
||||||
'insertcomment'
|
'insertcomment'
|
||||||
]
|
]
|
||||||
|
@ -1341,6 +1340,10 @@ L.Control.Menubar = L.Control.extend({
|
||||||
// Use original template as provided by server
|
// Use original template as provided by server
|
||||||
this._menubarCont = map.mainMenuTemplate.cloneNode(true);
|
this._menubarCont = map.mainMenuTemplate.cloneNode(true);
|
||||||
$('#main-menu-state').after(this._menubarCont);
|
$('#main-menu-state').after(this._menubarCont);
|
||||||
|
|
||||||
|
if (!this._map['wopi'].DisablePresentation)
|
||||||
|
this.options.allowedViewModeActions = this.options.allowedViewModeActions.concat(['fullscreen-presentation', 'presentation-currentslide', 'present-in-window']);
|
||||||
|
|
||||||
this._initializeMenu(this.options.initial);
|
this._initializeMenu(this.options.initial);
|
||||||
|
|
||||||
map.on('doclayerinit', this._onDocLayerInit, this);
|
map.on('doclayerinit', this._onDocLayerInit, this);
|
||||||
|
|
|
@ -36,6 +36,11 @@ L.Map.SlideShow = L.Handler.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_onFullScreen: function (e) {
|
_onFullScreen: function (e) {
|
||||||
|
if (this._checkPresentationDisabled()) {
|
||||||
|
this._notifyPresentationDisabled();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this._checkAlreadyPresenting()) {
|
if (this._checkAlreadyPresenting()) {
|
||||||
this._notifyAlreadyPresenting();
|
this._notifyAlreadyPresenting();
|
||||||
return;
|
return;
|
||||||
|
@ -94,6 +99,11 @@ L.Map.SlideShow = L.Handler.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_onPresentWindow: function (e) {
|
_onPresentWindow: function (e) {
|
||||||
|
if (this._checkPresentationDisabled()) {
|
||||||
|
this._notifyPresentationDisabled();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this._checkAlreadyPresenting()) {
|
if (this._checkAlreadyPresenting()) {
|
||||||
this._notifyAlreadyPresenting();
|
this._notifyAlreadyPresenting();
|
||||||
return;
|
return;
|
||||||
|
@ -295,6 +305,16 @@ L.Map.SlideShow = L.Handler.extend({
|
||||||
_('OK'), null, false);
|
_('OK'), null, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_checkPresentationDisabled: function() {
|
||||||
|
return this._map['wopi'].DisablePresentation;
|
||||||
|
},
|
||||||
|
|
||||||
|
_notifyPresentationDisabled: function() {
|
||||||
|
this._map.uiManager.showInfoModal('presentation-disabled-modal',
|
||||||
|
_('Presentation disabled'),
|
||||||
|
_('Presentation mode has been disabled for this document'), '',
|
||||||
|
_('OK'), null, false);
|
||||||
|
},
|
||||||
|
|
||||||
_onSlideWindowKeyPress: function(e) {
|
_onSlideWindowKeyPress: function(e) {
|
||||||
if (e.code === 'Escape') {
|
if (e.code === 'Escape') {
|
||||||
|
|
|
@ -32,6 +32,7 @@ L.Map.WOPI = L.Handler.extend({
|
||||||
SupportsRename: false,
|
SupportsRename: false,
|
||||||
UserCanRename: false,
|
UserCanRename: false,
|
||||||
UserCanWrite: false,
|
UserCanWrite: false,
|
||||||
|
DisablePresentation: false,
|
||||||
|
|
||||||
_appLoadedConditions: {
|
_appLoadedConditions: {
|
||||||
docloaded: false,
|
docloaded: false,
|
||||||
|
@ -127,6 +128,7 @@ L.Map.WOPI = L.Handler.extend({
|
||||||
this.UserCanRename = !!wopiInfo['UserCanRename'];
|
this.UserCanRename = !!wopiInfo['UserCanRename'];
|
||||||
this.EnableShare = !!wopiInfo['EnableShare'];
|
this.EnableShare = !!wopiInfo['EnableShare'];
|
||||||
this.UserCanWrite = !!wopiInfo['UserCanWrite'];
|
this.UserCanWrite = !!wopiInfo['UserCanWrite'];
|
||||||
|
this.DisablePresentation = wopiInfo['DisablePresentation'];
|
||||||
|
|
||||||
if (this.UserCanWrite && !app.isReadOnly()) // There are 2 places that set the file permissions, WOPI and URI. Don't change permission if URI doesn't allow.
|
if (this.UserCanWrite && !app.isReadOnly()) // There are 2 places that set the file permissions, WOPI and URI. Don't change permission if URI doesn't allow.
|
||||||
app.setPermission('edit');
|
app.setPermission('edit');
|
||||||
|
|
|
@ -81,6 +81,7 @@ public:
|
||||||
bool getDisableExport() const { return false; }
|
bool getDisableExport() const { return false; }
|
||||||
bool getDisableCopy() const { return false; }
|
bool getDisableCopy() const { return false; }
|
||||||
bool getEnableOwnerTermination() const { return false; }
|
bool getEnableOwnerTermination() const { return false; }
|
||||||
|
std::string getWatermarkText() const { return std::string(); }
|
||||||
|
|
||||||
TriState getDisableChangeTrackingShow() const { return TriState::Unset; }
|
TriState getDisableChangeTrackingShow() const { return TriState::Unset; }
|
||||||
TriState getDisableChangeTrackingRecord() const { return TriState::Unset; }
|
TriState getDisableChangeTrackingRecord() const { return TriState::Unset; }
|
||||||
|
|
|
@ -1493,6 +1493,12 @@ bool ClientSession::filterMessage(const std::string& message) const
|
||||||
allowed = false;
|
allowed = false;
|
||||||
LOG_WRN("WOPI host has disabled export for this session");
|
LOG_WRN("WOPI host has disabled export for this session");
|
||||||
}
|
}
|
||||||
|
else if (id == "slideshow" && _wopiFileInfo &&
|
||||||
|
(_wopiFileInfo->getDisableExport() || !_wopiFileInfo->getWatermarkText().empty()))
|
||||||
|
{
|
||||||
|
allowed = false;
|
||||||
|
LOG_WRN("WOPI host has disabled slideshow for this session");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -1230,6 +1230,8 @@ DocumentBroker::updateSessionWithWopiInfo(const std::shared_ptr<ClientSession>&
|
||||||
wopiInfo->set("HideChangeTrackingControls", wopiFileInfo->getHideChangeTrackingControls() ==
|
wopiInfo->set("HideChangeTrackingControls", wopiFileInfo->getHideChangeTrackingControls() ==
|
||||||
WopiStorage::WOPIFileInfo::TriState::True);
|
WopiStorage::WOPIFileInfo::TriState::True);
|
||||||
wopiInfo->set("IsOwner", session->isDocumentOwner());
|
wopiInfo->set("IsOwner", session->isDocumentOwner());
|
||||||
|
bool disablePresentation = !watermarkText.empty() || wopiFileInfo->getDisableExport() || wopiFileInfo->getHideExportOption();
|
||||||
|
wopiInfo->set("DisablePresentation", disablePresentation);
|
||||||
|
|
||||||
std::ostringstream ossWopiInfo;
|
std::ostringstream ossWopiInfo;
|
||||||
wopiInfo->stringify(ossWopiInfo);
|
wopiInfo->stringify(ossWopiInfo);
|
||||||
|
|
Loading…
Reference in New Issue