common/Session.cpp | 8 +++++++- common/Session.hpp | 7 +++++++ kit/Kit.cpp | 7 ++++--- loolwsd.xml.in | 4 ++++ wsd/ClientSession.cpp | 1 + 5 files changed, 23 insertions(+), 4 deletions(-)
New commits: commit 564414e6b2b0d4ec299253bde3cc95628b54e295 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Mon Aug 26 16:23:04 2019 -0400 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon Sep 2 11:25:33 2019 -0400 Add watermark opacity setting. Change-Id: I839e8aef91acfed40d4afd8c1b50176ed54c670a diff --git a/common/Session.cpp b/common/Session.cpp index 1c37e5ba2..f7ed7f33f 100644 --- a/common/Session.cpp +++ b/common/Session.cpp @@ -55,7 +55,8 @@ Session::Session(const std::string& name, const std::string& id, bool readOnly) _isReadOnly(readOnly), _docPassword(""), _haveDocPassword(false), - _isDocPasswordProtected(false) + _isDocPasswordProtected(false), + _watermarkOpacity(0.2) { } @@ -156,6 +157,11 @@ void Session::parseDocOptions(const std::vector<std::string>& tokens, int& part, Poco::URI::decode(value, _watermarkText); ++offset; } + else if (name == "watermarkOpacity") + { + _watermarkOpacity = std::stod(value); + ++offset; + } else if (name == "timestamp") { timestamp = value; diff --git a/common/Session.hpp b/common/Session.hpp index f09af7574..49f48b2e9 100644 --- a/common/Session.hpp +++ b/common/Session.hpp @@ -102,8 +102,12 @@ public: const std::string& getDocOptions() const { return _docOptions; } + bool hasWatermark() const { return !_watermarkText.empty() && _watermarkOpacity > 0.0; } + const std::string& getWatermarkText() const { return _watermarkText; } + double getWatermarkOpacity() const { return _watermarkOpacity; } + const std::string& getLang() const { return _lang; } bool getHaveDocPassword() const { return _haveDocPassword; } @@ -203,6 +207,9 @@ private: /// In case a watermark has to be rendered on each tile. std::string _watermarkText; + /// Opacity in case a watermark has to be rendered on each tile. + double _watermarkOpacity; + /// Language for the document based on what the user has in the UI. std::string _lang; }; diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 35c37818c..7bfe2dd96 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -632,13 +632,14 @@ public: class Watermark { public: - Watermark(const std::shared_ptr<lok::Document>& loKitDoc, const std::string& text) + Watermark(const std::shared_ptr<lok::Document>& loKitDoc, const std::string& text, + const std::shared_ptr<ChildSession> & session) : _loKitDoc(loKitDoc) , _text(text) , _font("Liberation Sans") , _width(0) , _height(0) - , _alphaLevel(0.2) + , _alphaLevel(session->getWatermarkOpacity()) { } @@ -1731,7 +1732,7 @@ private: _renderOpts = renderOpts; if (!watermarkText.empty()) - _docWatermark.reset(new Watermark(_loKitDocument, watermarkText)); + _docWatermark.reset(new Watermark(_loKitDocument, watermarkText, session)); } else { diff --git a/loolwsd.xml.in b/loolwsd.xml.in index 012d74ffc..e3f2e9e29 100644 --- a/loolwsd.xml.in +++ b/loolwsd.xml.in @@ -105,6 +105,10 @@ <capabilities desc="Should we require capabilities to isolate processes into chroot jails" type="bool" default="true">true</capabilities> </security> + <watermark> + <opacity desc="Opacity of on-screen watermark from 0.0 to 1.0" type="double" default="0.2"></opacity> + </watermark> + <storage desc="Backend storage"> <filesystem allow="false" /> <wopi desc="Allow/deny wopi storage. Mutually exclusive with webdav." allow="true"> diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index f3b970c79..c26c804a7 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -475,6 +475,7 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/, std::string encodedWatermarkText; Poco::URI::encode(getWatermarkText(), "", encodedWatermarkText); oss << " watermarkText=" << encodedWatermarkText; + oss << " watermarkOpacity=" << LOOLWSD::getConfigValue<double>("watermark.opacity", 0.2); } if (!getDocOptions().empty()) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits