jsdialog: dump internal image for buttons
Change-Id: I53687f67042490c19d1056c74619d43566bf1289
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117132
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119562
Tested-by: Jenkins
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 75bdf66..78534ea 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -623,6 +623,10 @@ class JSMenuButton : public JSWidget<SalInstanceMenuButton, ::MenuButton>
public:
JSMenuButton(JSDialogSender* pSender, ::MenuButton* pMenuButton, SalInstanceBuilder* pBuilder,
bool bTakeOwnership);
virtual void set_label(const OUString& rText) override;
virtual void set_image(VirtualDevice* pDevice) override;
virtual void set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage) override;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/jsdialog/jsdialogbuilder.cxx b/vcl/jsdialog/jsdialogbuilder.cxx
index 335b9cf..02e7948 100644
--- a/vcl/jsdialog/jsdialogbuilder.cxx
+++ b/vcl/jsdialog/jsdialogbuilder.cxx
@@ -1425,4 +1425,24 @@ JSMenuButton::JSMenuButton(JSDialogSender* pSender, ::MenuButton* pMenuButton,
{
}
void JSMenuButton::set_label(const OUString& rText)
{
OUString aPreviousLabel = get_label();
SalInstanceMenuButton::set_label(rText);
if (aPreviousLabel != rText)
sendUpdate();
}
void JSMenuButton::set_image(VirtualDevice* pDevice)
{
SalInstanceMenuButton::set_image(pDevice);
sendUpdate();
}
void JSMenuButton::set_image(const css::uno::Reference<css::graphic::XGraphic>& rImage)
{
SalInstanceMenuButton::set_image(rImage);
sendUpdate();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 897d556..ac867a2 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -20,6 +20,7 @@
#include <tools/poly.hxx>
#include <vcl/builder.hxx>
#include <vcl/cvtgrf.hxx>
#include <vcl/image.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/decoview.hxx>
@@ -42,11 +43,13 @@
#include <vclstatuslistener.hxx>
#include <osl/diagnose.h>
#include <comphelper/base64.hxx>
#include <comphelper/dispatchcommand.hxx>
#include <comphelper/lok.hxx>
#include <officecfg/Office/Common.hxx>
#include <boost/property_tree/ptree.hpp>
#include <tools/json_writer.hxx>
#include <tools/stream.hxx>
using namespace css;
@@ -580,6 +583,17 @@ void Button::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
Control::DumpAsPropertyTree(rJsonWriter);
rJsonWriter.put("text", GetText());
if (HasImage())
{
SvMemoryStream aOStm(6535, 6535);
if(GraphicConverter::Export(aOStm, GetModeImage().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());
}
}
}
IMPL_STATIC_LINK( Button, dispatchCommandHandler, Button*, pButton, void )