[Libreoffice-commits] core.git: sw/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Nov 22 16:10:12 UTC 2018
sw/source/core/doc/doctxm.cxx | 10 +++++-----
sw/source/core/fields/authfld.cxx | 8 ++++----
sw/source/core/inc/txmsrt.hxx | 19 +++++++++++--------
sw/source/core/tox/txmsrt.cxx | 18 +++++++++---------
4 files changed, 29 insertions(+), 26 deletions(-)
New commits:
commit 750ccfb2a60582a5652c08f3cbb6f11d4c152275
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Nov 22 11:54:45 2018 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Nov 22 17:09:47 2018 +0100
tdf#120703 PVS: V637 rename inconsistent < and == operators
i.e. lets not have...
if (a == b)
{
if (a < b)
}
Change-Id: I8ffb8a1e591cbd5f9bf24fbef497660700ed47b0
Reviewed-on: https://gerrit.libreoffice.org/63802
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index d39c33c2f5a5..52652fbab564 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -1826,9 +1826,9 @@ void SwTOXBaseSection::InsertSorted(std::unique_ptr<SwTOXSortTabBase> pNew)
for(short i = static_cast<short>(aRange.Min()); i < static_cast<short>(aRange.Max()); ++i)
{
SwTOXSortTabBase* pOld = m_aSortArr[i].get();
- if(*pOld == *pNew)
+ if (pOld->equivalent(*pNew))
{
- if(*pOld < *pNew)
+ if (pOld->sort_lt(*pNew))
{
return;
}
@@ -1849,7 +1849,7 @@ void SwTOXBaseSection::InsertSorted(std::unique_ptr<SwTOXSortTabBase> pNew)
for( i = aRange.Min(); i < aRange.Max(); ++i)
{ // Only check for same level
SwTOXSortTabBase* pOld = m_aSortArr[i].get();
- if(*pOld == *pNew)
+ if (pOld->equivalent(*pNew))
{
if(TOX_AUTHORITIES != SwTOXBase::GetType())
{
@@ -1873,7 +1873,7 @@ void SwTOXBaseSection::InsertSorted(std::unique_ptr<SwTOXSortTabBase> pNew)
OSL_FAIL("Bibliography entries cannot be found here");
#endif
}
- if(*pNew < *pOld)
+ if (pNew->sort_lt(*pOld))
break;
}
// Skip SubLevel
@@ -1921,7 +1921,7 @@ Range SwTOXBaseSection::GetKeyRange(const OUString& rStr, const OUString& rStrRe
rNew.GetLocale() ));
for(i = nMin; i < nMax; ++i)
{
- if(nLevel == m_aSortArr[i]->GetLevel() && *pKey < *(m_aSortArr[i]))
+ if (nLevel == m_aSortArr[i]->GetLevel() && pKey->sort_lt(*m_aSortArr[i]))
break;
}
m_aSortArr.insert(m_aSortArr.begin() + i, std::move(pKey));
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index 1e9c1ab6ed74..e5225f253b0b 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -289,11 +289,11 @@ sal_uInt16 SwAuthorityFieldType::GetSequencePos(sal_IntPtr nHandle,
for (size_t i = 0; i < rSortArr.size(); ++i)
{
SwTOXSortTabBase* pOld = rSortArr[i].get();
- if(*pOld == *pNew)
+ if (pOld->equivalent(*pNew))
{
//only the first occurrence in the document
//has to be in the array
- if(*pOld < *pNew)
+ if (pOld->sort_lt(*pNew))
pNew.reset();
else // remove the old content
rSortArr.erase(rSortArr.begin() + i);
@@ -301,14 +301,14 @@ sal_uInt16 SwAuthorityFieldType::GetSequencePos(sal_IntPtr nHandle,
}
}
//if it still exists - insert at the correct position
- if(pNew)
+ if (pNew)
{
size_t j {0};
while (j < rSortArr.size())
{
SwTOXSortTabBase* pOld = rSortArr[j].get();
- if(*pNew < *pOld)
+ if (pNew->sort_lt(*pOld))
break;
++j;
}
diff --git a/sw/source/core/inc/txmsrt.hxx b/sw/source/core/inc/txmsrt.hxx
index da33208dd297..548852698309 100644
--- a/sw/source/core/inc/txmsrt.hxx
+++ b/sw/source/core/inc/txmsrt.hxx
@@ -118,6 +118,9 @@ public:
*/
struct SwTOXSortTabBase
{
+ bool operator==(const SwTOXSortTabBase&) = delete;
+ bool operator<(const SwTOXSortTabBase&) = delete;
+
std::vector<SwTOXSource> aTOXSources;
css::lang::Locale aLocale;
const SwTextNode* pTOXNd;
@@ -140,8 +143,8 @@ struct SwTOXSortTabBase
virtual void FillText( SwTextNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField ) const;
virtual sal_uInt16 GetLevel() const = 0;
- virtual bool operator==( const SwTOXSortTabBase& );
- virtual bool operator<( const SwTOXSortTabBase& );
+ virtual bool equivalent( const SwTOXSortTabBase& );
+ virtual bool sort_lt( const SwTOXSortTabBase& );
virtual OUString GetURL() const;
@@ -183,8 +186,8 @@ struct SwTOXIndex : public SwTOXSortTabBase
virtual void FillText( SwTextNode& rNd, const SwIndex& rInsPos, sal_uInt16 nAuthField ) const override;
virtual sal_uInt16 GetLevel() const override;
- virtual bool operator==( const SwTOXSortTabBase& ) override;
- virtual bool operator<( const SwTOXSortTabBase& ) override;
+ virtual bool equivalent( const SwTOXSortTabBase& ) override;
+ virtual bool sort_lt( const SwTOXSortTabBase& ) override;
private:
virtual TextAndReading GetText_Impl() const override;
@@ -199,8 +202,8 @@ struct SwTOXCustom : public SwTOXSortTabBase
const css::lang::Locale& rLocale );
virtual sal_uInt16 GetLevel() const override;
- virtual bool operator==( const SwTOXSortTabBase& ) override;
- virtual bool operator<( const SwTOXSortTabBase& ) override;
+ virtual bool equivalent( const SwTOXSortTabBase& ) override;
+ virtual bool sort_lt( const SwTOXSortTabBase& ) override;
private:
virtual TextAndReading GetText_Impl() const override;
@@ -272,8 +275,8 @@ public:
SwFormatField& GetFieldFormat() {return m_rField;}
- virtual bool operator==( const SwTOXSortTabBase& ) override;
- virtual bool operator<( const SwTOXSortTabBase& ) override;
+ virtual bool equivalent( const SwTOXSortTabBase& ) override;
+ virtual bool sort_lt( const SwTOXSortTabBase& ) override;
virtual sal_uInt16 GetLevel() const override;
};
diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx
index b33d31c9d60e..f335f13460a3 100644
--- a/sw/source/core/tox/txmsrt.cxx
+++ b/sw/source/core/tox/txmsrt.cxx
@@ -191,7 +191,7 @@ void SwTOXSortTabBase::FillText( SwTextNode& rNd, const SwIndex& rInsPos,
rNd.InsertText( GetText().sText, rInsPos );
}
-bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp )
+bool SwTOXSortTabBase::equivalent(const SwTOXSortTabBase& rCmp)
{
bool bRet = nPos == rCmp.nPos && nCntPos == rCmp.nCntPos &&
(!aTOXSources[0].pNd || !rCmp.aTOXSources[0].pNd ||
@@ -217,7 +217,7 @@ bool SwTOXSortTabBase::operator==( const SwTOXSortTabBase& rCmp )
return bRet;
}
-bool SwTOXSortTabBase::operator<( const SwTOXSortTabBase& rCmp )
+bool SwTOXSortTabBase::sort_lt(const SwTOXSortTabBase& rCmp)
{
if( nPos < rCmp.nPos )
return true;
@@ -280,7 +280,7 @@ SwTOXIndex::SwTOXIndex( const SwTextNode& rNd,
// Compare keywords. Only relates to the text.
-bool SwTOXIndex::operator==( const SwTOXSortTabBase& rCmpBase )
+bool SwTOXIndex::equivalent(const SwTOXSortTabBase& rCmpBase)
{
const SwTOXIndex& rCmp = static_cast<const SwTOXIndex&>(rCmpBase);
@@ -302,7 +302,7 @@ bool SwTOXIndex::operator==( const SwTOXSortTabBase& rCmpBase )
// operator, only depends on the text
-bool SwTOXIndex::operator<( const SwTOXSortTabBase& rCmpBase )
+bool SwTOXIndex::sort_lt(const SwTOXSortTabBase& rCmpBase)
{
const SwTOXIndex& rCmp = static_cast<const SwTOXIndex&>(rCmpBase);
@@ -413,14 +413,14 @@ SwTOXCustom::SwTOXCustom(const TextAndReading& rKey,
{
}
-bool SwTOXCustom::operator==(const SwTOXSortTabBase& rCmpBase)
+bool SwTOXCustom::equivalent(const SwTOXSortTabBase& rCmpBase)
{
return GetLevel() == rCmpBase.GetLevel() &&
pTOXIntl->IsEqual( GetText(), GetLocale(),
rCmpBase.GetText(), rCmpBase.GetLocale() );
}
-bool SwTOXCustom::operator < (const SwTOXSortTabBase& rCmpBase)
+bool SwTOXCustom::sort_lt(const SwTOXSortTabBase& rCmpBase)
{
return GetLevel() <= rCmpBase.GetLevel() &&
pTOXIntl->IsLess( GetText(), GetLocale(),
@@ -725,21 +725,21 @@ void SwTOXAuthority::FillText( SwTextNode& rNd,
rNd.InsertText( sText, rInsPos );
}
-bool SwTOXAuthority::operator==( const SwTOXSortTabBase& rCmp)
+bool SwTOXAuthority::equivalent(const SwTOXSortTabBase& rCmp)
{
return nType == rCmp.nType &&
static_cast<SwAuthorityField*>(m_rField.GetField())->GetHandle() ==
static_cast<SwAuthorityField*>(static_cast<const SwTOXAuthority&>(rCmp).m_rField.GetField())->GetHandle();
}
-bool SwTOXAuthority::operator<( const SwTOXSortTabBase& rBase)
+bool SwTOXAuthority::sort_lt(const SwTOXSortTabBase& rBase)
{
bool bRet = false;
SwAuthorityField* pField = static_cast<SwAuthorityField*>(m_rField.GetField());
SwAuthorityFieldType* pType = static_cast<SwAuthorityFieldType*>(
pField->GetTyp());
if(pType->IsSortByDocument())
- bRet = SwTOXSortTabBase::operator<(rBase);
+ bRet = SwTOXSortTabBase::sort_lt(rBase);
else
{
SwAuthorityField* pCmpField =
More information about the Libreoffice-commits
mailing list