Simplify SwPosition comparison operators
Drop inequality, that is automatically deduced; and use less-than to define others. Change-Id: Ib979cbe74ec28c1fde0337276d4f602a1fe907b4 Signed-off-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/10674 Tested-by: Jenkins CPCI <releng@collaboraoffice.com> Reviewed-by: Noel Grandin <noel.grandin@collabora.com> (cherry picked from commit 9f8156beb5eb02ef7d7b00a3effbd6631fc58dfb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/210507 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
committed by
Xisco Fauli
parent
720a9455a6
commit
32ab4a61cc
+3
-3
@@ -67,9 +67,9 @@ struct SAL_WARN_UNUSED SW_DLLPUBLIC SwPosition
|
||||
SwDoc& GetDoc() const;
|
||||
|
||||
bool operator < (const SwPosition &) const;
|
||||
bool operator > (const SwPosition &) const;
|
||||
bool operator <=(const SwPosition &) const;
|
||||
bool operator >=(const SwPosition &) const;
|
||||
bool operator > (const SwPosition & rOther) const { return rOther < *this; }
|
||||
bool operator <=(const SwPosition & rOther) const { return !(*this > rOther); }
|
||||
bool operator >=(const SwPosition & rOther) const { return !(*this < rOther); }
|
||||
bool operator ==(const SwPosition &) const;
|
||||
void dumpAsXml(xmlTextWriterPtr pWriter) const;
|
||||
|
||||
|
||||
@@ -140,69 +140,6 @@ bool SwPosition::operator<(const SwPosition &rPos) const
|
||||
return nNode < rPos.nNode;
|
||||
}
|
||||
|
||||
bool SwPosition::operator>(const SwPosition &rPos) const
|
||||
{
|
||||
// cheaper to check for == first
|
||||
if( nNode == rPos.nNode )
|
||||
{
|
||||
// note that positions with text node but no SwContentIndex registered are
|
||||
// created for text frames anchored at para (see SwXFrame::getAnchor())
|
||||
SwContentNode const*const pThisReg(GetContentNode());
|
||||
SwContentNode const*const pOtherReg(rPos.GetContentNode());
|
||||
if (pThisReg && pOtherReg)
|
||||
{
|
||||
return (nContent > rPos.nContent);
|
||||
}
|
||||
else // by convention position with no index is smaller
|
||||
{
|
||||
return pThisReg != nullptr;
|
||||
}
|
||||
}
|
||||
return nNode > rPos.nNode;
|
||||
}
|
||||
|
||||
bool SwPosition::operator<=(const SwPosition &rPos) const
|
||||
{
|
||||
// cheaper to check for == first
|
||||
if( nNode == rPos.nNode )
|
||||
{
|
||||
// note that positions with text node but no SwContentIndex registered are
|
||||
// created for text frames anchored at para (see SwXFrame::getAnchor())
|
||||
SwContentNode const*const pThisReg(GetContentNode());
|
||||
SwContentNode const*const pOtherReg(rPos.GetContentNode());
|
||||
if (pThisReg && pOtherReg)
|
||||
{
|
||||
return (nContent <= rPos.nContent);
|
||||
}
|
||||
else // by convention position with no index is smaller
|
||||
{
|
||||
return pThisReg == nullptr;
|
||||
}
|
||||
}
|
||||
return nNode < rPos.nNode;
|
||||
}
|
||||
|
||||
bool SwPosition::operator>=(const SwPosition &rPos) const
|
||||
{
|
||||
// cheaper to check for == first
|
||||
if( nNode == rPos.nNode )
|
||||
{
|
||||
// note that positions with text node but no SwContentIndex registered are
|
||||
// created for text frames anchored at para (see SwXFrame::getAnchor())
|
||||
SwContentNode const*const pThisReg(GetContentNode());
|
||||
SwContentNode const*const pOtherReg(rPos.GetContentNode());
|
||||
if (pThisReg && pOtherReg)
|
||||
{
|
||||
return (nContent >= rPos.nContent);
|
||||
}
|
||||
else // by convention position with no index is smaller
|
||||
{
|
||||
return pOtherReg == nullptr;
|
||||
}
|
||||
}
|
||||
return nNode > rPos.nNode;
|
||||
}
|
||||
|
||||
bool SwPosition::operator==(const SwPosition &rPos) const
|
||||
{
|
||||
return (nNode == rPos.nNode)
|
||||
|
||||
Reference in New Issue
Block a user