Kaydet (Commit) bd8610eb authored tarafından Miklos Vajna's avatar Miklos Vajna

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
üst 9d8b3307
...@@ -350,6 +350,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, ...@@ -350,6 +350,7 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis,
int nTilePixelHeight, int nTilePixelHeight,
int nTileTwipWidth, int nTileTwipWidth,
int nTileTwipHeight); int nTileTwipHeight);
static void doc_setClientVisibleArea(LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
static int doc_createView(LibreOfficeKitDocument* pThis); static int doc_createView(LibreOfficeKitDocument* pThis);
static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId); static void doc_destroyView(LibreOfficeKitDocument* pThis, int nId);
static void doc_setView(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 ...@@ -396,6 +397,7 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone
m_pDocumentClass->resetSelection = doc_resetSelection; m_pDocumentClass->resetSelection = doc_resetSelection;
m_pDocumentClass->getCommandValues = doc_getCommandValues; m_pDocumentClass->getCommandValues = doc_getCommandValues;
m_pDocumentClass->setClientZoom = doc_setClientZoom; m_pDocumentClass->setClientZoom = doc_setClientZoom;
m_pDocumentClass->setClientVisibleArea = doc_setClientVisibleArea;
m_pDocumentClass->createView = doc_createView; m_pDocumentClass->createView = doc_createView;
m_pDocumentClass->destroyView = doc_destroyView; m_pDocumentClass->destroyView = doc_destroyView;
...@@ -1496,6 +1498,19 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTilePixelWidth ...@@ -1496,6 +1498,19 @@ static void doc_setClientZoom(LibreOfficeKitDocument* pThis, int nTilePixelWidth
pDoc->setClientZoom(nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight); 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*/) static int doc_createView(LibreOfficeKitDocument* /*pThis*/)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
......
...@@ -205,6 +205,8 @@ struct _LibreOfficeKitDocumentClass ...@@ -205,6 +205,8 @@ struct _LibreOfficeKitDocumentClass
int nTilePixelHeight, int nTilePixelHeight,
int nTileTwipWidth, int nTileTwipWidth,
int nTileTwipHeight); int nTileTwipHeight);
/// @see lok::Document::setVisibleArea).
void (*setClientVisibleArea) (LibreOfficeKitDocument* pThis, int nX, int nY, int nWidth, int nHeight);
/// @see lok::Document::createView(). /// @see lok::Document::createView().
int (*createView) (LibreOfficeKitDocument* pThis); int (*createView) (LibreOfficeKitDocument* pThis);
......
...@@ -332,6 +332,21 @@ public: ...@@ -332,6 +332,21 @@ public:
mpDoc->pClass->setClientZoom(mpDoc, nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight); mpDoc->pClass->setClientZoom(mpDoc, nTilePixelWidth, nTilePixelHeight, nTileTwipWidth, nTileTwipHeight);
} }
/**
* 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. * Create a new view for an existing document.
* By default a loaded document has 1 view. * By default a loaded document has 1 view.
......
...@@ -202,6 +202,11 @@ public: ...@@ -202,6 +202,11 @@ public:
(void) nTileTwipWidth; (void) nTileTwipWidth;
(void) nTileTwipHeight; (void) nTileTwipHeight;
} }
/// @see lok::Document::setClientVisibleArea().
virtual void setClientVisibleArea(const Rectangle& /*rRectangle*/)
{
}
}; };
} // namespace vcl } // namespace vcl
......
...@@ -569,7 +569,15 @@ postKeyEventInThread(gpointer data) ...@@ -569,7 +569,15 @@ postKeyEventInThread(gpointer data)
} }
if (priv->m_bVisibleAreaSet) 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; priv->m_bVisibleAreaSet = false;
} }
......
...@@ -434,6 +434,8 @@ public: ...@@ -434,6 +434,8 @@ public:
virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override; virtual void setClipboard(const css::uno::Reference<css::datatransfer::clipboard::XClipboard>& xClipboard) override;
/// @see vcl::ITiledRenderable::isMimeTypeSupported(). /// @see vcl::ITiledRenderable::isMimeTypeSupported().
virtual bool isMimeTypeSupported() override; virtual bool isMimeTypeSupported() override;
/// @see vcl::ITiledRenderable::setClientVisibleArea().
virtual void setClientVisibleArea(const Rectangle& rRectangle);
/// @see vcl::ITiledRenderable::getPointer(). /// @see vcl::ITiledRenderable::getPointer().
virtual Pointer getPointer() override; virtual Pointer getPointer() override;
......
...@@ -3180,6 +3180,15 @@ bool SwXTextDocument::isMimeTypeSupported() ...@@ -3180,6 +3180,15 @@ bool SwXTextDocument::isMimeTypeSupported()
return aDataHelper.GetXTransferable().is() && SwTransferable::IsPaste(*pWrtShell, aDataHelper); 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() Pointer SwXTextDocument::getPointer()
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment