summaryrefslogtreecommitdiff
path: root/vcl/source/window/toolbox2.cxx
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-07-06 11:50:38 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2021-08-17 17:13:28 +0200
commit1692ee279c7d0a6aa8210c923a6923c6919f46d3 (patch)
treeb1027c36c867c0488e40005fd08460921e941b14 /vcl/source/window/toolbox2.cxx
parent37dd6e18f5cf498d230ffe8a0a395cfdf9625e0c (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>
Diffstat (limited to 'vcl/source/window/toolbox2.cxx')
-rw-r--r--vcl/source/window/toolbox2.cxx18
1 files changed, 17 insertions, 1 deletions
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());
+ }
+ }
}
}
}