summaryrefslogtreecommitdiff
path: root/forms/source/component
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-11-01 13:32:13 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-11-01 13:32:13 +0100
commitafb8e470091e62230f8fefbfbd2863ef2b8085ba (patch)
tree4a0c325f82f0ef39dc11caf7dbb1ef4d86208d11 /forms/source/component
parentc7cd474ea28b4923c0b520815c071dee2ebc8918 (diff)
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.)
Diffstat (limited to 'forms/source/component')
-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?