[Libreoffice-commits] core.git: 6 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 11:56:09 PST 2015


 desktop/source/lib/init.cxx               |   18 ++++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h   |   18 ++++++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.hxx |   11 +++++++++++
 include/vcl/ITiledRenderable.hxx          |    9 +++++++++
 include/vcl/outdev.hxx                    |    8 ++++++++
 libreofficekit/source/gtk/lokdocview.c    |   19 +++++++++++++++++++
 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, 156 insertions(+)

New commits:
commit a989d6f5bd6ad9c301259f93ab1fc62a4fcebb93
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jan 6 17:31:42 2015 +0100

    LOK: add LibreOfficeKitCallbackType enumeration
    
    Change-Id: I0147b1985f87f25e70f4d8672beba18fdd9ba6c2

diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 1b20738..a4addb8 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -51,6 +51,19 @@ typedef enum
 }
 LibreOfficeKitPartMode;
 
+typedef enum
+{
+    /**
+     * Any tiles which are over the rectangle described in the payload are no
+     * longer valid.
+     *
+     * Rectangle format: "width,height,x,y", where all numbers are document
+     * coordinates, in twips.
+     */
+    LOK_CALLBACK_INVALIDATE_TILES
+}
+LibreOfficeKitCallbackType;
+
 typedef void (*LibreOfficeKitCallback)(int nType, const char* pPayload, void* pData);
 #endif // LOK_USE_UNSTABLE_API
 
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index 8eafb53..4e13f03 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -153,10 +153,16 @@ 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 );
+    switch (nType)
+    {
+    case LOK_CALLBACK_INVALIDATE_TILES:
+        // TODO for now just always render the document.
+        (void)pPayload;
+        renderDocument( pDocView );
+        break;
+    default:
+        break;
+    }
 }
 
 SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, char* pPath )
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index b51d56b3..d5e1902 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -6247,7 +6247,7 @@ void SwEditWin::LogicInvalidate(const vcl::Region* pRegion)
         ss << aRectangle.getWidth() << ", " << aRectangle.getHeight() << ", " << aRectangle.getX() << ", " << aRectangle.getY();
         sRectangle = ss.str().c_str();
     }
-    m_rView.GetWrtShell().libreOfficeKitCallback(0, sRectangle.getStr());
+    m_rView.GetWrtShell().libreOfficeKitCallback(LOK_CALLBACK_INVALIDATE_TILES, sRectangle.getStr());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3547424b9fa9c335e4e0c80fae8c5ac928403045
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 16a8a14..5102fa0 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 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 a3493bf..4bba535 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);
commit d9997df11fb353aa0d6856554e4f845abc315d4f
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 aa827f5fde5a95343bb5fa819eda7a10f57e9d36
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 8a8538e..08a353f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -199,6 +199,9 @@ static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,
                                 long* pHeight);
 static void doc_initializeForRendering(LibreOfficeKitDocument* pThis);
 
+static void doc_registerCallback(LibreOfficeKitDocument* pThis,
+                                LibreOfficeKitCallback pCallback,
+                                void* pData);
 
 struct LibLODocument_Impl : public _LibreOfficeKitDocument
 {
@@ -225,6 +228,7 @@ struct LibLODocument_Impl : public _LibreOfficeKitDocument
             m_pDocumentClass->paintTile = doc_paintTile;
             m_pDocumentClass->getDocumentSize = doc_getDocumentSize;
             m_pDocumentClass->initializeForRendering = doc_initializeForRendering;
+            m_pDocumentClass->registerCallback = doc_registerCallback;
 
             gDocumentClass = m_pDocumentClass;
         }
@@ -620,6 +624,20 @@ static void doc_initializeForRendering(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 de5df7f..1b20738 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
@@ -117,6 +119,9 @@ struct _LibreOfficeKitDocumentClass
   // Initialize document for rendering.
   void (*initializeForRendering) (LibreOfficeKitDocument* pThis);
 
+  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 274509c..2a57232 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -93,6 +93,17 @@ public:
         mpDoc->pClass->initializeForRendering(mpDoc);
     }
 
+    /**
+     * 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 0137974abd70d80589ae1a4853523ec2039be1ff
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 0d36309..5ce1a27 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1712,6 +1712,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 c22c5b1..ff8c980 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 bea2ade9151e44bb15eb1dd465ca53ee479693c8
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 d54bbef..15630c1 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -87,6 +87,15 @@ public:
     virtual void initializeForTiledRendering()
     {
     }
+
+    /**
+     * 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