tdf#103641: Implement ability to hide save, print, export options
Add more WOPI extensions for this - HidePrintOption, HideSaveOption, HideExportOption. Setting HideExportOption to 'true' in WOPI CheckFileInfo response would hide the 'Download as' option from the File menu. Change-Id: Ia2259ee9525cc6c4331a52e2221af4df188eab07
This commit is contained in:
parent
9c5928a87b
commit
2168617d60
7 changed files with 55 additions and 7 deletions
4
loleaflet/dist/toolbar/toolbar.js
vendored
4
loleaflet/dist/toolbar/toolbar.js
vendored
|
@ -751,6 +751,10 @@ map.on('doclayerinit', function () {
|
|||
}
|
||||
}
|
||||
|
||||
if (map['wopi'].HideSaveOption) {
|
||||
toolbar.hide('save');
|
||||
}
|
||||
|
||||
var statusbar = w2ui['toolbar-down'];
|
||||
switch (docType) {
|
||||
case 'spreadsheet':
|
||||
|
|
|
@ -463,6 +463,15 @@ L.Control.Menubar = L.Control.extend({
|
|||
continue;
|
||||
}
|
||||
|
||||
if (menu[i].id === 'print' && this._map['wopi'].HidePrintOption)
|
||||
continue;
|
||||
|
||||
if (menu[i].id === 'save' && this._map['wopi'].HideSaveOption)
|
||||
continue;
|
||||
|
||||
if (menu[i].id === 'downloadas' && this._map['wopi'].HideExportOption)
|
||||
continue;
|
||||
|
||||
var liItem = L.DomUtil.create('li', '');
|
||||
var aItem = L.DomUtil.create('a', '', liItem);
|
||||
aItem.innerHTML = menu[i].name;
|
||||
|
@ -470,6 +479,9 @@ L.Control.Menubar = L.Control.extend({
|
|||
if (menu[i].type === 'menu') {
|
||||
var ulItem = L.DomUtil.create('ul', '', liItem);
|
||||
var subitemList = this._createMenu(menu[i].menu);
|
||||
if (!subitemList.length) {
|
||||
continue;
|
||||
}
|
||||
for (var j in subitemList) {
|
||||
ulItem.appendChild(subitemList[j]);
|
||||
}
|
||||
|
|
|
@ -188,6 +188,10 @@ L.Socket = L.Class.extend({
|
|||
this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {'DocumentLoadedTime': this._map['wopi'].DocumentLoadedTime}});
|
||||
}
|
||||
|
||||
this._map['wopi'].HidePrintOption = !!wopiInfo['HidePrintOption'];
|
||||
this._map['wopi'].HideSaveOption = !!wopiInfo['HideSaveOption'];
|
||||
this._map['wopi'].HideExportOption = !!wopiInfo['HideExportOption'];
|
||||
|
||||
return;
|
||||
}
|
||||
else if (textMsg.startsWith('close: ')) {
|
||||
|
|
|
@ -6,6 +6,9 @@ L.Map.WOPI = L.Handler.extend({
|
|||
|
||||
PostMessageOrigin: false,
|
||||
DocumentLoadedTime: false,
|
||||
HidePrintOption: false,
|
||||
HideSaveOption: false,
|
||||
HideExportOption: false,
|
||||
|
||||
initialize: function(map) {
|
||||
this._map = map;
|
||||
|
|
|
@ -239,17 +239,21 @@ bool DocumentBroker::load(std::shared_ptr<ClientSession>& session, const std::st
|
|||
session->setReadOnly();
|
||||
}
|
||||
|
||||
// Construct a JSON containing relevant WOPI host properties
|
||||
Object::Ptr wopiInfo = new Object();
|
||||
if (!wopifileinfo._postMessageOrigin.empty())
|
||||
{
|
||||
// Construct a JSON containing relevant WOPI host properties
|
||||
Object::Ptr wopiInfo = new Object();
|
||||
wopiInfo->set("PostMessageOrigin", wopifileinfo._postMessageOrigin);
|
||||
std::ostringstream ossWopiInfo;
|
||||
wopiInfo->stringify(ossWopiInfo);
|
||||
|
||||
session->sendTextFrame("wopi: " + ossWopiInfo.str());
|
||||
}
|
||||
|
||||
wopiInfo->set("HidePrintOption", wopifileinfo._hidePrintOption);
|
||||
wopiInfo->set("HideSaveOption", wopifileinfo._hideSaveOption);
|
||||
wopiInfo->set("HideExportOption", wopifileinfo._hideExportOption);
|
||||
|
||||
std::ostringstream ossWopiInfo;
|
||||
wopiInfo->stringify(ossWopiInfo);
|
||||
session->sendTextFrame("wopi: " + ossWopiInfo.str());
|
||||
|
||||
// Mark the session as 'Document owner' if WOPI hosts supports it
|
||||
if (wopifileinfo._enableOwnerTermination && userid == _storage->getFileInfo()._ownerId)
|
||||
{
|
||||
|
|
|
@ -320,6 +320,9 @@ WopiStorage::WOPIFileInfo WopiStorage::getWOPIFileInfo(const Poco::URI& uriPubli
|
|||
bool canWrite = false;
|
||||
bool enableOwnerTermination = false;
|
||||
std::string postMessageOrigin;
|
||||
bool hidePrintOption = false;
|
||||
bool hideSaveOption = false;
|
||||
bool hideExportOption = false;
|
||||
std::string resMsg;
|
||||
Poco::StreamCopier::copyToString(rs, resMsg);
|
||||
|
||||
|
@ -346,6 +349,12 @@ WopiStorage::WOPIFileInfo WopiStorage::getWOPIFileInfo(const Poco::URI& uriPubli
|
|||
canWrite = canWriteVar.isString() ? (canWriteVar.toString() == "true") : false;
|
||||
const auto postMessageOriginVar = getOrWarn(object, "PostMessageOrigin");
|
||||
postMessageOrigin = postMessageOriginVar.isString() ? postMessageOriginVar.toString() : "";
|
||||
const auto hidePrintOptionVar = getOrWarn(object, "HidePrintOption");
|
||||
hidePrintOption = hidePrintOptionVar.isString() ? (hidePrintOptionVar.toString() == "true") : false;
|
||||
const auto hideSaveOptionVar = getOrWarn(object, "HideSaveOption");
|
||||
hideSaveOption = hideSaveOptionVar.isString() ? (hideSaveOptionVar.toString() == "true") : false;
|
||||
const auto hideExportOptionVar = getOrWarn(object, "HideExportOption");
|
||||
hideExportOption = hideExportOptionVar.isString() ? (hideExportOptionVar.toString() == "true") : false;
|
||||
const auto enableOwnerTerminationVar = getOrWarn(object, "EnableOwnerTermination");
|
||||
enableOwnerTermination = enableOwnerTerminationVar.isString() ? (enableOwnerTerminationVar.toString() == "true") : false;
|
||||
}
|
||||
|
@ -358,7 +367,7 @@ WopiStorage::WOPIFileInfo WopiStorage::getWOPIFileInfo(const Poco::URI& uriPubli
|
|||
_fileInfo = FileInfo({filename, ownerId, Poco::Timestamp(), size});
|
||||
}
|
||||
|
||||
return WOPIFileInfo({userId, userName, canWrite, postMessageOrigin, enableOwnerTermination, callDuration});
|
||||
return WOPIFileInfo({userId, userName, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, callDuration});
|
||||
}
|
||||
|
||||
/// uri format: http://server/<...>/wopi*/files/<id>/content
|
||||
|
|
|
@ -169,12 +169,18 @@ public:
|
|||
const std::string& username,
|
||||
const bool userCanWrite,
|
||||
const std::string& postMessageOrigin,
|
||||
const bool hidePrintOption,
|
||||
const bool hideSaveOption,
|
||||
const bool hideExportOption,
|
||||
const bool enableOwnerTermination,
|
||||
const std::chrono::duration<double> callDuration)
|
||||
: _userid(userid),
|
||||
_username(username),
|
||||
_userCanWrite(userCanWrite),
|
||||
_postMessageOrigin(postMessageOrigin),
|
||||
_hidePrintOption(hidePrintOption),
|
||||
_hideSaveOption(hideSaveOption),
|
||||
_hideExportOption(hideExportOption),
|
||||
_enableOwnerTermination(enableOwnerTermination),
|
||||
_callDuration(callDuration)
|
||||
{
|
||||
|
@ -188,6 +194,12 @@ public:
|
|||
bool _userCanWrite;
|
||||
/// WOPI Post message property
|
||||
std::string _postMessageOrigin;
|
||||
/// Hide print button from UI
|
||||
bool _hidePrintOption;
|
||||
/// Hide save button from UI
|
||||
bool _hideSaveOption;
|
||||
/// Hide 'Download as' button/menubar item from UI
|
||||
bool _hideExportOption;
|
||||
/// If WOPI host has enabled owner termination feature on
|
||||
bool _enableOwnerTermination;
|
||||
/// Time it took to call WOPI's CheckFileInfo
|
||||
|
|
Loading…
Reference in a new issue