summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-04-21 19:43:34 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2013-04-22 17:51:46 +0200
commit52bc6737cde524f04c9e0af7b7bc98c2030f2ff0 (patch)
tree15f8e286b0864e0d7ceaac441cccd7df7f5023b9
parent3e1a0c9b2f83a44f5e7ff154d6e09d4f7b26a5e5 (diff)
Data-aware ListBox: getCurrentValue should return *binding* values
As opposed to display values Change-Id: I8afb52d69786702776f4e8d24390ba8ede417e92
-rw-r--r--forms/source/component/ListBox.cxx51
1 files changed, 49 insertions, 2 deletions
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx
index b4152bbbe841..9cfdc70300fb 100644
--- a/forms/source/component/ListBox.cxx
+++ b/forms/source/component/ListBox.cxx
@@ -1327,6 +1327,53 @@ namespace frm
);
return makeAny( aSelectedEntriesTexts );
}
+
+ //................................................................
+ struct ExtractAnyFromValueList_Safe : public ::std::unary_function< sal_Int16, Any >
+ {
+ protected:
+ const ValueList& m_rList;
+
+ public:
+ ExtractAnyFromValueList_Safe( const ValueList& _rList ) : m_rList( _rList ) { }
+
+ Any operator ()( sal_Int16 _nIndex )
+ {
+ OSL_ENSURE( static_cast<ValueList::size_type>(_nIndex) < m_rList.size(), "ExtractAnyFromValueList: inconsistence!" );
+ if ( static_cast<ValueList::size_type>(_nIndex) < m_rList.size() )
+ return m_rList[ _nIndex ].makeAny();
+ return Any();
+ }
+ };
+
+ //................................................................
+ Any lcl_getSingleSelectedEntryAny( const Sequence< sal_Int16 >& _rSelectSequence, const ValueList& _rStringList )
+ {
+ Any aReturn;
+
+ // by definition, multiple selected entries are transfered as NULL if the
+ // binding does not support string lists
+ if ( _rSelectSequence.getLength() <= 1 )
+ {
+ if ( _rSelectSequence.getLength() == 1 )
+ aReturn = ExtractAnyFromValueList_Safe( _rStringList )( _rSelectSequence[0] );
+ }
+
+ return aReturn;
+ }
+
+ //................................................................
+ Any lcl_getMultiSelectedEntriesAny( const Sequence< sal_Int16 >& _rSelectSequence, const ValueList& _rStringList )
+ {
+ Sequence< Any > aSelectedEntriesValues( _rSelectSequence.getLength() );
+ ::std::transform(
+ _rSelectSequence.getConstArray(),
+ _rSelectSequence.getConstArray() + _rSelectSequence.getLength(),
+ aSelectedEntriesValues.getArray(),
+ ExtractAnyFromValueList_Safe( _rStringList )
+ );
+ return makeAny( aSelectedEntriesValues );
+ }
}
//--------------------------------------------------------------------
@@ -1395,9 +1442,9 @@ namespace frm
OSL_VERIFY( const_cast< OListBoxModel* >( this )->getPropertyValue( PROPERTY_MULTISELECTION ) >>= bMultiSelection );
if ( bMultiSelection )
- aCurretnValue = lcl_getMultiSelectedEntries( aSelectSequence, getStringItemList() );
+ aCurretnValue = lcl_getMultiSelectedEntriesAny( aSelectSequence, impl_getValues() );
else
- aCurretnValue = lcl_getSingleSelectedEntry( aSelectSequence, getStringItemList() );
+ aCurretnValue = lcl_getSingleSelectedEntryAny( aSelectSequence, impl_getValues() );
}
catch( const Exception& )
{