summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sc/inc/document.hxx2
-rw-r--r--sc/qa/unit/uicalc/data/tdf99913.xlsxbin0 -> 8829 bytes
-rw-r--r--sc/qa/unit/uicalc/uicalc.cxx9
-rw-r--r--sc/source/filter/oox/worksheethelper.cxx65
4 files changed, 66 insertions, 10 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index fb5980cc5b5e..72f84cd9ba9b 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1947,7 +1947,7 @@ public:
SC_DLLPUBLIC SCROW LastVisibleRow(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
SCROW CountVisibleRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
- bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
+ SC_DLLPUBLIC bool RowFiltered(SCROW nRow, SCTAB nTab, SCROW* pFirstRow = nullptr, SCROW* pLastRow = nullptr) const;
bool HasFilteredRows(SCROW nStartRow, SCROW nEndRow, SCTAB nTab) const;
bool ColFiltered(SCCOL nCol, SCTAB nTab) const;
SC_DLLPUBLIC void SetRowFiltered(SCROW nStartRow, SCROW nEndRow, SCTAB nTab, bool bFiltered);
diff --git a/sc/qa/unit/uicalc/data/tdf99913.xlsx b/sc/qa/unit/uicalc/data/tdf99913.xlsx
new file mode 100644
index 000000000000..3fd18a12984a
--- /dev/null
+++ b/sc/qa/unit/uicalc/data/tdf99913.xlsx
Binary files differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 818361ec9d83..48cde55df479 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -1387,6 +1387,15 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf116215)
CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A2:B2)"), aFormula);
}
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf99913)
+{
+ ScModelObj* pModelObj = createDoc("tdf99913.xlsx");
+ ScDocument* pDoc = pModelObj->GetDocument();
+ CPPUNIT_ASSERT(pDoc);
+
+ CPPUNIT_ASSERT(pDoc->RowFiltered(2, 0));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/filter/oox/worksheethelper.cxx b/sc/source/filter/oox/worksheethelper.cxx
index fe30d788b623..6d07bfd57cad 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -68,6 +68,8 @@
#include <stlsheet.hxx>
#include <stlpool.hxx>
#include <cellvalue.hxx>
+#include <columnspanset.hxx>
+#include <dbdata.hxx>
#include <svl/stritem.hxx>
#include <editeng/eeitem.hxx>
@@ -341,9 +343,12 @@ private:
void convertColumns( OutlineLevelVec& orColLevels, const ValueRange& rColRange, const ColumnModel& rModel );
/** Converts row properties for all rows in the sheet. */
- void convertRows();
+ void convertRows(const std::vector<sc::ColRowSpan>& rSpans);
/** Converts row properties. */
- void convertRows( OutlineLevelVec& orRowLevels, const ValueRange& rRowRange, const RowModel& rModel, double fDefHeight = -1.0 );
+ void convertRows(OutlineLevelVec& orRowLevels, const ValueRange& rRowRange,
+ const RowModel& rModel,
+ const std::vector<sc::ColRowSpan>& rSpans,
+ double fDefHeight = -1.0);
/** Converts outline grouping for the passed column or row. */
void convertOutlines( OutlineLevelVec& orLevels, sal_Int32 nColRow, sal_Int32 nLevel, bool bCollapsed, bool bRows );
@@ -947,7 +952,37 @@ void WorksheetGlobals::finalizeWorksheetImport()
lclUpdateProgressBar( mxFinalProgress, 0.5 );
convertColumns();
- convertRows();
+
+ // tdf#99913 rows hidden by filter need extra flag
+ ScDocument& rDoc = getScDocument();
+ std::vector<sc::ColRowSpan> aSpans;
+ SCTAB nTab = getSheetIndex();
+ ScDBData* pDBData = rDoc.GetAnonymousDBData(nTab);
+ if (pDBData && pDBData->HasAutoFilter())
+ {
+ ScRange aRange;
+ pDBData->GetArea(aRange);
+ SCCOLROW nStartRow = static_cast<SCCOLROW>(aRange.aStart.Row());
+ SCCOLROW nEndRow = static_cast<SCCOLROW>(aRange.aEnd.Row());
+ aSpans.push_back(sc::ColRowSpan(nStartRow, nEndRow));
+ }
+ ScDBCollection* pDocColl = rDoc.GetDBCollection();
+ if (!pDocColl->empty())
+ {
+ ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
+ for (const auto& rxDB : rDBs)
+ {
+ if (rxDB->GetTab() == nTab && rxDB->HasAutoFilter())
+ {
+ ScRange aRange;
+ rxDB->GetArea(aRange);
+ SCCOLROW nStartRow = static_cast<SCCOLROW>(aRange.aStart.Row());
+ SCCOLROW nEndRow = static_cast<SCCOLROW>(aRange.aEnd.Row());
+ aSpans.push_back(sc::ColRowSpan(nStartRow, nEndRow));
+ }
+ }
+ }
+ convertRows(aSpans);
lclUpdateProgressBar( mxFinalProgress, 1.0 );
}
@@ -1201,7 +1236,7 @@ void WorksheetGlobals::convertColumns( OutlineLevelVec& orColLevels,
convertOutlines( orColLevels, rColRange.mnFirst, rModel.mnLevel, rModel.mbCollapsed, false );
}
-void WorksheetGlobals::convertRows()
+void WorksheetGlobals::convertRows(const std::vector<sc::ColRowSpan>& rSpans)
{
sal_Int32 nNextRow = 0;
sal_Int32 nMaxRow = mrMaxApiPos.Row();
@@ -1214,21 +1249,23 @@ void WorksheetGlobals::convertRows()
ValueRange aRowRange( ::std::max( rowModel.first, nNextRow ), ::std::min( rowModel.second.second, nMaxRow ) );
// process gap between two row models, use default row model
if( nNextRow < aRowRange.mnFirst )
- convertRows( aRowLevels, ValueRange( nNextRow, aRowRange.mnFirst - 1 ), maDefRowModel );
+ convertRows(aRowLevels, ValueRange(nNextRow, aRowRange.mnFirst - 1), maDefRowModel,
+ rSpans);
// process the row model
- convertRows( aRowLevels, aRowRange, rowModel.second.first, maDefRowModel.mfHeight );
+ convertRows(aRowLevels, aRowRange, rowModel.second.first, rSpans, maDefRowModel.mfHeight);
// cache next row to be processed
nNextRow = aRowRange.mnLast + 1;
}
// remaining default rows to end of sheet
- convertRows( aRowLevels, ValueRange( nNextRow, nMaxRow ), maDefRowModel );
+ convertRows(aRowLevels, ValueRange(nNextRow, nMaxRow), maDefRowModel, rSpans);
// close remaining row outlines spanning to end of sheet
convertOutlines( aRowLevels, nMaxRow + 1, 0, false, true );
}
-void WorksheetGlobals::convertRows( OutlineLevelVec& orRowLevels,
- const ValueRange& rRowRange, const RowModel& rModel, double fDefHeight )
+void WorksheetGlobals::convertRows(OutlineLevelVec& orRowLevels, const ValueRange& rRowRange,
+ const RowModel& rModel,
+ const std::vector<sc::ColRowSpan>& rSpans, double fDefHeight)
{
// row height: convert points to row height in 1/100 mm
double fHeight = (rModel.mfHeight >= 0.0) ? rModel.mfHeight : fDefHeight;
@@ -1251,6 +1288,16 @@ void WorksheetGlobals::convertRows( OutlineLevelVec& orRowLevels,
{
ScDocument& rDoc = getScDocument();
rDoc.SetRowHidden( nStartRow, nEndRow, nTab, true );
+ for (const auto& rSpan : rSpans)
+ {
+ // tdf#99913 rows hidden by filter need extra flag
+ if (rSpan.mnStart <= nStartRow && nStartRow <= rSpan.mnEnd)
+ {
+ SCROW nLast = ::std::min(nEndRow, rSpan.mnEnd);
+ rDoc.SetRowFiltered(nStartRow, nLast, nTab, true);
+ break;
+ }
+ }
}
// outline settings for this row range