135360
From 54cbf52419e6318c2cdf19232f79a515ffb6e7f6 Mon Sep 17 00:00:00 2001
135360
From: Pranav Kant <pranavk@gnome.org>
135360
Date: Thu, 24 Sep 2015 18:47:01 +0200
135360
Subject: [PATCH 166/398] lokdocview: Reset view completely
135360
135360
Resetting tiles only is not enough. We need to empty stale
135360
selection rectangles, handle bars, cursor positions etc., so that
135360
they do not interfere with next view to be opened using same
135360
widget instance.
135360
135360
We are not destroying the document here, so the widget would
135360
still point to the same document unless it is made to point to
135360
another document by subsequent lok_doc_view_open_document calls.
135360
135360
Change-Id: I3c7cc789c8c7393b3793b4edf6aa96d54bc0b1a3
135360
Reviewed-on: https://gerrit.libreoffice.org/18866
135360
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
135360
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
135360
(cherry picked from commit c3ce35f0a12af2887b10987f76675174563487d7)
135360
---
135360
 libreofficekit/source/gtk/lokdocview.cxx | 37 ++++++++++++++++++++++++++++++++
135360
 1 file changed, 37 insertions(+)
135360
135360
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
135360
index 6679cee56cd3..99476764e69d 100644
135360
--- a/libreofficekit/source/gtk/lokdocview.cxx
135360
+++ b/libreofficekit/source/gtk/lokdocview.cxx
135360
@@ -1986,6 +1986,43 @@ lok_doc_view_reset_view(LOKDocView* pDocView)
135360
 {
135360
     LOKDocViewPrivate *priv = static_cast<LOKDocViewPrivate*>(lok_doc_view_get_instance_private (pDocView));
135360
     priv->m_aTileBuffer.resetAllTiles();
135360
+    priv->m_nLoadProgress = 0.0;
135360
+
135360
+    memset(&priv->m_aVisibleCursor, 0, sizeof(priv->m_aVisibleCursor));
135360
+    priv->m_bCursorOverlayVisible = false;
135360
+    priv->m_bCursorVisible = false;
135360
+
135360
+    priv->m_nLastButtonPressTime = 0;
135360
+    priv->m_nLastButtonReleaseTime = 0;
135360
+    priv->m_aTextSelectionRectangles.clear();
135360
+
135360
+    memset(&priv->m_aTextSelectionStart, 0, sizeof(priv->m_aTextSelectionStart));
135360
+    memset(&priv->m_aTextSelectionEnd, 0, sizeof(priv->m_aTextSelectionEnd));
135360
+    memset(&priv->m_aGraphicSelection, 0, sizeof(priv->m_aGraphicSelection));
135360
+    priv->m_bInDragGraphicSelection = false;
135360
+
135360
+    cairo_surface_destroy(priv->m_pHandleStart);
135360
+    priv->m_pHandleStart = 0;
135360
+    memset(&priv->m_aHandleStartRect, 0, sizeof(priv->m_aHandleStartRect));
135360
+    priv->m_bInDragStartHandle = false;
135360
+
135360
+    cairo_surface_destroy(priv->m_pHandleMiddle);
135360
+    priv->m_pHandleMiddle = 0;
135360
+    memset(&priv->m_aHandleMiddleRect, 0, sizeof(priv->m_aHandleMiddleRect));
135360
+    priv->m_bInDragMiddleHandle = false;
135360
+
135360
+    cairo_surface_destroy(priv->m_pHandleEnd);
135360
+    priv->m_pHandleEnd = 0;
135360
+    memset(&priv->m_aHandleEndRect, 0, sizeof(priv->m_aHandleEndRect));
135360
+    priv->m_bInDragEndHandle = false;
135360
+
135360
+    cairo_surface_destroy(priv->m_pGraphicHandle);
135360
+    priv->m_pGraphicHandle = 0;
135360
+    memset(&priv->m_aGraphicHandleRects, 0, sizeof(priv->m_aGraphicHandleRects));
135360
+    memset(&priv->m_bInDragGraphicHandles, 0, sizeof(priv->m_bInDragGraphicHandles));
135360
+
135360
+    priv->m_nViewId = 0;
135360
+
135360
     gtk_widget_queue_draw(GTK_WIDGET(pDocView));
135360
 }
135360
 
135360
-- 
135360
2.12.0
135360