[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - vcl/inc vcl/jsdialog vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 15 10:23:37 UTC 2021


 vcl/inc/jsdialog/jsdialogbuilder.hxx |    4 ++++
 vcl/jsdialog/jsdialogbuilder.cxx     |   20 ++++++++++++++++++++
 vcl/source/control/button.cxx        |   14 ++++++++++++++
 3 files changed, 38 insertions(+)

New commits:
commit 51180d95d50257a2651d58250c9db3e7db7fa4c8
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Mon Jun 14 10:07:02 2021 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Jun 15 12:22:57 2021 +0200

    jsdialog: dump internal image for buttons
    
    Change-Id: I53687f67042490c19d1056c74619d43566bf1289
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117132
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx
index 70eb489f42ba..7594edbdc1ed 100644
--- a/vcl/inc/jsdialog/jsdialogbuilder.hxx
+++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx
@@ -622,6 +622,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 79df2662cb04..87efbc466f72 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 0fb24dc744a0..68fa3c3d0dd3 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -19,6 +19,7 @@
 
 #include <tools/poly.hxx>
 
+#include <vcl/cvtgrf.hxx>
 #include <vcl/image.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/decoview.hxx>
@@ -41,11 +42,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;
@@ -557,6 +560,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 )


More information about the Libreoffice-commits mailing list