[Libreoffice-commits] core.git: 2 commits - desktop/source include/LibreOfficeKit include/vcl libreofficekit/qa libreofficekit/source sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Feb 2 09:58:14 UTC 2016


 desktop/source/lib/init.cxx                         |   15 +++++++++
 include/LibreOfficeKit/LibreOfficeKit.h             |    2 +
 include/LibreOfficeKit/LibreOfficeKit.hxx           |   15 +++++++++
 include/LibreOfficeKit/LibreOfficeKitGtk.h          |   11 ++++++
 include/vcl/ITiledRenderable.hxx                    |    5 +++
 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx |    3 +
 libreofficekit/source/gtk/lokdocview.cxx            |   32 +++++++++++++++++++-
 sw/inc/unotxdoc.hxx                                 |    2 +
 sw/source/uibase/uno/unotxdoc.cxx                   |    9 +++++
 9 files changed, 93 insertions(+), 1 deletion(-)

New commits:
commit bd8610ebafa9caf9f09a5aba9cca04c23691513d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 2 10:32:36 2016 +0100

    LOK: add Document::setClientVisibleArea()
    
    ... and implement it in Writer.
    
    Otherwise there is no way we can perform e.g. page down in an expected
    way. Without this, the core visible area depends on the zoom in the
    document, and the client visible area can be something entirely
    different.
    
    Change-Id: Iadfb5a225da09a2551ffa41ddf503bb3d22b3eae

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index aaf52f1..5010bd0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -350,6 +350,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
                                     int nTilePixelHeight,
                                     int nTileTwipWidth,
                                     int nTileTwipHeight);
+static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
 static int doc_createView(LibreOfficeKitDocument* pThis);
 static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
 static void doc_setView(LibreOfficeKitDocument* pThis, int nId);
@@ -396,6 +397,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
         m_pDocumentClass->resetSelection = doc_resetSelection;
         m_pDocumentClass->getCommandValues = doc_getCommandValues;
         m_pDocumentClass->setClientZoom = doc_setClientZoom;
+        m_pDocumentClass->setClientVisibleArea = doc_setClientVisibleArea;
 
         m_pDocumentClass->createView = doc_createView;
         m_pDocumentClass->destroyView = doc_destroyView;
@@ -1496,6 +1498,19 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTilePixelWidth
     pDoc->setClientZoom(nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
 }
 
+static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight)
+{
+    ITiledRenderable* pDoc = getTiledRenderable(pThis);
+    if (!pDoc)
+    {
+        gImpl->maLastExceptionMsg = "Document doesn't support tiled rendering";
+        return;
+    }
+
+    Rectangle aRectangle(Point(nX, nY), Size(nWidth, nHeight));
+    pDoc->setClientVisibleArea(aRectangle);
+}
+
 static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
 {
     SolarMutexGuard aGuard;
diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h
index 3411b6f..c98dd1f 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -205,6 +205,8 @@ struct _LibreOfficeKitDocumentClass
             int nTilePixelHeight,
             int nTileTwipWidth,
             int nTileTwipHeight);
+    /// @see lok::Document::setVisibleArea).
+    void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
 
     /// @see lok::Document::createView().
     int (*createView) (LibreOfficeKitDocument* pThis);
diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx
index 3132891..1fbd784 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -333,6 +333,21 @@ public:
     }
 
     /**
+     * Inform core about the currently visible area of the document on the
+     * client, so that it can perform e.g. page down (which depends on the
+     * visible height) in a sane way.
+     *
+     * @param nX - top left corner horizontal position
+     * @param nY - top left corner vertical position
+     * @param nWidth - area width
+     * @param nHeight - area height
+     */
+    inline void setClientVisibleArea(int nX, int nY, int nWidth, int nHeight)
+    {
+        mpDoc->pClass->setClientVisibleArea(mpDoc, nX, nY, nWidth, nHeight);
+    }
+
+    /**
      * Create a new view for an existing document.
      * By default a loaded document has 1 view.
      * @return the ID of the new view.
diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx
index a1e1d80..d9cd347 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -202,6 +202,11 @@ public:
         (void) nTileTwipWidth;
         (void) nTileTwipHeight;
     }
+
+    /// @see lok::Document::setClientVisibleArea().
+    virtual void setClientVisibleArea(const Rectangle& /*rRectangle*/)
+    {
+    }
 };
 
 } // namespace vcl
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index dfe14a0..825a72f 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -569,7 +569,15 @@ postKeyEventInThread(gpointer data)
     }
     if (priv->m_bVisibleAreaSet)
     {
-        // TODO invoke lok::Document::setVisibleArea() here.
+        std::stringstream ss;
+        ss << "lok::Document::setClientVisibleArea(" << priv->m_aVisibleArea.x << ", " << priv->m_aVisibleArea.y << ", ";
+        ss << priv->m_aVisibleArea.width << ", " << priv->m_aVisibleArea.height << ")";
+        g_info("%s", ss.str().c_str());
+        priv->m_pDocument->pClass->setClientVisibleArea(priv->m_pDocument,
+                                                        priv->m_aVisibleArea.x,
+                                                        priv->m_aVisibleArea.y,
+                                                        priv->m_aVisibleArea.width,
+                                                        priv->m_aVisibleArea.height);
         priv->m_bVisibleAreaSet = false;
     }
 
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index cd6135a..5b2e6d0 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -434,6 +434,8 @@ public:
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() override;
+    /// @see vcl::ITiledRenderable::setClientVisibleArea().
+    virtual void setClientVisibleArea(const Rectangle& rRectangle);
     /// @see vcl::ITiledRenderable::getPointer().
     virtual Pointer getPointer() override;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 972edd9..c42bcca 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3180,6 +3180,15 @@ bool SwXTextDocument::isMimeTypeSupported()
     return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper);
 }
 
+void SwXTextDocument::setClientVisibleArea(const Rectangle& rRectangle)
+{
+    SwView* pView = pDocShell->GetView();
+    if (!pView)
+        return;
+
+    pView->SetVisArea(rRectangle);
+}
+
 Pointer SwXTextDocument::getPointer()
 {
     SolarMutexGuard aGuard;
commit 9d8b33079494cf7b5e66bd6c9d71f025efd9a653
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 2 09:46:30 2016 +0100

    lokdocview: add a set_visible_area()
    
    Change-Id: Ib63959ad64fe52b648e0c0d3fe6d49fb282d57ee

diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h
index e06d154..c3e4b28 100644
--- a/include/LibreOfficeKit/LibreOfficeKitGtk.h
+++ b/include/LibreOfficeKit/LibreOfficeKitGtk.h
@@ -113,6 +113,17 @@ LibreOfficeKitDocument*        lok_doc_view_get_document           (LOKDocView*
  */
 void                           lok_doc_view_set_zoom               (LOKDocView* pDocView,
                                                                     float fZoom);
+/**
+ * lok_doc_view_set_visible_area:
+ * @pDocView: The #LOKDocView instance
+ * @fZoom: The new visible area of pDocView in twips.
+ *
+ * Sets the new visible area of the widget. This helps e.g. the page down key
+ * to jump the correct length, which depends on the amount of visible height of
+ * the document.
+ */
+void                           lok_doc_view_set_visible_area       (LOKDocView* pDocView,
+                                                                    GdkRectangle* pVisibleArea);
 
 /**
  * lok_doc_view_get_zoom:
diff --git a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
index 8b7c931..45ac17e 100644
--- a/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
+++ b/libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx
@@ -440,6 +440,9 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
         if ( pDocView )
         {
             lok_doc_view_set_zoom( LOK_DOC_VIEW(pDocView), fZoom );
+            GdkRectangle aVisibleArea;
+            getVisibleAreaTwips(pDocView, &aVisibleArea);
+            lok_doc_view_set_visible_area(LOK_DOC_VIEW(pDocView), &aVisibleArea);
         }
     }
     std::string aZoom = std::to_string(int(fZoom * 100)) + std::string("%");
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index e6da630..dfe14a0 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -14,6 +14,7 @@
 #include <vector>
 #include <string>
 #include <sstream>
+#include <iostream>
 #include <boost/property_tree/json_parser.hpp>
 
 #include <com/sun/star/awt/Key.hpp>
@@ -129,6 +130,9 @@ struct LOKDocViewPrivateImpl
     */
     int m_nTileSizeTwips;
 
+    GdkRectangle m_aVisibleArea;
+    bool m_bVisibleAreaSet;
+
     LOKDocViewPrivateImpl()
         : m_aLOPath(nullptr),
         m_aDocPath(nullptr),
@@ -166,7 +170,9 @@ struct LOKDocViewPrivateImpl
         m_bInDragEndHandle(false),
         m_pGraphicHandle(nullptr),
         m_nViewId(0),
-        m_nTileSizeTwips(0)
+        m_nTileSizeTwips(0),
+        m_aVisibleArea({0, 0, 0, 0}),
+        m_bVisibleAreaSet(false)
     {
         memset(&m_aGraphicHandleRects, 0, sizeof(m_aGraphicHandleRects));
         memset(&m_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles));
@@ -561,6 +567,11 @@ postKeyEventInThread(gpointer data)
                                                  priv->m_nTileSizeTwips);
         priv->m_nTileSizeTwips = 0;
     }
+    if (priv->m_bVisibleAreaSet)
+    {
+        // TODO invoke lok::Document::setVisibleArea() here.
+        priv->m_bVisibleAreaSet = false;
+    }
 
     std::stringstream ss;
     ss << "lok::Document::postKeyEvent(" << pLOEvent->m_nKeyEvent << ", " << pLOEvent->m_nCharCode << ", " << pLOEvent->m_nKeyCode << ")";
@@ -2521,6 +2532,17 @@ lok_doc_view_get_document (LOKDocView* pDocView)
 }
 
 SAL_DLLPUBLIC_EXPORT void
+lok_doc_view_set_visible_area (LOKDocView* pDocView, GdkRectangle* pVisibleArea)
+{
+    if (!pVisibleArea)
+        return;
+
+    LOKDocViewPrivate& priv = getPrivate(pDocView);
+    priv->m_aVisibleArea = *pVisibleArea;
+    priv->m_bVisibleAreaSet = true;
+}
+
+SAL_DLLPUBLIC_EXPORT void
 lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
 {
     LOKDocViewPrivate& priv = getPrivate(pDocView);


More information about the Libreoffice-commits mailing list