diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-07-06 11:50:38 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2021-08-17 17:13:28 +0200 |
commit | 1692ee279c7d0a6aa8210c923a6923c6919f46d3 (patch) | |
tree | b1027c36c867c0488e40005fd08460921e941b14 | |
parent | 37dd6e18f5cf498d230ffe8a0a395cfdf9625e0c (diff) |
jsdialog: dump image for toolitems
Change-Id: If47eb57cc18c6f04e5b2e3a14a6bcea657e03df8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118472
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120543
Tested-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 1 | ||||
-rw-r--r-- | vcl/jsdialog/jsdialogbuilder.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/toolbox2.cxx | 18 |
3 files changed, 24 insertions, 1 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx index cfc5e52e5bb9..8bfa06d0742b 100644 --- a/vcl/inc/jsdialog/jsdialogbuilder.hxx +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -568,6 +568,7 @@ public: virtual void set_menu_item_active(const OString& rIdent, bool bActive) override; virtual void set_item_sensitive(const OString& rIdent, bool bSensitive) override; + virtual void set_item_icon_name(const OString& rIdent, const OUString& rIconName) override; }; class JSTextView final : public JSWidget<SalInstanceTextView, ::VclMultiLineEdit> diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx index 4f0e6aa6bfc5..03087e4fd82a 100644 --- a/vcl/jsdialog/jsdialogbuilder.cxx +++ b/vcl/jsdialog/jsdialogbuilder.cxx @@ -1382,6 +1382,12 @@ void JSToolbar::set_item_sensitive(const OString& rIdent, bool bSensitive) sendUpdate(); } +void JSToolbar::set_item_icon_name(const OString& rIdent, const OUString& rIconName) +{ + SalInstanceToolbar::set_item_icon_name(rIdent, rIconName); + sendUpdate(); +} + JSTextView::JSTextView(JSDialogSender* pSender, ::VclMultiLineEdit* pTextView, SalInstanceBuilder* pBuilder, bool bTakeOwnership) : JSWidget<SalInstanceTextView, ::VclMultiLineEdit>(pSender, pTextView, pBuilder, diff --git a/vcl/source/window/toolbox2.cxx b/vcl/source/window/toolbox2.cxx index 47bc4d1ff743..c3f53303e15a 100644 --- a/vcl/source/window/toolbox2.cxx +++ b/vcl/source/window/toolbox2.cxx @@ -21,9 +21,11 @@ #include <vcl/uitest/logger.hxx> #include <sal/log.hxx> +#include <comphelper/base64.hxx> #include <comphelper/processfactory.hxx> #include <boost/property_tree/ptree.hpp> +#include <vcl/cvtgrf.hxx> #include <vcl/svapp.hxx> #include <vcl/idle.hxx> #include <vcl/bitmap.hxx> @@ -1749,15 +1751,29 @@ void ToolBox::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter) } else { + OUString sCommand = GetItemCommand(nId); rJsonWriter.put("type", "toolitem"); rJsonWriter.put("text", GetItemText(nId)); - rJsonWriter.put("command", GetItemCommand(nId)); + rJsonWriter.put("command", sCommand); if (!IsItemVisible(nId)) rJsonWriter.put("visible", false); if (GetItemBits(nId) & ToolBoxItemBits::DROPDOWN) rJsonWriter.put("dropdown", true); if (!IsItemEnabled(nId)) rJsonWriter.put("enabled", false); + + Image aImage = GetItemImage(nId); + if (!sCommand.startsWith(".uno:") && !!aImage) + { + SvMemoryStream aOStm(6535, 6535); + if(GraphicConverter::Export(aOStm, aImage.GetBitmapEx(), ConvertDataFormat::PNG) == ERRCODE_NONE) + { + css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell()); + OUStringBuffer aBuffer("data:image/png;base64,"); + ::comphelper::Base64::encode(aBuffer, aSeq); + rJsonWriter.put("image", aBuffer.makeStringAndClear()); + } + } } } } |