Blame SOURCES/0016-lokdocview-wrap-a-functionality-inside-a-member-func.patch

f325b2
From d7f30799b250c8ffd3d25307e9efb5e7f13ce8b0 Mon Sep 17 00:00:00 2001
f325b2
From: Pranav Kant <pranavk@gnome.org>
f325b2
Date: Thu, 4 Jun 2015 14:15:58 +0530
f325b2
Subject: [PATCH 016/398] lokdocview: wrap a functionality inside a member
f325b2
 function
f325b2
f325b2
Lets use a member function to set invalid tiles that come under the
f325b2
given GdkRectangle.
f325b2
f325b2
Change-Id: I440336ddf3c5fd9094f35bb89479aa76a42477fa
f325b2
(cherry picked from commit ad0a404ef3097d92cf9a0e861e076a72074a5258)
f325b2
---
f325b2
 libreofficekit/source/gtk/lokdocview.cxx | 54 ++++++++++++++------------------
f325b2
 1 file changed, 24 insertions(+), 30 deletions(-)
f325b2
f325b2
diff --git a/libreofficekit/source/gtk/lokdocview.cxx b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
index bfb414f0909c..cfa71a357f22 100644
f325b2
--- a/libreofficekit/source/gtk/lokdocview.cxx
f325b2
+++ b/libreofficekit/source/gtk/lokdocview.cxx
f325b2
@@ -212,6 +212,8 @@ struct LOKDocView_Impl
f325b2
     void searchNotFound(const std::string& rPayload);
f325b2
     /// LOK decided to change parts, need to update UI.
f325b2
     void setPart(const std::string& rPayload);
f325b2
+    /// Sets the tiles enclosed by rRectangle as invalid in m_pTileBuffer
f325b2
+    void setTilesInvalid(const GdkRectangle& rRectangle);
f325b2
 };
f325b2
 
f325b2
 namespace {
f325b2
@@ -646,6 +648,26 @@ bool LOKDocView_Impl::isEmptyRectangle(const GdkRectangle& rRectangle)
f325b2
     return rRectangle.x == 0 && rRectangle.y == 0 && rRectangle.width == 0 && rRectangle.height == 0;
f325b2
 }
f325b2
 
f325b2
+void LOKDocView_Impl::setTilesInvalid(const GdkRectangle& rRectangle)
f325b2
+{
f325b2
+    GdkRectangle aRectanglePixels;
f325b2
+    GdkPoint aStart, aEnd;
f325b2
+
f325b2
+    aRectanglePixels.x = twipToPixel(rRectangle.x, m_fZoom);
f325b2
+    aRectanglePixels.y = twipToPixel(rRectangle.y, m_fZoom);
f325b2
+    aRectanglePixels.width = twipToPixel(rRectangle.width, m_fZoom);
f325b2
+    aRectanglePixels.height = twipToPixel(rRectangle.height, m_fZoom);
f325b2
+
f325b2
+    aStart.x = aRectanglePixels.y / nTileSizePixels;
f325b2
+    aStart.y = aRectanglePixels.x / nTileSizePixels;
f325b2
+    aEnd.x = (aRectanglePixels.y + aRectanglePixels.height + nTileSizePixels) / nTileSizePixels;
f325b2
+    aEnd.y = (aRectanglePixels.x + aRectanglePixels.width + nTileSizePixels) / nTileSizePixels;
f325b2
+
f325b2
+    for (int i = aStart.x; i < aEnd.x; i++)
f325b2
+        for (int j = aStart.y; j < aEnd.y; j++)
f325b2
+            m_pTileBuffer->tile_buffer_set_invalid(i, j);
f325b2
+}
f325b2
+
f325b2
 void LOKDocView_Impl::renderHandle(cairo_t* pCairo, const GdkRectangle& rCursor, cairo_surface_t* pHandle, GdkRectangle& rRectangle)
f325b2
 {
f325b2
     GdkPoint aCursorBottom;
f325b2
@@ -915,21 +937,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
f325b2
         if (pCallback->m_aPayload != "EMPTY")
f325b2
         {
f325b2
             GdkRectangle aRectangle = LOKDocView_Impl::payloadToRectangle(pCallback->m_aPayload.c_str());
f325b2
-            GdkRectangle aRectanglePixels;
f325b2
-            aRectanglePixels.x = twipToPixel(aRectangle.x, m_fZoom);
f325b2
-            aRectanglePixels.y = twipToPixel(aRectangle.y, m_fZoom);
f325b2
-            aRectanglePixels.width = twipToPixel(aRectangle.width, m_fZoom);
f325b2
-            aRectanglePixels.height = twipToPixel(aRectangle.height, m_fZoom);
f325b2
-            int rowStart = aRectanglePixels.y / nTileSizePixels;
f325b2
-            int colStart = aRectanglePixels.x / nTileSizePixels;
f325b2
-            int rowEnd = (aRectanglePixels.y + aRectanglePixels.height + nTileSizePixels) / nTileSizePixels;
f325b2
-            int colEnd = (aRectanglePixels.x + aRectanglePixels.width + nTileSizePixels) / nTileSizePixels;
f325b2
-            int i,j;
f325b2
-            for (i = rowStart; i < rowEnd; i++) {
f325b2
-                for (j = colStart; j < colEnd; j++) {
f325b2
-                    m_pTileBuffer->tile_buffer_set_invalid(i, j);
f325b2
-                }
f325b2
-            }
f325b2
+            setTilesInvalid(aRectangle);
f325b2
             renderDocument(0);
f325b2
         }
f325b2
         else
f325b2
@@ -943,21 +951,7 @@ gboolean LOKDocView_Impl::callbackImpl(CallbackData* pCallback)
f325b2
     {
f325b2
         m_aVisibleCursor = LOKDocView_Impl::payloadToRectangle(pCallback->m_aPayload.c_str());
f325b2
         m_bCursorOverlayVisible = true;
f325b2
-        GdkRectangle aRectanglePixels;
f325b2
-        aRectanglePixels.x = twipToPixel(m_aVisibleCursor.x, m_fZoom);
f325b2
-        aRectanglePixels.y = twipToPixel(m_aVisibleCursor.y, m_fZoom);
f325b2
-        aRectanglePixels.width = twipToPixel(m_aVisibleCursor.width, m_fZoom);
f325b2
-        aRectanglePixels.height = twipToPixel(m_aVisibleCursor.height, m_fZoom);
f325b2
-        int rowStart = aRectanglePixels.y / nTileSizePixels;
f325b2
-        int colStart = aRectanglePixels.x / nTileSizePixels;
f325b2
-        int rowEnd = (aRectanglePixels.y + aRectanglePixels.height + nTileSizePixels) / nTileSizePixels;
f325b2
-        int colEnd = (aRectanglePixels.x + aRectanglePixels.width + nTileSizePixels) / nTileSizePixels;
f325b2
-        int i,j;
f325b2
-        for (i = rowStart; i < rowEnd; i++) {
f325b2
-            for (j = colStart; j < colEnd; j++) {
f325b2
-                m_pTileBuffer->tile_buffer_set_invalid(i, j);
f325b2
-            }
f325b2
-        }
f325b2
+        setTilesInvalid(m_aVisibleCursor);
f325b2
         renderDocument(0);
f325b2
     }
f325b2
     break;
f325b2
-- 
f325b2
2.12.0
f325b2