summaryrefslogtreecommitdiffstats
path: root/libreofficekit
diff options
context:
space:
mode:
authorMihai Varga <mihai.varga@collabora.com>2015-11-06 14:34:28 +0200
committerMihai Varga <mihai.mv13@gmail.com>2015-11-13 09:55:19 +0200
commit96cd2abd748ed24e5aba50cc4c300cf06e512db3 (patch)
treea1e6636aef83f49a1d9ee81c87d0a9f71c88b5d2 /libreofficekit
parenttdf#95744: saving shape names re-enabled (diff)
downloadcore-96cd2abd748ed24e5aba50cc4c300cf06e512db3.tar.gz
core-96cd2abd748ed24e5aba50cc4c300cf06e512db3.zip
LOK: setClientZoom() - sets the client zoom level
We need to know the client's view level to correctly handle the mouse events in calc. PaintTile() set a zoom level that corresponds to the requested tiles and previously postMouseEvent would call SetZoom(1,1). Now we can make use of knowing the client's view level and call SetZoom() with the correct parameters Change-Id: I34b5afcdcc06a671a8ac92c03e87404e42adf4cd Conflicts: sc/source/ui/unoobj/docuno.cxx
Diffstat (limited to 'libreofficekit')
-rw-r--r--libreofficekit/source/gtk/lokdocview.cxx38
-rw-r--r--libreofficekit/source/gtk/tilebuffer.hxx11
2 files changed, 48 insertions, 1 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index 550a9221744e..f52ba6176b31 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -1506,6 +1506,23 @@ setGraphicSelectionInThread(gpointer data)
}
static void
+setClientZoomInThread(gpointer data)
+{
+ GTask* task = G_TASK(data);
+ LOKDocView* pDocView = LOK_DOC_VIEW(g_task_get_source_object(task));
+ LOKDocViewPrivate& priv = getPrivate(pDocView);
+ LOEvent* pLOEvent = static_cast<LOEvent*>(g_task_get_task_data(task));
+
+ if (!priv->m_pDocument)
+ return;
+ priv->m_pDocument->pClass->setClientZoom(priv->m_pDocument,
+ pLOEvent->m_nTilePixelWidth,
+ pLOEvent->m_nTilePixelHeight,
+ pLOEvent->m_nTileTwipWidth,
+ pLOEvent->m_nTileTwipHeight);
+}
+
+static void
postMouseEventInThread(gpointer data)
{
GTask* task = G_TASK(data);
@@ -1721,6 +1738,9 @@ lokThreadFunc(gpointer data, gpointer /*user_data*/)
case LOK_SET_GRAPHIC_SELECTION:
setGraphicSelectionInThread(task);
break;
+ case LOK_SET_CLIENT_ZOOM:
+ setClientZoomInThread(task);
+ break;
}
g_object_unref(task);
@@ -2301,6 +2321,7 @@ SAL_DLLPUBLIC_EXPORT void
lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
{
LOKDocViewPrivate& priv = getPrivate(pDocView);
+ GError* error = NULL;
priv->m_fZoom = fZoom;
long nDocumentWidthPixels = twipToPixel(priv->m_nDocumentWidthTwips, fZoom);
@@ -2313,6 +2334,23 @@ lok_doc_view_set_zoom (LOKDocView* pDocView, float fZoom)
gtk_widget_set_size_request(GTK_WIDGET(pDocView),
nDocumentWidthPixels,
nDocumentHeightPixels);
+
+ // Update the client's view size
+ GTask* task = g_task_new(pDocView, NULL, NULL, NULL);
+ LOEvent* pLOEvent = new LOEvent(LOK_SET_CLIENT_ZOOM);
+ pLOEvent->m_nTilePixelWidth = nTileSizePixels;
+ pLOEvent->m_nTilePixelHeight = nTileSizePixels;
+ pLOEvent->m_nTileTwipWidth = pixelToTwip(nTileSizePixels, fZoom);
+ pLOEvent->m_nTileTwipHeight = pixelToTwip(nTileSizePixels, fZoom);
+ g_task_set_task_data(task, pLOEvent, LOEvent::destroy);
+
+ g_thread_pool_push(priv->lokThreadPool, g_object_ref(task), &error);
+ if (error != NULL)
+ {
+ g_warning("Unable to call LOK_SET_CLIENT_ZOOM: %s", error->message);
+ g_clear_error(&error);
+ }
+ g_object_unref(task);
}
SAL_DLLPUBLIC_EXPORT float
diff --git a/libreofficekit/source/gtk/tilebuffer.hxx b/libreofficekit/source/gtk/tilebuffer.hxx
index 7d7160e0450e..c8f401d38c0a 100644
--- a/libreofficekit/source/gtk/tilebuffer.hxx
+++ b/libreofficekit/source/gtk/tilebuffer.hxx
@@ -157,7 +157,8 @@ enum
LOK_POST_KEY,
LOK_PAINT_TILE,
LOK_POST_MOUSE_EVENT,
- LOK_SET_GRAPHIC_SELECTION
+ LOK_SET_GRAPHIC_SELECTION,
+ LOK_SET_CLIENT_ZOOM
};
enum
@@ -231,6 +232,14 @@ struct LOEvent
int m_nSetGraphicSelectionY;
///@}
+ /// @name setClientView parameters
+ ///@{
+ int m_nTilePixelWidth;
+ int m_nTilePixelHeight;
+ int m_nTileTwipWidth;
+ int m_nTileTwipHeight;
+ ///@}
+
/// Constructor to instantiate an object of type `type`.
LOEvent(int type)
: m_nType(type)