summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2015-01-06 16:05:45 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2015-01-06 20:55:25 +0100
commit3547424b9fa9c335e4e0c80fae8c5ac928403045 (patch)
tree25198c55caf609764155fd9ad2ddfaa8dbd24704
parentd9997df11fb353aa0d6856554e4f845abc315d4f (diff)
sw: notify LOK clients about invalidations
So that when the document changes, they can know what tiles to throw away. Change-Id: I1f00585e7691a40af8fe5de71ac1a4225bc4e67f
-rw-r--r--sw/inc/unotxdoc.hxx8
-rw-r--r--sw/inc/viewsh.hxx10
-rw-r--r--sw/source/core/view/viewsh.cxx12
-rw-r--r--sw/source/core/view/vnew.cxx4
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx15
-rw-r--r--sw/source/uibase/inc/edtwin.hxx6
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx7
7 files changed, 62 insertions, 0 deletions
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 16a8a144e6fe..5102fa05f63b 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -442,6 +442,14 @@ public:
long nTileHeight ) SAL_OVERRIDE;
virtual Size getDocumentSize() SAL_OVERRIDE;
virtual void initializeForTiledRendering() SAL_OVERRIDE;
+ /**
+ * Registers a callback that will be invoked whenever the tiled renderer
+ * wants to notify the client about an event.
+ *
+ * @param pCallBack is the callback function
+ * @param pData is private data of the client that will be sent back when the callback is invoked
+ */
+ virtual void registerCallback(LibreOfficeKitCallback pCallback, void* pData) SAL_OVERRIDE;
void Invalidate();
void Reactivate(SwDocShell* pNewDocShell);
diff --git a/sw/inc/viewsh.hxx b/sw/inc/viewsh.hxx
index 1c5eddb2a5f5..574933c430e2 100644
--- a/sw/inc/viewsh.hxx
+++ b/sw/inc/viewsh.hxx
@@ -30,6 +30,7 @@
#include <stack>
#include <vcl/mapmod.hxx>
#include <vcl/print.hxx>
+#include <vcl/ITiledRenderable.hxx>
namespace com { namespace sun { namespace star { namespace accessibility {
class XAccessible; } } } }
@@ -194,6 +195,9 @@ protected:
sal_uInt16 mnLockPaint; ///< != 0 if Paint is locked.
bool mbSelectAll; ///< Special select all mode: whole document selected, even if doc starts with table.
+ LibreOfficeKitCallback mpLibreOfficeKitCallback;
+ void* mpLibreOfficeKitData;
+
public:
TYPEINFO();
@@ -572,6 +576,12 @@ public:
bool IsShowHeaderFooterSeparator( FrameControlType eControl ) { return (eControl == Header)? mbShowHeaderSeparator: mbShowFooterSeparator; }
virtual void SetShowHeaderFooterSeparator( FrameControlType eControl, bool bShow ) { if ( eControl == Header ) mbShowHeaderSeparator = bShow; else mbShowFooterSeparator = bShow; }
bool IsSelectAll() { return mbSelectAll; }
+
+ /// The actual implementation of the vcl::ITiledRenderable::registerCallback() API for Writer.
+ void registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pLibreOfficeKitData);
+ /// Invokes the registered callback, if there are any.
+ void libreOfficeKitCallback(int nType, const char* pPayload);
+
SwViewShell* GetNext()
{ return GetNextInRing(); }
const SwViewShell* GetNext() const
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 14a4ade90ca5..27ec8a394605 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -117,6 +117,18 @@ void SwViewShell::ToggleHeaderFooterEdit()
GetWin()->Invalidate();
}
+void SwViewShell::registerLibreOfficeKitCallback(LibreOfficeKitCallback pCallback, void* pData)
+{
+ mpLibreOfficeKitCallback = pCallback;
+ mpLibreOfficeKitData = pData;
+}
+
+void SwViewShell::libreOfficeKitCallback(int nType, const char* pPayload)
+{
+ if (mpLibreOfficeKitCallback)
+ mpLibreOfficeKitCallback(nType, pPayload, mpLibreOfficeKitData);
+}
+
static void
lcl_PaintTransparentFormControls(SwViewShell & rShell, SwRect const& rRect)
{
diff --git a/sw/source/core/view/vnew.cxx b/sw/source/core/view/vnew.cxx
index 3cfe6798e6d5..6fef15854c5c 100644
--- a/sw/source/core/view/vnew.cxx
+++ b/sw/source/core/view/vnew.cxx
@@ -169,6 +169,8 @@ SwViewShell::SwViewShell( SwDoc& rDocument, vcl::Window *pWindow,
mnStartAction( 0 ),
mnLockPaint( 0 ),
mbSelectAll(false),
+ mpLibreOfficeKitCallback(0),
+ mpLibreOfficeKitData(0),
mpPrePostOutDev(0), // #i72754#
maPrePostMapMode()
{
@@ -245,6 +247,8 @@ SwViewShell::SwViewShell( SwViewShell& rShell, vcl::Window *pWindow,
mnStartAction( 0 ),
mnLockPaint( 0 ),
mbSelectAll(false),
+ mpLibreOfficeKitCallback(0),
+ mpLibreOfficeKitData(0),
mpPrePostOutDev(0), // #i72754#
maPrePostMapMode()
{
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index dfa4306a5177..b51d56b32506 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6235,4 +6235,19 @@ void SwEditWin::SwitchView()
#endif
}
+void SwEditWin::LogicInvalidate(const vcl::Region* pRegion)
+{
+ OString sRectangle;
+ if (!pRegion)
+ sRectangle = "EMPTY";
+ else
+ {
+ std::stringstream ss;
+ Rectangle aRectangle = pRegion->GetBoundRect();
+ ss << aRectangle.getWidth() << ", " << aRectangle.getHeight() << ", " << aRectangle.getX() << ", " << aRectangle.getY();
+ sRectangle = ss.str().c_str();
+ }
+ m_rView.GetWrtShell().libreOfficeKitCallback(0, sRectangle.getStr());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index e08e23750cdc..ff049097c950 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -296,6 +296,12 @@ public:
SwEditWin(vcl::Window *pParent, SwView &);
virtual ~SwEditWin();
virtual void SwitchView();
+ /**
+ * Notification about some region of the output device got invalidated.
+ *
+ * @param pRegion If 0, that means the whole area, otherwise the area in logic coordinates.
+ */
+ void LogicInvalidate(const vcl::Region* pRegion) SAL_OVERRIDE;
};
#endif
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index a3493bfd79c6..4bba53506e77 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3157,6 +3157,13 @@ void SwXTextDocument::initializeForTiledRendering()
pView->SetViewLayout(nColumns, bBookMode, true);
}
+void SwXTextDocument::registerCallback(LibreOfficeKitCallback pCallback, void* pData)
+{
+ SwDoc* pDoc = pDocShell->GetDoc();
+ SwViewShell* pViewShell = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell();
+ pViewShell->registerLibreOfficeKitCallback(pCallback, pData);
+}
+
void * SAL_CALL SwXTextDocument::operator new( size_t t) throw()
{
return SwXTextDocumentBaseClass::operator new(t);