diff options
author | Fabio Buso <dev.siroibaf@gmail.com> | 2016-08-09 10:25:37 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2016-08-10 14:32:32 +0000 |
commit | 2c76fd1e04441889fbc416d4e5815ef31b474193 (patch) | |
tree | cd7aea0a33a0df8a3bef79ec801db5bed2fd62bf /dbaccess | |
parent | d6e8d4f773d970b69baedd8523a426f18a8d8eef (diff) |
tdf#67647 getStructuredFilter returns operator
Change-Id: I010ea3c24b4d5411711a93e35d4b173f5bde9e55
Reviewed-on: https://gerrit.libreoffice.org/28000
Reviewed-by: Lionel Elie Mamane <lionel@mamane.lu>
Tested-by: Lionel Elie Mamane <lionel@mamane.lu>
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/api/SingleSelectQueryComposer.cxx | 25 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/unodatbr.cxx | 6 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/queryfilter.cxx | 41 |
3 files changed, 9 insertions, 63 deletions
diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx index 1b8f13404017..4bd1fe4fc84c 100644 --- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx +++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx @@ -1115,7 +1115,7 @@ sal_Int32 OSingleSelectQueryComposer::getPredicateType(OSQLParseNode * _pPredica bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pCondition, OSQLParseTreeIterator& _rIterator, ::std::vector < PropertyValue >& rFilter, const Reference< css::util::XNumberFormatter > & xFormatter) const { - OSL_ENSURE(SQL_ISRULE(pCondition, comparison_predicate),"setComparsionPredicate: pCondition ist kein ComparsionPredicate"); + OSL_ENSURE(SQL_ISRULE(pCondition, comparison_predicate),"setComparsionPredicate: pCondition is not a ComparsionPredicate"); if (SQL_ISRULE(pCondition->getChild(0), column_ref) || SQL_ISRULE(pCondition->getChild(pCondition->count()-1), column_ref)) { @@ -1128,12 +1128,9 @@ bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pConditi sal_uInt32 i=1; aItem.Handle = getPredicateType(pCondition->getChild(i)); - // don't display the equal - if (pCondition->getChild(i)->getNodeType() == SQLNodeType::Equal) - i++; - // go forward - for (;i < pCondition->count();i++) + // go forward - don't display the operator + for (i++;i < pCondition->count();i++) pCondition->getChild(i)->parseNodeToPredicateStr( aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>(m_sDecimalSep.toChar() ) ); } @@ -1145,44 +1142,33 @@ bool OSingleSelectQueryComposer::setComparsionPredicate(OSQLParseNode * pConditi switch (pCondition->getChild(i)->getNodeType()) { case SQLNodeType::Equal: - // don't display the equal - i--; aItem.Handle = SQLFilterOperator::EQUAL; break; case SQLNodeType::NotEqual: - i--; aItem.Handle = SQLFilterOperator::NOT_EQUAL; break; case SQLNodeType::Less: // take the opposite as we change the order - i--; - aValue = ">="; aItem.Handle = SQLFilterOperator::GREATER_EQUAL; break; case SQLNodeType::LessEq: // take the opposite as we change the order - i--; - aValue = ">"; aItem.Handle = SQLFilterOperator::GREATER; break; case SQLNodeType::Great: // take the opposite as we change the order - i--; - aValue = "<="; aItem.Handle = SQLFilterOperator::LESS_EQUAL; break; case SQLNodeType::GreatEq: // take the opposite as we change the order - i--; - aValue = "<"; aItem.Handle = SQLFilterOperator::LESS; break; default: break; } - // go backward - for (; i >= 0; i--) + // go backward - don't display the operator + for (i--; i >= 0; i--) pCondition->getChild(i)->parseNodeToPredicateStr( aValue, m_xConnection, xFormatter, m_aLocale, static_cast<sal_Char>( m_sDecimalSep.toChar() ) ); } @@ -1729,6 +1715,7 @@ Sequence< Sequence< PropertyValue > > OSingleSelectQueryComposer::getStructuredC Sequence< Sequence< PropertyValue > > aFilterSeq; OUString sFilter = getStatementPart( _aGetFunctor, m_aAdditiveIterator ); + if ( !sFilter.isEmpty() ) { OUString aSql(m_aPureSelectSQL + STR_WHERE + sFilter); diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index bae2bbfe1a23..c38e5b4b93ca 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -480,11 +480,7 @@ void SbaTableQueryBrowser::impl_sanitizeRowSetClauses_nothrow() // "SELECT * FROM <table> WHERE <other_table>.<column> = <value>", it will return "<column>". But // there's no API at all to retrieve the information about "<other_table>" - which is what would // be needed here. - // That'd be a chance to replace getStructuredFilter with something more reasonable. This method - // has at least one other problem: for a clause like "<column> != <value>", it will return "<column>" - // as column name, "NOT_EQUAL" as operator, and "!= <value>" as value, effectively duplicating the - // information about the operator, and begging all clients to manually remove the "!=" from the value - // string. + // That'd be a chance to replace getStructuredFilter with something more reasonable. // So, what really would be handy, is some // XNormalizedFilter getNormalizedFilter(); // with diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx index 27bec94f4563..5193bf587ede 100644 --- a/dbaccess/source/ui/dlg/queryfilter.cxx +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -469,9 +469,8 @@ IMPL_LINK_TYPED( DlgFilterCrit, PredicateLoseFocus, Control&, rControl, void ) void DlgFilterCrit::SetLine( sal_uInt16 nIdx,const PropertyValue& _rItem,bool _bOr ) { - OUString aCondition; - _rItem.Value >>= aCondition; - OUString aStr = aCondition; + OUString aStr; + _rItem.Value >>= aStr; if ( _rItem.Handle == SQLFilterOperator::LIKE || _rItem.Handle == SQLFilterOperator::NOT_LIKE ) ::Replace_SQL_PlaceHolder(aStr); @@ -479,42 +478,6 @@ void DlgFilterCrit::SetLine( sal_uInt16 nIdx,const PropertyValue& _rItem,bool _b Reference< XPropertySet > xColumn = getColumn( _rItem.Name ); - // remove the predicate from the condition - switch(_rItem.Handle) - { - case SQLFilterOperator::EQUAL: - // aStr.Erase(0,1); - break; - case SQLFilterOperator::NOT_EQUAL: - aStr = aStr.copy(2); - break; - case SQLFilterOperator::LESS: - aStr = aStr.copy(1); - break; - case SQLFilterOperator::LESS_EQUAL: - aStr = aStr.copy(2); - break; - case SQLFilterOperator::GREATER: - aStr = aStr.copy(1); - break; - case SQLFilterOperator::GREATER_EQUAL: - aStr = aStr.copy(2); - break; - case SQLFilterOperator::NOT_LIKE: - aStr = aStr.copy(8); - break; - case SQLFilterOperator::LIKE: - aStr = aStr.copy(4); - break; - case SQLFilterOperator::SQLNULL: - aStr = aStr.copy(7); - break; - case SQLFilterOperator::NOT_SQLNULL: - aStr = aStr.copy(11); - break; - } - aStr = comphelper::string::stripStart(aStr, ' '); - // to make sure that we only set first three ListBox* pColumnListControl = nullptr; ListBox* pPredicateListControl = nullptr; |