From 24497be46946032324aade1eeaed6cf0b87a610a Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 29 Nov 2011 16:02:35 -0500 Subject: [PATCH] Removed duplicate code block. --- sc/source/ui/unoobj/datauno.cxx | 105 ++++++++++++-------------------- 1 file changed, 39 insertions(+), 66 deletions(-) diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx index 8d601b45f15d..960ac081d6db 100644 --- a/sc/source/ui/unoobj/datauno.cxx +++ b/sc/source/ui/unoobj/datauno.cxx @@ -1181,6 +1181,43 @@ void convertQueryEntryToUno(const ScQueryEntry& rEntry, T& rField) } } +template +void convertUnoToQueryEntry(const T& rField, ScQueryEntry& rEntry) +{ + rEntry.bDoQuery = true; + rEntry.eConnect = (rField.Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR; + rEntry.nField = rField.Field; + + switch (rField.Operator) // FilterOperator + { + case sheet::FilterOperator2::EQUAL: rEntry.eOp = SC_EQUAL; break; + case sheet::FilterOperator2::LESS: rEntry.eOp = SC_LESS; break; + case sheet::FilterOperator2::GREATER: rEntry.eOp = SC_GREATER; break; + case sheet::FilterOperator2::LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break; + case sheet::FilterOperator2::GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break; + case sheet::FilterOperator2::NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break; + case sheet::FilterOperator2::TOP_VALUES: rEntry.eOp = SC_TOPVAL; break; + case sheet::FilterOperator2::BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break; + case sheet::FilterOperator2::TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break; + case sheet::FilterOperator2::BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break; + case sheet::FilterOperator2::CONTAINS: rEntry.eOp = SC_CONTAINS; break; + case sheet::FilterOperator2::DOES_NOT_CONTAIN: rEntry.eOp = SC_DOES_NOT_CONTAIN; break; + case sheet::FilterOperator2::BEGINS_WITH: rEntry.eOp = SC_BEGINS_WITH; break; + case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH: rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break; + case sheet::FilterOperator2::ENDS_WITH: rEntry.eOp = SC_ENDS_WITH; break; + case sheet::FilterOperator2::DOES_NOT_END_WITH: rEntry.eOp = SC_DOES_NOT_END_WITH; break; + case sheet::FilterOperator2::EMPTY: + rEntry.SetQueryByEmpty(); + break; + case sheet::FilterOperator2::NOT_EMPTY: + rEntry.SetQueryByNonEmpty(); + break; + default: + OSL_FAIL("Unknown filter operator type."); + rEntry.eOp = SC_EQUAL; + } +} + void fillQueryParam( ScQueryParam& rParam, ScDocument* pDoc, const uno::Sequence& aFilterFields) @@ -1192,39 +1229,7 @@ void fillQueryParam( for (size_t i = 0; i < nCount; ++i) { ScQueryEntry& rEntry = rParam.GetEntry(i); - - rEntry.bDoQuery = true; - rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR; - rEntry.nField = pAry[i].Field; - - switch (pAry[i].Operator) // FilterOperator - { - case sheet::FilterOperator2::EQUAL: rEntry.eOp = SC_EQUAL; break; - case sheet::FilterOperator2::LESS: rEntry.eOp = SC_LESS; break; - case sheet::FilterOperator2::GREATER: rEntry.eOp = SC_GREATER; break; - case sheet::FilterOperator2::LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break; - case sheet::FilterOperator2::GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break; - case sheet::FilterOperator2::NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break; - case sheet::FilterOperator2::TOP_VALUES: rEntry.eOp = SC_TOPVAL; break; - case sheet::FilterOperator2::BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break; - case sheet::FilterOperator2::TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break; - case sheet::FilterOperator2::BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break; - case sheet::FilterOperator2::CONTAINS: rEntry.eOp = SC_CONTAINS; break; - case sheet::FilterOperator2::DOES_NOT_CONTAIN: rEntry.eOp = SC_DOES_NOT_CONTAIN; break; - case sheet::FilterOperator2::BEGINS_WITH: rEntry.eOp = SC_BEGINS_WITH; break; - case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH: rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break; - case sheet::FilterOperator2::ENDS_WITH: rEntry.eOp = SC_ENDS_WITH; break; - case sheet::FilterOperator2::DOES_NOT_END_WITH: rEntry.eOp = SC_DOES_NOT_END_WITH; break; - case sheet::FilterOperator2::EMPTY: - rEntry.SetQueryByEmpty(); - break; - case sheet::FilterOperator2::NOT_EMPTY: - rEntry.SetQueryByNonEmpty(); - break; - default: - OSL_FAIL("Falscher Query-enum"); - rEntry.eOp = SC_EQUAL; - } + convertUnoToQueryEntry(pAry[i], rEntry); if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY) { @@ -1254,39 +1259,7 @@ void fillQueryParam( for (size_t i = 0; i < nCount; ++i) { ScQueryEntry& rEntry = rParam.GetEntry(i); - - rEntry.bDoQuery = true; - rEntry.eConnect = (pAry[i].Connection == sheet::FilterConnection_AND) ? SC_AND : SC_OR; - rEntry.nField = pAry[i].Field; - - switch (pAry[i].Operator) // FilterOperator - { - case sheet::FilterOperator2::EQUAL: rEntry.eOp = SC_EQUAL; break; - case sheet::FilterOperator2::LESS: rEntry.eOp = SC_LESS; break; - case sheet::FilterOperator2::GREATER: rEntry.eOp = SC_GREATER; break; - case sheet::FilterOperator2::LESS_EQUAL: rEntry.eOp = SC_LESS_EQUAL; break; - case sheet::FilterOperator2::GREATER_EQUAL: rEntry.eOp = SC_GREATER_EQUAL; break; - case sheet::FilterOperator2::NOT_EQUAL: rEntry.eOp = SC_NOT_EQUAL; break; - case sheet::FilterOperator2::TOP_VALUES: rEntry.eOp = SC_TOPVAL; break; - case sheet::FilterOperator2::BOTTOM_VALUES: rEntry.eOp = SC_BOTVAL; break; - case sheet::FilterOperator2::TOP_PERCENT: rEntry.eOp = SC_TOPPERC; break; - case sheet::FilterOperator2::BOTTOM_PERCENT: rEntry.eOp = SC_BOTPERC; break; - case sheet::FilterOperator2::CONTAINS: rEntry.eOp = SC_CONTAINS; break; - case sheet::FilterOperator2::DOES_NOT_CONTAIN: rEntry.eOp = SC_DOES_NOT_CONTAIN; break; - case sheet::FilterOperator2::BEGINS_WITH: rEntry.eOp = SC_BEGINS_WITH; break; - case sheet::FilterOperator2::DOES_NOT_BEGIN_WITH: rEntry.eOp = SC_DOES_NOT_BEGIN_WITH;break; - case sheet::FilterOperator2::ENDS_WITH: rEntry.eOp = SC_ENDS_WITH; break; - case sheet::FilterOperator2::DOES_NOT_END_WITH: rEntry.eOp = SC_DOES_NOT_END_WITH; break; - case sheet::FilterOperator2::EMPTY: - rEntry.SetQueryByEmpty(); - break; - case sheet::FilterOperator2::NOT_EMPTY: - rEntry.SetQueryByNonEmpty(); - break; - default: - OSL_FAIL("Unknown filter operator type."); - rEntry.eOp = SC_EQUAL; - } + convertUnoToQueryEntry(pAry[i], rEntry); if (pAry[i].Operator != sheet::FilterOperator2::EMPTY && pAry[i].Operator != sheet::FilterOperator2::NOT_EMPTY) {