diff options
-rw-r--r-- | connectivity/source/commontools/filtermanager.cxx | 54 | ||||
-rw-r--r-- | connectivity/source/commontools/parameters.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/core/misc/DatabaseDataProvider.cxx | 4 | ||||
-rw-r--r-- | forms/source/component/DatabaseForm.cxx | 8 | ||||
-rw-r--r-- | include/connectivity/filtermanager.hxx | 26 |
5 files changed, 41 insertions, 53 deletions
diff --git a/connectivity/source/commontools/filtermanager.cxx b/connectivity/source/commontools/filtermanager.cxx index cadb35923ea9..6296e2c55d98 100644 --- a/connectivity/source/commontools/filtermanager.cxx +++ b/connectivity/source/commontools/filtermanager.cxx @@ -39,8 +39,7 @@ namespace dbtools using namespace connectivity; FilterManager::FilterManager( ) - :m_aFilterComponents( FC_COMPONENT_COUNT ) - ,m_bApplyPublicFilter( true ) + :m_bApplyPublicFilter( true ) { } @@ -63,16 +62,19 @@ namespace dbtools const OUString& FilterManager::getFilterComponent( FilterComponent _eWhich ) const { - return m_aFilterComponents[ _eWhich ]; + return _eWhich == FilterComponent::PublicFilter ? m_aPublicFilterComponent : m_aLinkFilterComponent; } void FilterManager::setFilterComponent( FilterComponent _eWhich, const OUString& _rComponent ) { - m_aFilterComponents[ _eWhich ] = _rComponent; + if (_eWhich == FilterComponent::PublicFilter) + m_aPublicFilterComponent = _rComponent; + else + m_aLinkFilterComponent = _rComponent; try { - if ( m_xComponentAggregate.is() && (( _eWhich != fcPublicFilter ) || m_bApplyPublicFilter ) ) + if ( m_xComponentAggregate.is() && (( _eWhich != FilterComponent::PublicFilter ) || m_bApplyPublicFilter ) ) m_xComponentAggregate->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FILTER), makeAny( getComposedFilter() ) ); } catch( const Exception& ) @@ -91,7 +93,7 @@ namespace dbtools try { - if ( m_xComponentAggregate.is() && !getFilterComponent( fcPublicFilter ).isEmpty() ) + if ( m_xComponentAggregate.is() && !getFilterComponent( FilterComponent::PublicFilter ).isEmpty() ) { // only if there changed something m_xComponentAggregate->setPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FILTER), makeAny( getComposedFilter() ) ); } @@ -120,32 +122,25 @@ namespace dbtools bool FilterManager::isThereAtMostOneComponent( OUStringBuffer& o_singleComponent ) const { - sal_Int32 nOnlyNonEmpty = -1; - sal_Int32 i; - for ( i = getFirstApplicableFilterIndex(); i < FC_COMPONENT_COUNT; ++i ) - { - if ( !m_aFilterComponents[ i ].isEmpty() ) - { - if ( nOnlyNonEmpty != -1 ) - // it's the second non-empty component - break; - else - nOnlyNonEmpty = i; - } - } - if ( nOnlyNonEmpty == -1 ) - { - o_singleComponent.makeStringAndClear(); + if (m_bApplyPublicFilter) { + if (!m_aPublicFilterComponent.isEmpty() && !m_aLinkFilterComponent.isEmpty()) + return false; + if (!m_aPublicFilterComponent.isEmpty()) + o_singleComponent = m_aPublicFilterComponent; + else if (!m_aLinkFilterComponent.isEmpty()) + o_singleComponent = m_aLinkFilterComponent; + else + o_singleComponent.makeStringAndClear(); return true; } - - if ( i == FC_COMPONENT_COUNT ) + else { - // we found only one non-empty filter component - o_singleComponent = m_aFilterComponents[ nOnlyNonEmpty ]; + if (m_aLinkFilterComponent.isEmpty()) + o_singleComponent.makeStringAndClear(); + else + o_singleComponent = m_aLinkFilterComponent; return true; } - return false; } @@ -157,8 +152,9 @@ namespace dbtools if ( !isThereAtMostOneComponent( aComposedFilter ) ) { // append the single components - for ( sal_Int32 i = getFirstApplicableFilterIndex(); i < FC_COMPONENT_COUNT; ++i ) - appendFilterComponent( aComposedFilter, m_aFilterComponents[ i ] ); + if (m_bApplyPublicFilter) + appendFilterComponent( aComposedFilter, m_aPublicFilterComponent ); + appendFilterComponent( aComposedFilter, m_aLinkFilterComponent ); } return aComposedFilter.makeStringAndClear(); diff --git a/connectivity/source/commontools/parameters.cxx b/connectivity/source/commontools/parameters.cxx index 1f43707fb17b..559483e9c3ef 100644 --- a/connectivity/source/commontools/parameters.cxx +++ b/connectivity/source/commontools/parameters.cxx @@ -398,7 +398,7 @@ namespace dbtools } // now set this filter at the 's filter manager - _rFilterManager.setFilterComponent( FilterManager::fcLinkFilter, sAdditionalFilter.makeStringAndClear() ); + _rFilterManager.setFilterComponent( FilterManager::FilterComponent::LinkFilter, sAdditionalFilter.makeStringAndClear() ); _rColumnsInLinkDetails = true; } diff --git a/dbaccess/source/core/misc/DatabaseDataProvider.cxx b/dbaccess/source/core/misc/DatabaseDataProvider.cxx index 5a107f04ba41..2e71809c1f75 100644 --- a/dbaccess/source/core/misc/DatabaseDataProvider.cxx +++ b/dbaccess/source/core/misc/DatabaseDataProvider.cxx @@ -496,14 +496,14 @@ void SAL_CALL DatabaseDataProvider::setCommandType(::sal_Int32 the_value) throw OUString SAL_CALL DatabaseDataProvider::getFilter() throw (uno::RuntimeException, std::exception) { osl::MutexGuard g(m_aMutex); - return m_aFilterManager.getFilterComponent( dbtools::FilterManager::fcPublicFilter ); + return m_aFilterManager.getFilterComponent( dbtools::FilterManager::FilterComponent::PublicFilter ); } void SAL_CALL DatabaseDataProvider::setFilter(const OUString & the_value) throw (uno::RuntimeException, std::exception) { { osl::MutexGuard g(m_aMutex); - m_aFilterManager.setFilterComponent( dbtools::FilterManager::fcPublicFilter, the_value ); + m_aFilterManager.setFilterComponent( dbtools::FilterManager::FilterComponent::PublicFilter, the_value ); } set(PROPERTY_FILTER,the_value,m_Filter); } diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx index 3f122a9fd5db..8d9eb1771185 100644 --- a/forms/source/component/DatabaseForm.cxx +++ b/forms/source/component/DatabaseForm.cxx @@ -1500,7 +1500,7 @@ void ODatabaseForm::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const break; case PROPERTY_ID_FILTER: - rValue <<= m_aFilterManager.getFilterComponent( FilterManager::fcPublicFilter ); + rValue <<= m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicFilter ); break; case PROPERTY_ID_APPLYFILTER: @@ -1583,7 +1583,7 @@ sal_Bool ODatabaseForm::convertFastPropertyValue( Any& rConvertedValue, Any& rOl break; case PROPERTY_ID_FILTER: - bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aFilterManager.getFilterComponent( FilterManager::fcPublicFilter ) ); + bModified = tryPropertyValue( rConvertedValue, rOldValue, rValue, m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicFilter ) ); break; case PROPERTY_ID_APPLYFILTER: @@ -1672,7 +1672,7 @@ void ODatabaseForm::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const A { OUString sNewFilter; rValue >>= sNewFilter; - m_aFilterManager.setFilterComponent( FilterManager::fcPublicFilter, sNewFilter ); + m_aFilterManager.setFilterComponent( FilterManager::FilterComponent::PublicFilter, sNewFilter ); } break; @@ -1815,7 +1815,7 @@ PropertyState ODatabaseForm::getPropertyStateByHandle(sal_Int32 nHandle) break; case PROPERTY_ID_FILTER: - if ( m_aFilterManager.getFilterComponent( FilterManager::fcPublicFilter ).isEmpty() ) + if ( m_aFilterManager.getFilterComponent( FilterManager::FilterComponent::PublicFilter ).isEmpty() ) eState = PropertyState_DEFAULT_VALUE; else eState = PropertyState_DIRECT_VALUE; diff --git a/include/connectivity/filtermanager.hxx b/include/connectivity/filtermanager.hxx index 06869b5b0f0b..73e9e87d3922 100644 --- a/include/connectivity/filtermanager.hxx +++ b/include/connectivity/filtermanager.hxx @@ -58,20 +58,18 @@ namespace dbtools class OOO_DLLPUBLIC_DBTOOLS FilterManager { public: - enum FilterComponent + enum class FilterComponent { - fcPublicFilter = 0, // the filter which is to be published as "Filter" property of the database component - fcLinkFilter, // the filter part which is implicitly created for a database component when connecting - // master and detail database components via column names - - FC_COMPONENT_COUNT // boundary delimiter, not to be used from outside + PublicFilter, // The filter which is to be published as "Filter" property of the database component. + LinkFilter // The filter part which is implicitly created for a database component when connecting + // master and detail database components via column names. }; private: - css::uno::Reference< css::beans::XPropertySet > - m_xComponentAggregate; - ::std::vector< OUString > m_aFilterComponents; - bool m_bApplyPublicFilter; + css::uno::Reference< css::beans::XPropertySet > m_xComponentAggregate; + OUString m_aPublicFilterComponent; + OUString m_aLinkFilterComponent; + bool m_bApplyPublicFilter; public: /// ctor @@ -84,7 +82,7 @@ namespace dbtools void dispose( ); const OUString& getFilterComponent( FilterComponent _eWhich ) const; - void setFilterComponent( FilterComponent _eWhich, const OUString& _rComponent ); + void setFilterComponent( FilterComponent _eWhich, const OUString& _rComponent ); inline bool isApplyPublicFilter( ) const { return m_bApplyPublicFilter; } void setApplyPublicFilter( bool _bApply ); @@ -100,12 +98,6 @@ namespace dbtools /// checks whether there is only one (or even no) non-empty filter component bool isThereAtMostOneComponent( OUStringBuffer& o_singleComponent ) const; - - /// returns the index of the first filter component which should be considered when building the composed filter - inline sal_Int32 getFirstApplicableFilterIndex() const - { - return m_bApplyPublicFilter ? fcPublicFilter : fcPublicFilter + 1; - } }; |