[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.0' - desktop/source include/LibreOfficeKit include/vcl sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Feb 2 10:23:34 UTC 2016


 desktop/source/lib/init.cxx               |   15 +++++++++++++++
 include/LibreOfficeKit/LibreOfficeKit.h   |    2 ++
 include/LibreOfficeKit/LibreOfficeKit.hxx |   15 +++++++++++++++
 include/vcl/ITiledRenderable.hxx          |    5 +++++
 sw/inc/unotxdoc.hxx                       |    2 ++
 sw/source/uibase/uno/unotxdoc.cxx         |    9 +++++++++
 6 files changed, 48 insertions(+)

New commits:
commit 1ae319aa81b7d42441886dd232256b0336308cf3
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.
    
    (cherry picked from commit bd8610ebafa9caf9f09a5aba9cca04c23691513d)
    
    Conflicts:
    	libreofficekit/source/gtk/lokdocview.cxx
    	sw/inc/unotxdoc.hxx
    
    Change-Id: Iadfb5a225da09a2551ffa41ddf503bb3d22b3eae

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 5360309..0fbece0 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -369,6 +369,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);
@@ -415,6 +416,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;
@@ -1543,6 +1545,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 b3b61ba..4feaaf7 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.h
+++ b/include/LibreOfficeKit/LibreOfficeKit.h
@@ -203,6 +203,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 df9e211..1f2311a 100644
--- a/include/LibreOfficeKit/LibreOfficeKit.hxx
+++ b/include/LibreOfficeKit/LibreOfficeKit.hxx
@@ -330,6 +330,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 e31fd70..34f5315 100644
--- a/include/vcl/ITiledRenderable.hxx
+++ b/include/vcl/ITiledRenderable.hxx
@@ -197,6 +197,11 @@ public:
                                int /*nTileTwipHeight*/)
     {
     }
+
+    /// @see lok::Document::setClientVisibleArea().
+    virtual void setClientVisibleArea(const Rectangle& /*rRectangle*/)
+    {
+    }
 };
 
 } // namespace vcl
diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx
index 37cadfd..1251f76 100644
--- a/sw/inc/unotxdoc.hxx
+++ b/sw/inc/unotxdoc.hxx
@@ -438,6 +438,8 @@ public:
     virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::isMimeTypeSupported().
     virtual bool isMimeTypeSupported() SAL_OVERRIDE;
+    /// @see vcl::ITiledRenderable::setClientVisibleArea().
+    virtual void setClientVisibleArea(const Rectangle& rRectangle) SAL_OVERRIDE;
     /// @see vcl::ITiledRenderable::getPointer().
     virtual Pointer getPointer() SAL_OVERRIDE;
 
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index 6a0a216..27612b1 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3218,6 +3218,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;


More information about the Libreoffice-commits mailing list