diff options
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKitGtk.h | 11 | ||||
-rw-r--r-- | libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 3 | ||||
-rw-r--r-- | libreofficekit/source/gtk/lokdocview.cxx | 24 |
3 files changed, 37 insertions, 1 deletions
diff --git a/include/LibreOfficeKit/LibreOfficeKitGtk.h b/include/LibreOfficeKit/LibreOfficeKitGtk.h index e06d154f772e..c3e4b284f2e5 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 8b7c931dc4d3..45ac17e1f134 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 e6da63017017..dfe14a0c22d6 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); |