sc/source/filter/oox/sheetdatabuffer.cxx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
New commits: commit 1a1957eab90a11b5481faa1ef6d877eed1ce564a Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Fri Mar 18 17:20:47 2022 +0100 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Sat Mar 19 09:53:49 2022 +0100 handle broken row ranges in excel import, #2 In ad1f6e62298612f4b277708b813a219ba390f1b0 I didn't add a second std::unique() pass, that seems to be necessary with some broken documents as well (sc_column3_regroupformulacells_heap_buffer_overflow.sample from crashtesting). Change-Id: I6865085a9b77fe51246180e519bf1a2309615144 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131834 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lu...@collabora.com> diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx index 82fc10f35069..63b9b4f11145 100644 --- a/sc/source/filter/oox/sheetdatabuffer.cxx +++ b/sc/source/filter/oox/sheetdatabuffer.cxx @@ -379,9 +379,15 @@ void SheetDataBuffer::addColXfStyles() // as operator< is somewhat specific (see StyleRowRangeComp). { return !StyleRowRangeComp()(lhs,rhs) && !StyleRowRangeComp()(rhs,lhs); } ), s.end()); - // Broken documents may have overlapping ranges that cause problems, re-sort again if needed. + // Broken documents may have overlapping ranges that cause problems, repeat once more. if(!std::is_sorted(s.begin(), s.end(), StyleRowRangeComp())) + { std::sort( s.begin(), s.end(), StyleRowRangeComp()); + s.erase( std::unique( s.begin(), s.end(), + [](const RowRangeStyle& lhs, const RowRangeStyle& rhs) + { return !StyleRowRangeComp()(lhs,rhs) && !StyleRowRangeComp()(rhs,lhs); } ), + s.end()); + } maStylesPerColumn[ rowStyles.first ].insert_sorted_unique_vector( std::move( s )); } }