diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-10-10 21:39:41 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2017-10-11 07:03:42 +0200 |
commit | 33f126b4262d1af9c3f0c2e850f5a13b3c6acfc2 (patch) | |
tree | f8e31f4f88062416a14e0e63a5ca8f16834d6f9e /sc/source/ui | |
parent | ff578127e279c1f9949923c601636aa274d52892 (diff) |
Replace list by vector "DataPilotSort" from dbfunc3 (sc)
Change-Id: Ib8754d7e459d1019ed2d5f49ce593e20af0b7f0c
Reviewed-on: https://gerrit.libreoffice.org/43315
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'sc/source/ui')
-rw-r--r-- | sc/source/ui/view/dbfunc3.cxx | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 186007cae57a..0b65d959edc4 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -84,7 +84,6 @@ using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::beans::XPropertySet; using ::com::sun::star::container::XNameAccess; using ::com::sun::star::sheet::XDimensionsSupplier; -using ::std::list; using ::std::vector; // outliner @@ -1649,7 +1648,7 @@ void ScDBFunc::DataPilotSort(ScDPObject* pDPObj, long nDimIndex, bool bAscending { typedef ScDPSaveDimension::MemberList MemList; const MemList& rDimMembers = pSaveDim->GetMembers(); - list<OUString> aMembers; + vector<OUString> aMembers; std::unordered_set<OUString, OUStringHash> aMemberSet; size_t nMemberCount = 0; for (MemList::const_iterator itr = rDimMembers.begin(), itrEnd = rDimMembers.end(); @@ -1663,7 +1662,7 @@ void ScDBFunc::DataPilotSort(ScDPObject* pDPObj, long nDimIndex, bool bAscending // Sort the member list in ascending order. ScOUStringCollate aCollate( ScGlobal::GetCollator() ); - aMembers.sort(aCollate); + std::stable_sort(aMembers.begin(), aMembers.end(), aCollate); // Collect and rank those custom sort strings that also exist in the member name list. @@ -1699,12 +1698,10 @@ void ScDBFunc::DataPilotSort(ScDPObject* pDPObj, long nDimIndex, bool bAscending vector<OUString> aRankedNames(nMemberCount); sal_uInt16 nCurStrId = 0; - for (list<OUString>::const_iterator itr = aMembers.begin(), itrEnd = aMembers.end(); - itr != itrEnd; ++itr) + for (auto const& aMemberName : aMembers) { - OUString aName = *itr; sal_uInt16 nRank = 0; - UserSortMap::const_iterator itrSub = aSubStrs.find(aName); + UserSortMap::const_iterator itrSub = aSubStrs.find(aMemberName); if (itrSub == aSubStrs.end()) nRank = nSubCount + nCurStrId++; else @@ -1713,15 +1710,13 @@ void ScDBFunc::DataPilotSort(ScDPObject* pDPObj, long nDimIndex, bool bAscending if (!bAscending) nRank = static_cast< sal_uInt16 >( nMemberCount - nRank - 1 ); - aRankedNames[nRank] = aName; + aRankedNames[nRank] = aMemberName; } // Re-order ScDPSaveMember instances with the new ranks. - - for (vector<OUString>::const_iterator itr = aRankedNames.begin(), itrEnd = aRankedNames.end(); - itr != itrEnd; ++itr) + for (auto const& aRankedName : aRankedNames) { - const ScDPSaveMember* pOldMem = pSaveDim->GetExistingMemberByName(*itr); + const ScDPSaveMember* pOldMem = pSaveDim->GetExistingMemberByName(aRankedName); if (!pOldMem) // All members are supposed to be present. continue; |