summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-10-10 14:35:22 +0100
committerMichael Meeks <michael.meeks@collabora.com>2019-10-10 19:41:54 +0200
commit7d9932ade30464abf297f2e3c3690cca68d6bf71 (patch)
treed33256dcb636e8c4b370b584780ee89b40e31985 /sfx2
parent5db9bfee77e560c46457a40aee3d2b0752ab2fd8 (diff)
jsdialogs: emit JSON at idle to avoid repeated emission.
Change-Id: If8ddfaf9097f706d82117e102a56b4a8b2a41cdd Reviewed-on: https://gerrit.libreoffice.org/80616 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/sidebar/Deck.cxx42
1 files changed, 30 insertions, 12 deletions
diff --git a/sfx2/source/sidebar/Deck.cxx b/sfx2/source/sidebar/Deck.cxx
index af9ac0c68bb6..a2e9024433f6 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();
}
}