Blob Blame History Raw
From 71ce3c4cc6e973d252f6db0a22c01670d9fc571f Mon Sep 17 00:00:00 2001
From: Pranav Kant <pranavk@gnome.org>
Date: Fri, 5 Jun 2015 20:38:55 +0530
Subject: [PATCH 020/398] lokdocview: move GtkDrawingArea size request out of
 renderDocument()

... and place it at places only where the widget can change its size.

Change-Id: I4a4b28b35eba06a6faab434677d4d70d2a33339a
(cherry picked from commit 1483643ba5930474b9eab73b723a775dd3c8c850)
---
 libreofficekit/source/gtk/lokdocview.cxx | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
index d9e8c14aa9d5..42dd14cb34ed 100644
--- a/libreofficekit/source/gtk/lokdocview.cxx
+++ b/libreofficekit/source/gtk/lokdocview.cxx
@@ -790,7 +790,6 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
     guint nRows = ceil((double)nDocumentHeightPixels / nTileSizePixels);
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
 
-    gtk_widget_set_size_request(m_pDrawingArea, nDocumentWidthPixels, nDocumentHeightPixels);
     cairo_t *pcairo = gdk_cairo_create(m_pDrawingArea->window);
 
     // Render the tiles.
@@ -826,7 +825,7 @@ void LOKDocView_Impl::renderDocument(GdkRectangle* pPartial)
 
             if (bPaint)
             {
-                g_info("tile_buffer_get_tile (%d, %d)", nRow, nColumn);
+                //g_info("tile_buffer_get_tile (%d, %d)", nRow, nColumn);
 
                 Tile& currentTile = m_pTileBuffer->getTile(nRow, nColumn);
                 GdkPixbuf* pPixBuf = currentTile.getBuffer();
@@ -1028,6 +1027,10 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
     case LOK_CALLBACK_DOCUMENT_SIZE_CHANGED:
     {
         payloadToSize(pCallback->m_aPayload.c_str(), m_nDocumentWidthTwips, m_nDocumentHeightTwips);
+        gtk_widget_set_size_request(m_pDrawingArea,
+                                    twipToPixel(m_nDocumentWidthTwips, m_fZoom),
+                                    twipToPixel(m_nDocumentHeightTwips, m_fZoom));
+        m_pTileBuffer->resetAllTiles();
     }
     break;
     case LOK_CALLBACK_SET_PART:
@@ -1252,6 +1255,9 @@ SAL_DLLPUBLIC_EXPORT gboolean lok_docview_open_document( LOKDocView* pDocView, c
                                                           nTileSizePixels,
                                                           nRows,
                                                           nColumns);
+        gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
+                                    nDocumentWidthPixels,
+                                    nDocumentHeightPixels);
         pDocView->m_pImpl->renderDocument(0);
     }
 
@@ -1273,6 +1279,9 @@ SAL_DLLPUBLIC_EXPORT void lok_docview_set_zoom ( LOKDocView* pDocView, float fZo
     guint nColumns = ceil((double)nDocumentWidthPixels / nTileSizePixels);
 
     pDocView->m_pImpl->m_pTileBuffer->setZoom(fZoom, nRows, nColumns);
+    gtk_widget_set_size_request(pDocView->m_pImpl->m_pDrawingArea,
+                                nDocumentWidthPixels,
+                                nDocumentHeightPixels);
 
     if ( pDocView->m_pImpl->m_pDocument )
         pDocView->m_pImpl->renderDocument(0);
-- 
2.12.0