summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2022-03-15 20:03:50 +0100
committerLuboš Luňák <l.lunak@collabora.com>2022-04-14 10:17:02 +0200
commit6338a0a44d3c9eeac26419aecb866682a41eed52 (patch)
tree1cac2d6cbb4407e2b35a15bc46cdcf29bda8f632 /sc
parente6abff6c96f5b429f8da5ff0db173cbda558c69b (diff)
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.lunak@collabora.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/xlsx/tdf58243.xlsxbin0 -> 17952 bytes
-rw-r--r--sc/qa/unit/subsequent_export_test2.cxx11
-rw-r--r--sc/source/core/data/attarray.cxx9
-rw-r--r--sc/source/filter/inc/sheetdatabuffer.hxx9
-rw-r--r--sc/source/filter/oox/sheetdatabuffer.cxx2
5 files changed, 27 insertions, 4 deletions
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
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/tdf58243.xlsx
Binary files differ
diff --git a/sc/qa/unit/subsequent_export_test2.cxx b/sc/qa/unit/subsequent_export_test2.cxx
index ad3f125db7d9..9776b1629197 100644
--- a/sc/qa/unit/subsequent_export_test2.cxx
+++ b/sc/qa/unit/subsequent_export_test2.cxx
@@ -217,6 +217,7 @@ public:
void testTdf145059();
void testTdf130104_XLSXIndent();
void testWholeRowBold();
+ void testXlsxRowsOrder();
CPPUNIT_TEST_SUITE(ScExportTest2);
@@ -333,6 +334,7 @@ public:
CPPUNIT_TEST(testTdf145059);
CPPUNIT_TEST(testTdf130104_XLSXIndent);
CPPUNIT_TEST(testWholeRowBold);
+ CPPUNIT_TEST(testXlsxRowsOrder);
CPPUNIT_TEST_SUITE_END();
@@ -3113,6 +3115,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 5af0e3b3609d..1b84ae4616a5 100644
--- a/sc/source/core/data/attarray.cxx
+++ b/sc/source/core/data/attarray.cxx
@@ -930,6 +930,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 33366fde9f9e..8eee9f7b79b0 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -199,14 +199,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;