summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2017-07-28 18:07:44 +0530
committerPranav Kant <pranavk@collabora.co.uk>2017-10-02 10:57:15 +0530
commit9874cd5efae7fb45f68da0e5ebc7701fdad0414a (patch)
treef5895b5a779958e436117149bd25943e31e491c2
parent706e4d198683f6c2075a91050d21a298ad186cc6 (diff)
lokdialog: Dialog invalidation support
For now, just invalidate the whole dialog whenever any of the controls in the dialog get invalidated. Since during dialog painting, many such invalidations are triggered, don't listen to them when we are painting. Change-Id: Ia8fc12cf9469691d60e91ef770d687e5ff01a7ef
-rw-r--r--comphelper/source/misc/lok.cxx12
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitEnums.h6
-rw-r--r--include/comphelper/lok.hxx4
-rw-r--r--include/sfx2/basedlgs.hxx2
-rw-r--r--include/sfx2/lokhelper.hxx2
-rw-r--r--include/vcl/ctrl.hxx2
-rw-r--r--include/vcl/dialog.hxx7
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx4
-rw-r--r--sfx2/source/dialog/basedlgs.cxx11
-rw-r--r--sfx2/source/view/lokhelper.cxx13
-rw-r--r--vcl/source/control/ctrl.cxx15
-rw-r--r--vcl/source/window/dialog.cxx2
12 files changed, 76 insertions, 4 deletions
diff --git a/comphelper/source/misc/lok.cxx b/comphelper/source/misc/lok.cxx
index 44487da953ca..a4f60ac6c565 100644
--- a/comphelper/source/misc/lok.cxx
+++ b/comphelper/source/misc/lok.cxx
@@ -21,6 +21,8 @@ static bool g_bPartInInvalidation(false);
static bool g_bTiledPainting(false);
+static bool g_bDialogPainting(false);
+
static bool g_bTiledAnnotations(true);
void setActive(bool bActive)
@@ -53,6 +55,16 @@ bool isTiledPainting()
return g_bTiledPainting;
}
+void setDialogPainting(bool bDialogPainting)
+{
+ g_bDialogPainting = bDialogPainting;
+}
+
+bool isDialogPainting()
+{
+ return g_bDialogPainting;
+}
+
void setTiledAnnotations(bool bTiledAnnotations)
{
g_bTiledAnnotations = bTiledAnnotations;
diff --git a/include/LibreOfficeKit/LibreOfficeKitEnums.h b/include/LibreOfficeKit/LibreOfficeKitEnums.h
index c3b71f3f1aad..fdad6919e0e1 100644
--- a/include/LibreOfficeKit/LibreOfficeKitEnums.h
+++ b/include/LibreOfficeKit/LibreOfficeKitEnums.h
@@ -521,7 +521,11 @@ typedef enum
*
* Here all aproperties are same as described in svxruler.
*/
- LOK_CALLBACK_RULER_UPDATE = 35
+ LOK_CALLBACK_RULER_UPDATE = 35,
+ /**
+ * Dialog invalidation
+ */
+ LOK_CALLBACK_DIALOG_INVALIDATE = 36
}
LibreOfficeKitCallbackType;
diff --git a/include/comphelper/lok.hxx b/include/comphelper/lok.hxx
index 253541a80cb6..7a293ca70352 100644
--- a/include/comphelper/lok.hxx
+++ b/include/comphelper/lok.hxx
@@ -52,6 +52,10 @@ COMPHELPER_DLLPUBLIC void setPartInInvalidation(bool bPartInInvalidation);
COMPHELPER_DLLPUBLIC bool isTiledPainting();
/// Set if we are doing tiled painting.
COMPHELPER_DLLPUBLIC void setTiledPainting(bool bTiledPainting);
+/// Check if we are painting the dialog.
+COMPHELPER_DLLPUBLIC bool isDialogPainting();
+/// Set if we are painting the dialog.
+COMPHELPER_DLLPUBLIC void setDialogPainting(bool bDialogPainting);
/// Set if we want no annotations rendering
COMPHELPER_DLLPUBLIC void setTiledAnnotations(bool bTiledAnnotations);
/// Check if annotations rendering is turned off
diff --git a/include/sfx2/basedlgs.hxx b/include/sfx2/basedlgs.hxx
index cb403c78a075..7609229db2a6 100644
--- a/include/sfx2/basedlgs.hxx
+++ b/include/sfx2/basedlgs.hxx
@@ -105,6 +105,8 @@ public:
SfxBindings& GetBindings()
{ return *pBindings; }
+ virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override;
+
DECL_LINK(TimerHdl, Timer *, void);
};
diff --git a/include/sfx2/lokhelper.hxx b/include/sfx2/lokhelper.hxx
index 9cf98fa40c88..514726ee1e0b 100644
--- a/include/sfx2/lokhelper.hxx
+++ b/include/sfx2/lokhelper.hxx
@@ -40,6 +40,8 @@ public:
static void notifyOtherViews(SfxViewShell* pThisView, int nType, const OString& rKey, const OString& rPayload);
/// Same as notifyOtherViews(), but works on a selected "other" view, not on all of them.
static void notifyOtherView(SfxViewShell* pThisView, SfxViewShell const* pOtherView, int nType, const OString& rKey, const OString& rPayload);
+ /// Emits a LOK_CALLBACK_DIALOG_INVALIDATE with 'invalidate' action
+ static void notifyDialogInvalidation(const OUString& rPayload);
/// Emits a LOK_CALLBACK_INVALIDATE_TILES, but tweaks it according to setOptionalFeatures() if needed.
static void notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload);
/// A special value to signify 'infinity'.
diff --git a/include/vcl/ctrl.hxx b/include/vcl/ctrl.hxx
index cb68cfe8f78a..8e2926ae1774 100644
--- a/include/vcl/ctrl.hxx
+++ b/include/vcl/ctrl.hxx
@@ -44,6 +44,8 @@ private:
SAL_DLLPRIVATE void ImplInitControlData();
+ virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override;
+
Control (const Control &) = delete;
Control & operator= (const Control &) = delete;
diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx
index 457943c08d37..7a3aa4c0c1c0 100644
--- a/include/vcl/dialog.hxx
+++ b/include/vcl/dialog.hxx
@@ -72,10 +72,14 @@ private:
protected:
using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag = InitFlag::Default );
+ OUString maID; // identifier for this dialog
public:
SAL_DLLPRIVATE bool IsInClose() const { return mbInClose; }
virtual void doDeferredInit(WinBits nBits) override;
+ virtual void LogicInvalidate(const tools::Rectangle* pRectangle) override { (void)pRectangle; }
+ // Paints the current dialog to the given virtual device
+ void paintDialog(VirtualDevice& rDevice);
protected:
explicit Dialog( WindowType nType );
@@ -114,9 +118,6 @@ public:
virtual void PrePaint(vcl::RenderContext& rRenderContext) override;
virtual void PostPaint(vcl::RenderContext& rRenderContext) override;
- // Paints the current dialog to the given virtual device
- void paintDialog(VirtualDevice& rDevice);
-
// ensureRepaint - triggers Application::Yield until the dialog is
// completely repainted. Sometimes needed for dialogs showing progress
// during actions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 3d4b0fa8279d..4700cffadab6 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -436,6 +436,8 @@ callbackTypeToString (int nType)
return "LOK_CALLBACK_COMMENT";
case LOK_CALLBACK_RULER_UPDATE:
return "LOK_CALLBACK_RULER_UPDATE";
+ case LOK_CALLBACK_DIALOG_INVALIDATE:
+ return "LOK_CALLBACK_DIALOG_INVALIDATE";
}
g_assert(false);
return nullptr;
@@ -1427,6 +1429,8 @@ callback (gpointer pData)
break;
case LOK_CALLBACK_RULER_UPDATE:
g_signal_emit(pCallback->m_pDocView, doc_view_signals[RULER], 0, pCallback->m_aPayload.c_str());
+ case LOK_CALLBACK_DIALOG_INVALIDATE:
+ // TODO: Register the signal with lokdocview and emit it
break;
default:
g_assert(false);
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index fceeab0d7e50..0d2d90d142de 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -18,7 +18,10 @@
*/
#include <stdlib.h>
+
+#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
+
#include <osl/file.hxx>
#include <vcl/fixed.hxx>
#include <vcl/help.hxx>
@@ -29,6 +32,7 @@
#include <vcl/idle.hxx>
#include <sfx2/basedlgs.hxx>
+#include <sfx2/lokhelper.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/tabdlg.hxx>
#include <sfx2/app.hxx>
@@ -390,6 +394,13 @@ void SfxModelessDialog::FillInfo(SfxChildWinInfo& rInfo) const
}
+void SfxModelessDialog::LogicInvalidate(const tools::Rectangle* /*pRectangle*/)
+{
+ if (!comphelper::LibreOfficeKit::isDialogPainting())
+ SfxLokHelper::notifyDialogInvalidation(maID);
+}
+
+
bool SfxFloatingWindow::EventNotify( NotifyEvent& rEvt )
/* [Description]
diff --git a/sfx2/source/view/lokhelper.cxx b/sfx2/source/view/lokhelper.cxx
index 1597174af5b0..d63d0ad2fb4f 100644
--- a/sfx2/source/view/lokhelper.cxx
+++ b/sfx2/source/view/lokhelper.cxx
@@ -144,6 +144,19 @@ void SfxLokHelper::notifyOtherViews(SfxViewShell* pThisView, int nType, const OS
}
}
+void SfxLokHelper::notifyDialogInvalidation(const OUString& rDialogID)
+{
+ if (SfxLokHelper::getViewsCount() <= 0)
+ return;
+
+ SfxViewShell* pViewShell = SfxViewShell::GetFirst();
+ while (pViewShell)
+ {
+ pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_DIALOG_INVALIDATE, OUStringToOString(rDialogID, RTL_TEXTENCODING_UTF8).getStr());
+ pViewShell = SfxViewShell::GetNext(*pViewShell);
+ }
+}
+
void SfxLokHelper::notifyInvalidation(SfxViewShell const* pThisView, const OString& rPayload)
{
OStringBuffer aBuf;
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 5df29a0d3560..3bd877ea7162 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -18,11 +18,13 @@
*/
#include <comphelper/processfactory.hxx>
+#include <comphelper/lok.hxx>
#include <vcl/svapp.hxx>
#include <vcl/event.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/decoview.hxx>
+#include <vcl/dialog.hxx>
#include <vcl/salnativewidgets.hxx>
#include <vcl/settings.hxx>
#include <vcl/uitest/logger.hxx>
@@ -412,6 +414,19 @@ void Control::ImplInitSettings()
ApplySettings(*this);
}
+void Control::LogicInvalidate(const tools::Rectangle* /*pRectangle*/)
+{
+ // Several repaint, resize invalidations are emitted when we are painting,
+ // ignore all of those
+ if (comphelper::LibreOfficeKit::isActive() && !comphelper::LibreOfficeKit::isDialogPainting())
+ {
+ // For now just invalidate the whole dialog
+ Dialog* pParentDlg = GetParentDialog();
+ if (pParentDlg)
+ pParentDlg->LogicInvalidate(nullptr);
+ }
+}
+
tools::Rectangle Control::DrawControlText( OutputDevice& _rTargetDevice, const tools::Rectangle& rRect, const OUString& _rStr,
DrawTextFlags _nStyle, MetricVector* _pVector, OUString* _pDisplayText, const Size* i_pDeviceSize ) const
{
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 679c83ba462b..b4e5b6a667fb 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -514,6 +514,7 @@ void Dialog::doDeferredInit(WinBits nBits)
Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription)
: SystemWindow(WindowType::DIALOG)
, mnInitFlag(InitFlag::Default)
+ , maID(rID)
{
ImplInitDialogData();
loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);
@@ -522,6 +523,7 @@ Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXML
Dialog::Dialog(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription, WindowType nType, InitFlag eFlag)
: SystemWindow(nType)
, mnInitFlag(eFlag)
+ , maID(rID)
{
ImplInitDialogData();
loadUI(pParent, OUStringToOString(rID, RTL_TEXTENCODING_UTF8), rUIXMLDescription);