[Libreoffice-commits] online.git: 4 commits - 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 11:40:56 UTC 2018


 loleaflet/src/map/handler/Map.WOPI.js |    5 +++++
 wsd/DocumentBroker.cpp                |    4 ++++
 wsd/LOOLWSD.cpp                       |    8 ++++----
 wsd/Storage.cpp                       |    7 ++++++-
 wsd/Storage.hpp                       |    6 ++++++
 wsd/reference.md                      |   23 +++++++++++++++++++++++
 6 files changed, 48 insertions(+), 5 deletions(-)

New commits:
commit 2cf0907bffbeee58606b29988d37db198e7c46f3
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Thu Dec 20 12:40:24 2018 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Dec 20 12:40:35 2018 +0100

    Document /hosting/capabilities.
    
    Change-Id: Ib18d2cc44f0e6b36d9628039457dc09f1d1b4f62

diff --git a/wsd/reference.md b/wsd/reference.md
index 70eeb9609..78165b836 100644
--- a/wsd/reference.md
+++ b/wsd/reference.md
@@ -170,3 +170,21 @@ Hosts should not save the file to storage in such cases and respond with HTTP 40
 When the user chooses "overwrite" when asked how to resolve the conflict, LibreOffice will attempt one more save operation, but this time it will lack the X-LOOL-WOPI-Timestamp header, which means "save regardless of state of the
 file".
 
+/hosting/capabilities
+---------------------
+
+With new features, it is important for the integrations to know if the Online they are using is supporting them.  For this reason, we have introduced a /hosting/capabilities endpoint that returns a JSON with information about the availability of various features.
+
+Currently the following are present:
+
+* convert-to: {available: true/false }
+
+  The property *available* is *true* when the convert-to functionality is present and correctly accessible from the WOPI host.
+
+* hasTemplateSaveAs: true/false
+
+  is *true* when the Online supports the TemplateSaveAs CheckFileInfo property.
+
+* hasMobileSupport: true/false
+
+  is *true* when the Online has a good support for the mobile devices and responsive design.
commit 21e9749d90877230b9417a579deadaaa9860f07b
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Dec 19 14:56:01 2018 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Dec 20 12:40:35 2018 +0100

    capabilities: Encourage use on mobile devices.
    
    Change-Id: Ia090503220d659b5a5daf422eaa7580630bde444

diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 541b77ed8..f43aca9c5 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2767,7 +2767,7 @@ private:
         return ostrXML.str();
     }
 
-    /// Process the capabilities.json file and return as string.
+    /// Create the /hosting/capabilities JSON and return as string.
     std::string getCapabilitiesJson(const Poco::Net::HTTPRequest& request)
     {
         std::shared_ptr<StreamSocket> socket = _socket.lock();
@@ -2783,8 +2783,8 @@ private:
         // Supports the TemplateSaveAs in CheckFileInfo?
         capabilities->set("hasTemplateSaveAs", true);
 
-        // Version
-        capabilities->set("version", LOOLWSD_VERSION);
+        // Hint to encourage use on mobile devices
+        capabilities->set("hasMobileSupport", true);
 
         std::ostringstream ostrJSON;
         capabilities->stringify(ostrJSON);
commit a877885d9c34192430828a4dd8c9910748007bb5
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Tue Dec 18 13:14:38 2018 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Dec 20 12:40:35 2018 +0100

    TemplateSaveAs: Don't forward to the client if not specified.
    
    So that we don't attempt saving as the first thing after opening.
    
    Change-Id: I30864ccdc766ec8843a60b40e991461f1be9cf8f

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 449ef0353..4199ece0c 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -542,7 +542,10 @@ 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());
+
+        if (!wopifileinfo->getTemplateSaveAs().empty())
+            wopiInfo->set("TemplateSaveAs", wopifileinfo->getTemplateSaveAs());
+
         wopiInfo->set("HidePrintOption", wopifileinfo->getHidePrintOption());
         wopiInfo->set("HideSaveOption", wopifileinfo->getHideSaveOption());
         wopiInfo->set("HideExportOption", wopifileinfo->getHideExportOption());
commit f2fcf49b3b4a2f74ff6a18c037b61387208ce7bc
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Wed Nov 14 20:16:26 2018 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Thu Dec 20 12:40:35 2018 +0100

    checkfileinfo: TemplateSaveAs to trigger PutRelativeFile...
    
    ...as the first thing after load.
    
    Change-Id: I8c372ebe0228682d4f1d7cb89fe80ea59455c5bb

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 b52241785..541b77ed8 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