diff options
author | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-22 08:14:22 +0100 |
---|---|---|
committer | Ocke Janssen [oj] <Ocke.Janssen@sun.com> | 2010-01-22 08:14:22 +0100 |
commit | 80f468de1e670de020ae4ac6ab15baefbd905a71 (patch) | |
tree | 17ddcb06b316d176b4dbf9a7117ad5035dc3a1af /forms | |
parent | fad7c8d823d0a451874616e19334e76ca93385b8 (diff) |
dba33f: #i108548# extend SingleSelectQueryComposer appendFilterByColumn with additonal parameter
Diffstat (limited to 'forms')
-rw-r--r-- | forms/source/component/ComboBox.cxx | 23 | ||||
-rw-r--r-- | forms/source/component/Filter.cxx | 15 | ||||
-rw-r--r-- | forms/source/component/FormattedField.cxx | 2 | ||||
-rw-r--r-- | forms/source/component/ListBox.cxx | 20 | ||||
-rw-r--r-- | forms/source/runtime/formoperations.cxx | 22 |
5 files changed, 31 insertions, 51 deletions
diff --git a/forms/source/component/ComboBox.cxx b/forms/source/component/ComboBox.cxx index 432bc5124775..d88744c8d325 100644 --- a/forms/source/component/ComboBox.cxx +++ b/forms/source/component/ComboBox.cxx @@ -535,26 +535,11 @@ void OComboBoxModel::loadData( bool _bForce ) else { // otherwise look for the alias - Reference<XSQLQueryComposerFactory> xFactory(xConnection, UNO_QUERY); - if (!xFactory.is()) - break; - - Reference<XSQLQueryComposer> xComposer = xFactory->createQueryComposer(); - try - { - Reference<XPropertySet> xFormAsSet(xForm, UNO_QUERY); - ::rtl::OUString aStatement; - xFormAsSet->getPropertyValue(PROPERTY_ACTIVECOMMAND) >>= aStatement; - xComposer->setQuery(aStatement); - } - catch(Exception&) - { - disposeComponent(xComposer); - break; - } + Reference<XPropertySet> xFormProp(xForm,UNO_QUERY); + Reference< XColumnsSupplier > xSupplyFields; + xFormProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupplyFields; // search the field - Reference< XColumnsSupplier > xSupplyFields(xComposer, UNO_QUERY); DBG_ASSERT(xSupplyFields.is(), "OComboBoxModel::loadData : invalid query composer !"); Reference< XNameAccess > xFieldNames = xSupplyFields->getColumns(); @@ -565,8 +550,6 @@ void OComboBoxModel::loadData( bool _bForce ) if (hasProperty(PROPERTY_FIELDSOURCE, xComposerFieldAsSet)) xComposerFieldAsSet->getPropertyValue(PROPERTY_FIELDSOURCE) >>= aFieldName; } - - disposeComponent(xComposer); } if (!aFieldName.getLength()) diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 0ff3faca8beb..6e2eb5d1d049 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -400,17 +400,10 @@ namespace frm const Reference< XPropertySet > xFormProps( xForm, UNO_QUERY_THROW ); // create a query composer - const Reference< XConnection > xConnection( ::dbtools::getConnection( xForm ), UNO_SET_THROW ); - const Reference< XSQLQueryComposerFactory > xFactory( xConnection, UNO_QUERY_THROW ); - const Reference< XSQLQueryComposer > xComposer( xFactory->createQueryComposer(), UNO_SET_THROW ); - - // set the statement on the composer - ::rtl::OUString sStatement; - xFormProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= sStatement; - xComposer->setQuery( sStatement ); + Reference< XColumnsSupplier > xSuppColumns; + xFormProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSuppColumns; - // the field we're bound to - const Reference< XColumnsSupplier > xSuppColumns( xComposer, UNO_QUERY_THROW ); + const Reference< XConnection > xConnection( ::dbtools::getConnection( xForm ), UNO_SET_THROW ); const Reference< XNameAccess > xFieldNames( xSuppColumns->getColumns(), UNO_SET_THROW ); if ( !xFieldNames->hasByName( sFieldName ) ) return; @@ -420,7 +413,7 @@ namespace frm xComposerFieldProps->getPropertyValue( PROPERTY_TABLENAME ) >>= sTableName; // obtain the table of the field - const Reference< XTablesSupplier > xSuppTables( xComposer, UNO_QUERY_THROW ); + const Reference< XTablesSupplier > xSuppTables( xSuppColumns, UNO_QUERY_THROW ); const Reference< XNameAccess > xTablesNames( xSuppTables->getTables(), UNO_SET_THROW ); const Reference< XNamed > xNamedTable( xTablesNames->getByName( sTableName ), UNO_QUERY_THROW ); sTableName = xNamedTable->getName(); diff --git a/forms/source/component/FormattedField.cxx b/forms/source/component/FormattedField.cxx index 3add838333b9..62f73166af3f 100644 --- a/forms/source/component/FormattedField.cxx +++ b/forms/source/component/FormattedField.cxx @@ -583,7 +583,7 @@ void OFormattedModel::_propertyChanged( const com::sun::star::beans::PropertyCha // as m_aSaveValue (which is used by commitControlValueToDbColumn) is format dependent we have // to recalc it, which is done by translateDbColumnToControlValue - if ( m_xColumn.is() && m_xAggregateFastSet.is() ) + if ( m_xColumn.is() && m_xAggregateFastSet.is() && !m_xCursor->isBeforeFirst() && !m_xCursor->isAfterLast()) { setControlValue( translateDbColumnToControlValue(), eOther ); } diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 4bbf42381900..47ebca435b6c 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -704,25 +704,10 @@ namespace frm else { // otherwise look for the alias - Reference<XSQLQueryComposerFactory> xFactory(xConnection, UNO_QUERY); - if (!xFactory.is()) - break; - - Reference<XSQLQueryComposer> xComposer = xFactory->createQueryComposer(); - try - { - ::rtl::OUString aStatement; - xFormProps->getPropertyValue( PROPERTY_ACTIVECOMMAND ) >>= aStatement; - xComposer->setQuery( aStatement ); - } - catch(Exception&) - { - disposeComponent(xComposer); - break; - } + Reference< XColumnsSupplier > xSupplyFields; + xFormProps->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupplyFields; // search the field - Reference<XColumnsSupplier> xSupplyFields(xComposer, UNO_QUERY); DBG_ASSERT(xSupplyFields.is(), "OListBoxModel::loadData : invalid query composer !"); Reference<XNameAccess> xFieldNames = xSupplyFields->getColumns(); @@ -733,7 +718,6 @@ namespace frm if (hasProperty(PROPERTY_FIELDSOURCE, xComposerFieldAsSet)) xComposerFieldAsSet->getPropertyValue(PROPERTY_FIELDSOURCE) >>= aFieldName; } - disposeComponent(xComposer); } } if (!aFieldName.getLength()) diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx index 6b63d4b8a756..9c0264b7f3f6 100644 --- a/forms/source/runtime/formoperations.cxx +++ b/forms/source/runtime/formoperations.cxx @@ -51,6 +51,8 @@ #include <com/sun/star/form/XConfirmDeleteListener.hpp> #include <com/sun/star/sdb/RowChangeEvent.hpp> #include <com/sun/star/sdb/RowChangeAction.hpp> +#include <com/sun/star/sdb/SQLFilterOperator.hpp> +#include <com/sun/star/sdbc/DataType.hpp> #include <com/sun/star/form/XReset.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> @@ -97,6 +99,7 @@ namespace frm using ::com::sun::star::form::runtime::FeatureState; using ::com::sun::star::lang::IllegalArgumentException; using ::com::sun::star::sdbc::SQLException; + using namespace ::com::sun::star::sdbc; using ::com::sun::star::form::XForm; using ::com::sun::star::ucb::AlreadyInitializedException; using ::com::sun::star::util::XModifyBroadcaster; @@ -115,6 +118,7 @@ namespace frm using ::com::sun::star::sdbcx::XRowLocate; using ::com::sun::star::form::XConfirmDeleteListener; using ::com::sun::star::sdb::RowChangeEvent; + using namespace ::com::sun::star::sdb; using ::com::sun::star::form::XReset; using ::com::sun::star::beans::XMultiPropertySet; using ::com::sun::star::uno::makeAny; @@ -1687,7 +1691,23 @@ namespace frm void FormOperations::impl_appendFilterByColumn_throw( const void* _pActionParam ) const { const param_appendFilterByColumn* pParam = static_cast< const param_appendFilterByColumn* >( _pActionParam ); - m_xParser->appendFilterByColumn( pParam->xField, sal_True ); + sal_Int32 nOp = SQLFilterOperator::EQUAL; + if ( pParam->xField.is() ) + { + sal_Int32 nType = 0; + pParam->xField->getPropertyValue(PROPERTY_FIELDTYPE) >>= nType; + switch(nType) + { + case DataType::VARCHAR: + case DataType::CHAR: + case DataType::LONGVARCHAR: + nOp = SQLFilterOperator::LIKE; + break; + default: + nOp = SQLFilterOperator::EQUAL; + } + } + m_xParser->appendFilterByColumn( pParam->xField, sal_True,nOp ); } //------------------------------------------------------------------------------ |