[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/sfx2 sfx2/source
Ashod Nakashian (via logerrit)
logerrit at kemper.freedesktop.org
Thu Oct 31 10:57:30 UTC 2019
include/sfx2/sidebar/SidebarDockingWindow.hxx | 3 +
sfx2/source/sidebar/SidebarDockingWindow.cxx | 58 +++++++++++++++++++++++---
2 files changed, 55 insertions(+), 6 deletions(-)
New commits:
commit a7dd46575d10dfdfdfa8b51976de1d67210e81e7
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Oct 30 06:12:26 2019 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Thu Oct 31 11:56:54 2019 +0100
sidebars: add JSDialog support to sidebars
Currently the JSDialog path is only for mobile
and we use the passive notifications for desktop
Online.
Change-Id: I5d26fee9475ede665f269ca1f7b582455be08e50
Reviewed-on: https://gerrit.libreoffice.org/81754
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/include/sfx2/sidebar/SidebarDockingWindow.hxx b/include/sfx2/sidebar/SidebarDockingWindow.hxx
index e54d55f2b791..5706b8a4ddea 100644
--- a/include/sfx2/sidebar/SidebarDockingWindow.hxx
+++ b/include/sfx2/sidebar/SidebarDockingWindow.hxx
@@ -33,6 +33,8 @@ class SidebarChildWindow;
class SidebarController;
+class SidebarNotifyIdle;
+
class SidebarDockingWindow : public SfxDockingWindow
{
public:
@@ -68,6 +70,7 @@ private:
const bool mbSidebarVisibleInLOK;
const SfxViewShell* mpOldViewShell;
+ std::unique_ptr<SidebarNotifyIdle> mpIdleNotify;
};
} } // end of namespace sfx2::sidebar
diff --git a/sfx2/source/sidebar/SidebarDockingWindow.cxx b/sfx2/source/sidebar/SidebarDockingWindow.cxx
index 799c0ec712e6..a0ed9440180d 100644
--- a/sfx2/source/sidebar/SidebarDockingWindow.cxx
+++ b/sfx2/source/sidebar/SidebarDockingWindow.cxx
@@ -28,12 +28,61 @@
#include <tools/gen.hxx>
#include <vcl/event.hxx>
#include <comphelper/lok.hxx>
+#include <LibreOfficeKit/LibreOfficeKitEnums.h>
+
+#include <boost/property_tree/json_parser.hpp>
using namespace css;
using namespace css::uno;
namespace sfx2 { namespace sidebar {
+class SidebarNotifyIdle : public Idle
+{
+ SidebarDockingWindow &mrSidebarDockingWin;
+
+public:
+ SidebarNotifyIdle(SidebarDockingWindow &rSidebarDockingWin) :
+ Idle("Sidebar notify"),
+ mrSidebarDockingWin(rSidebarDockingWin)
+ {
+ SetPriority(TaskPriority::POST_PAINT);
+ }
+
+ void Invoke() override
+ {
+ auto pNotifier = mrSidebarDockingWin.GetLOKNotifier();
+ if (!pNotifier || !comphelper::LibreOfficeKit::isActive())
+ return;
+
+ try
+ {
+ if (comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()))
+ {
+ // Mobile.
+ std::stringstream aStream;
+ boost::property_tree::write_json(aStream, mrSidebarDockingWin.DumpAsPropertyTree());
+ pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aStream.str().c_str());
+ }
+ else
+ {
+ // On desktop use the classic notifications.
+ std::vector<vcl::LOKPayloadItem> aItems;
+ aItems.emplace_back("type", "deck");
+ const Point pos = Point(mrSidebarDockingWin.GetOutOffXPixel(),
+ mrSidebarDockingWin.GetOutOffYPixel());
+ aItems.emplace_back("position", pos.toString());
+ aItems.emplace_back("size", mrSidebarDockingWin.GetSizePixel().toString());
+ pNotifier->notifyWindow(mrSidebarDockingWin.GetLOKWindowId(), "created", aItems);
+ }
+ }
+ catch (boost::property_tree::json_parser::json_parser_error& rError)
+ {
+ SAL_WARN("sfx.sidebar", rError.message());
+ }
+ }
+};
+
SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChildWindow& rChildWindow,
vcl::Window* pParentWindow, WinBits nBits)
: SfxDockingWindow(pSfxBindings, &rChildWindow, pParentWindow, nBits)
@@ -41,6 +90,7 @@ SidebarDockingWindow::SidebarDockingWindow(SfxBindings* pSfxBindings, SidebarChi
, mbIsReadyToDrag(false)
, mbSidebarVisibleInLOK(rChildWindow.IsSidebarVisibleInLOK())
, mpOldViewShell(SfxViewShell::Current())
+ , mpIdleNotify(new SidebarNotifyIdle(*this))
{
// Get the XFrame from the bindings.
if (pSfxBindings==nullptr || pSfxBindings->GetDispatcher()==nullptr)
@@ -125,13 +175,9 @@ void SidebarDockingWindow::NotifyResize()
if (mpSidebarController.is() && !GetLOKNotifier())
SetLOKNotifier(SfxViewShell::Current());
- if (const vcl::ILibreOfficeKitNotifier* pNotifier = GetLOKNotifier())
+ if (GetLOKNotifier())
{
- std::vector<vcl::LOKPayloadItem> aItems;
- aItems.emplace_back("type", "deck");
- aItems.emplace_back(std::make_pair("position", Point(GetOutOffXPixel(), GetOutOffYPixel()).toString()));
- aItems.emplace_back(std::make_pair("size", GetSizePixel().toString()));
- pNotifier->notifyWindow(GetLOKWindowId(), "created", aItems);
+ mpIdleNotify->Start();
}
}
}
More information about the Libreoffice-commits
mailing list