sc/inc/address.hxx | 39 +++++++++++---------------------------- sc/source/core/tool/address.cxx | 22 ---------------------- 2 files changed, 11 insertions(+), 50 deletions(-)
New commits: commit 51d1f84abf889df32218b018e66ecd1deccafd7d Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Feb 10 12:48:17 2022 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Thu Feb 10 15:57:24 2022 +0100 Deduplicate PutInOrder's Change-Id: I76db8dd5398628e544fdd76179046b98f76d80a8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129773 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx index a5f25f2bd87c..a87f1bbf2b2c 100644 --- a/sc/inc/address.hxx +++ b/sc/inc/address.hxx @@ -140,6 +140,12 @@ const SCROW MAXROW_30 = 8191; return nTab < 0 ? 0 : (nTab > MAXTAB ? MAXTAB : nTab); } +template <typename T> inline void PutInOrder(T& nStart, T& nEnd) +{ + if (nEnd < nStart) + std::swap(nStart, nEnd); +} + // The result of ConvertRef() is a bit group of the following: enum class ScRefFlags : sal_uInt16 { @@ -382,24 +388,9 @@ inline std::basic_ostream<charT, traits> & operator <<(std::basic_ostream<charT, inline void ScAddress::PutInOrder( ScAddress& rAddress ) { - if ( rAddress.Col() < Col() ) - { - SCCOL nTmp = rAddress.Col(); - rAddress.SetCol( Col() ); - SetCol( nTmp ); - } - if ( rAddress.Row() < Row() ) - { - SCROW nTmp = rAddress.Row(); - rAddress.SetRow( Row() ); - SetRow( nTmp ); - } - if ( rAddress.Tab() < Tab() ) - { - SCTAB nTmp = rAddress.Tab(); - rAddress.SetTab( Tab() ); - SetTab( nTmp ); - } + ::PutInOrder(nCol, rAddress.nCol); + ::PutInOrder(nRow, rAddress.nRow); + ::PutInOrder(nTab, rAddress.nTab); } inline void ScAddress::Set( SCCOL nColP, SCROW nRowP, SCTAB nTabP ) @@ -512,7 +503,7 @@ public: ScRange( const ScAddress& aInputStart, const ScAddress& aInputEnd ) : aStart( aInputStart ), aEnd( aInputEnd ) { - aStart.PutInOrder( aEnd ); + PutInOrder(); } ScRange( const ScRange& rRange ) : aStart( rRange.aStart ), aEnd( rRange.aEnd ) @@ -621,7 +612,7 @@ public: inline void GetVars( SCCOL& nCol1, SCROW& nRow1, SCTAB& nTab1, SCCOL& nCol2, SCROW& nRow2, SCTAB& nTab2 ) const; - void PutInOrder(); + void PutInOrder() { aStart.PutInOrder(aEnd); } /** @param rErrorRange @@ -958,14 +949,6 @@ inline bool ScRefAddress::operator==( const ScRefAddress& rRefAddress ) const #define BCA_BRDCST_ALWAYS ScAddress( 0, SCROW_MAX, 0 ) #define BCA_LISTEN_ALWAYS ScRange( BCA_BRDCST_ALWAYS, BCA_BRDCST_ALWAYS ) -template< typename T > inline void PutInOrder( T& nStart, T& nEnd ) -{ - if (nEnd < nStart) - { - std::swap(nStart, nEnd); - } -} - bool ConvertSingleRef( const ScDocument& pDocument, const OUString& rRefString, SCTAB nDefTab, ScRefAddress& rRefAddress, const ScAddress::Details& rDetails, diff --git a/sc/source/core/tool/address.cxx b/sc/source/core/tool/address.cxx index e7cda8a368e5..ade934380aae 100644 --- a/sc/source/core/tool/address.cxx +++ b/sc/source/core/tool/address.cxx @@ -1571,28 +1571,6 @@ ScRange ScRange::Intersection( const ScRange& rOther ) const return ScRange(nCol1, nRow1, nTab1, nCol2, nRow2, nTab2); } -void ScRange::PutInOrder() -{ - SCCOL nTempCol; - if ( aEnd.Col() < (nTempCol = aStart.Col()) ) - { - aStart.SetCol(aEnd.Col()); - aEnd.SetCol(nTempCol); - } - SCROW nTempRow; - if ( aEnd.Row() < (nTempRow = aStart.Row()) ) - { - aStart.SetRow(aEnd.Row()); - aEnd.SetRow(nTempRow); - } - SCTAB nTempTab; - if ( aEnd.Tab() < (nTempTab = aStart.Tab()) ) - { - aStart.SetTab(aEnd.Tab()); - aEnd.SetTab(nTempTab); - } -} - void ScRange::ExtendTo( const ScRange& rRange ) { OSL_ENSURE( rRange.IsValid(), "ScRange::ExtendTo - cannot extend to invalid range" );