[Libreoffice-commits] core.git: Branch 'feature/tiled-editing' - 5 commits - desktop/source include/LibreOfficeKit include/vcl libreofficekit/source sw/inc sw/source vcl/source
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jan 6 07:38:05 PST 2015
desktop/source/lib/init.cxx | 18 ++++++++++++++++++
include/LibreOfficeKit/LibreOfficeKit.h | 5 +++++
include/LibreOfficeKit/LibreOfficeKit.hxx | 12 ++++++++++++
include/vcl/ITiledRenderable.hxx | 9 +++++++++
include/vcl/outdev.hxx | 8 ++++++++
libreofficekit/source/gtk/lokdocview.c | 13 +++++++++++++
sw/inc/unotxdoc.hxx | 8 ++++++++
sw/inc/viewsh.hxx | 10 ++++++++++
sw/source/core/view/viewsh.cxx | 12 ++++++++++++
sw/source/core/view/vnew.cxx | 4 ++++
sw/source/uibase/docvw/edtwin.cxx | 15 +++++++++++++++
sw/source/uibase/inc/edtwin.hxx | 6 ++++++
sw/source/uibase/uno/unotxdoc.cxx | 7 +++++++
vcl/source/window/paint.cxx | 11 +++++++++++
14 files changed, 138 insertions(+)
New commits:
commit 4bbe07a214d21dd68201a1b2e2ef9c5b7b6d40f6
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 6 16:05:45 2015 +0100
sw: notify LOK clients about invalidations
So that when the document changes, they can know what tiles to throw
away.
Change-Id: I1f00585e7691a40af8fe5de71ac1a4225bc4e67f
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index de1507b..e46d2d5 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -441,6 +441,14 @@ public:
long nTileWidth,
long nTileHeight ) SAL_OVERRIDE;
virtual Size getDocumentSize() 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 1c5eddb..574933c 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 14a4ade..27ec8a3 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 3cfe679..6fef158 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 dfa4306..b51d56b3 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 e08e237..ff04909 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 ea3683f..04bf845 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3143,6 +3143,13 @@ Size SwXTextDocument::getDocumentSize()
return pViewShell->GetDocSize();
}
+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);
commit b946b97d65cb3e16c8d7e08ce1da5151fa4777dd
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 6 15:56:23 2015 +0100
gtktiledviewer: register a LOK callback and re-render the document ...
... when the callback is invoked
Change-Id: I979a75bc7c7ad1e0d0b9c5413c238ed7260d2093
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 5884e66..8eafb53 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -149,6 +149,16 @@ void renderDocument( LOKDocView* pDocView )
gtk_image_set_from_pixbuf( GTK_IMAGE( pDocView->pCanvas ), pDocView->pPixBuf );
}
+static void lok_docview_callback(int nType, const char* pPayload, void* pData)
+{
+ LOKDocView* pDocView = pData;
+
+ // TODO for now just always render the document.
+ (void)nType;
+ (void)pPayload;
+ renderDocument( pDocView );
+}
+
SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
{
if ( pDocView->pDocument )
@@ -167,7 +177,10 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
return FALSE;
}
else
+ {
renderDocument( pDocView );
+ pDocView->pDocument->pClass->registerCallback(pDocView->pDocument, &lok_docview_callback, pDocView);
+ }
return TRUE;
}
commit 2427f9bb7c6a345474f7c439410a8be2945df073
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 6 15:49:12 2015 +0100
lok::Document: add registerCallback()
So that LOK clients can invoke the new
vcl::ITiledRenderable::registerCallback().
Change-Id: I6d9974acbd7fb5eea217c88f963e6ebb10343078
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b3593d0..c7da4d9 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -197,6 +197,9 @@ void doc_paintTile(LibreOfficeKitDocument* pThis,
static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight);
+static void doc_registerCallback(LibreOfficeKitDocument* pThis,
+ LibreOfficeKitCallback pCallback,
+ void* pData);
struct LibLODocument_Impl : public _LibreOfficeKitDocument
{
@@ -222,6 +225,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
m_pDocumentClass->setPartMode = doc_setPartMode;
m_pDocumentClass->paintTile = doc_paintTile;
m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
+ m_pDocumentClass->registerCallback = doc_registerCallback;
gDocumentClass = m_pDocumentClass;
}
@@ -608,6 +612,20 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
}
}
+static void doc_registerCallback(LibreOfficeKitDocument* pThis,
+ LibreOfficeKitCallback pCallback,
+ void* pData)
+{
+ ITiledRenderable* pDoc = getTiledRenderable(pThis);
+ if (!pDoc)
+ {
+ gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+ return;
+ }
+
+ pDoc->registerCallback(pCallback, pData);
+}
+
static char* lo_getError (LibreOfficeKit *pThis)
{
LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index d7b8e41..594f83c 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -50,6 +50,8 @@ typedef enum
LOK_PARTMODE_EMBEDDEDOBJ
}
LibreOfficeKitPartMode;
+
+typedef void (*LibreOfficeKitCallback)(int nType, const char* pPayload, void* pData);
#endif // LOK_USE_UNSTABLE_API
struct _LibreOfficeKit
@@ -113,6 +115,9 @@ struct _LibreOfficeKitDocumentClass
void (*getDocumentSize) (LibreOfficeKitDocument* pThis,
long* pWidth,
long* pHeight);
+ void (*registerCallback) (LibreOfficeKitDocument* pThis,
+ LibreOfficeKitCallback pCallback,
+ void* pData);
#endif // LOK_USE_UNSTABLE_API
};
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index f1255f4..a7bf230 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -87,6 +87,18 @@ public:
{
mpDoc->pClass->getDocumentSize(mpDoc, pWidth, pHeight);
}
+
+ /**
+ * Registers a callback. LOK will invoke this function when it wants to
+ * inform the client about events.
+ *
+ * @param pCallback the callback to invoke
+ * @param pData the user data, will be passed to the callback on invocation
+ */
+ inline void registerCallback(LibreOfficeKitCallback pCallback, void* pData)
+ {
+ mpDoc->pClass->registerCallback(mpDoc, pCallback, pData);
+ }
#endif // LOK_USE_UNSTABLE_API
};
commit c79787b6ae2abc2137123e1c40f58fa24c7fe5fa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 6 15:07:45 2015 +0100
vcl: add OutputDevice::LogicInvalidate()
This way subclasses may know when and what is invalidated.
Change-Id: Ie4aa843fcf45b2643b24ca49534627fbf43afd94
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 23abb00..c35b311 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1710,6 +1710,14 @@ public:
SAL_DLLPRIVATE DeviceCoordinate LogicWidthToDeviceCoordinate( long nWidth ) const;
SAL_DLLPRIVATE DeviceCoordinate LogicHeightToDeviceCoordinate( long nHeight ) const;
+protected:
+ /**
+ * 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.
+ */
+ virtual void LogicInvalidate(const vcl::Region* /*pRegion*/) { }
+
private:
/** Convert a logical X coordinate to a device pixel's X coordinate.
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 4cdaf36..b896029 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -860,6 +860,7 @@ void Window::Invalidate( sal_uInt16 nFlags )
return;
ImplInvalidate( NULL, nFlags );
+ LogicInvalidate(0);
}
void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
@@ -874,6 +875,8 @@ void Window::Invalidate( const Rectangle& rRect, sal_uInt16 nFlags )
{
vcl::Region aRegion( aRect );
ImplInvalidate( &aRegion, nFlags );
+ vcl::Region aLogicRegion(rRect);
+ LogicInvalidate(&aLogicRegion);
}
}
@@ -884,12 +887,19 @@ void Window::Invalidate( const vcl::Region& rRegion, sal_uInt16 nFlags )
return;
if ( rRegion.IsNull() )
+ {
ImplInvalidate( NULL, nFlags );
+ LogicInvalidate(0);
+ }
else
{
vcl::Region aRegion = ImplPixelToDevicePixel( LogicToPixel( rRegion ) );
if ( !aRegion.IsEmpty() )
+ {
ImplInvalidate( &aRegion, nFlags );
+ vcl::Region aLogicRegion(rRegion);
+ LogicInvalidate(&aLogicRegion);
+ }
}
}
@@ -900,6 +910,7 @@ void Window::Validate( sal_uInt16 nFlags )
return;
ImplValidate( NULL, nFlags );
+ LogicInvalidate(0);
}
bool Window::HasPaintEvent() const
commit 140be93340423cace4a78503fcf32cf002cff100
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jan 6 15:06:51 2015 +0100
vcl::ITiledRenderable: add registerCallback()
This can be overriden in applications, if they need a callback.
Change-Id: I0441e48afbbfd63a96d47c5cf837e6635ce72aff
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index f07ccd5..a693c43 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -83,6 +83,15 @@ public:
{
(void) ePartMode;
}
+
+ /**
+ * 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*/) { }
};
} // namespace vcl
More information about the Libreoffice-commits
mailing list