From 0096dc80abf5c1456389848c2fcc33edcc29cca0 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 17 Sep 2010 08:38:54 +0200 Subject: dba34a: #i114403# fixed the form-based filter for list boxes --- forms/source/component/Filter.cxx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'forms/source/component/Filter.cxx') diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 9cbc5237cf95..f4aa133a44f4 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -57,6 +57,7 @@ #include #include #include +#include /** === end UNO includes === **/ #include @@ -342,11 +343,16 @@ namespace frm case FormComponentType::LISTBOX: { - Sequence< ::rtl::OUString> aValueSelection; - Reference< XPropertySet > aPropertyPointer(getModel(), UNO_QUERY); - aPropertyPointer->getPropertyValue(PROPERTY_VALUE_SEQ) >>= aValueSelection; - if (rEvent.Selected <= aValueSelection.getLength()) - aText.append( aValueSelection[ rEvent.Selected ] ); + try + { + const Reference< XItemList > xItemList( getModel(), UNO_QUERY_THROW ); + const ::rtl::OUString sItemText( xItemList->getItemText( rEvent.Selected ) ); + aText.append( sItemText ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } break; -- cgit From afb8e470091e62230f8fefbfbd2863ef2b8085ba Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 1 Nov 2010 13:32:13 +0100 Subject: dba34a: #i114403# when delivering our text (getText, plus notifications), and we're a filter list box created for a list box control, translate between display strings and values. (Filter list boxes (*not* combo boxes!) still messed up. This needs a follow-up issue.) --- forms/source/component/Filter.cxx | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'forms/source/component/Filter.cxx') diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index f4aa133a44f4..d664be8e4a86 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -346,7 +346,19 @@ namespace frm try { const Reference< XItemList > xItemList( getModel(), UNO_QUERY_THROW ); - const ::rtl::OUString sItemText( xItemList->getItemText( rEvent.Selected ) ); + ::rtl::OUString sItemText( xItemList->getItemText( rEvent.Selected ) ); + + const MapString2String::const_iterator itemPos = m_aDisplayItemToValueItem.find( sItemText ); + if ( itemPos != m_aDisplayItemToValueItem.end() ) + { + sItemText = itemPos->second; + if ( sItemText.getLength() ) + { + ::dbtools::OPredicateInputController aPredicateInput( m_aContext.getLegacyServiceFactory(), m_xConnection, getParseContext() ); + ::rtl::OUString sErrorMessage; + OSL_VERIFY( aPredicateInput.normalizePredicateString( sItemText, m_xField, &sErrorMessage ) ); + } + } aText.append( sItemText ); } catch( const Exception& ) @@ -620,6 +632,16 @@ namespace frm { m_aText = aText; xListBox->selectItem(m_aText, sal_True); + if ( xListBox->getSelectedItemPos() >= 0 ) + { + const bool isQuoted = ( aText.getLength() > 0 ) + && ( aText[0] == '\'' ) + && ( aText[aText.getLength() - 1] == '\'' ); + if ( isQuoted ) + { + xListBox->selectItem( aText.copy( 1, aText.getLength() - 2 ), sal_True ); + } + } } } break; default: @@ -810,6 +832,16 @@ namespace frm case FormComponentType::LISTBOX: case FormComponentType::COMBOBOX: m_nControlClass = nClassId; + if ( FormComponentType::LISTBOX == nClassId ) + { + Sequence< ::rtl::OUString > aDisplayItems; + OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_STRINGITEMLIST ) >>= aDisplayItems ); + Sequence< ::rtl::OUString > aValueItems; + OSL_VERIFY( xControlModel->getPropertyValue( PROPERTY_VALUE_SEQ ) >>= aValueItems ); + OSL_ENSURE( aDisplayItems.getLength() == aValueItems.getLength(), "OFilterControl::initialize: inconsistent item lists!" ); + for ( sal_Int32 i=0; i < ::std::min( aDisplayItems.getLength(), aValueItems.getLength() ); ++i ) + m_aDisplayItemToValueItem[ aDisplayItems[i] ] = aValueItems[i]; + } break; default: m_bMultiLine = ::comphelper::hasProperty( PROPERTY_MULTILINE, xControlModel ) && ::comphelper::getBOOL( xControlModel->getPropertyValue( PROPERTY_MULTILINE ) ); -- cgit From abe4496cfce679e999aa59d98649fc37f1dacc02 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Tue, 23 Nov 2010 18:41:04 +0100 Subject: vcl117: removed obsolete header --- forms/source/component/Filter.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'forms/source/component/Filter.cxx') diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index 9cbc5237cf95..9cba722789e8 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -71,7 +71,7 @@ #include #include #include -#include +#include //-------------------------------------------------------------------------- extern "C" void SAL_CALL createRegistryInfo_OFilterControl() -- cgit From 09cfbd6086296a987ded9275d9dad4b607c3e38c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 6 Dec 2010 14:14:11 +0100 Subject: gridsort: give the UnoControl(Model/Base) classes a ctor taking a service factory, so we have access to the factory which created us, and don't need to resort to the process'es service factory --- forms/source/component/Filter.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'forms/source/component/Filter.cxx') diff --git a/forms/source/component/Filter.cxx b/forms/source/component/Filter.cxx index d664be8e4a86..dacfd334579c 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -104,8 +104,8 @@ namespace frm //===================================================================== //--------------------------------------------------------------------- OFilterControl::OFilterControl( const Reference< XMultiServiceFactory >& _rxORB ) - :m_aTextListeners( *this ) - ,m_aContext( _rxORB ) + :UnoControl( _rxORB ) + ,m_aTextListeners( *this ) ,m_aParser( _rxORB ) ,m_nControlClass( FormComponentType::TEXTFIELD ) ,m_bFilterList( sal_False ) @@ -132,11 +132,11 @@ namespace frm if ( !m_xFormatter.is() ) { // we can create one from the connection, if it's an SDB connection - Reference< XNumberFormatsSupplier > xFormatSupplier = ::dbtools::getNumberFormats( m_xConnection, sal_True, m_aContext.getLegacyServiceFactory() ); + Reference< XNumberFormatsSupplier > xFormatSupplier = ::dbtools::getNumberFormats( m_xConnection, sal_True, maContext.getLegacyServiceFactory() ); if ( xFormatSupplier.is() ) { - m_aContext.createComponent( "com.sun.star.util.NumberFormatter", m_xFormatter ); + maContext.createComponent( "com.sun.star.util.NumberFormatter", m_xFormatter ); if ( m_xFormatter.is() ) m_xFormatter->attachNumberFormatsSupplier( xFormatSupplier ); } @@ -354,7 +354,7 @@ namespace frm sItemText = itemPos->second; if ( sItemText.getLength() ) { - ::dbtools::OPredicateInputController aPredicateInput( m_aContext.getLegacyServiceFactory(), m_xConnection, getParseContext() ); + ::dbtools::OPredicateInputController aPredicateInput( maContext.getLegacyServiceFactory(), m_xConnection, getParseContext() ); ::rtl::OUString sErrorMessage; OSL_VERIFY( aPredicateInput.normalizePredicateString( sItemText, m_xField, &sErrorMessage ) ); } @@ -539,7 +539,7 @@ namespace frm aNewText.trim(); if ( aNewText.getLength() ) { - ::dbtools::OPredicateInputController aPredicateInput( m_aContext.getLegacyServiceFactory(), m_xConnection, getParseContext() ); + ::dbtools::OPredicateInputController aPredicateInput( maContext.getLegacyServiceFactory(), m_xConnection, getParseContext() ); ::rtl::OUString sErrorMessage; if ( !aPredicateInput.normalizePredicateString( aNewText, m_xField, &sErrorMessage ) ) { @@ -743,7 +743,7 @@ namespace frm static ::rtl::OUString s_sDialogServiceName = ::rtl::OUString::createFromAscii( "com.sun.star.sdb.ErrorMessageDialog" ); - Reference< XExecutableDialog > xErrorDialog( m_aContext.createComponentWithArguments( s_sDialogServiceName, aArgs ), UNO_QUERY ); + Reference< XExecutableDialog > xErrorDialog( maContext.createComponentWithArguments( s_sDialogServiceName, aArgs ), UNO_QUERY ); if ( xErrorDialog.is() ) xErrorDialog->execute(); else -- cgit