summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSahas <sahasr@naman.ms>2015-10-18 21:46:25 +0530
committerEike Rathke <erack@redhat.com>2015-11-05 20:36:56 +0000
commitef6ddb36751f917cd4ddab4a7fc609d5cf212b1b (patch)
tree0dd88f5745d3b9028ae4c2b61013c7b3c766cb95
parent8299b8b81cc547ab698106499916a8dcb8fe57aa (diff)
tdf#79983 - Fix to make calc sort lists case sensitive
Change-Id: I9d4aec8ccb395f8bf59f08d0f5ed461e99c9ea64 Reviewed-on: https://gerrit.libreoffice.org/19433 Reviewed-by: Eike Rathke <erack@redhat.com> Tested-by: Eike Rathke <erack@redhat.com>
-rw-r--r--sc/inc/userlist.hxx2
-rw-r--r--sc/source/core/data/table4.cxx5
-rw-r--r--sc/source/core/tool/userlist.cxx35
3 files changed, 30 insertions, 12 deletions
diff --git a/sc/inc/userlist.hxx b/sc/inc/userlist.hxx
index f174b362fcb1..8983026283b8 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 b8f3a956d29c..1be25d44e2f3 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 3f3cac76e292..d29e38899451 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