[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - include/sfx2 sfx2/source

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Thu Oct 10 14:25:30 UTC 2019


 include/sfx2/sidebar/Deck.hxx |    2 ++
 sfx2/source/sidebar/Deck.cxx  |   42 ++++++++++++++++++++++++++++++------------
 2 files changed, 32 insertions(+), 12 deletions(-)

New commits:
commit 520dc93ef80e641b7e838122ec7424f030a57859
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Thu Oct 10 14:35:22 2019 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Oct 10 16:24:46 2019 +0200

    jsdialogs: emit JSON at idle to avoid repeated emission.
    
    Change-Id: If8ddfaf9097f706d82117e102a56b4a8b2a41cdd
    Reviewed-on: https://gerrit.libreoffice.org/80609
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/include/sfx2/sidebar/Deck.hxx b/include/sfx2/sidebar/Deck.hxx
index 4c9558a1966b..d631c6f26438 100644
--- a/include/sfx2/sidebar/Deck.hxx
+++ b/include/sfx2/sidebar/Deck.hxx
@@ -31,6 +31,7 @@ namespace sfx2 { namespace sidebar {
 
 class DeckDescriptor;
 class DeckTitleBar;
+class DeckNotifyIdle;
 
 /** This is the parent window of the panels.
     It displays the deck title.
@@ -91,6 +92,7 @@ private:
     sal_Int32 mnMinimalWidth;
     sal_Int32 mnMinimalHeight;
     SharedPanelContainer maPanels;
+    std::unique_ptr<DeckNotifyIdle> mpIdleNotify;
     VclPtr<DeckTitleBar> mpTitleBar;
     VclPtr<vcl::Window> mpScrollClipWindow;
     VclPtr<ScrollContainerWindow> mpScrollContainer;
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index b38525bf7e4d..db47c0bd3ba2 100644
--- a/sfx2/source/sidebar/Deck.cxx
+++ b/sfx2/source/sidebar/Deck.cxx
@@ -44,8 +44,35 @@
 using namespace css;
 using namespace css::uno;
 
+
 namespace sfx2 { namespace sidebar {
 
+class DeckNotifyIdle : public Idle
+{
+    Deck &mrDeck;
+public:
+    DeckNotifyIdle(Deck &rDeck) :
+        Idle("Deck notify"),
+        mrDeck(rDeck)
+    {
+        SetPriority(TaskPriority::POST_PAINT);
+    }
+    void Invoke() override
+    {
+        auto pNotifier = mrDeck.GetLOKNotifier();
+        try
+        {
+            std::stringstream aStream;
+            boost::property_tree::write_json(aStream, mrDeck.DumpAsPropertyTree());
+            pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aStream.str().c_str());
+        }
+        catch(boost::property_tree::json_parser::json_parser_error& rError)
+        {
+            SAL_WARN("sfx.sidebar", rError.message());
+        }
+    }
+};
+
 Deck::Deck(const DeckDescriptor& rDeckDescriptor, vcl::Window* pParentWindow,
            const std::function<void()>& rCloserAction)
     : Window(pParentWindow, 0)
@@ -53,6 +80,7 @@ Deck::Deck(const DeckDescriptor& rDeckDescriptor, vcl::Window* pParentWindow,
     , mnMinimalWidth(0)
     , mnMinimalHeight(0)
     , maPanels()
+    , mpIdleNotify(new DeckNotifyIdle(*this))
     , mpTitleBar(VclPtr<DeckTitleBar>::Create(rDeckDescriptor.msTitle, this, rCloserAction))
     , mpScrollClipWindow(VclPtr<vcl::Window>::Create(this))
     , mpScrollContainer(VclPtr<ScrollContainerWindow>::Create(mpScrollClipWindow.get()))
@@ -187,21 +215,11 @@ void Deck::Resize()
 {
     Window::Resize();
 
-    const vcl::ILibreOfficeKitNotifier *pNotifier;
     if (comphelper::LibreOfficeKit::isActive() &&
         comphelper::LibreOfficeKit::isMobile(SfxLokHelper::getView()) &&
-        (pNotifier = GetLOKNotifier()))
+        GetLOKNotifier())
     {
-        try
-        {
-            std::stringstream aStream;
-            boost::property_tree::write_json(aStream, DumpAsPropertyTree());
-            pNotifier->libreOfficeKitViewCallback(LOK_CALLBACK_JSDIALOG, aStream.str().c_str());
-        }
-        catch(boost::property_tree::json_parser::json_parser_error& rError)
-        {
-            SAL_WARN("sfx.sidebar", rError.message());
-        }
+        mpIdleNotify->Start();
     }
 }
 


More information about the Libreoffice-commits mailing list