[Libreoffice-commits] .: 4 commits - sc/inc sc/qa sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Wed Apr 11 13:03:25 PDT 2012


 sc/inc/document.hxx            |    2 
 sc/inc/table.hxx               |    1 
 sc/qa/unit/ucalc.cxx           |   35 +++
 sc/source/core/data/table2.cxx |    5 
 sc/source/core/data/table4.cxx |  464 +++++++++++++++++++++++------------------
 5 files changed, 308 insertions(+), 199 deletions(-)

New commits:
commit 73ff3a49a0891c7787f08eec86357c320a76c263
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 11 22:02:06 2012 +0200

    first part for ScTable::GetAutoFillPreview
    
    Actually this is a bit more tricky. Currently it is showing wrong values
    for hidden rows/columns

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 7c9fcf9..e091504 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1027,7 +1027,7 @@ String ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW n
                             aValue = ((ScStringCell*)pCell)->GetString();
                         else
                             aValue = ((ScEditCell*)pCell)->GetString();
-                        if ( !(nScFillModeMouseModifier & KEY_MOD1) && !IsDataFiltered(nCol1, nRow1, nEndX, nEndY) )
+                        if ( !(nScFillModeMouseModifier & KEY_MOD1) )
                         {
                             sal_Int32 nVal;
                             sal_uInt16 nCellDigits = 0; // look at each source cell individually
@@ -1048,7 +1048,7 @@ String ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW n
                     {
                         //  dabei kann's keinen Ueberlauf geben...
                         double nVal = ((ScValueCell*)pCell)->GetValue();
-                        if ( !(nScFillModeMouseModifier & KEY_MOD1) && !IsDataFiltered(nCol1, nRow1, nEndX, nEndY) )
+                        if ( !(nScFillModeMouseModifier & KEY_MOD1) )
                             nVal += (double) nDelta;
 
                         Color* pColor;
commit 290a851bdc42a78426dea987ffbcb511e36c34fb
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 11 21:53:30 2012 +0200

    ScTable::FillAuto should work with hidden rows/columsn now too

diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index fa23055..7c9fcf9 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -536,7 +536,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     sal_uLong nIMin = nIStart;
     sal_uLong nIMax = nIEnd;
     PutInOrder(nIMin,nIMax);
-    bool bHasFiltered = IsDataFiltered(aFillRange.aStart.Col(), aFillRange.aStart.Row(), aFillRange.aEnd.Col(), aFillRange.aEnd.Row());
+    bool bHasFiltered = IsDataFiltered(aFillRange);
 
     if (!bHasFiltered)
     {
@@ -569,52 +569,52 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         rInner = nIStart;
         while (true)        // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
         {
-            if ( bGetPattern )
+            if (!ColHidden(nCol) && !RowHidden(nRow))
             {
-                delete pNewPattern;
-                if (bVertical)      // rInner&:=nRow, rOuter&:=nCol
-                    pSrcPattern = aCol[nCol].GetPattern(static_cast<SCROW>(nAtSrc));
-                else                // rInner&:=nCol, rOuter&:=nRow
-                    pSrcPattern = aCol[nAtSrc].GetPattern(static_cast<SCROW>(nRow));
-                bGetPattern = false;
-                pStyleSheet = pSrcPattern->GetStyleSheet();
-                //  Merge/Mergeflag nicht uebernehmen,
-                const SfxItemSet& rSet = pSrcPattern->GetItemSet();
-                if ( rSet.GetItemState(ATTR_MERGE, false) == SFX_ITEM_SET
-                  || rSet.GetItemState(ATTR_MERGE_FLAG, false) == SFX_ITEM_SET )
+                if ( bGetPattern )
                 {
-                    pNewPattern = new ScPatternAttr( *pSrcPattern );
-                    SfxItemSet& rNewSet = pNewPattern->GetItemSet();
-                    rNewSet.ClearItem(ATTR_MERGE);
-                    rNewSet.ClearItem(ATTR_MERGE_FLAG);
+                    delete pNewPattern;
+                    if (bVertical)      // rInner&:=nRow, rOuter&:=nCol
+                        pSrcPattern = aCol[nCol].GetPattern(static_cast<SCROW>(nAtSrc));
+                    else                // rInner&:=nCol, rOuter&:=nRow
+                        pSrcPattern = aCol[nAtSrc].GetPattern(static_cast<SCROW>(nRow));
+                    bGetPattern = false;
+                    pStyleSheet = pSrcPattern->GetStyleSheet();
+                    //  Merge/Mergeflag nicht uebernehmen,
+                    const SfxItemSet& rSet = pSrcPattern->GetItemSet();
+                    if ( rSet.GetItemState(ATTR_MERGE, false) == SFX_ITEM_SET
+                            || rSet.GetItemState(ATTR_MERGE_FLAG, false) == SFX_ITEM_SET )
+                    {
+                        pNewPattern = new ScPatternAttr( *pSrcPattern );
+                        SfxItemSet& rNewSet = pNewPattern->GetItemSet();
+                        rNewSet.ClearItem(ATTR_MERGE);
+                        rNewSet.ClearItem(ATTR_MERGE_FLAG);
+                    }
+                    else
+                        pNewPattern = NULL;
                 }
-                else
-                    pNewPattern = NULL;
-            }
 
-            if ( bVertical && nISrcStart == nISrcEnd && !bHasFiltered )
-            {
-                //  Attribute komplett am Stueck setzen
-                if (pNewPattern || pSrcPattern != pDocument->GetDefPattern())
+                if ( bVertical && nISrcStart == nISrcEnd && !bHasFiltered )
                 {
-                    //  Default steht schon da (DeleteArea)
-                    SCROW nY1 = static_cast<SCROW>(Min( nIStart, nIEnd ));
-                    SCROW nY2 = static_cast<SCROW>(Max( nIStart, nIEnd ));
-                    if ( pStyleSheet )
-                        aCol[nCol].ApplyStyleArea( nY1, nY2, *pStyleSheet );
-                    if ( pNewPattern )
-                        aCol[nCol].ApplyPatternArea( nY1, nY2, *pNewPattern );
-                    else
-                        aCol[nCol].ApplyPatternArea( nY1, nY2, *pSrcPattern );
+                    //  Attribute komplett am Stueck setzen
+                    if (pNewPattern || pSrcPattern != pDocument->GetDefPattern())
+                    {
+                        //  Default steht schon da (DeleteArea)
+                        SCROW nY1 = static_cast<SCROW>(Min( nIStart, nIEnd ));
+                        SCROW nY2 = static_cast<SCROW>(Max( nIStart, nIEnd ));
+                        if ( pStyleSheet )
+                            aCol[nCol].ApplyStyleArea( nY1, nY2, *pStyleSheet );
+                        if ( pNewPattern )
+                            aCol[nCol].ApplyPatternArea( nY1, nY2, *pNewPattern );
+                        else
+                            aCol[nCol].ApplyPatternArea( nY1, nY2, *pSrcPattern );
+                    }
+                    break;      // Schleife abbrechen
                 }
-                break;      // Schleife abbrechen
-            }
 
-            if (!RowFiltered( nRow ))
-            {
                 if ( bHasFiltered )
                     DeleteArea(static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow),
-                               static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), IDF_AUTOFILL);
+                            static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), IDF_AUTOFILL);
 
                 if ( pSrcPattern != aCol[nCol].GetPattern( static_cast<SCROW>(nRow) ) )
                 {
@@ -693,17 +693,20 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             rInner = nIStart;
             while (true)        // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
             {
-                if (bPositive)
+                if(!ColHidden(nCol) && !RowHidden(nRow))
                 {
-                    ++nListIndex;
-                    if (nListIndex >= nListCount) nListIndex = 0;
-                }
-                else
-                {
-                    if (nListIndex == 0) nListIndex = nListCount;
-                    --nListIndex;
+                    if (bPositive)
+                    {
+                        ++nListIndex;
+                        if (nListIndex >= nListCount) nListIndex = 0;
+                    }
+                    else
+                    {
+                        if (nListIndex == 0) nListIndex = nListCount;
+                        --nListIndex;
+                    }
+                    aCol[nCol].Insert(static_cast<SCROW>(nRow), new ScStringCell(pListData->GetSubStr(nListIndex)));
                 }
-                aCol[nCol].Insert(static_cast<SCROW>(nRow), new ScStringCell(pListData->GetSubStr(nListIndex)));
 
                 if (rInner == nIEnd) break;
                 if (bPositive) ++rInner; else --rInner;
@@ -718,7 +721,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         {
             sal_uLong nSource = nISrcStart;
             double nDelta;
-            if ( (nScFillModeMouseModifier & KEY_MOD1) || bHasFiltered )
+            if ( (nScFillModeMouseModifier & KEY_MOD1) )
                 nDelta = 0.0;
             else if ( bPositive )
                 nDelta = 1.0;
@@ -735,56 +738,53 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             ScBaseCell* pSrcCell = NULL;
             CellType eCellType = CELLTYPE_NONE;
             bool bIsOrdinalSuffix = false;
-            bool bRowFiltered = false;
 
             rInner = nIStart;
             while (true)        // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
             {
-                if ( bGetCell )
+                if(!ColHidden(nCol) && !RowHidden(nRow))
                 {
-                    if (bVertical)      // rInner&:=nRow, rOuter&:=nCol
-                        pSrcCell = aCol[nCol].GetCell( static_cast<SCROW>(nSource) );
-                    else                // rInner&:=nCol, rOuter&:=nRow
-                        pSrcCell = aCol[nSource].GetCell( static_cast<SCROW>(nRow) );
-                    bGetCell = false;
-                    if ( pSrcCell )
+                    if ( bGetCell )
                     {
-                        eCellType = pSrcCell->GetCellType();
-                        switch ( eCellType )
+                        if (bVertical)      // rInner&:=nRow, rOuter&:=nCol
+                            pSrcCell = aCol[nCol].GetCell( static_cast<SCROW>(nSource) );
+                        else                // rInner&:=nCol, rOuter&:=nRow
+                            pSrcCell = aCol[nSource].GetCell( static_cast<SCROW>(nRow) );
+                        bGetCell = false;
+                        if ( pSrcCell )
                         {
-                            case CELLTYPE_VALUE:
-                                nVal = ((ScValueCell*)pSrcCell)->GetValue();
-                            break;
-                            case CELLTYPE_STRING:
-                            case CELLTYPE_EDIT:
-                                if ( eCellType == CELLTYPE_STRING )
-                                    aValue = ((ScStringCell*)pSrcCell)->GetString();
-                                else
-                                    aValue = ((ScEditCell*)pSrcCell)->GetString();
-                                if ( !(nScFillModeMouseModifier & KEY_MOD1) && !bHasFiltered )
-                                {
-                                    nCellDigits = 0;    // look at each source cell individually
-                                    nHeadNoneTail = lcl_DecompValueString(
-                                        aValue, nStringValue, &nCellDigits );
-
-                                    bIsOrdinalSuffix = aValue.Equals(
-                                            ScGlobal::GetOrdinalSuffix( nStringValue));
-                                }
-                            break;
-                            default:
+                            eCellType = pSrcCell->GetCellType();
+                            switch ( eCellType )
                             {
-                                // added to avoid warnings
+                                case CELLTYPE_VALUE:
+                                    nVal = ((ScValueCell*)pSrcCell)->GetValue();
+                                    break;
+                                case CELLTYPE_STRING:
+                                case CELLTYPE_EDIT:
+                                    if ( eCellType == CELLTYPE_STRING )
+                                        aValue = ((ScStringCell*)pSrcCell)->GetString();
+                                    else
+                                        aValue = ((ScEditCell*)pSrcCell)->GetString();
+                                    if ( !(nScFillModeMouseModifier & KEY_MOD1) && !bHasFiltered )
+                                    {
+                                        nCellDigits = 0;    // look at each source cell individually
+                                        nHeadNoneTail = lcl_DecompValueString(
+                                                aValue, nStringValue, &nCellDigits );
+
+                                        bIsOrdinalSuffix = aValue.Equals(
+                                                ScGlobal::GetOrdinalSuffix( nStringValue));
+                                    }
+                                    break;
+                                default:
+                                    {
+                                        // added to avoid warnings
+                                    }
                             }
                         }
+                        else
+                            eCellType = CELLTYPE_NONE;
                     }
-                    else
-                        eCellType = CELLTYPE_NONE;
-                }
-
-                bRowFiltered = RowHidden(nRow);
 
-                if (!bRowFiltered)
-                {
                     switch (eCellType)
                     {
                         case CELLTYPE_VALUE:
@@ -823,11 +823,11 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                     case CELLTYPE_STRING:
                                     case CELLTYPE_EDIT:
                                         aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) );
-                                    break;
+                                        break;
                                     default:
-                                    {
-                                        // added to avoid warnings
-                                    }
+                                        {
+                                            // added to avoid warnings
+                                        }
                                 }
                             }
                             break;
@@ -840,9 +840,9 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                                 nMaxFormCnt = nFormulaCounter - nActFormCnt;
                             break;
                         default:
-                        {
-                            // added to avoid warnings
-                        }
+                            {
+                                // added to avoid warnings
+                            }
                     }
 
                     if (nSource==nISrcEnd)
@@ -852,7 +852,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                             nSource = nISrcStart;
                             bGetCell = true;
                         }
-                        if ( !(nScFillModeMouseModifier & KEY_MOD1) && !bHasFiltered )
+                        if ( !(nScFillModeMouseModifier & KEY_MOD1) )
                         {
                             if ( bPositive )
                                 nDelta += 1.0;
commit a6a0ea2f352f98b801bb6aade04caeb07e180403
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 11 21:44:09 2012 +0200

    add unit test for autofill

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index bc96ea5..11e247e 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1146,7 +1146,7 @@ public:
 
     void            UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY );
 
-    void            Fill(   SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
+    SC_DLLPUBLIC void Fill(   SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                             ScProgress* pProgress, const ScMarkData& rMark,
                             sal_uLong nFillCount, FillDir eFillDir = FILL_TO_BOTTOM,
                             FillCmd eFillCmd = FILL_LINEAR, FillDateCmd eFillDateCmd = FILL_DAY,
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index e9b4d90..8f15b8d 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -208,6 +208,8 @@ public:
     void testSetBackgroundColor();
     void testRenameTable();
 
+    void testAutoFill();
+
     CPPUNIT_TEST_SUITE(Test);
     CPPUNIT_TEST(testCollator);
     CPPUNIT_TEST(testInput);
@@ -246,6 +248,7 @@ public:
     CPPUNIT_TEST(testJumpToPrecedentsDependents);
     CPPUNIT_TEST(testSetBackgroundColor);
     CPPUNIT_TEST(testRenameTable);
+    CPPUNIT_TEST(testAutoFill);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -4151,6 +4154,38 @@ void Test::testJumpToPrecedentsDependents()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testAutoFill()
+{
+    m_pDoc->InsertTab(0, "test");
+
+    m_pDoc->SetValue(0,0,0,1);
+
+    ScMarkData aMarkData;
+    aMarkData.SelectTable(0, true);
+
+    m_pDoc->Fill( 0, 0, 0, 0, NULL, aMarkData, 5);
+    for (SCROW i = 0; i< 6; ++i)
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i+1.0), m_pDoc->GetValue(0, i, 0), 0.00000001);
+
+    // check that hidden rows are not affected by autofill
+    // set values for hidden rows
+    m_pDoc->SetValue(0,1,0,10);
+    m_pDoc->SetValue(0,2,0,10);
+
+    m_pDoc->SetRowHidden(1, 2, 0, true);
+    m_pDoc->Fill( 0, 0, 0, 0, NULL, aMarkData, 8);
+
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, m_pDoc->GetValue(0,1,0), 1e-08);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, m_pDoc->GetValue(0,2,0), 1e-08);
+    for (SCROW i = 3; i< 8; ++i)
+        CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(i-1.0), m_pDoc->GetValue(0, i, 0), 0.00000001);
+
+
+
+
+    m_pDoc->DeleteTab(0);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 }
commit f61cbce529d039bb0e208e81cf66974cc4428420
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Apr 11 21:35:59 2012 +0200

    make ScTable::FillSeries work correctly with hidden rows/columns

diff --git a/sc/inc/table.hxx b/sc/inc/table.hxx
index 2261718..6393bfa 100644
--- a/sc/inc/table.hxx
+++ b/sc/inc/table.hxx
@@ -675,6 +675,7 @@ public:
     SCROW      GetLastChangedRow() const;
 
     bool       IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SCROW nRowEnd) const;
+    bool       IsDataFiltered(const ScRange& rRange) const;
     sal_uInt8       GetColFlags( SCCOL nCol ) const;
     sal_uInt8       GetRowFlags( SCROW nRow ) const;
 
diff --git a/sc/source/core/data/table2.cxx b/sc/source/core/data/table2.cxx
index 646e0d8..c6fed2b 100644
--- a/sc/source/core/data/table2.cxx
+++ b/sc/source/core/data/table2.cxx
@@ -2821,6 +2821,11 @@ bool ScTable::IsDataFiltered(SCCOL nColStart, SCROW nRowStart, SCCOL nColEnd, SC
     return false;
 }
 
+bool ScTable::IsDataFiltered(const ScRange& rRange) const
+{
+    return IsDataFiltered(rRange.aStart.Col(), rRange.aStart.Row(),
+                rRange.aEnd.Col(), rRange.aEnd.Row());
+}
 
 void ScTable::SetRowFlags( SCROW nRow, sal_uInt8 nNewFlags )
 {
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index e3d57be..fa23055 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -489,6 +489,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     sal_uLong nIEnd;
     sal_uLong nISrcStart;
     sal_uLong nISrcEnd;
+    ScRange aFillRange;
 
     if (bVertical)
     {
@@ -500,6 +501,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             nISrcEnd = nRow2;
             nIStart = nRow2 + 1;
             nIEnd = nRow2 + nFillCount;
+            aFillRange = ScRange(nCol1, nRow2+1, 0, nCol2, nRow2 + nFillCount, 0);
         }
         else
         {
@@ -507,6 +509,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             nISrcEnd = nRow1;
             nIStart = nRow1 - 1;
             nIEnd = nRow1 - nFillCount;
+            aFillRange = ScRange(nCol1, nRow1-1, 0, nCol2, nRow2 - nFillCount, 0);
         }
     }
     else
@@ -519,6 +522,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             nISrcEnd = nCol2;
             nIStart = nCol2 + 1;
             nIEnd = nCol2 + nFillCount;
+            aFillRange = ScRange(nCol2 + 1, nRow1, 0, nCol2 + nFillCount, nRow2, 0);
         }
         else
         {
@@ -526,12 +530,13 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             nISrcEnd = nCol1;
             nIStart = nCol1 - 1;
             nIEnd = nCol1 - nFillCount;
+            aFillRange = ScRange(nCol1 - 1, nRow1, 0, nCol1 - nFillCount, nRow2, 0);
         }
     }
     sal_uLong nIMin = nIStart;
     sal_uLong nIMax = nIEnd;
     PutInOrder(nIMin,nIMax);
-    bool bHasFiltered = IsDataFiltered(nCol1, nRow1, nCol2, nRow2);
+    bool bHasFiltered = IsDataFiltered(aFillRange.aStart.Col(), aFillRange.aStart.Row(), aFillRange.aEnd.Col(), aFillRange.aEnd.Row());
 
     if (!bHasFiltered)
     {
@@ -776,7 +781,7 @@ void ScTable::FillAuto( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                         eCellType = CELLTYPE_NONE;
                 }
 
-                bRowFiltered = mpFilteredRows->getValue(nRow);
+                bRowFiltered = RowHidden(nRow);
 
                 if (!bRowFiltered)
                 {
@@ -1022,7 +1027,7 @@ String ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW n
                             aValue = ((ScStringCell*)pCell)->GetString();
                         else
                             aValue = ((ScEditCell*)pCell)->GetString();
-                        if ( !(nScFillModeMouseModifier & KEY_MOD1) && !IsDataFiltered(nCol1, nRow1, nCol2, nRow2) )
+                        if ( !(nScFillModeMouseModifier & KEY_MOD1) && !IsDataFiltered(nCol1, nRow1, nEndX, nEndY) )
                         {
                             sal_Int32 nVal;
                             sal_uInt16 nCellDigits = 0; // look at each source cell individually
@@ -1043,7 +1048,7 @@ String ScTable::GetAutoFillPreview( const ScRange& rSource, SCCOL nEndX, SCROW n
                     {
                         //  dabei kann's keinen Ueberlauf geben...
                         double nVal = ((ScValueCell*)pCell)->GetValue();
-                        if ( !(nScFillModeMouseModifier & KEY_MOD1) && !IsDataFiltered(nCol1, nRow1, nCol2, nRow2) )
+                        if ( !(nScFillModeMouseModifier & KEY_MOD1) && !IsDataFiltered(nCol1, nRow1, nEndX, nEndY) )
                             nVal += (double) nDelta;
 
                         Color* pColor;
@@ -1250,6 +1255,23 @@ void ScTable::IncDate(double& rVal, sal_uInt16& nDayOfMonth, double nStep, FillD
     rVal = aDate - aNullDate;
 }
 
+namespace
+{
+
+bool HiddenRowColumn(sal_uLong nRowColumn, bool bVertical, ScTable* pTable)
+{
+    if(bVertical)
+    {
+        return pTable->RowHidden(static_cast<SCROW>(nRowColumn));
+    }
+    else
+    {
+        return pTable->ColHidden(static_cast<SCCOL>(nRowColumn));
+    }
+}
+
+}
+
 void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                     sal_uLong nFillCount, FillDir eFillDir, FillCmd eFillCmd, FillDateCmd eFillDateCmd,
                     double nStepValue, double nMaxValue, sal_uInt16 nArgMinDigits,
@@ -1271,6 +1293,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     sal_uLong nIStart;
     sal_uLong nIEnd;
     sal_uLong nISource;
+    ScRange aFillRange;
 
     if (bVertical)
     {
@@ -1284,12 +1307,14 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             nISource = nRow1;
             nIStart = nRow1 + 1;
             nIEnd = nRow1 + nFillCount;
+            aFillRange = ScRange(nCol1, nRow1 + 1, nTab, nCol2, nRow1 + nFillCount, nTab);
         }
         else
         {
             nISource = nRow2;
             nIStart = nRow2 - 1;
             nIEnd = nRow2 - nFillCount;
+            aFillRange = ScRange(nCol1, nRow2 -1, nTab, nCol2, nRow2 - nFillCount, nTab);
         }
     }
     else
@@ -1304,12 +1329,14 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
             nISource = nCol1;
             nIStart = nCol1 + 1;
             nIEnd = nCol1 + nFillCount;
+            aFillRange = ScRange(nCol1 + 1, nRow1, nTab, nCol1 + nFillCount, nRow2, nTab);
         }
         else
         {
             nISource = nCol2;
             nIStart = nCol2 - 1;
             nIEnd = nCol2 - nFillCount;
+            aFillRange = ScRange(nCol2 - 1, nRow1, nTab, nCol2 - nFillCount, nRow2, nTab);
         }
     }
 
@@ -1317,10 +1344,15 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
     sal_uLong nIMax = nIEnd;
     PutInOrder(nIMin,nIMax);
     sal_uInt16 nDel = bAttribs ? IDF_AUTOFILL : (IDF_AUTOFILL & IDF_CONTENTS);
-    if (bVertical)
-        DeleteArea(nCol1, static_cast<SCROW>(nIMin), nCol2, static_cast<SCROW>(nIMax), nDel);
-    else
-        DeleteArea(static_cast<SCCOL>(nIMin), nRow1, static_cast<SCCOL>(nIMax), nRow2, nDel);
+
+    bool bIsFiltered = IsDataFiltered(aFillRange);
+    if (!bIsFiltered)
+    {
+        if (bVertical)
+            DeleteArea(nCol1, static_cast<SCROW>(nIMin), nCol2, static_cast<SCROW>(nIMax), nDel);
+        else
+            DeleteArea(static_cast<SCCOL>(nIMin), nRow1, static_cast<SCCOL>(nIMax), nRow2, nDel);
+    }
 
     sal_uLong nProgress = 0;
     if (pProgress)
@@ -1344,11 +1376,29 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
         {
             const ScPatternAttr* pSrcPattern = aCol[nCol].GetPattern(static_cast<SCROW>(nRow));
             if (bVertical)
-                aCol[nCol].SetPatternArea( static_cast<SCROW>(nIMin),
-                        static_cast<SCROW>(nIMax), *pSrcPattern, true );
+            {
+                // if not filtered use the faster method
+                // hidden cols/rows should be skiped
+                if(!bIsFiltered)
+                {
+                    aCol[nCol].SetPatternArea( static_cast<SCROW>(nIMin),
+                            static_cast<SCROW>(nIMax), *pSrcPattern, true );
+                }
+                else
+                {
+                    for(SCROW nAtRow = static_cast<SCROW>(nIMin); nAtRow <= static_cast<SCROW>(nIMax); ++nAtRow)
+                    {
+                        if(!RowHidden(nAtRow))
+                            aCol[nCol].SetPatternArea( static_cast<SCROW>(nAtRow),
+                                    static_cast<SCROW>(nAtRow), *pSrcPattern, true);
+                    }
+
+                }
+            }
             else
                 for (SCCOL nAtCol = static_cast<SCCOL>(nIMin); nAtCol <= sal::static_int_cast<SCCOL>(nIMax); nAtCol++)
-                    aCol[nAtCol].SetPattern(static_cast<SCROW>(nRow), *pSrcPattern, true);
+                    if(!ColHidden(nAtCol))
+                        aCol[nAtCol].SetPattern(static_cast<SCROW>(nRow), *pSrcPattern, true);
         }
 
         if (pSrcCell)
@@ -1361,7 +1411,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                 {
                     for (rInner = nIMin; rInner <= nIMax; rInner++)
                     {
-                        if (pDocument->RowFiltered( rInner, nTab))
+                        if(HiddenRowColumn(rInner, bVertical, this))
                             continue;
                         sal_uLong nInd = nActFormCnt;
                         FillFormula(nInd, bFirst, (ScFormulaCell*)pSrcCell,
@@ -1375,7 +1425,7 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                 {
                     for (rInner = nIMin; rInner <= nIMax; rInner++)
                     {
-                        if (pDocument->RowFiltered( rInner, nTab))
+                        if(HiddenRowColumn(rInner, bVertical, this))
                             continue;
                         ScAddress aDestPos( static_cast<SCCOL>(nCol), static_cast<SCROW>(nRow), nTab );
                         aCol[nCol].Insert( aDestPos.Row(), pSrcCell->Clone( *pDocument ) );
@@ -1402,62 +1452,75 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                 rInner = nIStart;
                 while (true)        // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
                 {
-                    if (!bError && !bOverflow)
+                    if(!ColHidden(nCol) && !RowHidden(nRow))
                     {
-                        switch (eFillCmd)
+                        if (!bError && !bOverflow)
                         {
-                            case FILL_LINEAR:
-                                {
-                                    //  use multiplication instead of repeated addition
-                                    //  to avoid accumulating rounding errors
-                                    nVal = nStartVal;
-                                    double nAdd = nStepValue;
-                                    if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) ||
-                                         !SubTotal::SafePlus( nVal, nAdd ) )
-                                        bError = true;
-                                }
-                                break;
-                            case FILL_GROWTH:
-                                if (!SubTotal::SafeMult(nVal, nStepValue))
-                                    bError = true;
-                                break;
-                            case FILL_DATE:
-                                if (fabs(nVal) > _D_MAX_LONG_)
-                                    bError = true;
-                                else
-                                    IncDate(nVal, nDayOfMonth, nStepValue, eFillDateCmd);
-                                break;
-                            default:
+                            switch (eFillCmd)
                             {
-                                // added to avoid warnings
+                                case FILL_LINEAR:
+                                    {
+                                        //  use multiplication instead of repeated addition
+                                        //  to avoid accumulating rounding errors
+                                        nVal = nStartVal;
+                                        double nAdd = nStepValue;
+                                        if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) ||
+                                                !SubTotal::SafePlus( nVal, nAdd ) )
+                                            bError = true;
+                                    }
+                                    break;
+                                case FILL_GROWTH:
+                                    if (!SubTotal::SafeMult(nVal, nStepValue))
+                                        bError = true;
+                                    break;
+                                case FILL_DATE:
+                                    if (fabs(nVal) > _D_MAX_LONG_)
+                                        bError = true;
+                                    else
+                                        IncDate(nVal, nDayOfMonth, nStepValue, eFillDateCmd);
+                                    break;
+                                default:
+                                    {
+                                        // added to avoid warnings
+                                    }
                             }
-                        }
 
-                        if (nStepValue >= 0)
-                        {
-                            if (nVal > nMaxValue)           // Zielwert erreicht?
+                            if (nStepValue >= 0)
                             {
-                                nVal = nMaxValue;
-                                bOverflow = true;
+                                if (nVal > nMaxValue)           // Zielwert erreicht?
+                                {
+                                    nVal = nMaxValue;
+                                    bOverflow = true;
+                                }
                             }
-                        }
-                        else
-                        {
-                            if (nVal < nMaxValue)
+                            else
                             {
-                                nVal = nMaxValue;
-                                bOverflow = true;
+                                if (nVal < nMaxValue)
+                                {
+                                    nVal = nMaxValue;
+                                    bOverflow = true;
+                                }
                             }
                         }
-                    }
 
-                    if (bError)
-                        aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue);
-                    else if (!bOverflow)
-                        aCol[nCol].SetValue(static_cast<SCROW>(nRow), nVal);
+                        if (bError)
+                            aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue);
+                        else if (bOverflow)
+                            aCol[nCol].SetError(static_cast<SCROW>(nRow), errIllegalFPOperation);
+                        else
+                            aCol[nCol].SetValue(static_cast<SCROW>(nRow), nVal);
+                    }
 
-                    if (rInner == nIEnd) break;
-                    if (bPositive) ++rInner; else --rInner;
+                    if (rInner == nIEnd)
+                        break;
+                    if (bPositive)
+                    {
+                        ++rInner;
+                    }
+                    else
+                    {
+                        --rInner;
+                    }
                 }
                 nProgress += nIMax - nIMin + 1;
                 if(pProgress)
@@ -1497,68 +1560,73 @@ void ScTable::FillSeries( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2,
                     rInner = nIStart;
                     while (true)        // #i53728# with "for (;;)" old solaris/x86 compiler mis-optimizes
                     {
-                        if (!bError && !bOverflow)
+                        if(!ColHidden(nCol) && !RowHidden(nRow))
                         {
-                            switch (eFillCmd)
+                            if (!bError && !bOverflow)
                             {
-                                case FILL_LINEAR:
-                                    {
-                                        //  use multiplication instead of repeated addition
-                                        //  to avoid accumulating rounding errors
-                                        nVal = nStartVal;
-                                        double nAdd = nStepValue;
-                                        if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) ||
-                                             !SubTotal::SafePlus( nVal, nAdd ) )
-                                            bError = true;
-                                    }
-                                    break;
-                                case FILL_GROWTH:
-                                    if (!SubTotal::SafeMult(nVal, nStepValue))
-                                        bError = true;
-                                    break;
-                                default:
+                                switch (eFillCmd)
                                 {
-                                    // added to avoid warnings
+                                    case FILL_LINEAR:
+                                        {
+                                            //  use multiplication instead of repeated addition
+                                            //  to avoid accumulating rounding errors
+                                            nVal = nStartVal;
+                                            double nAdd = nStepValue;
+                                            if ( !SubTotal::SafeMult( nAdd, (double) ++nIndex ) ||
+                                                    !SubTotal::SafePlus( nVal, nAdd ) )
+                                                bError = true;
+                                        }
+                                        break;
+                                    case FILL_GROWTH:
+                                        if (!SubTotal::SafeMult(nVal, nStepValue))
+                                            bError = true;
+                                        break;
+                                    default:
+                                        {
+                                            // added to avoid warnings
+                                        }
                                 }
-                            }
 
-                            if (nStepValue >= 0)
-                            {
-                                if (nVal > nMaxValue)           // Zielwert erreicht?
+                                if (nStepValue >= 0)
                                 {
-                                    nVal = nMaxValue;
-                                    bOverflow = true;
+                                    if (nVal > nMaxValue)           // Zielwert erreicht?
+                                    {
+                                        nVal = nMaxValue;
+                                        bOverflow = true;
+                                    }
                                 }
-                            }
-                            else
-                            {
-                                if (nVal < nMaxValue)
+                                else
                                 {
-                                    nVal = nMaxValue;
-                                    bOverflow = true;
+                                    if (nVal < nMaxValue)
+                                    {
+                                        nVal = nMaxValue;
+                                        bOverflow = true;
+                                    }
                                 }
                             }
-                        }
 
-                        if (bError)
-                            aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue);
-                        else if (!bOverflow)
-                        {
-                            nStringValue = (sal_Int32)nVal;
-                            String aStr;
-                            if ( nHeadNoneTail < 0 )
-                            {
-                                aCol[nCol].Insert( static_cast<SCROW>(nRow),
-                                        lcl_getSuffixCell( pDocument,
-                                            nStringValue, nMinDigits, aValue,
-                                            eCellType, bIsOrdinalSuffix ));
-                            }
+                            if (bError)
+                                aCol[nCol].SetError(static_cast<SCROW>(nRow), errNoValue);
+                            else if (bOverflow)
+                                aCol[nCol].SetError(static_cast<SCROW>(nRow), errIllegalFPOperation);
                             else
                             {
-                                aStr = aValue;
-                                aStr += lcl_ValueString( nStringValue, nMinDigits );
-                                ScStringCell* pCell = new ScStringCell( aStr );
-                                aCol[nCol].Insert( static_cast<SCROW>(nRow), pCell );
+                                nStringValue = (sal_Int32)nVal;
+                                String aStr;
+                                if ( nHeadNoneTail < 0 )
+                                {
+                                    aCol[nCol].Insert( static_cast<SCROW>(nRow),
+                                            lcl_getSuffixCell( pDocument,
+                                                nStringValue, nMinDigits, aValue,
+                                                eCellType, bIsOrdinalSuffix ));
+                                }
+                                else
+                                {
+                                    aStr = aValue;
+                                    aStr += lcl_ValueString( nStringValue, nMinDigits );
+                                    ScStringCell* pCell = new ScStringCell( aStr );
+                                    aCol[nCol].Insert( static_cast<SCROW>(nRow), pCell );
+                                }
                             }
                         }
 


More information about the Libreoffice-commits mailing list