diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-27 19:16:58 +0200 |
---|---|---|
committer | Szymon Kłos <szymon.klos@collabora.com> | 2017-05-31 00:16:31 +0200 |
commit | 9956849c2ea6049582e2ccf04c355542c1ef00a1 (patch) | |
tree | 3565ce097412a939681ce87f753c8d9edb8c3a25 | |
parent | e55f887be63b00e0966cb34863bb5d52fcac6d1d (diff) |
tdf#107797 select all entries in the dropdown
Change-Id: I3ee33040744eab35f841d3622cb8981b49d04333
Reviewed-on: https://gerrit.libreoffice.org/38091
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
-rw-r--r-- | sc/inc/queryparam.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/tool/queryparam.cxx | 17 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 6 |
3 files changed, 21 insertions, 3 deletions
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx index 68ac18b6f84a..16b4573c9fa6 100644 --- a/sc/inc/queryparam.hxx +++ b/sc/inc/queryparam.hxx @@ -57,6 +57,7 @@ struct ScQueryParamBase SC_DLLPUBLIC ScQueryEntry& GetEntry(SCSIZE n); SC_DLLPUBLIC ScQueryEntry& AppendEntry(); ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew); + std::vector<ScQueryEntry*> FindAllEntriesByField(SCCOLROW nField); SC_DLLPUBLIC void RemoveEntryByField(SCCOLROW nField); void Resize(size_t nNew); void FillInExcelSyntax( svl::SharedStringPool& rPool, const OUString& aCellStr, SCSIZE nIndex, diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx index 43276e3e6a27..2406ca523e0d 100644 --- a/sc/source/core/tool/queryparam.cxx +++ b/sc/source/core/tool/queryparam.cxx @@ -144,6 +144,23 @@ ScQueryEntry* ScQueryParamBase::FindEntryByField(SCCOLROW nField, bool bNew) return &AppendEntry(); } +std::vector<ScQueryEntry*> ScQueryParamBase::FindAllEntriesByField(SCCOLROW nField) +{ + std::vector<ScQueryEntry*> aEntries; + + EntriesType::iterator itr = std::find_if( + m_Entries.begin(), m_Entries.end(), FindByField(nField)); + + while (itr != m_Entries.end()) + { + aEntries.push_back((*itr).get()); + itr = std::find_if( + itr + 1, m_Entries.end(), FindByField(nField)); + } + + return aEntries; +} + void ScQueryParamBase::RemoveEntryByField(SCCOLROW nField) { EntriesType::iterator itr = std::find_if( diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index fbb1a9e8379f..65d7b0132c46 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -646,11 +646,11 @@ void ScGridWindow::LaunchAutoFilterMenu(SCCOL nCol, SCROW nRow) ScQueryParam aParam; pDBData->GetQueryParam(aParam); - ScQueryEntry* pEntry = aParam.FindEntryByField(nCol, false); + std::vector<ScQueryEntry*> aEntries = aParam.FindAllEntriesByField(nCol); std::unordered_set<OUString, OUStringHash> aSelected; - if (pEntry && pEntry->bDoQuery) + for (ScQueryEntry* pEntry : aEntries) { - if (pEntry->eOp == SC_EQUAL) + if (pEntry && pEntry->bDoQuery && pEntry->eOp == SC_EQUAL) { ScQueryEntry::QueryItemsType& rItems = pEntry->GetQueryItems(); std::for_each(rItems.begin(), rItems.end(), AddSelectedItemString(aSelected)); |