[Libreoffice-commits] core.git: 2 commits - sfx2/source vcl/inc vcl/jsdialog vcl/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 17 15:14:03 UTC 2021


 sfx2/source/sidebar/SidebarController.cxx |   26 ++++++++++++++++++++++++++
 vcl/inc/jsdialog/jsdialogbuilder.hxx      |    1 +
 vcl/jsdialog/jsdialogbuilder.cxx          |    6 ++++++
 vcl/source/window/toolbox2.cxx            |   18 +++++++++++++++++-
 4 files changed, 50 insertions(+), 1 deletion(-)

New commits:
commit 2ca212f93cb4ae1da84fa71bf70dde24784e8df7
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jul 6 14:15:17 2021 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Aug 17 17:13:44 2021 +0200

    jsdialog: sidebar: send message on sidebar close
    
    Revert needed code removed in 64bd4dd
    
    Change-Id: If45facbd68ea8f3af433b78e127fbb0745e62c25
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118483
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120565
    Tested-by: Szymon Kłos <szymon.klos at collabora.com>

diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index fff93887c3a7..803d1c10a739 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -40,6 +40,7 @@
 #include <vcl/svapp.hxx>
 #include <splitwin.hxx>
 #include <tools/diagnose_ex.h>
+#include <tools/json_writer.hxx>
 #include <tools/link.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <comphelper/processfactory.hxx>
@@ -1229,6 +1230,31 @@ IMPL_LINK(SidebarController, OnSubMenuItemSelected, const OString&, rCurItemId,
 
 void SidebarController::RequestCloseDeck()
 {
+    if (comphelper::LibreOfficeKit::isActive() && mpCurrentDeck)
+    {
+        const SfxViewShell* pViewShell = SfxViewShell::Current();
+        if (pViewShell && pViewShell->isLOKMobilePhone())
+        {
+            // Mobile phone - TODO: unify with desktop
+            tools::JsonWriter aJsonWriter;
+            aJsonWriter.put("id", mpParentWindow->get_id());
+            aJsonWriter.put("type", "dockingwindow");
+            aJsonWriter.put("text", mpParentWindow->GetText());
+            aJsonWriter.put("enabled", false);
+            const std::string message = aJsonWriter.extractAsStdString();
+            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+        }
+        else if (pViewShell)
+        {
+            tools::JsonWriter aJsonWriter;
+            aJsonWriter.put("id", mpParentWindow->get_id());
+            aJsonWriter.put("action", "close");
+            aJsonWriter.put("jsontype", "sidebar");
+            const std::string message = aJsonWriter.extractAsStdString();
+            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, message.c_str());
+        }
+    }
+
     mbIsDeckRequestedOpen = false;
     UpdateDeckOpenState();
 
commit 1692ee279c7d0a6aa8210c923a6923c6919f46d3
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Tue Jul 6 11:50:38 2021 +0200
Commit:     Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Tue Aug 17 17:13:28 2021 +0200

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

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());
+                    }
+                }
             }
         }
     }


More information about the Libreoffice-commits mailing list