loleaflet/src/control/Control.Menubar.js | 5 +++++ loleaflet/src/map/handler/Map.WOPI.js | 2 ++ wsd/DocumentBroker.cpp | 1 + wsd/Storage.cpp | 4 +++- wsd/Storage.hpp | 4 ++++ 5 files changed, 15 insertions(+), 1 deletion(-)
New commits: commit 6a73c19d160a312cc4345014ae9f79ee63f9b234 Author: Pranav Kant <pran...@collabora.co.uk> Date: Tue Oct 3 20:36:02 2017 +0530 Show save-as option based on CheckFileInfo params If UserCanNotWriteRelative is mentioned in the CheckFileInfo response. Change-Id: I33d2e21159b3e18ae88fd72f404f2d1d1d9b64e5 diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js index 56319ebc..14f62e3b 100644 --- a/loleaflet/src/control/Control.Menubar.js +++ b/loleaflet/src/control/Control.Menubar.js @@ -187,6 +187,7 @@ L.Control.Menubar = L.Control.extend({ presentation: [ {name: _('File'), id: 'file', type: 'menu', menu: [ {name: _('Save'), id: 'save', type: 'action'}, + {name: _('Save As'), id: 'saveas', type: 'action'}, {name: _('Print'), id: 'print', type: 'action'}, {name: _('See revision history'), id: 'rev-history', type: 'action'}, {name: _('Download as'), id: 'downloadas', type: 'menu', menu: [ @@ -251,6 +252,7 @@ L.Control.Menubar = L.Control.extend({ spreadsheet: [ {name: _('File'), id: 'file', type: 'menu', menu: [ {name: _('Save'), id: 'save', type: 'action'}, + {name: _('Save As'), id: 'saveas', type: 'action'}, {name: _('Print'), id: 'print', type: 'action'}, {name: _('See revision history'), id: 'rev-history', type: 'action'}, {name: _('Download as'), id:'downloadas', type: 'menu', menu: [ @@ -775,6 +777,9 @@ L.Control.Menubar = L.Control.extend({ if (menu[i].id === 'save' && this._map['wopi'].HideSaveOption) continue; + if (menu[i].id === 'saveas' && this._map['wopi'].UserCanNotWriteRelative) + continue; + if (menu[i].id && menu[i].id.startsWith('fullscreen-presentation') && this._map['wopi'].HideExportOption) continue; diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js index 211ab469..f1bd0701 100644 --- a/loleaflet/src/map/handler/Map.WOPI.js +++ b/loleaflet/src/map/handler/Map.WOPI.js @@ -16,6 +16,7 @@ L.Map.WOPI = L.Handler.extend({ DisableExport: false, DisableCopy: false, DisableInactiveMessages: false, + UserCanNotWriteRelative: true, _appLoadedConditions: { docloaded: false, @@ -67,6 +68,7 @@ L.Map.WOPI = L.Handler.extend({ this.DisableExport = !!wopiInfo['DisableExport']; this.DisableCopy = !!wopiInfo['DisableCopy']; this.DisableInactiveMessages = !!wopiInfo['DisableInactiveMessages']; + this.UserCanNotWriteRelative = !!wopiInfo['UserCanNotWriteRelative']; this._map.fire('postMessage', {msgId: 'App_LoadingStatus', args: {Status: 'Frame_Ready'}}); }, diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 6eff18bb..7a72393d 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -470,6 +470,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s wopiInfo->set("DisableExport", wopifileinfo->_disableExport); wopiInfo->set("DisableCopy", wopifileinfo->_disableCopy); wopiInfo->set("DisableInactiveMessages", wopifileinfo->_disableInactiveMessages); + wopiInfo->set("UserCanNotWriteRelative", wopifileinfo->_userCanNotWriteRelative); std::ostringstream ossWopiInfo; wopiInfo->stringify(ossWopiInfo); diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index 6a02649a..7612fa98 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -552,6 +552,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au bool disableCopy = false; bool disableInactiveMessages = false; std::string lastModifiedTime; + bool userCanNotWriteRelative = true; LOG_DBG("WOPI::CheckFileInfo returned: " << resMsg << ". Call duration: " << callDuration.count() << "s"); Poco::JSON::Object::Ptr object; @@ -575,6 +576,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au getWOPIValue(object, "DisableCopy", disableCopy); getWOPIValue(object, "DisableInactiveMessages", disableInactiveMessages); getWOPIValue(object, "LastModifiedTime", lastModifiedTime); + getWOPIValue(object, "UserCanNotWriteRelative", userCanNotWriteRelative); } else { @@ -585,7 +587,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au const Poco::Timestamp modifiedTime = iso8601ToTimestamp(lastModifiedTime); _fileInfo = FileInfo({filename, ownerId, modifiedTime, size}); - return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, userExtraInfo, watermarkText, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, disableExport, disableCopy, disableInactiveMessages, callDuration})); + return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo({userId, userName, userExtraInfo, watermarkText, canWrite, postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption, enableOwnerTermination, disablePrint, disableExport, disableCopy, disableInactiveMessages, userCanNotWriteRelative, callDuration})); } /// PutRelativeFile - uri format: http://server/<...>/wopi*/files/<id>/ diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp index 6b3ce9af..e94108e0 100644 --- a/wsd/Storage.hpp +++ b/wsd/Storage.hpp @@ -225,6 +225,7 @@ public: const bool disableExport, const bool disableCopy, const bool disableInactiveMessages, + const bool userCanNotWriteRelative, const std::chrono::duration<double> callDuration) : _userid(userid), _username(username), @@ -239,6 +240,7 @@ public: _disableExport(disableExport), _disableCopy(disableCopy), _disableInactiveMessages(disableInactiveMessages), + _userCanNotWriteRelative(userCanNotWriteRelative), _callDuration(callDuration) { _userExtraInfo = userExtraInfo; @@ -272,6 +274,8 @@ public: bool _disableCopy; /// If WOPI host has allowed the loleaflet to show texts on the overlay informing about inactivity, or if the integration is handling that. bool _disableInactiveMessages; + /// If set to false, users can access the save-as functionality + bool _userCanNotWriteRelative; /// Time it took to call WOPI's CheckFileInfo std::chrono::duration<double> _callDuration; }; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits