diff options
author | Lionel Elie Mamane <lionel@mamane.lu> | 2017-07-30 17:57:14 +0200 |
---|---|---|
committer | Lionel Elie Mamane <lionel@mamane.lu> | 2017-07-30 20:23:09 +0200 |
commit | 2b1d6f0d3b0b025148c81986ba7f109659d838af (patch) | |
tree | 475feb3567e60c37b5bc6f669711c1b9a65c33ad /dbaccess/source/ui | |
parent | aba73077851a744c06e72b3bddf5a0bae85d7c28 (diff) |
tdf#96370 rework filtering to be aware of WHERE vs HAVING clause
Several bugs (AFAIK not filed into tdf bugzilla) fixed.
Remaining problems:
When some filter clauses go into WHERE and others in HAVING,
they are always logically ANDed (it cannot be any other way),
but that is not communicated to the user in the UI.
Some things left undone:
* DatabaseDataProvider (and its users?) needs to be updated
to be HAVING-aware, too.
* Form-based filter (.uno:FormFilter) not HAVING-aware
it reads the current filter in function
svxform::FormController::setFilter
in
svx/source/form/formcontrollers.cxx
That's one place that needs to be updated.
The other place is the one that applies the filter.
Change-Id: I0e9d30a1927b6739a16ae7627e8d0dae8823b376
Diffstat (limited to 'dbaccess/source/ui')
-rw-r--r-- | dbaccess/source/ui/browser/brwctrlr.cxx | 16 | ||||
-rw-r--r-- | dbaccess/source/ui/dlg/queryfilter.cxx | 14 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/queryfilter.hxx | 4 |
3 files changed, 13 insertions, 21 deletions
diff --git a/dbaccess/source/ui/browser/brwctrlr.cxx b/dbaccess/source/ui/browser/brwctrlr.cxx index af094e97620d..4cc6913b0866 100644 --- a/dbaccess/source/ui/browser/brwctrlr.cxx +++ b/dbaccess/source/ui/browser/brwctrlr.cxx @@ -2006,18 +2006,7 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property break; // check if the column is a aggregate function - bool bHaving = false; - OUString sName; - xField->getPropertyValue(PROPERTY_NAME) >>= sName; - Reference< XColumnsSupplier > xColumnsSupplier(m_xParser, UNO_QUERY); - Reference< css::container::XNameAccess > xCols = xColumnsSupplier.is() ? xColumnsSupplier->getColumns() : Reference< css::container::XNameAccess > (); - if ( xCols.is() && xCols->hasByName(sName) ) - { - Reference<XPropertySet> xProp(xCols->getByName(sName),UNO_QUERY); - static const char sAgg[] = "AggregateFunction"; - if ( xProp->getPropertySetInfo()->hasPropertyByName(sAgg) ) - xProp->getPropertyValue(sAgg) >>= bHaving; - } + const bool bHaving(isAggregateColumn(m_xParser, xField)); Reference< XSingleSelectQueryComposer > xParser = createParser_nothrow(); const OUString sOldFilter = xParser->getFilter(); @@ -2029,7 +2018,8 @@ void SbaXDataBrowserController::Execute(sal_uInt16 nId, const Sequence< Property // -> completely overwrite it, else append one if (!bApplied) { - DO_SAFE( (bHaving ? xParser->setHavingClause(OUString()) : xParser->setFilter(::OUString())), "SbaXDataBrowserController::Execute : caught an exception while resetting the new filter !" ); + DO_SAFE( xParser->setFilter( OUString()), "SbaXDataBrowserController::Execute : caught an exception while resetting unapplied filter !" ); + DO_SAFE( xParser->setHavingClause(OUString()), "SbaXDataBrowserController::Execute : caught an exception while resetting unapplied HAVING clause !" ); } bool bParserSuccess = false; diff --git a/dbaccess/source/ui/dlg/queryfilter.cxx b/dbaccess/source/ui/dlg/queryfilter.cxx index c9678ac2bfda..f7d04f0f0a4b 100644 --- a/dbaccess/source/ui/dlg/queryfilter.cxx +++ b/dbaccess/source/ui/dlg/queryfilter.cxx @@ -169,9 +169,10 @@ DlgFilterCrit::DlgFilterCrit(vcl::Window * pParent, // insert the criteria into the dialog Sequence<Sequence<PropertyValue > > aValues = m_xQueryComposer->getStructuredFilter(); - fillLines(aValues); + int i(0); + fillLines(i, aValues); aValues = m_xQueryComposer->getStructuredHavingClause(); - fillLines(aValues); + fillLines(i, aValues); EnableLines(); @@ -467,7 +468,7 @@ IMPL_LINK( DlgFilterCrit, PredicateLoseFocus, Control&, rControl, void ) } } -void DlgFilterCrit::SetLine( sal_uInt16 nIdx,const PropertyValue& _rItem,bool _bOr ) +void DlgFilterCrit::SetLine( int nIdx, const PropertyValue& _rItem, bool _bOr ) { OUString aStr; _rItem.Value >>= aStr; @@ -785,13 +786,13 @@ void DlgFilterCrit::BuildWherePart() } } -void DlgFilterCrit::fillLines(const Sequence<Sequence<PropertyValue > >& _aValues) +void DlgFilterCrit::fillLines(int &i, const Sequence< Sequence< PropertyValue > >& _aValues) { const Sequence<PropertyValue >* pOrIter = _aValues.getConstArray(); const Sequence<PropertyValue >* pOrEnd = pOrIter + _aValues.getLength(); - for(sal_uInt16 i=0;pOrIter != pOrEnd; ++pOrIter) + bool bOr(i != 0); // WHERE clause and HAVING clause are always ANDed, nor ORed + for(; pOrIter != pOrEnd; ++pOrIter) { - bool bOr = true; const PropertyValue* pAndIter = pOrIter->getConstArray(); const PropertyValue* pAndEnd = pAndIter + pOrIter->getLength(); for(;pAndIter != pAndEnd; ++pAndIter) @@ -799,6 +800,7 @@ void DlgFilterCrit::fillLines(const Sequence<Sequence<PropertyValue > >& _aValue SetLine( i++,*pAndIter,bOr); bOr = false; } + bOr=true; } } diff --git a/dbaccess/source/ui/inc/queryfilter.hxx b/dbaccess/source/ui/inc/queryfilter.hxx index f7253f1fa76a..5dd72f1e40ef 100644 --- a/dbaccess/source/ui/inc/queryfilter.hxx +++ b/dbaccess/source/ui/inc/queryfilter.hxx @@ -94,12 +94,12 @@ namespace dbaui DECL_LINK( ListSelectHdl, ListBox&, void ); DECL_LINK( ListSelectCompHdl, ListBox&, void ); - void SetLine( sal_uInt16 nIdx,const css::beans::PropertyValue& _rItem,bool _bOr ); + void SetLine( int nIdx, const css::beans::PropertyValue& _rItem, bool _bOr ); void EnableLines(); sal_Int32 GetOSQLPredicateType( const OUString& _rSelectedPredicate ) const; static sal_Int32 GetSelectionPos(sal_Int32 eType,const ListBox& rListBox); bool getCondition(const ListBox& _rField,const ListBox& _rComp,const Edit& _rValue,css::beans::PropertyValue& _rFilter) const; - void fillLines(const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& _aValues); + void fillLines(int &i, const css::uno::Sequence< css::uno::Sequence< css::beans::PropertyValue > >& _aValues); css::uno::Reference< css::beans::XPropertySet > getMatchingColumn( const Edit& _rValueInput ) const; css::uno::Reference< css::beans::XPropertySet > getColumn( const OUString& _rFieldName ) const; |