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


Hi Eike

Now you also changed bOnlyDown=false to bOnlyDown=true, which leads to
not include newly appended columns of an area.

half true: the condition is exactly that the newly appended column data touch by an angle the already defined area (like C3 to B2) and that all other cells below the area are empty.
All columns right/left of the area are filtered.

Why?
very bad reason: I did not really intended to commit this change yet. I wanted to ask you about it. But it seems I was too deeply thinking about it, I oversee my mixing. F**

less bad reason: If you activates the auto-filter, and append a column as mentioned above, you suddenly have columns filtered without "seeing" it, the drop-down at the top of the column not being present.

I will change it (due to point 1), except you oppose :- )

Grounded speculation: if user adds a column or row immediately adjacent
to a data area it is usually related to the already existing data and
she wants that to be included, maybe even doesn't know that earlier the
filter was setup using a selection.

A good point. On the other hand,this makes impossible to filter in the middle of data. But this case is very special.


Else, I have attached 3 patches for review touching this function:

* the first one make the flag onlyDown working also for shrinking... No reason that you can just extend down, but shrink on all direction? This seems to be more coherent with the flag activation.

* the second patch make the shrinking corresponding to the name of the function: GetDataArea: i.e. shrinks as long as the outer row/column is empty, and not just delete the last one since empty.

* the 3d one: just minor clean up: variable scope reduction and better documentation.

Thanks for all
best regards
Pierre-André
From cfd04dda7e441ffa3dcc5a21b6b8f87cbfda05b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre-Andr=C3=A9=20Jacquod?= <pjacquod@alumni.ethz.ch>
Date: Tue, 29 Nov 2011 09:10:26 +0100
Subject: [PATCH 3/3] reduce scope of var and better comment of function GetDataArea

---
 sc/source/core/data/table1.cxx |   40 +++++++++++++++++++++-------------------
 1 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index ce2051b..5de641f 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -741,17 +741,19 @@ bool ScTable::GetDataStart( SCCOL& rStartCol, SCROW& rStartRow ) const
 void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, SCROW& rEndRow,
                            bool bIncludeOld, bool bOnlyDown ) const
 {
-    // bIncludeOld = true ensure that the returned area contains at least the initial area,
-    //              independently of the case if this area has empty rows / columns at its borders
-    // bOnlyDown = true means extend the inputed area only down, i.e increase only rEndRow
+    // return the smallest area containing at least all contiguous cells having data. This area
+    // is a square containing also empty cells. It may shrink or extend the area given as input
+    // Flags as modifiers:
+    //
+    //     bIncludeOld = true ensure that the returned area contains at least the initial area,
+    //                   independently of the emptniess of rows / columns (i.e. does not allow 
shrinking)
+    //     bOnlyDown = true means extend / shrink the inputed area only down, i.e modifiy only 
rEndRow
+
     bool bLeft = false;
     bool bRight  = false;
     bool bTop = false;
     bool bBottom = false;
-    bool bChanged;
-    bool bFound;
-    SCCOL i;
-    SCROW nTest;
+    bool bChanged = false;
 
     do
     {
@@ -782,12 +784,12 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& 
rEndCol, S
 
             if (rStartRow > 0)
             {
-                nTest = rStartRow-1;
-                bFound = false;
-                for (i=rStartCol; i<=rEndCol && !bFound; i++)
+                SCROW nTest = rStartRow-1;
+                bool needExtend = false;
+                for ( SCCOL i = rStartCol; i<=rEndCol && !needExtend; i++)
                     if (aCol[i].HasDataAt(nTest))
-                        bFound = true;
-                if (bFound)
+                        needExtend = true;
+                if (needExtend)
                 {
                     --rStartRow;
                     bChanged = true;
@@ -798,12 +800,12 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& 
rEndCol, S
 
         if (rEndRow < MAXROW)
         {
-            nTest = rEndRow+1;
-            bFound = false;
-            for (i=rStartCol; i<=rEndCol && !bFound; i++)
+            SCROW nTest = rEndRow+1;
+            bool needExtend = false;
+            for ( SCCOL i = rStartCol; i<=rEndCol && !needExtend; i++)
                 if (aCol[i].HasDataAt(nTest))
-                    bFound = true;
-            if (bFound)
+                    needExtend = true;
+            if (needExtend)
             {
                 ++rEndRow;
                 bChanged = true;
@@ -828,7 +830,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
             bool shrink = true;
             do
             {
-                for (i=rStartCol; i<=rEndCol && shrink; i++)
+                for ( SCCOL i = rStartCol; i<=rEndCol && shrink; i++)
                     if (aCol[i].HasDataAt(rStartRow))
                         shrink = false;
                 if (shrink)
@@ -844,7 +846,7 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, S
             bool shrink = true;
             do
             {
-                for (i=rStartCol; i<=rEndCol && shrink; i++)
+                for ( SCCOL i = rStartCol; i<=rEndCol && shrink; i++)
                     if (aCol[i].HasDataAt(rEndRow))
                         shrink = false;
                 if (shrink)
-- 
1.7.3.4

From 50e437728c28b42c45c63c134a3a2475920236fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre-Andr=C3=A9=20Jacquod?= <pjacquod@alumni.ethz.ch>
Date: Mon, 28 Nov 2011 10:10:15 +0100
Subject: [PATCH 2/3] if empty row / col leads to shrink area, suppress all empty rows/col

and not just the last one, leaving the other within the selection
area
---
 sc/source/core/data/table1.cxx |   38 ++++++++++++++++++++++----------------
 1 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 48d7455..ce2051b 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -815,22 +815,25 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& 
rEndCol, S
 
     if ( !bIncludeOld && !bOnlyDown )
     {
-        if ( !bLeft && rStartCol < MAXCOL && rStartCol < rEndCol )
-            if ( aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
+        if ( !bLeft )
+            while ( aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) && rStartCol < MAXCOL && 
rStartCol < rEndCol)
                 ++rStartCol;
 
-        if ( !bRight && rEndCol > 0 && rStartCol < rEndCol )
-            if ( aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
+        if ( !bRight )
+            while ( aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) && rEndCol > 0 && rStartCol < 
rEndCol)
                 --rEndCol;
 
         if ( !bTop && rStartRow < MAXROW && rStartRow < rEndRow )
         {
-            bFound = false;
-            for (i=rStartCol; i<=rEndCol && !bFound; i++)
-                if (aCol[i].HasDataAt(rStartRow))
-                    bFound = true;
-            if (!bFound)
-                ++rStartRow;
+            bool shrink = true;
+            do
+            {
+                for (i=rStartCol; i<=rEndCol && shrink; i++)
+                    if (aCol[i].HasDataAt(rStartRow))
+                        shrink = false;
+                if (shrink)
+                    ++rStartRow;
+            }while( shrink && rStartRow < MAXROW && rStartRow < rEndRow);
         }
     }
 
@@ -838,12 +841,15 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& 
rEndCol, S
     {
         if ( !bBottom && rEndRow > 0 && rStartRow < rEndRow )
         {
-            bFound = false;
-            for (i=rStartCol; i<=rEndCol && !bFound; i++)
-                if (aCol[i].HasDataAt(rEndRow))
-                    bFound = true;
-            if (!bFound)
-                --rEndRow;
+            bool shrink = true;
+            do
+            {
+                for (i=rStartCol; i<=rEndCol && shrink; i++)
+                    if (aCol[i].HasDataAt(rEndRow))
+                        shrink = false;
+                if (shrink)
+                    --rEndRow;
+            }while( shrink && rEndRow > 0 && rStartRow < rEndRow );
         }
     }
 }
-- 
1.7.3.4

From 482314b654dad0681fc2e86786e04641a3132654 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pierre-Andr=C3=A9=20Jacquod?= <pjacquod@alumni.ethz.ch>
Date: Mon, 28 Nov 2011 09:54:59 +0100
Subject: [PATCH 1/3] if changes selection only down, this is also valid for shrinking

and not only for expanding the selected area. Hence both part should
test this condition.
---
 sc/source/core/data/table1.cxx |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/sc/source/core/data/table1.cxx b/sc/source/core/data/table1.cxx
index 3cf1ca1..48d7455 100644
--- a/sc/source/core/data/table1.cxx
+++ b/sc/source/core/data/table1.cxx
@@ -813,14 +813,16 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& 
rEndCol, S
     }
     while( bChanged );
 
-    if ( !bIncludeOld )
+    if ( !bIncludeOld && !bOnlyDown )
     {
         if ( !bLeft && rStartCol < MAXCOL && rStartCol < rEndCol )
             if ( aCol[rStartCol].IsEmptyBlock(rStartRow,rEndRow) )
                 ++rStartCol;
+
         if ( !bRight && rEndCol > 0 && rStartCol < rEndCol )
             if ( aCol[rEndCol].IsEmptyBlock(rStartRow,rEndRow) )
                 --rEndCol;
+
         if ( !bTop && rStartRow < MAXROW && rStartRow < rEndRow )
         {
             bFound = false;
@@ -830,6 +832,10 @@ void ScTable::GetDataArea( SCCOL& rStartCol, SCROW& rStartRow, SCCOL& rEndCol, 
S
             if (!bFound)
                 ++rStartRow;
         }
+    }
+
+    if ( !bIncludeOld )
+    {
         if ( !bBottom && rEndRow > 0 && rStartRow < rEndRow )
         {
             bFound = false;
-- 
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.