summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-02-02 10:32:36 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-02-02 10:56:40 +0100
commitbd8610ebafa9caf9f09a5aba9cca04c23691513d (patch)
tree86d0c99b905a89b2d2c06158f66ff4b5c1603554
parent9d8b33079494cf7b5e66bd6c9d71f025efd9a653 (diff)
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
-rw-r--r--desktop/source/lib/init.cxx15
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.h2
-rw-r--r--include/LibreOfficeKit/LibreOfficeKit.hxx15
-rw-r--r--include/vcl/ITiledRenderable.hxx5
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx10
-rw-r--r--sw/inc/unotxdoc.hxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx9
7 files changed, 57 insertions, 1 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index aaf52f1c9cb6..5010bd0347c3 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 3411b6f4e310..c98dd1fed6a8 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 31328914e239..1fbd78425273 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 a1e1d80128d9..d9cd34720512 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 dfe14a0c22d6..825a72fb05de 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 cd6135a05df4..5b2e6d054340 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 972edd95ae00..c42bcca0a0c5 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;