summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/inc/sheetdatabuffer.hxx7
-rw-r--r--sc/source/filter/oox/sheetdatabuffer.cxx10
2 files changed, 9 insertions, 8 deletions
diff --git a/sc/source/filter/inc/sheetdatabuffer.hxx b/sc/source/filter/inc/sheetdatabuffer.hxx
index c212c8f0e09d..a6bec5a55807 100644
--- a/sc/source/filter/inc/sheetdatabuffer.hxx
+++ b/sc/source/filter/inc/sheetdatabuffer.hxx
@@ -206,13 +206,6 @@ private:
return lhs.mnEndRow<rhs.mnStartRow;
}
};
- struct StyleRowRangeCompEqual
- {
- bool operator() (const RowRangeStyle& lhs, const RowRangeStyle& rhs) const
- {
- return lhs.mnStartRow==rhs.mnStartRow && lhs.mnEndRow == rhs.mnEndRow;
- }
- };
typedef ::o3tl::sorted_vector< RowRangeStyle, StyleRowRangeComp > RowStyles;
typedef ::std::map< sal_Int32, RowStyles > ColStyles;
typedef ::std::vector< RowRangeStyle > TmpRowStyles;
diff --git a/sc/source/filter/oox/sheetdatabuffer.cxx b/sc/source/filter/oox/sheetdatabuffer.cxx
index 259e3190107b..82fc10f35069 100644
--- a/sc/source/filter/oox/sheetdatabuffer.cxx
+++ b/sc/source/filter/oox/sheetdatabuffer.cxx
@@ -373,7 +373,15 @@ void SheetDataBuffer::addColXfStyles()
{
TmpRowStyles& s = rowStyles.second;
std::sort( s.begin(), s.end(), StyleRowRangeComp());
- s.erase( std::unique( s.begin(), s.end(), StyleRowRangeCompEqual()), s.end());
+ s.erase( std::unique( s.begin(), s.end(),
+ [](const RowRangeStyle& lhs, const RowRangeStyle& rhs)
+ // Synthetize operator== from operator < . Do not create an actual operator==
+ // 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.
+ if(!std::is_sorted(s.begin(), s.end(), StyleRowRangeComp()))
+ std::sort( s.begin(), s.end(), StyleRowRangeComp());
maStylesPerColumn[ rowStyles.first ].insert_sorted_unique_vector( std::move( s ));
}
}