[Libreoffice-commits] online.git: wsd/LOOLWSD.cpp
Muhammet Kara (via logerrit)
logerrit at kemper.freedesktop.org
Tue Oct 8 13:33:56 UTC 2019
wsd/LOOLWSD.cpp | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
New commits:
commit 2c167a2df29f358478a801d10a3c09bfad2381bf
Author: Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Mon Oct 7 22:51:38 2019 +0300
Commit: Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Tue Oct 8 15:33:37 2019 +0200
wsd: Add FullSheetPreview support for convert-to endpoint
This requires commit 28eb367a3743002ecb1037e2dd2ca3c709f6893d
on core distro/collabora/cp-6.2
Change-Id: I02a5616810a930c6add3c3a0373b5e25e863236c
Reviewed-on: https://gerrit.libreoffice.org/80418
Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>
Tested-by: Muhammet Kara <muhammet.kara at collabora.com>
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 4559f4c80..d0dd39878 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2501,6 +2501,18 @@ private:
return "application/octet-stream";
}
+ static bool isSpreadsheet(const std::string& fileName)
+ {
+ std::string sContentType = getContentType(fileName);
+
+ if (sContentType == "application/vnd.oasis.opendocument.spreadsheet"
+ || sContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
+ || sContentType == "application/vnd.ms-excel")
+ return true;
+ else
+ return false;
+ }
+
void handlePostRequest(const Poco::Net::HTTPRequest& request,
Poco::MemoryInputStream& message,
SocketDisposition &disposition)
@@ -2531,7 +2543,10 @@ private:
ConvertToPartHandler handler(/*convertTo =*/ true);
HTMLForm form(request, message, handler);
+ std::string sOptions("");
std::string format = (form.has("format") ? form.get("format") : "");
+ std::string sFullSheetPreview = (form.has("FullSheetPreview") ? form.get("FullSheetPreview") : "");
+ bool bFullSheetPreview = sFullSheetPreview == "true" ? true : false;
// prefer what is in the URI
if (tokens.count() > 3)
@@ -2545,6 +2560,15 @@ private:
Poco::URI uriPublic = DocumentBroker::sanitizeURI(fromPath);
const std::string docKey = DocumentBroker::getDocKey(uriPublic);
+ if (bFullSheetPreview && format == "pdf" && isSpreadsheet(fromPath))
+ {
+ sOptions += std::string(",FullSheetPreview=") + sFullSheetPreview + std::string("FULLSHEETPREVEND");
+ }
+ else
+ {
+ bFullSheetPreview = false;
+ }
+
// This lock could become a bottleneck.
// In that case, we can use a pool and index by publicPath.
std::unique_lock<std::mutex> docBrokersLock(DocBrokersMutex);
@@ -2566,7 +2590,7 @@ private:
nullptr, _id, uriPublic, docBroker, isReadOnly, "nocliphost");
if (clientSession)
{
- disposition.setMove([docBroker, clientSession, format]
+ disposition.setMove([docBroker, clientSession, format, sOptions]
(const std::shared_ptr<Socket> &moveSocket)
{
// Perform all of this after removing the socket
@@ -2577,7 +2601,7 @@ private:
// We no longer own this socket.
moveSocket->setThreadOwner(std::thread::id(0));
- docBroker->addCallback([docBroker, moveSocket, clientSession, format]()
+ docBroker->addCallback([docBroker, moveSocket, clientSession, format, sOptions]()
{
auto streamSocket = std::static_pointer_cast<StreamSocket>(moveSocket);
clientSession->setSaveAsSocket(streamSocket);
@@ -2603,7 +2627,7 @@ private:
URI::encode(toJailURL, "", encodedTo);
// Convert it to the requested format.
- const auto saveas = "saveas url=" + encodedTo + " format=" + format + " options=";
+ const auto saveas = "saveas url=" + encodedTo + " format=" + format + " options=" + sOptions;
std::vector<char> saveasRequest(saveas.begin(), saveas.end());
clientSession->handleMessage(true, WSOpCode::Text, saveasRequest);
});
More information about the Libreoffice-commits
mailing list