sc/qa/unit/data/xlsx/tdf58243.xlsx |binary sc/qa/unit/subsequent_export_test2.cxx | 11 +++++++++++ sc/source/core/data/attarray.cxx | 9 +++++++++ sc/source/filter/inc/sheetdatabuffer.hxx | 9 +++++++-- sc/source/filter/oox/sheetdatabuffer.cxx | 2 -- 5 files changed, 27 insertions(+), 4 deletions(-)
New commits: commit 1fa46653315810a579009f712f2c1bbdf1f5fd44 Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Tue Mar 15 20:03:50 2022 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Tue Mar 15 22:39:17 2022 +0100 fix comparison operators in Excel export, #2 It turns out that the end-vs-start comparison was intentional and the file causing problems is broken, so more or less revert 83d599fd7c530d14f70ac60bd673b66640191bf7, and I'll handle the problematic file in another commit. Change-Id: I5c7538a7c3eeea9c5fd1661e1a9a2c3370b799c9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131636 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/qa/unit/data/xlsx/tdf58243.xlsx b/sc/qa/unit/data/xlsx/tdf58243.xlsx new file mode 100644 index 000000000000..f95e13b4b6db Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf58243.xlsx differ diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx index 0ed29cae605c..4d22a2ffdbc6 100644 --- a/sc/qa/unit/subsequent_export_test2.cxx +++ b/sc/qa/unit/subsequent_export_test2.cxx @@ -185,6 +185,7 @@ public: void testTdf145059(); void testTdf130104_XLSXIndent(); void testWholeRowBold(); + void testXlsxRowsOrder(); CPPUNIT_TEST_SUITE(ScExportTest2); @@ -303,6 +304,7 @@ public: CPPUNIT_TEST(testTdf145059); CPPUNIT_TEST(testTdf130104_XLSXIndent); CPPUNIT_TEST(testWholeRowBold); + CPPUNIT_TEST(testXlsxRowsOrder); CPPUNIT_TEST_SUITE_END(); @@ -3099,6 +3101,15 @@ void ScExportTest2::testWholeRowBold() xDocSh3->DoClose(); } +void ScExportTest2::testXlsxRowsOrder() +{ + ScDocShellRef xDocSh = loadDoc(u"tdf58243.", FORMAT_XLSX); + CPPUNIT_ASSERT(xDocSh.is()); + // Make sure code in SheetDataBuffer doesn't assert columns/rows sorting. + ScBootstrapFixture::exportTo(*xDocSh, FORMAT_XLSX); + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(ScExportTest2); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index a7ee5ff2276e..042213bda05c 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -923,6 +923,15 @@ void ScAttrArray::SetAttrEntries(std::vector<ScAttrEntry> && vNewData) pDocPool->Remove(*rEntry.pPattern); mvData = std::move(vNewData); + +#ifdef DBG_UTIL + SCROW lastEndRow = -1; + for(const auto& entry : mvData) + { // Verify that the data is not corrupted. + assert(entry.nEndRow > lastEndRow); + lastEndRow = entry.nEndRow; + } +#endif } static void lcl_MergeDeep( SfxItemSet& rMergeSet, const SfxItemSet& rSource ) diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx index 0cca3f0c7c84..c212c8f0e09d 100644 --- a/sc/source/filter/inc/sheetdatabuffer.hxx +++ b/sc/source/filter/inc/sheetdatabuffer.hxx @@ -198,14 +198,19 @@ private: { bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) const { - return lhs.mnStartRow<rhs.mnStartRow; + // This end-vs-start comparison is needed by the lower_bound() use + // in SheetDataBuffer::addColXfStyleProcessRowRanges() that searches + // for partially overlapping ranges. In all other places the ranges + // should be non-overlapping, in which case this is the same as the "normal" + // comparison. + return lhs.mnEndRow<rhs.mnStartRow; } }; struct StyleRowRangeCompEqual { bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) const { - return lhs.mnStartRow==rhs.mnStartRow; + return lhs.mnStartRow==rhs.mnStartRow && lhs.mnEndRow == rhs.mnEndRow; } }; typedef ::o3tl::sorted_vector< RowRangeStyle, StyleRowRangeComp > RowStyles; diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index 6dbec9e6bd9d..259e3190107b 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -409,8 +409,6 @@ void SheetDataBuffer::addColXfStyleProcessRowRanges() RowRangeStyle aStyleRows; aStyleRows.mnNumFmt.first = nXfId; aStyleRows.mnNumFmt.second = -1; - aStyleRows.mnStartRow = rRange.mnFirst; - aStyleRows.mnEndRow = rRange.mnLast; // Reset row range for each column aStyleRows.mnStartRow = rRange.mnFirst;