Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Only update needed entries instead of iterating over the whole list.
From 9d431bbe0227594473f8179d84389166730feb99 Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Fri, 3 Jun 2011 22:31:15 -0430
Subject: [PATCH 19/21] Remove rebundant check since we already know its in boundaries.

---
 sc/source/ui/view/gridwin4.cxx |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx
index 9441425..5046c15 100644
--- a/sc/source/ui/view/gridwin4.cxx
+++ b/sc/source/ui/view/gridwin4.cxx
@@ -804,16 +804,14 @@ void ScGridWindow::Draw( SCCOL nX1, SCROW nY1, SCCOL nX2, SCROW nY2, 
ScUpdateMod
             for (sal_uInt16 i=0; i<nCount; i++)
             {
                 ScRangeFindData* pData = pRangeFinder->GetObject(i);
-                if (pData)
-                {
-                    ScRange aRef = pData->aRef;
-                    aRef.Justify();
-                    if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
-                        aOutputData.DrawRefMark( aRef.aStart.Col(), aRef.aStart.Row(),
-                                                aRef.aEnd.Col(), aRef.aEnd.Row(),
-                                                Color( ScRangeFindList::GetColorName( i ) ),
-                                                sal_True );
-                }
+
+                ScRange aRef = pData->aRef;
+                aRef.Justify();
+                if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
+                    aOutputData.DrawRefMark( aRef.aStart.Col(), aRef.aStart.Row(),
+                                            aRef.aEnd.Col(), aRef.aEnd.Row(),
+                                            Color( ScRangeFindList::GetColorName( i ) ),
+                                            sal_True );
             }
         }
     }
-- 
1.7.3.4

From cc840f34c9ae7efef51755b41c6ca1305c527fe9 Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Fri, 3 Jun 2011 22:34:55 -0430
Subject: [PATCH 20/21] Remove rebundant check since we already know its in boundaries.

---
 sc/source/ui/view/gridwin.cxx |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx
index fb2506d..d8885a2 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -4545,7 +4545,7 @@ sal_Bool ScGridWindow::HitRangeFinder( const Point& rMouse, sal_Bool& rCorner,
                 //     rueckwaerts suchen, damit der zuletzt gepaintete Rahmen gefunden wird
                 --i;
                 ScRangeFindData* pData = pRangeFinder->GetObject(i);
-                if ( pData && pData->aRef.In(aAddr) )
+                if ( pData->aRef.In(aAddr) )
                 {
                     if (pIndex)        *pIndex = i;
                     if (pAddX) *pAddX = nPosX - pData->aRef.aStart.Col();
@@ -4709,8 +4709,6 @@ void ScGridWindow::RFMouseMove( const MouseEvent& rMEvt, sal_Bool bUp )
     if (!pRangeFinder || nRFIndex >= pRangeFinder->Count())
         return;
     ScRangeFindData* pData = pRangeFinder->GetObject( nRFIndex );
-    if (!pData)
-        return;
 
     // Mauszeiger
 
-- 
1.7.3.4

From 8fb136cdb4e24968261525ea238fc1ef1c7b1ede Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Sat, 4 Jun 2011 07:30:58 -0430
Subject: [PATCH 21/21] Refactor PaintRangeFinder to only iterate needed entries.

Added a helper function PaintRangeFinderEntry.
---
 sc/source/ui/inc/tabview.hxx   |   13 ++++
 sc/source/ui/view/tabview3.cxx |  136 +++++++++++++++++++++-------------------
 2 files changed, 85 insertions(+), 64 deletions(-)

diff --git a/sc/source/ui/inc/tabview.hxx b/sc/source/ui/inc/tabview.hxx
index fa0f2ed..a86a6a6 100644
--- a/sc/source/ui/inc/tabview.hxx
+++ b/sc/source/ui/inc/tabview.hxx
@@ -43,6 +43,7 @@ class ScRowBar;
 class ScColBar;
 class ScTabControl;
 class ScTabViewShell;
+class ScRangeFindData;
 class SfxPrinter;
 class ScDrawView;
 class SvBorder;
@@ -200,6 +201,18 @@ private:
     void            SkipCursorHorizontal(SCsCOL& rCurX, SCsROW& rCurY, SCsCOL nOldX, SCsROW nMovX);
     void            SkipCursorVertical(SCsCOL& rCurX, SCsROW& rCurY, SCsROW nOldY, SCsROW nMovY);
 
+    /**
+     *
+     *  @brief Update marks for a selected Range. This is a helper function
+     *  for PaintRangeFinder.
+     *
+     *  @param pData: Range to update for painting.
+     *  @param nTab: Current tab.
+     *
+     **/
+
+    void            PaintRangeFinderEntry (ScRangeFindData* pData, SCTAB nTab);
+
 protected:
     void                       UpdateHeaderWidth( const ScVSplitPos* pWhich = NULL,
                                         const SCROW* pPosY = NULL );
diff --git a/sc/source/ui/view/tabview3.cxx b/sc/source/ui/view/tabview3.cxx
index 2b28a05..26d3d50 100644
--- a/sc/source/ui/view/tabview3.cxx
+++ b/sc/source/ui/view/tabview3.cxx
@@ -1940,6 +1940,67 @@ void ScTabView::PaintArea( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, 
SCRO
     // is set (width or height changed).
 }
 
+void ScTabView::PaintRangeFinderEntry (ScRangeFindData* pData, const SCTAB nTab)
+{
+    ScRange aRef = pData->aRef;
+    aRef.Justify();                                    // Justify fuer die Abfragen unten
+
+    if ( aRef.aStart == aRef.aEnd )            //! Tab ignorieren?
+        aViewData.GetDocument()->ExtendMerge(aRef);
+
+    if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
+    {
+        SCCOL nCol1 = aRef.aStart.Col();
+        SCROW nRow1 = aRef.aStart.Row();
+        SCCOL nCol2 = aRef.aEnd.Col();
+        SCROW nRow2 = aRef.aEnd.Row();
+
+        //     wegnehmen -> Repaint
+        //     SC_UPDATE_MARKS: Invalidate, nicht bis zum Zeilenende
+
+        bool bHiddenEdge = false;
+        SCROW nTmp;
+        ScDocument* pDoc = aViewData.GetDocument();
+        while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab) )
+        {
+            --nCol1;
+            bHiddenEdge = true;
+        }
+        while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab) )
+        {
+            ++nCol2;
+            bHiddenEdge = true;
+        }
+        nTmp = pDoc->LastVisibleRow(0, nRow1, nTab);
+        if (!ValidRow(nTmp))
+            nTmp = 0;
+        if (nTmp < nRow1)
+        {
+            nRow1 = nTmp;
+            bHiddenEdge = true;
+        }
+        nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab);
+        if (!ValidRow(nTmp))
+            nTmp = MAXROW;
+        if (nTmp > nRow2)
+        {
+            nRow2 = nTmp;
+            bHiddenEdge = true;
+        }
+
+        if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge )
+        {
+            // nur an den Raendern entlang
+            PaintArea( nCol1, nRow1, nCol2, nRow1, SC_UPDATE_MARKS );
+            PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, SC_UPDATE_MARKS );
+            PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, SC_UPDATE_MARKS );
+            PaintArea( nCol1, nRow2, nCol2, nRow2, SC_UPDATE_MARKS );
+        }
+        else   // alles am Stueck
+            PaintArea( nCol1, nRow1, nCol2, nRow2, SC_UPDATE_MARKS );
+    }
+}
+
 void ScTabView::PaintRangeFinder( long nNumber )
 {
     ScInputHandler* pHdl = SC_MOD()->GetInputHdl( aViewData.GetViewShell() );
@@ -1950,71 +2011,18 @@ void ScTabView::PaintRangeFinder( long nNumber )
         {
             SCTAB nTab = aViewData.GetTabNo();
             sal_uInt16 nCount = (sal_uInt16)pRangeFinder->Count();
-            for (sal_uInt16 i=0; i<nCount; i++)
-                if ( nNumber < 0 || nNumber == i )
-                {
-                    ScRangeFindData* pData = pRangeFinder->GetObject(i);
-                    if (pData)
-                    {
-                        ScRange aRef = pData->aRef;
-                        aRef.Justify();                                        // Justify fuer die 
Abfragen unten
-
-                        if ( aRef.aStart == aRef.aEnd )                //! Tab ignorieren?
-                            aViewData.GetDocument()->ExtendMerge(aRef);
-
-                        if ( aRef.aStart.Tab() >= nTab && aRef.aEnd.Tab() <= nTab )
-                        {
-                            SCCOL nCol1 = aRef.aStart.Col();
-                            SCROW nRow1 = aRef.aStart.Row();
-                            SCCOL nCol2 = aRef.aEnd.Col();
-                            SCROW nRow2 = aRef.aEnd.Row();
-
-                            // wegnehmen -> Repaint
-                            // SC_UPDATE_MARKS: Invalidate, nicht bis zum Zeilenende
-
-                            bool bHiddenEdge = false;
-                            SCROW nTmp;
-                            ScDocument* pDoc = aViewData.GetDocument();
-                            while ( nCol1 > 0 && pDoc->ColHidden(nCol1, nTab) )
-                            {
-                                --nCol1;
-                                bHiddenEdge = true;
-                            }
-                            while ( nCol2 < MAXCOL && pDoc->ColHidden(nCol2, nTab) )
-                            {
-                                ++nCol2;
-                                bHiddenEdge = true;
-                            }
-                            nTmp = pDoc->LastVisibleRow(0, nRow1, nTab);
-                            if (!ValidRow(nTmp))
-                                nTmp = 0;
-                            if (nTmp < nRow1)
-                            {
-                                nRow1 = nTmp;
-                                bHiddenEdge = true;
-                            }
-                            nTmp = pDoc->FirstVisibleRow(nRow2, MAXROW, nTab);
-                            if (!ValidRow(nTmp))
-                                nTmp = MAXROW;
-                            if (nTmp > nRow2)
-                            {
-                                nRow2 = nTmp;
-                                bHiddenEdge = true;
-                            }
 
-                            if ( nCol2 - nCol1 > 1 && nRow2 - nRow1 > 1 && !bHiddenEdge )
-                            {
-                                //     nur an den Raendern entlang
-                                PaintArea( nCol1, nRow1, nCol2, nRow1, SC_UPDATE_MARKS );
-                                PaintArea( nCol1, nRow1+1, nCol1, nRow2-1, SC_UPDATE_MARKS );
-                                PaintArea( nCol2, nRow1+1, nCol2, nRow2-1, SC_UPDATE_MARKS );
-                                PaintArea( nCol1, nRow2, nCol2, nRow2, SC_UPDATE_MARKS );
-                            }
-                            else       // alles am Stueck
-                                PaintArea( nCol1, nRow1, nCol2, nRow2, SC_UPDATE_MARKS );
-                        }
-                    }
-                }
+            if (nNumber < 0)
+            {
+                for (sal_uInt16 i=0; i<nCount; i++)
+                    PaintRangeFinderEntry(pRangeFinder->GetObject(i),nTab);
+            }
+            else
+            {
+                sal_uInt16 idx = nNumber;
+                if (idx < nCount)
+                    PaintRangeFinderEntry(pRangeFinder->GetObject(idx),nTab);
+            }
         }
     }
 }
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.