summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamas Bunth <tamas.bunth@collabora.co.uk>2017-08-11 00:45:59 +0200
committerTamás Bunth <btomi96@gmail.com>2017-08-10 22:27:23 +0200
commitb946ab02b246e85c34f8fa77d99e19dacda07fe5 (patch)
treeb1a97f5f50c2a735437e31a7d02f4ee3a23969c8
parent7e728965b3f5a37a6f0bd75d616d2acb16c40f71 (diff)
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 <ci@libreoffice.org> Reviewed-by: Tamás Bunth <btomi96@gmail.com>
-rw-r--r--sc/inc/queryparam.hxx3
-rw-r--r--sc/source/core/tool/queryparam.cxx11
-rw-r--r--sc/source/ui/view/gridwin.cxx10
3 files changed, 16 insertions, 8 deletions
diff --git a/sc/inc/queryparam.hxx b/sc/inc/queryparam.hxx
index a96375a8002e..3b406bb49bc5 100644
--- a/sc/inc/queryparam.hxx
+++ b/sc/inc/queryparam.hxx
@@ -59,7 +59,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 72fa4919537e..c902d2796bd4 100644
--- a/sc/source/core/tool/queryparam.cxx
+++ b/sc/source/core/tool/queryparam.cxx
@@ -161,10 +161,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())
{
@@ -173,7 +174,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 1de9b9533815..e54bf486f7d8 100644
--- a/sc/source/ui/view/gridwin.cxx
+++ b/sc/source/ui/view/gridwin.cxx
@@ -778,12 +778,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);