[Libreoffice-commits] core.git: sc/inc sc/source
Sahas
sahasr at naman.ms
Thu Nov 5 12:37:23 PST 2015
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 <sahasr at 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 <erack at redhat.com>
Tested-by: Eike Rathke <erack at 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
More information about the Libreoffice-commits
mailing list