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

lokdocview: add a set_visible_area()

Change-Id: Ib63959ad64fe52b648e0c0d3fe6d49fb282d57ee
üst 6691d78f
...@@ -113,6 +113,17 @@ LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView* ...@@ -113,6 +113,17 @@ LibreOfficeKitDocument* lok_doc_view_get_document (LOKDocView*
*/ */
void lok_doc_view_set_zoom (LOKDocView* pDocView, void lok_doc_view_set_zoom (LOKDocView* pDocView,
float fZoom); 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: * lok_doc_view_get_zoom:
......
...@@ -440,6 +440,9 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ ) ...@@ -440,6 +440,9 @@ static void changeZoom( GtkWidget* pButton, gpointer /* pItem */ )
if ( pDocView ) if ( pDocView )
{ {
lok_doc_view_set_zoom( LOK_DOC_VIEW(pDocView), fZoom ); 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("%"); std::string aZoom = std::to_string(int(fZoom * 100)) + std::string("%");
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <sstream> #include <sstream>
#include <iostream>
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include <com/sun/star/awt/Key.hpp> #include <com/sun/star/awt/Key.hpp>
...@@ -129,6 +130,9 @@ struct LOKDocViewPrivateImpl ...@@ -129,6 +130,9 @@ struct LOKDocViewPrivateImpl
*/ */
int m_nTileSizeTwips; int m_nTileSizeTwips;
GdkRectangle m_aVisibleArea;
bool m_bVisibleAreaSet;
LOKDocViewPrivateImpl() LOKDocViewPrivateImpl()
: m_aLOPath(nullptr), : m_aLOPath(nullptr),
m_aDocPath(nullptr), m_aDocPath(nullptr),
...@@ -166,7 +170,9 @@ struct LOKDocViewPrivateImpl ...@@ -166,7 +170,9 @@ struct LOKDocViewPrivateImpl
m_bInDragEndHandle(false), m_bInDragEndHandle(false),
m_pGraphicHandle(nullptr), m_pGraphicHandle(nullptr),
m_nViewId(0), 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_aGraphicHandleRects, 0, sizeof(m_aGraphicHandleRects));
memset(&m_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles)); memset(&m_bInDragGraphicHandles, 0, sizeof(m_bInDragGraphicHandles));
...@@ -561,6 +567,11 @@ postKeyEventInThread(gpointer data) ...@@ -561,6 +567,11 @@ postKeyEventInThread(gpointer data)
priv->m_nTileSizeTwips); priv->m_nTileSizeTwips);
priv->m_nTileSizeTwips = 0; priv->m_nTileSizeTwips = 0;
} }
if (priv->m_bVisibleAreaSet)
{
// TODO invoke lok::Document::setVisibleArea() here.
priv->m_bVisibleAreaSet = false;
}
std::stringstream ss; std::stringstream ss;
ss << "lok::Document::postKeyEvent(" << pLOEvent->m_nKeyEvent << ", " << pLOEvent->m_nCharCode << ", " << pLOEvent->m_nKeyCode << ")"; ss << "lok::Document::postKeyEvent(" << pLOEvent->m_nKeyEvent << ", " << pLOEvent->m_nCharCode << ", " << pLOEvent->m_nKeyCode << ")";
...@@ -2520,6 +2531,17 @@ lok_doc_view_get_document (LOKDocView* pDocView) ...@@ -2520,6 +2531,17 @@ lok_doc_view_get_document (LOKDocView* pDocView)
return priv->m_pDocument; return priv->m_pDocument;
} }
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 SAL_DLLPUBLIC_EXPORT void
lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom) lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
{ {
......
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