summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--forms/source/component/Filter.cxx34
-rw-r--r--forms/source/component/Filter.hxx5
2 files changed, 37 insertions, 2 deletions
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 ) );
diff --git a/forms/source/component/Filter.hxx b/forms/source/component/Filter.hxx
index 8e2933e93158..99c621d6cdf6 100644
--- a/forms/source/component/Filter.hxx
+++ b/forms/source/component/Filter.hxx
@@ -45,7 +45,7 @@
#include <connectivity/sqlparse.hxx>
#include <svx/ParseContext.hxx>
-class Window;
+#include <hash_map>
//.........................................................................
namespace frm
@@ -75,6 +75,9 @@ namespace frm
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xMessageParent;
+ typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash > MapString2String;
+ MapString2String m_aDisplayItemToValueItem;
+
::rtl::OUString m_aText;
::connectivity::OSQLParser m_aParser;
sal_Int16 m_nControlClass; // which kind of control do we use?