[Libreoffice-commits] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Nov 29 22:32:58 PST 2011
sc/source/core/data/dociter.cxx | 4 +++-
sc/source/core/tool/queryentry.cxx | 16 ++++++++--------
sc/source/ui/unoobj/cellsuno.cxx | 4 +++-
sc/source/ui/unoobj/datauno.cxx | 17 ++++++++++++-----
4 files changed, 26 insertions(+), 15 deletions(-)
New commits:
commit e4b924df8f9ad02c66549751cb8e123e420e8508
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Wed Nov 30 01:20:45 2011 -0500
Reduce usage of GetQueryItem() (singular version).
I added that as a convenience method while working on implementing
multi-value filtering. But we need to stick with the plural version
GetQueryItems() from now on for clarity.
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index be05630..0b466c0 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -533,7 +533,9 @@ ScDBQueryDataIterator::DataAccessInternal::DataAccessInternal(const ScDBQueryDat
for (i=0; (i<nCount) && (mpParam->GetEntry(i).bDoQuery); i++)
{
ScQueryEntry& rEntry = mpParam->GetEntry(i);
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
+ rItems.resize(1);
+ ScQueryEntry::Item& rItem = rItems.front();
sal_uInt32 nIndex = 0;
bool bNumber = mpDoc->GetFormatTable()->IsNumberFormat(
rItem.maString, nIndex, rItem.mfVal);
diff --git a/sc/source/core/tool/queryentry.cxx b/sc/source/core/tool/queryentry.cxx
index be107e7..1f9be97 100644
--- a/sc/source/core/tool/queryentry.cxx
+++ b/sc/source/core/tool/queryentry.cxx
@@ -101,7 +101,8 @@ const ScQueryEntry::QueryItemsType& ScQueryEntry::GetQueryItems() const
void ScQueryEntry::SetQueryByEmpty()
{
eOp = SC_EQUAL;
- Item& rItem = GetQueryItem();
+ maQueryItems.resize(1);
+ Item& rItem = maQueryItems[0];
rItem.meType = ByEmpty;
rItem.maString = rtl::OUString();
rItem.mfVal = SC_EMPTYFIELDS;
@@ -109,11 +110,10 @@ void ScQueryEntry::SetQueryByEmpty()
bool ScQueryEntry::IsQueryByEmpty() const
{
- if (maQueryItems.size() > 1)
- // multi-item query.
+ if (maQueryItems.size() != 1)
return false;
- const Item& rItem = GetQueryItem();
+ const Item& rItem = maQueryItems[0];
return eOp == SC_EQUAL &&
rItem.meType == ByEmpty &&
rItem.maString.isEmpty() &&
@@ -123,7 +123,8 @@ bool ScQueryEntry::IsQueryByEmpty() const
void ScQueryEntry::SetQueryByNonEmpty()
{
eOp = SC_EQUAL;
- Item& rItem = GetQueryItem();
+ maQueryItems.resize(1);
+ Item& rItem = maQueryItems[0];
rItem.meType = ByEmpty;
rItem.maString = rtl::OUString();
rItem.mfVal = SC_NONEMPTYFIELDS;
@@ -131,11 +132,10 @@ void ScQueryEntry::SetQueryByNonEmpty()
bool ScQueryEntry::IsQueryByNonEmpty() const
{
- if (maQueryItems.size() > 1)
- // multi-item query.
+ if (maQueryItems.size() != 1)
return false;
- const Item& rItem = GetQueryItem();
+ const Item& rItem = maQueryItems[0];
return eOp == SC_EQUAL &&
rItem.meType == ByEmpty &&
rItem.maString.isEmpty() &&
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index e26ae90..6be0239 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -5683,7 +5683,9 @@ void SAL_CALL ScCellRangeObj::filter( const uno::Reference<sheet::XSheetFilterDe
{
rEntry.nField += nFieldStart;
// Im Dialog wird immer der String angezeigt -> muss zum Wert passen
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
+ rItems.resize(1);
+ ScQueryEntry::Item& rItem = rItems.front();
if (rItem.meType != ScQueryEntry::ByString)
{
pDocSh->GetDocument()->GetFormatTable()->
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 960ac08..3695f14 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -1105,7 +1105,10 @@ uno::Sequence<sheet::TableFilterField> SAL_CALL ScFilterDescriptorBase::getFilte
for (SCSIZE i=0; i<nCount; i++)
{
const ScQueryEntry& rEntry = aParam.GetEntry(i);
- const ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ if (rEntry.GetQueryItems().empty())
+ continue;
+
+ const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
aField.Connection = (rEntry.eConnect == SC_AND) ? sheet::FilterConnection_AND :
sheet::FilterConnection_OR;
@@ -1233,7 +1236,9 @@ void fillQueryParam(
if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY)
{
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
+ rItems.resize(1);
+ ScQueryEntry::Item& rItem = rItems.front();
rItem.meType = pAry[i].IsNumeric ? ScQueryEntry::ByValue : ScQueryEntry::ByString;
rItem.mfVal = pAry[i].NumericValue;
rItem.maString = pAry[i].StringValue;
@@ -1326,9 +1331,9 @@ throw(uno::RuntimeException)
}
}
- if (!bByEmpty)
+ if (!bByEmpty && !rEntry.GetQueryItems().empty())
{
- const ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ const ScQueryEntry::Item& rItem = rEntry.GetQueryItems().front();
aField.IsNumeric = !rItem.meType != ScQueryEntry::ByString;
aField.StringValue = rItem.maString;
aField.NumericValue = rItem.mfVal;
@@ -1415,7 +1420,9 @@ void SAL_CALL ScFilterDescriptorBase::setFilterFields(
for (i=0; i<nCount; i++)
{
ScQueryEntry& rEntry = aParam.GetEntry(i);
- ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
+ ScQueryEntry::QueryItemsType& rItems = rEntry.GetQueryItems();
+ rItems.resize(1);
+ ScQueryEntry::Item& rItem = rItems.front();
rEntry.bDoQuery = true;
rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR;
rEntry.nField = pAry[i].Field;
More information about the Libreoffice-commits
mailing list