diff options
author | Eike Rathke <erack@redhat.com> | 2016-11-30 17:37:12 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-11-30 17:44:48 +0100 |
commit | c038d88c228bb2f4d0dde88f59ee4b9c6620687e (patch) | |
tree | 4f6885fbd60fc42591e267d4d11947701455eecb | |
parent | ad2bc869bfe2d34bde7d42e10593db1c5ffccc2a (diff) |
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 50106435e9a5bbc067e9beeabc5147ed9f305286
Date: Thu Nov 24 00:02:45 2016 +0100
tdf#48140 Change types of variables and remove uneeded code
Change-Id: I63d365f62868099b79de4812534c323b89dc2ee1
-rw-r--r-- | sc/inc/address.hxx | 27 | ||||
-rw-r--r-- | sc/source/filter/xml/XMLExportIterator.cxx | 12 |
2 files changed, 30 insertions, 9 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index d801d0593752..a1a75f2a9a3a 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -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 lessThanByRow( const ScAddress& rAddress ) const; inline size_t hash() const; @@ -398,8 +399,7 @@ inline bool ScAddress::operator!=( const ScAddress& rAddress ) const return !operator==( rAddress ); } -/** Same behavior as the old sal_uInt32 nAddress < r.nAddress with encoded - tab|col|row bit fields. */ +/** Less than ordered by tab,col,row. */ inline bool ScAddress::operator<( const ScAddress& rAddress ) const { if (nTab == rAddress.nTab) @@ -418,6 +418,20 @@ inline bool ScAddress::operator<=( const ScAddress& rAddress ) const 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 { // Assume that there are not that many addresses with row > 2^16 AND column @@ -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 lessThanByRow( const ScRange& rRange ) const; /// Hash 2D area ignoring table number. inline size_t hashArea() const; @@ -645,7 +660,7 @@ inline bool ScRange::operator!=( const ScRange& rRange ) const 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 { return aStart < r.aStart || (aStart == r.aStart && aEnd < r.aEnd) ; @@ -656,6 +671,12 @@ inline bool ScRange::operator<=( const ScRange& rRange ) const 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 { return diff --git a/sc/source/filter/xml/XMLExportIterator.cxx b/sc/source/filter/xml/XMLExportIterator.cxx index b680dd936c61..c4903e6f17ce 100644 --- a/sc/source/filter/xml/XMLExportIterator.cxx +++ b/sc/source/filter/xml/XMLExportIterator.cxx @@ -52,7 +52,7 @@ void ScMyIteratorBase::UpdateAddress( ScAddress& rCellAddress ) inline bool ScMyShape::operator<(const ScMyShape& aShape) const { - return ( aAddress < aShape.aAddress ); + return aAddress.lessThanByRow( aShape.aAddress ); } ScMyShapesContainer::ScMyShapesContainer() @@ -108,7 +108,7 @@ void ScMyShapesContainer::Sort() inline bool ScMyNoteShape::operator<(const ScMyNoteShape& aNote) const { - return ( aPos < aNote.aPos ); + return aPos.lessThanByRow( aNote.aPos ); } ScMyNoteShapesContainer::ScMyNoteShapesContainer() @@ -159,7 +159,7 @@ void ScMyNoteShapesContainer::Sort() inline bool ScMyMergedRange::operator<(const ScMyMergedRange& aRange) const { - return ( aCellRange.aStart < aRange.aCellRange.aStart ); + return aCellRange.aStart.lessThanByRow( aRange.aCellRange.aStart ); } ScMyMergedRangesContainer::ScMyMergedRangesContainer() @@ -253,7 +253,7 @@ bool ScMyAreaLink::Compare( 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() : @@ -379,7 +379,7 @@ void ScMyEmptyDatabaseRangesContainer::Sort() inline bool ScMyDetectiveObj::operator<( const ScMyDetectiveObj& rDetObj) const { - return ( aPosition < rDetObj.aPosition ); + return aPosition.lessThanByRow( rDetObj.aPosition ); } ScMyDetectiveObjContainer::ScMyDetectiveObjContainer() : @@ -461,7 +461,7 @@ void ScMyDetectiveObjContainer::Sort() inline bool ScMyDetectiveOp::operator<( const ScMyDetectiveOp& rDetOp) const { - return ( aPosition < rDetOp.aPosition ); + return aPosition.lessThanByRow( rDetOp.aPosition ); } ScMyDetectiveOpContainer::ScMyDetectiveOpContainer() : |