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 /forms/source/component/DatabaseForm.cxx | |
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 'forms/source/component/DatabaseForm.cxx')
-rw-r--r-- | forms/source/component/DatabaseForm.cxx | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 925d8a8fa3f2..1aae5d88aa39 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -1288,7 +1288,7 @@ void ODatabaseForm::describeFixedAndAggregateProperties( Sequence< Property >& _rProps, Sequence< Property >& _rAggregateProps ) const { - _rProps.realloc( 22 ); + _rProps.realloc( 23 ); css::beans::Property* pProperties = _rProps.getArray(); if (m_xAggregateSet.is()) @@ -1312,6 +1312,7 @@ void ODatabaseForm::describeFixedAndAggregateProperties( // (e.g. the ones which result from linking master fields to detail fields // via column names instead of parameters) RemoveProperty( _rAggregateProps, PROPERTY_FILTER ); + RemoveProperty( _rAggregateProps, PROPERTY_HAVINGCLAUSE ); RemoveProperty( _rAggregateProps, PROPERTY_APPLYFILTER ); DECL_IFACE_PROP4( ACTIVE_CONNECTION,XConnection, BOUND, TRANSIENT, MAYBEVOID, CONSTRAINED); @@ -1322,6 +1323,7 @@ void ODatabaseForm::describeFixedAndAggregateProperties( DECL_PROP2 ( DATASOURCE, OUString, BOUND, CONSTRAINED ); DECL_PROP3 ( CYCLE, TabulatorCycle, BOUND, MAYBEVOID, MAYBEDEFAULT ); DECL_PROP2 ( FILTER, OUString, BOUND, MAYBEDEFAULT ); + DECL_PROP2 ( HAVINGCLAUSE, OUString, BOUND, MAYBEDEFAULT ); DECL_BOOL_PROP2 ( INSERTONLY, BOUND, MAYBEDEFAULT ); DECL_PROP1 ( NAVIGATION, NavigationBarMode, BOUND ); DECL_BOOL_PROP1 ( ALLOWADDITIONS, BOUND ); @@ -1464,6 +1466,10 @@ void ODatabaseForm::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const rValue <<= m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicFilter ); break; + case PROPERTY_ID_HAVINGCLAUSE: + rValue <<= m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicHaving ); + break; + case PROPERTY_ID_APPLYFILTER: rValue <<= m_aFilterManager.isApplyPublicFilter(); break; @@ -1546,6 +1552,10 @@ sal_Bool ODatabaseForm::convertFastPropertyValue( Any& rConvertedValue, Any& rOl bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicFilter ) ); break; + case PROPERTY_ID_HAVINGCLAUSE: + bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicHaving ) ); + break; + case PROPERTY_ID_APPLYFILTER: bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aFilterManager.isApplyPublicFilter() ); break; @@ -1635,6 +1645,14 @@ void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const A } break; + case PROPERTY_ID_HAVINGCLAUSE: + { + OUString sNewFilter; + rValue >>= sNewFilter; + m_aFilterManager.setFilterComponent( FilterManager::FilterComponent::PublicHaving, sNewFilter ); + } + break; + case PROPERTY_ID_APPLYFILTER: { bool bApply = true; @@ -1780,6 +1798,13 @@ PropertyState ODatabaseForm::getPropertyStateByHandle(sal_Int32 nHandle) eState = PropertyState_DIRECT_VALUE; break; + case PROPERTY_ID_HAVINGCLAUSE: + if ( m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicHaving ).isEmpty() ) + eState = PropertyState_DEFAULT_VALUE; + else + eState = PropertyState_DIRECT_VALUE; + break; + case PROPERTY_ID_APPLYFILTER: eState = m_aFilterManager.isApplyPublicFilter() ? PropertyState_DEFAULT_VALUE : PropertyState_DIRECT_VALUE; break; @@ -1813,6 +1838,7 @@ void ODatabaseForm::setPropertyToDefaultByHandle(sal_Int32 nHandle) { case PROPERTY_ID_INSERTONLY: case PROPERTY_ID_FILTER: + case PROPERTY_ID_HAVINGCLAUSE: case PROPERTY_ID_APPLYFILTER: case PROPERTY_ID_NAVIGATION: case PROPERTY_ID_CYCLE: @@ -1843,6 +1869,10 @@ Any ODatabaseForm::getPropertyDefaultByHandle( sal_Int32 nHandle ) const aReturn <<= OUString(); break; + case PROPERTY_ID_HAVINGCLAUSE: + aReturn <<= OUString(); + break; + case PROPERTY_ID_APPLYFILTER: aReturn <<= true; break; @@ -3741,7 +3771,7 @@ void SAL_CALL ODatabaseForm::write(const Reference<XObjectOutputStream>& _rxOutS OFormComponents::write(_rxOutStream); // version - _rxOutStream->writeShort(0x0003); + _rxOutStream->writeShort(0x0004); // Name _rxOutStream << m_sName; @@ -3819,10 +3849,13 @@ void SAL_CALL ODatabaseForm::write(const Reference<XObjectOutputStream>& _rxOutS _rxOutStream->writeShort((sal_Int16)m_eNavigation); OUString sFilter; + OUString sHaving; OUString sOrder; if (m_xAggregateSet.is()) { m_xAggregateSet->getPropertyValue(PROPERTY_FILTER) >>= sFilter; + // version 4 + m_xAggregateSet->getPropertyValue(PROPERTY_HAVINGCLAUSE) >>= sHaving; m_xAggregateSet->getPropertyValue(PROPERTY_SORT) >>= sOrder; } _rxOutStream << sFilter; @@ -3922,6 +3955,11 @@ void SAL_CALL ODatabaseForm::read(const Reference<XObjectInputStream>& _rxInStre _rxInStream >> sAggregateProp; setPropertyValue(PROPERTY_FILTER, makeAny(sAggregateProp)); + if(nVersion > 3) + { + _rxInStream >> sAggregateProp; + setPropertyValue(PROPERTY_HAVINGCLAUSE, makeAny(sAggregateProp)); + } _rxInStream >> sAggregateProp; if (m_xAggregateSet.is()) |