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

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