From 4c47c0802599e0d24c192ed0cb73b5d64fbfc421 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 16 Feb 2011 14:35:27 +0100 Subject: dba34d: #i116215# de-select all items when the to-be-selected string is invalid or empty --- forms/source/component/Filter.cxx | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 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 f9f17524756f..a5159679c9de 100644 --- a/forms/source/component/Filter.cxx +++ b/forms/source/component/Filter.cxx @@ -631,19 +631,39 @@ namespace frm if (xListBox.is()) { m_aText = aText; - xListBox->selectItem(m_aText, sal_True); - if ( xListBox->getSelectedItemPos() >= 0 ) + MapString2String::const_iterator itemPos = m_aDisplayItemToValueItem.find( m_aText ); + if ( itemPos == m_aDisplayItemToValueItem.end() ) { - const bool isQuoted = ( aText.getLength() > 0 ) - && ( aText[0] == '\'' ) - && ( aText[aText.getLength() - 1] == '\'' ); + const bool isQuoted = ( m_aText.getLength() > 1 ) + && ( m_aText[0] == '\'' ) + && ( m_aText[ m_aText.getLength() - 1 ] == '\'' ); if ( isQuoted ) { - xListBox->selectItem( aText.copy( 1, aText.getLength() - 2 ), sal_True ); + m_aText = m_aText.copy( 1, m_aText.getLength() - 2 ); + itemPos = m_aDisplayItemToValueItem.find( m_aText ); } } + + OSL_ENSURE( ( itemPos != m_aDisplayItemToValueItem.end() ) || ( m_aText.getLength() == 0 ), + "OFilterControl::setText: this text is not in my display list!" ); + if ( itemPos == m_aDisplayItemToValueItem.end() ) + m_aText = ::rtl::OUString(); + + if ( m_aText.getLength() == 0) + { + while ( xListBox->getSelectedItemPos() >= 0 ) + { + xListBox->selectItemPos( xListBox->getSelectedItemPos(), sal_False ); + } + } + else + { + xListBox->selectItem( m_aText, sal_True ); + } } - } break; + } + break; + default: { Reference< XTextComponent > xText( getPeer(), UNO_QUERY ); -- cgit