[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - loleaflet/src wsd/DocumentBroker.cpp wsd/LOOLWSD.cpp wsd/reference.md wsd/Storage.cpp wsd/Storage.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Dec 20 12:00:38 UTC 2018
loleaflet/src/map/handler/Map.WOPI.js | 5 +++++
wsd/DocumentBroker.cpp | 1 +
wsd/LOOLWSD.cpp | 2 +-
wsd/Storage.cpp | 7 ++++++-
wsd/Storage.hpp | 6 ++++++
wsd/reference.md | 5 +++++
6 files changed, 24 insertions(+), 2 deletions(-)
New commits:
commit b8d27017a09119a2f08856542f5aa654e41570e4
Author: Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Nov 14 20:16:26 2018 +0100
Commit: Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Dec 20 13:00:21 2018 +0100
checkfileinfo: TemplateSaveAs to trigger PutRelativeFile...
...as the first thing after load.
Change-Id: I8c372ebe0228682d4f1d7cb89fe80ea59455c5bb
Reviewed-on: https://gerrit.libreoffice.org/65483
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index b0d5a7750..cf0bf7013 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -92,6 +92,11 @@ L.Map.WOPI = L.Handler.extend({
}
}
});
+
+ if ('TemplateSaveAs' in wopiInfo) {
+ this._map.showBusy(_('Creating new file from template...'), false);
+ this._map.saveAs(wopiInfo['TemplateSaveAs']);
+ }
},
resetAppLoaded: function() {
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 631f95a39..449ef0353 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -542,6 +542,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
wopifileinfo->setHideExportOption(true);
wopiInfo->set("BaseFileName", wopiStorage->getFileInfo().getFilename());
+ wopiInfo->set("TemplateSaveAs", wopifileinfo->getTemplateSaveAs());
wopiInfo->set("HidePrintOption", wopifileinfo->getHidePrintOption());
wopiInfo->set("HideSaveOption", wopifileinfo->getHideSaveOption());
wopiInfo->set("HideExportOption", wopifileinfo->getHideExportOption());
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7907fbf3d..5a5215ec2 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2781,7 +2781,7 @@ private:
capabilities->set("convert-to", convert_to);
// Supports the TemplateSaveAs in CheckFileInfo?
- capabilities->set("hasTemplateSaveAs", false);
+ capabilities->set("hasTemplateSaveAs", true);
// Version
capabilities->set("version", LOOLWSD_VERSION);
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index ebb5acd42..a5ebcdc39 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -484,6 +484,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au
std::string obfuscatedUserId;
std::string userExtraInfo;
std::string watermarkText;
+ std::string templateSaveAs;
bool canWrite = false;
bool enableOwnerTermination = false;
std::string postMessageOrigin;
@@ -515,6 +516,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au
JsonUtil::findJSONValue(object, "OwnerId", ownerId);
JsonUtil::findJSONValue(object, "UserId", userId);
JsonUtil::findJSONValue(object, "UserFriendlyName", userName);
+ JsonUtil::findJSONValue(object, "TemplateSaveAs", templateSaveAs);
// Anonymize key values.
if (LOOLWSD::AnonymizeFilenames || LOOLWSD::AnonymizeUsernames)
@@ -550,7 +552,10 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au
object->remove("ObfuscatedUserId");
if (LOOLWSD::AnonymizeFilenames)
+ {
object->remove("BaseFileName");
+ object->remove("TemplateSaveAs");
+ }
if (LOOLWSD::AnonymizeUsernames)
{
@@ -604,7 +609,7 @@ std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Au
setFileInfo(FileInfo({filename, ownerId, modifiedTime, size}));
return std::unique_ptr<WopiStorage::WOPIFileInfo>(new WOPIFileInfo(
- {userId, obfuscatedUserId, userName, userExtraInfo, watermarkText, canWrite,
+ {userId, obfuscatedUserId, userName, userExtraInfo, watermarkText, templateSaveAs, canWrite,
postMessageOrigin, hidePrintOption, hideSaveOption, hideExportOption,
enableOwnerTermination, disablePrint, disableExport, disableCopy,
disableInactiveMessages, userCanNotWriteRelative, enableInsertRemoteImage, enableShare,
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 3591ac8b1..bf228721a 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -311,6 +311,7 @@ public:
const std::string& username,
const std::string& userExtraInfo,
const std::string& watermarkText,
+ const std::string& templateSaveAs,
const bool userCanWrite,
const std::string& postMessageOrigin,
const bool hidePrintOption,
@@ -333,6 +334,7 @@ public:
_obfuscatedUserId(obfuscatedUserId),
_username(username),
_watermarkText(watermarkText),
+ _templateSaveAs(templateSaveAs),
_userCanWrite(userCanWrite),
_postMessageOrigin(postMessageOrigin),
_hidePrintOption(hidePrintOption),
@@ -363,6 +365,8 @@ public:
const std::string& getWatermarkText() const { return _watermarkText; }
+ const std::string& getTemplateSaveAs() const { return _templateSaveAs; }
+
bool getUserCanWrite() const { return _userCanWrite; }
std::string& getPostMessageOrigin() { return _postMessageOrigin; }
@@ -414,6 +418,8 @@ public:
std::string _userExtraInfo;
/// In case a watermark has to be rendered on each tile.
std::string _watermarkText;
+ /// In case we want to use this file as a template, it should be first re-saved under this name (using PutRelativeFile).
+ std::string _templateSaveAs;
/// If user accessing the file has write permission
bool _userCanWrite;
/// WOPI Post message property
diff --git a/wsd/reference.md b/wsd/reference.md
index 243e60d17..70eeb9609 100644
--- a/wsd/reference.md
+++ b/wsd/reference.md
@@ -59,6 +59,11 @@ A string for the domain the host page sends/receives PostMessages from, we only
### Size
Size of the file in bytes (64bit)
+### TemplateSaveAs
+In case this file should be treated as a template, the file name (potentially including a suitable path - that the WOPI host has to interpret) will be used as the real name under which the resulting file will be stored.
+
+Storing the file resulting from a template uses the normal PutRelativeFile workflow, which means a new CheckFileInfo will have to be sent upon load of the resulting file.
+
### UserCanWrite
A boolean flag, indicating whether the user has permission to edit and/or over-write the file. If not set PutFile will fail.
More information about the Libreoffice-commits
mailing list