Kaydet (Commit) c038d88c authored tarafından Eike Rathke's avatar Eike Rathke

ScAddress::operator<() is not what we need here, tdf#48140 follow-up fix

ScAddress::operator<() compares by tab,col,row while we need tab,row,col
for ODF import/export.

This caused the export crash tests
http://dev-builds.libreoffice.org/crashtest/27ec6d1cb96a0d3becf14309a26d1c024a0f8603/exportCrash.txt
to fail due to assert

sax/source/expatwrap/saxwriter.cxx:1143: virtual void
{anonymous}::SAXWriter::endElement(const rtl::OUString&): Assertion
`aName == m_pSaxWriterHelper->m_DebugStartedElements.top()'

Fallout from
commit 50106435
Date:   Thu Nov 24 00:02:45 2016 +0100

    tdf#48140 Change types of variables and remove uneeded code

Change-Id: I63d365f62868099b79de4812534c323b89dc2ee1
üst ad2bc869
...@@ -344,6 +344,7 @@ public: ...@@ -344,6 +344,7 @@ public:
inline bool operator!=( const ScAddress& rAddress ) const; inline bool operator!=( const ScAddress& rAddress ) const;
inline bool operator<( const ScAddress& rAddress ) const; inline bool operator<( const ScAddress& rAddress ) const;
inline bool operator<=( const ScAddress& rAddress ) const; inline bool operator<=( const ScAddress& rAddress ) const;
inline bool lessThanByRow( const ScAddress& rAddress ) const;
inline size_t hash() const; inline size_t hash() const;
...@@ -398,8 +399,7 @@ inline bool ScAddress::operator!=( const ScAddress& rAddress ) const ...@@ -398,8 +399,7 @@ inline bool ScAddress::operator!=( const ScAddress& rAddress ) const
return !operator==( rAddress ); return !operator==( rAddress );
} }
/** Same behavior as the old sal_uInt32 nAddress < r.nAddress with encoded /** Less than ordered by tab,col,row. */
tab|col|row bit fields. */
inline bool ScAddress::operator<( const ScAddress& rAddress ) const inline bool ScAddress::operator<( const ScAddress& rAddress ) const
{ {
if (nTab == rAddress.nTab) if (nTab == rAddress.nTab)
...@@ -418,6 +418,20 @@ inline bool ScAddress::operator<=( const ScAddress& rAddress ) const ...@@ -418,6 +418,20 @@ inline bool ScAddress::operator<=( const ScAddress& rAddress ) const
return operator<( rAddress ) || operator==( rAddress ); return operator<( rAddress ) || operator==( rAddress );
} }
/** Less than ordered by tab,row,col as needed by row-wise import/export */
inline bool ScAddress::lessThanByRow( const ScAddress& rAddress ) const
{
if (nTab == rAddress.nTab)
{
if (nRow == rAddress.nRow)
return nCol < rAddress.nCol;
else
return nRow < rAddress.nRow;
}
else
return nTab < rAddress.nTab;
}
inline size_t ScAddress::hash() const inline size_t ScAddress::hash() const
{ {
// Assume that there are not that many addresses with row > 2^16 AND column // Assume that there are not that many addresses with row > 2^16 AND column
...@@ -609,6 +623,7 @@ public: ...@@ -609,6 +623,7 @@ public:
inline bool operator!=( const ScRange& rRange ) const; inline bool operator!=( const ScRange& rRange ) const;
inline bool operator<( const ScRange& rRange ) const; inline bool operator<( const ScRange& rRange ) const;
inline bool operator<=( const ScRange& rRange ) const; inline bool operator<=( const ScRange& rRange ) const;
inline bool lessThanByRow( const ScRange& rRange ) const;
/// Hash 2D area ignoring table number. /// Hash 2D area ignoring table number.
inline size_t hashArea() const; inline size_t hashArea() const;
...@@ -645,7 +660,7 @@ inline bool ScRange::operator!=( const ScRange& rRange ) const ...@@ -645,7 +660,7 @@ inline bool ScRange::operator!=( const ScRange& rRange ) const
return !operator==( rRange ); return !operator==( rRange );
} }
/// Sort on upper left corner, if equal then use lower right too. /// Sort on upper left corner tab,col,row, if equal then use lower right too.
inline bool ScRange::operator<( const ScRange& r ) const inline bool ScRange::operator<( const ScRange& r ) const
{ {
return aStart < r.aStart || (aStart == r.aStart && aEnd < r.aEnd) ; return aStart < r.aStart || (aStart == r.aStart && aEnd < r.aEnd) ;
...@@ -656,6 +671,12 @@ inline bool ScRange::operator<=( const ScRange& rRange ) const ...@@ -656,6 +671,12 @@ inline bool ScRange::operator<=( const ScRange& rRange ) const
return operator<( rRange ) || operator==( rRange ); return operator<( rRange ) || operator==( rRange );
} }
/// Sort on upper left corner tab,row,col, if equal then use lower right too.
inline bool ScRange::lessThanByRow( const ScRange& r ) const
{
return aStart.lessThanByRow( r.aStart) || (aStart == r.aStart && aEnd.lessThanByRow( r.aEnd)) ;
}
inline bool ScRange::In( const ScAddress& rAddress ) const inline bool ScRange::In( const ScAddress& rAddress ) const
{ {
return return
......
...@@ -52,7 +52,7 @@ void ScMyIteratorBase::UpdateAddress( ScAddress& rCellAddress ) ...@@ -52,7 +52,7 @@ void ScMyIteratorBase::UpdateAddress( ScAddress& rCellAddress )
inline bool ScMyShape::operator<(const ScMyShape& aShape) const inline bool ScMyShape::operator<(const ScMyShape& aShape) const
{ {
return ( aAddress < aShape.aAddress ); return aAddress.lessThanByRow( aShape.aAddress );
} }
ScMyShapesContainer::ScMyShapesContainer() ScMyShapesContainer::ScMyShapesContainer()
...@@ -108,7 +108,7 @@ void ScMyShapesContainer::Sort() ...@@ -108,7 +108,7 @@ void ScMyShapesContainer::Sort()
inline bool ScMyNoteShape::operator<(const ScMyNoteShape& aNote) const inline bool ScMyNoteShape::operator<(const ScMyNoteShape& aNote) const
{ {
return ( aPos < aNote.aPos ); return aPos.lessThanByRow( aNote.aPos );
} }
ScMyNoteShapesContainer::ScMyNoteShapesContainer() ScMyNoteShapesContainer::ScMyNoteShapesContainer()
...@@ -159,7 +159,7 @@ void ScMyNoteShapesContainer::Sort() ...@@ -159,7 +159,7 @@ void ScMyNoteShapesContainer::Sort()
inline bool ScMyMergedRange::operator<(const ScMyMergedRange& aRange) const inline bool ScMyMergedRange::operator<(const ScMyMergedRange& aRange) const
{ {
return ( aCellRange.aStart < aRange.aCellRange.aStart ); return aCellRange.aStart.lessThanByRow( aRange.aCellRange.aStart );
} }
ScMyMergedRangesContainer::ScMyMergedRangesContainer() ScMyMergedRangesContainer::ScMyMergedRangesContainer()
...@@ -253,7 +253,7 @@ bool ScMyAreaLink::Compare( const ScMyAreaLink& rAreaLink ) const ...@@ -253,7 +253,7 @@ bool ScMyAreaLink::Compare( const ScMyAreaLink& rAreaLink ) const
inline bool ScMyAreaLink::operator<(const ScMyAreaLink& rAreaLink ) const inline bool ScMyAreaLink::operator<(const ScMyAreaLink& rAreaLink ) const
{ {
return ( aDestRange.aStart < rAreaLink.aDestRange.aStart ); return aDestRange.aStart.lessThanByRow( rAreaLink.aDestRange.aStart );
} }
ScMyAreaLinksContainer::ScMyAreaLinksContainer() : ScMyAreaLinksContainer::ScMyAreaLinksContainer() :
...@@ -379,7 +379,7 @@ void ScMyEmptyDatabaseRangesContainer::Sort() ...@@ -379,7 +379,7 @@ void ScMyEmptyDatabaseRangesContainer::Sort()
inline bool ScMyDetectiveObj::operator<( const ScMyDetectiveObj& rDetObj) const inline bool ScMyDetectiveObj::operator<( const ScMyDetectiveObj& rDetObj) const
{ {
return ( aPosition < rDetObj.aPosition ); return aPosition.lessThanByRow( rDetObj.aPosition );
} }
ScMyDetectiveObjContainer::ScMyDetectiveObjContainer() : ScMyDetectiveObjContainer::ScMyDetectiveObjContainer() :
...@@ -461,7 +461,7 @@ void ScMyDetectiveObjContainer::Sort() ...@@ -461,7 +461,7 @@ void ScMyDetectiveObjContainer::Sort()
inline bool ScMyDetectiveOp::operator<( const ScMyDetectiveOp& rDetOp) const inline bool ScMyDetectiveOp::operator<( const ScMyDetectiveOp& rDetOp) const
{ {
return ( aPosition < rDetOp.aPosition ); return aPosition.lessThanByRow( rDetOp.aPosition );
} }
ScMyDetectiveOpContainer::ScMyDetectiveOpContainer() : ScMyDetectiveOpContainer::ScMyDetectiveOpContainer() :
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment