sc/inc/queryparam.hxx | 3 ++- sc/source/core/tool/queryparam.cxx | 11 ++++++++++- sc/source/ui/view/gridwin.cxx | 10 ++++------ 3 files changed, 16 insertions(+), 8 deletions(-)
New commits: commit 01b1870736641f954d06d8e23589225b41a4e890 Author: Tamas Bunth <tamas.bu...@collabora.co.uk> Date: Fri Aug 11 00:45:59 2017 +0200 tdf#107797 UpdateAutoFilter handle more entries Prepare UpdateAutoFilterFromMenu to handle more entries. Filter items can be hold by more than one entries. In that case we have to remove all the old entries before updating. E.g. setting AutoFilter from vba script results in more than one entries. Change-Id: I4f18f26281d0b8e689cd331f9a66f4c344fb6c6b Reviewed-on: https://gerrit.libreoffice.org/40967 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Tamás Bunth <btom...@gmail.com> Reviewed-on: https://gerrit.libreoffice.org/41042 Reviewed-by: Aron Budea <aron.bu...@collabora.com> Tested-by: Aron Budea <aron.bu...@collabora.com> diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx index 16b4573c9fa6..ee31f473ae7a 100644 --- a/sc/inc/queryparam.hxx +++ b/sc/inc/queryparam.hxx @@ -58,7 +58,8 @@ struct ScQueryParamBase SC_DLLPUBLIC ScQueryEntry& AppendEntry(); ScQueryEntry* FindEntryByField(SCCOLROW nField, bool bNew); std::vector<ScQueryEntry*> FindAllEntriesByField(SCCOLROW nField); - SC_DLLPUBLIC void RemoveEntryByField(SCCOLROW nField); + SC_DLLPUBLIC bool RemoveEntryByField(SCCOLROW nField); + SC_DLLPUBLIC void RemoveAllEntriesByField(SCCOLROW nField); void Resize(size_t nNew); void FillInExcelSyntax( svl::SharedStringPool& rPool, const OUString& aCellStr, SCSIZE nIndex, SvNumberFormatter* pFormatter ); diff --git a/sc/source/core/tool/queryparam.cxx b/sc/source/core/tool/queryparam.cxx index f5630b66b565..197141c90c74 100644 --- a/sc/source/core/tool/queryparam.cxx +++ b/sc/source/core/tool/queryparam.cxx @@ -160,10 +160,11 @@ std::vector<ScQueryEntry*> ScQueryParamBase::FindAllEntriesByField(SCCOLROW nFie return aEntries; } -void ScQueryParamBase::RemoveEntryByField(SCCOLROW nField) +bool ScQueryParamBase::RemoveEntryByField(SCCOLROW nField) { EntriesType::iterator itr = std::find_if( m_Entries.begin(), m_Entries.end(), FindByField(nField)); + bool bRet = false; if (itr != m_Entries.end()) { @@ -172,7 +173,15 @@ void ScQueryParamBase::RemoveEntryByField(SCCOLROW nField) // Make sure that we have at least MAXQUERY number of entries at // all times. m_Entries.push_back(o3tl::make_unique<ScQueryEntry>()); + bRet = true; } + + return bRet; +} + +void ScQueryParamBase::RemoveAllEntriesByField(SCCOLROW nField) +{ + while( RemoveEntryByField( nField ) ) {} } void ScQueryParamBase::Resize(size_t nNew) diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index d2a1223e86ce..243e2ea62ea7 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -833,12 +833,10 @@ void ScGridWindow::UpdateAutoFilterFromMenu(AutoFilterMode eMode) ScQueryParam aParam; pDBData->GetQueryParam(aParam); - if (eMode == Normal && mpAutoFilterPopup->isAllSelected()) - { - // Remove this entry. - aParam.RemoveEntryByField(rPos.Col()); - } - else + // Remove old entries. + aParam.RemoveAllEntriesByField(rPos.Col()); + + if( !(eMode == Normal && mpAutoFilterPopup->isAllSelected() ) ) { // Try to use the existing entry for the column (if one exists). ScQueryEntry* pEntry = aParam.FindEntryByField(rPos.Col(), true);
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits