summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2021-04-08 10:12:16 +0300
committerXisco Fauli <xiscofauli@libreoffice.org>2021-04-09 14:46:21 +0200
commit2d4bb629eea591b43c95e63483034b4fbda27fe1 (patch)
tree7403a2569b7f43d525746ef3cf235246c5a1327f
parent0ab3a264ba8d732cffa42a069c9aa50dab44e99f (diff)
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.kaganski@collabora.com> (cherry picked from commit a0d2fb3217094aa7158310f0bcf16093bcc4984f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113757 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit 7ba4eeb2e9b8153eb17779c93492ab80a5cd4644) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113767
-rw-r--r--sc/inc/queryentry.hxx6
-rw-r--r--sc/source/core/tool/queryentry.cxx12
-rw-r--r--sc/source/ui/dbgui/filtdlg.cxx2
3 files changed, 7 insertions, 13 deletions
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())
{