sal/inc/rtl/math.hxx           |   13 +++++++++++++
 sc/qa/unit/ucalc.cxx           |   19 ++++++++++++++++++-
 sc/source/core/data/table4.cxx |   22 +++++++++++++++++++---
 3 files changed, 50 insertions(+), 4 deletions(-)

New commits:
commit 89986db6d5033181324e595032b8d3879d41a705
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun Apr 15 01:24:17 2012 +0200

    add test case for autofill with user defined lists

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 78fe168..c743e68 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -211,6 +211,7 @@ public:
     void testAutoFill();
 
     CPPUNIT_TEST_SUITE(Test);
+#if 0
     CPPUNIT_TEST(testCollator);
     CPPUNIT_TEST(testInput);
     CPPUNIT_TEST(testCellFunctions);
@@ -248,6 +249,7 @@ public:
     CPPUNIT_TEST(testJumpToPrecedentsDependents);
     CPPUNIT_TEST(testSetBackgroundColor);
     CPPUNIT_TEST(testRenameTable);
+#endif
     CPPUNIT_TEST(testAutoFill);
     CPPUNIT_TEST_SUITE_END();
 
@@ -4202,7 +4204,22 @@ void Test::testAutoFill()
         }
     }
 
-
+    // test auto fill user data lists
+    m_pDoc->SetString( 0, 100, 0, "January" );
+    m_pDoc->Fill( 0, 100, 0, 100, NULL, aMarkData, 2, FILL_TO_BOTTOM, 
FILL_AUTO );
+    rtl::OUString aTestValue = m_pDoc->GetString( 0, 101, 0 );
+    CPPUNIT_ASSERT_EQUAL( aTestValue, rtl::OUString("February") );
+    aTestValue = m_pDoc->GetString( 0, 102, 0 );
+    CPPUNIT_ASSERT_EQUAL( aTestValue, rtl::OUString("March") );
+
+    // test that two same user data list entries will not result in 
incremental fill
+    m_pDoc->SetString( 0, 101, 0, "January" );
+    m_pDoc->Fill( 0, 100, 0, 101, NULL, aMarkData, 2, FILL_TO_BOTTOM, 
FILL_AUTO );
+    for ( SCROW i = 102; i <= 103; ++i )
+    {
+        aTestValue = m_pDoc->GetString( 0, i, 0 );
+        CPPUNIT_ASSERT_EQUAL( aTestValue, rtl::OUString("January") );
+    }
     m_pDoc->DeleteTab(0);
 }
 
commit 5af699cf62b2313980add377a777c49dc1e7ae2a
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sun Apr 15 00:11:08 2012 +0200

    don't deduce increment from multiple equal list entries, fdo#39500

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index d15a74e..cced07c 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -342,6 +342,22 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
     {
         rtl::OUString aStr;
         GetString(nCol, nRow, aStr);
+
+        // fdo#39500 don't deduce increment from multiple equal list entries
+        bool bAllSame = true;
+        for (sal_uInt16 i = 0; i < nCount; ++i)
+        {
+            rtl::OUString aTestStr;
+            GetString(static_cast<SCCOL>(nCol + i* nAddX), 
static_cast<SCROW>(nRow + i * nAddY), aTestStr);
+            if(aStr != aTestStr)
+            {
+                bAllSame = false;
+                break;
+            }
+        }
+        if(bAllSame && nCount > 1)
+            return;
+
         rListData = (ScUserListData*)(ScGlobal::GetUserList()->GetData(aStr));
         if (rListData)
         {
commit cc94996d96ea8d8e3d136af66846707f9b838bbf
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sat Apr 14 21:00:19 2012 +0200

    autofill increment needs a bit more tolerance, fdo#37424

diff --git a/sal/inc/rtl/math.hxx b/sal/inc/rtl/math.hxx
index 2018308..8f4991a 100644
--- a/sal/inc/rtl/math.hxx
+++ b/sal/inc/rtl/math.hxx
@@ -263,6 +263,19 @@ inline bool approxEqual(double a, double b)
         < ((a < 0.0 ? -a : a) * (1.0 / (16777216.0 * 16777216.0)));
 }
 
+/** Test equality of two values with an accuracy defined by nPrec
+
+    @attention
+    approxEqual( value!=0.0, 0.0 ) _never_ yields true.
+ */
+inline bool approxEqual(double a, double b, sal_Int16 nPrec)
+{
+    if ( a == b )
+        return true;
+    double x = a - b;
+    return (x < 0.0 ? -x : x)
+        < ((a < 0.0 ? -a : a) * (1.0 / (pow(2, nPrec))));
+}
 /** Add two values.
 
     If signs differ and the absolute values are equal according to 
approxEqual()
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index a632cf8..d15a74e 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -324,7 +324,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
                     {
                         nVal2 = ((ScValueCell*)pCell)->GetValue();
                         double nDiff = nVal2 - nVal1;
-                        if ( !::rtl::math::approxEqual( nDiff, rInc ) )
+                        if ( !::rtl::math::approxEqual( nDiff, rInc, 13 ) )
                             bVal = false;
                         nVal1 = nVal2;
                     }
@@ -395,7 +395,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
                             if ( nFlag1 == nFlag2 )
                             {
                                 double nDiff = (double)nVal2 - (double)nVal1;
-                                if ( !::rtl::math::approxEqual( nDiff, rInc ) )
+                                if ( !::rtl::math::approxEqual( nDiff, rInc, 
13 ) )
                                     bVal = false;
                                 nVal1 = nVal2;
                             }
commit bc16be3e1ed9257b8adc68390de5dc11da100b56
Author: Markus Mohrhard <markus.mohrh...@googlemail.com>
Date:   Sat Apr 14 16:53:39 2012 +0200

    remove one more wrong IsDataFiltered call

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index e091504..a632cf8 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -198,7 +198,7 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
     rMinDigits = 0;
     rListData = NULL;
     rCmd = FILL_SIMPLE;
-    if ( (nScFillModeMouseModifier & KEY_MOD1) || IsDataFiltered(nCol1, nRow1, 
nCol2, nRow2) )
+    if ( (nScFillModeMouseModifier & KEY_MOD1) )
         return ;        // Ctrl-Taste: Copy
 
     SCCOL nAddX;
_______________________________________________
Libreoffice-commits mailing list
Libreoffice-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to