sc/inc/queryentry.hxx | 6 ++++-- sc/source/core/tool/queryentry.cxx | 12 ++---------- sc/source/ui/dbgui/filtdlg.cxx | 2 +- 3 files changed, 7 insertions(+), 13 deletions(-)
New commits: commit 2d4bb629eea591b43c95e63483034b4fbda27fe1 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Thu Apr 8 10:12:16 2021 +0300 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Fri Apr 9 14:46:21 2021 +0200 tdf#141547: maQueryItems can be 0 E.g., fillQueryParam (sc/source/ui/unoobj/datauno.cxx) may clear it and leave empty if relevant input item is empty. Note how commit e4b924df8f9ad02c66549751cb8e123e420e8508 had changed the same checks in ScQueryEntry::IsQueryBy[Non]Empty. Change-Id: I552462c72e69ddce43711bcff645dc6c7b133db7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113783 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> (cherry picked from commit a0d2fb3217094aa7158310f0bcf16093bcc4984f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113757 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit 7ba4eeb2e9b8153eb17779c93492ab80a5cd4644) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113767 diff --git a/sc/inc/queryentry.hxx b/sc/inc/queryentry.hxx index 46a65b957658..f1282e21a5a0 100644 --- a/sc/inc/queryentry.hxx +++ b/sc/inc/queryentry.hxx @@ -68,13 +68,15 @@ struct SC_DLLPUBLIC ScQueryEntry bool IsQueryByEmpty() const; void SetQueryByNonEmpty(); bool IsQueryByNonEmpty() const; - const Item& GetQueryItem() const; - Item& GetQueryItem(); + const Item& GetQueryItem() const { return GetQueryItemImpl(); } + Item& GetQueryItem() { return GetQueryItemImpl(); } void Clear(); ScQueryEntry& operator=( const ScQueryEntry& r ); bool operator==( const ScQueryEntry& r ) const; private: + Item& GetQueryItemImpl() const; + /** * Stores all query items. It must contain at least one item at all times * (for single equality match queries or comparative queries). It may diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx index 6ebcf0003e9b..1c4326c47b29 100644 --- a/sc/source/core/tool/queryentry.cxx +++ b/sc/source/core/tool/queryentry.cxx @@ -115,17 +115,9 @@ bool ScQueryEntry::IsQueryByNonEmpty() const rItem.mfVal == SC_NONEMPTYFIELDS; } -const ScQueryEntry::Item& ScQueryEntry::GetQueryItem() const +ScQueryEntry::Item& ScQueryEntry::GetQueryItemImpl() const { - if (maQueryItems.size() > 1) - // Reset to a single query mode. - maQueryItems.resize(1); - return maQueryItems[0]; -} - -ScQueryEntry::Item& ScQueryEntry::GetQueryItem() -{ - if (maQueryItems.size() > 1) + if (maQueryItems.size() != 1) // Reset to a single query mode. maQueryItems.resize(1); return maQueryItems[0]; diff --git a/sc/source/ui/dbgui/filtdlg.cxx b/sc/source/ui/dbgui/filtdlg.cxx index addfedbe0f4c..6471149c0765 100644 --- a/sc/source/ui/dbgui/filtdlg.cxx +++ b/sc/source/ui/dbgui/filtdlg.cxx @@ -205,7 +205,6 @@ void ScFilterDlg::Init( const SfxItemSet& rArgSet ) ScQueryEntry& rEntry = theQueryData.GetEntry(i); if ( rEntry.bDoQuery ) { - const ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); nCondPos = static_cast<size_t>(rEntry.eOp); nFieldSelPos = GetFieldSelPos( static_cast<SCCOL>(rEntry.nField) ); if (rEntry.IsQueryByEmpty()) @@ -220,6 +219,7 @@ void ScFilterDlg::Init( const SfxItemSet& rArgSet ) } else { + const ScQueryEntry::Item& rItem = rEntry.GetQueryItem(); OUString aQueryStr = rItem.maString.getString(); if (aQueryStr.isEmpty()) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits