sc/inc/userlist.hxx | 2 +- sc/source/core/data/table4.cxx | 5 +++-- sc/source/core/tool/userlist.cxx | 35 ++++++++++++++++++++++++++--------- 3 files changed, 30 insertions(+), 12 deletions(-)
New commits: commit ef6ddb36751f917cd4ddab4a7fc609d5cf212b1b Author: Sahas <sah...@naman.ms> Date: Sun Oct 18 21:46:25 2015 +0530 tdf#79983 - Fix to make calc sort lists case sensitive Change-Id: I9d4aec8ccb395f8bf59f08d0f5ed461e99c9ea64 Reviewed-on: https://gerrit.libreoffice.org/19433 Reviewed-by: Eike Rathke <er...@redhat.com> Tested-by: Eike Rathke <er...@redhat.com> diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx index f174b36..8983026 100644 --- a/sc/inc/userlist.hxx +++ b/sc/inc/userlist.hxx @@ -51,7 +51,7 @@ public: const OUString& GetString() const { return aStr; } void SetString(const OUString& rStr); size_t GetSubCount() const; - bool GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex) const; + bool GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex, bool& bMatchCase) const; OUString GetSubStr(sal_uInt16 nIndex) const; sal_Int32 Compare(const OUString& rSubStr1, const OUString& rSubStr2) const; sal_Int32 ICompare(const OUString& rSubStr1, const OUString& rSubStr2) const; diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index b8f3a95..1be25d4 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -362,13 +362,14 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, rListData = const_cast<ScUserListData*>(ScGlobal::GetUserList()->GetData(aStr)); if (rListData) { - (void)rListData->GetSubIndex(aStr, rListIndex); + bool bMatchCase = false; + (void)rListData->GetSubIndex(aStr, rListIndex, bMatchCase); nCol = sal::static_int_cast<SCCOL>( nCol + nAddX ); nRow = sal::static_int_cast<SCROW>( nRow + nAddY ); for (sal_uInt16 i=1; i<nCount && rListData; i++) { (void)GetString(nCol, nRow, aStr); - if (!rListData->GetSubIndex(aStr, rListIndex)) + if (!rListData->GetSubIndex(aStr, rListIndex, bMatchCase)) rListData = NULL; nCol = sal::static_int_cast<SCCOL>( nCol + nAddX ); nRow = sal::static_int_cast<SCROW>( nRow + nAddY ); diff --git a/sc/source/core/tool/userlist.cxx b/sc/source/core/tool/userlist.cxx index 3f3cac7..d29e388 100644 --- a/sc/source/core/tool/userlist.cxx +++ b/sc/source/core/tool/userlist.cxx @@ -111,7 +111,7 @@ size_t ScUserListData::GetSubCount() const return maSubStrings.size(); } -bool ScUserListData::GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex) const +bool ScUserListData::GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex, bool& bMatchCase) const { // First, case sensitive search. SubStringsType::const_iterator itr = ::std::find_if( @@ -119,6 +119,7 @@ bool ScUserListData::GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex) co if (itr != maSubStrings.end()) { rIndex = ::std::distance(maSubStrings.begin(), itr); + bMatchCase = true; return true; } @@ -130,8 +131,10 @@ bool ScUserListData::GetSubIndex(const OUString& rSubStr, sal_uInt16& rIndex) co if (itr != maSubStrings.end()) { rIndex = ::std::distance(maSubStrings.begin(), itr); + bMatchCase = false; return true; } + bMatchCase = false; return false; } @@ -146,8 +149,9 @@ OUString ScUserListData::GetSubStr(sal_uInt16 nIndex) const sal_Int32 ScUserListData::Compare(const OUString& rSubStr1, const OUString& rSubStr2) const { sal_uInt16 nIndex1, nIndex2; - bool bFound1 = GetSubIndex(rSubStr1, nIndex1); - bool bFound2 = GetSubIndex(rSubStr2, nIndex2); + bool bMatchCase; + bool bFound1 = GetSubIndex(rSubStr1, nIndex1, bMatchCase); + bool bFound2 = GetSubIndex(rSubStr2, nIndex2, bMatchCase); if (bFound1) { if (bFound2) @@ -171,8 +175,9 @@ sal_Int32 ScUserListData::Compare(const OUString& rSubStr1, const OUString& rSub sal_Int32 ScUserListData::ICompare(const OUString& rSubStr1, const OUString& rSubStr2) const { sal_uInt16 nIndex1, nIndex2; - bool bFound1 = GetSubIndex(rSubStr1, nIndex1); - bool bFound2 = GetSubIndex(rSubStr2, nIndex2); + bool bMatchCase; + bool bFound1 = GetSubIndex(rSubStr1, nIndex1, bMatchCase); + bool bFound2 = GetSubIndex(rSubStr2, nIndex2, bMatchCase); if (bFound1) { if (bFound2) @@ -269,14 +274,26 @@ ScUserList::ScUserList(const ScUserList& r) : const ScUserListData* ScUserList::GetData(const OUString& rSubStr) const { + std::vector<DataType::const_iterator> matchData; DataType::const_iterator itr = maData.begin(), itrEnd = maData.end(); + sal_uInt16 nIndex; + bool bMatchCase = false; + for (; itr != itrEnd; ++itr) { - sal_uInt16 nIndex; - if (itr->GetSubIndex(rSubStr, nIndex)) - return &(*itr); + if (itr->GetSubIndex(rSubStr, nIndex, bMatchCase)) + { + if (bMatchCase) + return &(*itr); + matchData.push_back(itr); + } + } + if (matchData.empty()) + { + return NULL; } - return NULL; + + return &(**matchData.begin()); } const ScUserListData& ScUserList::operator[](size_t nIndex) const _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits