From 567a4fcf02bee6e989ddefcff81ad186b1a02eea Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Mon, 22 Apr 2013 17:37:17 +0200 Subject: Data-aware bindable ListBox new feature: bind *value* As opposed to index in list or *display* string Change-Id: I5fa74c80b28db843d45ee68523a4349ba44d229b --- forms/source/component/ListBox.cxx | 34 ++++++++++++++++++++-- .../star/form/binding/BindableDatabaseListBox.idl | 21 +++++++++---- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 2ea90a99dacf..8771869e50ae 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -1246,8 +1246,10 @@ namespace frm { eIndexList, /// as list of indexes of selected entries eIndex, /// as index of the selected entry - eEntryList, /// as list of string representations of selected entries - eEntry /// as string representation of the selected entry + eEntryList, /// as list of string representations of selected *display* entries + eEntry, /// as string representation of the selected *display* entry + eValueList, /// as list of string representations of selected values + eValue /// as string representation of the selected value }; //-------------------------------------------------------------------- @@ -1255,6 +1257,8 @@ namespace frm { switch ( _rExchangeType.getTypeClass() ) { + case TypeClass_ANY: + return eValue; case TypeClass_STRING: return eEntry; case TypeClass_LONG: @@ -1264,6 +1268,8 @@ namespace frm Type aElementType = ::comphelper::getSequenceElementType( _rExchangeType ); switch ( aElementType.getTypeClass() ) { + case TypeClass_ANY: + return eValueList; case TypeClass_STRING: return eEntryList; case TypeClass_LONG: @@ -1287,6 +1293,22 @@ namespace frm switch ( lcl_getCurrentExchangeType( getExternalValueType() ) ) { + case eValueList: + { + Sequence< const Any > aExternalValues; + OSL_VERIFY( _rExternalValue >>= aExternalValues ); + aSelectIndexes = translateBindingValuesToControlValue( aExternalValues ); + } + break; + + case eValue: + { + ORowSetValue v; + v.fill(_rExternalValue); + aSelectIndexes = translateDbValueToControlValue(v); + } + break; + case eIndexList: { // unfortunately, our select sequence is a sequence, while the external binding @@ -1475,6 +1497,14 @@ namespace frm Any aReturn; switch ( lcl_getCurrentExchangeType( getExternalValueType() ) ) { + case eValueList: + aReturn = getCurrentMultiValue(); + break; + + case eValue: + aReturn = getCurrentSingleValue(); + break; + case eIndexList: { // unfortunately, the select sequence is a sequence, but our binding diff --git a/offapi/com/sun/star/form/binding/BindableDatabaseListBox.idl b/offapi/com/sun/star/form/binding/BindableDatabaseListBox.idl index 64acb45c4d04..4540dde132a4 100644 --- a/offapi/com/sun/star/form/binding/BindableDatabaseListBox.idl +++ b/offapi/com/sun/star/form/binding/BindableDatabaseListBox.idl @@ -26,17 +26,28 @@ module com { module sun { module star { module form { module binding { - /** This service specifies a list box model which is data-aware and thus can be bound to a database field, and additionally supports binding to arbitrary external values. -

There are four possible ways how a BindableDatabaseListBox exchanges - values with an external binding, the following lists explains all of them. If a new binding +

There are six possible ways that a BindableDatabaseListBox exchanges + values with an external binding. If a new binding is set at a BindableDatabaseListBox, the types from the following list are tried in descending order: The first type supported by the binding is used for data exchange. -

  1. sequences of integers: When used, the integers in the sequence will represent +
      +
    1. sequences of anys: + The elements in the sequence will represent + the values the selected entries of the list box + (taken from ValueList or read from BoundColumn). + In other words, the SelectedValues property.
    2. +
    3. any value: + The value will represent the value of the selected entry + (taken from ValueList or read from BoundColumn). + If more than one entry is selected, + will be transfered. + In other words, the SelectedValue property.
    4. +
    5. sequences of long integers: When used, the integers in the sequence will represent the indexes of the selected entries of the list box.
    6. -
    7. integer values: When used, the value will represent the index of the selected entry. +
    8. long integer value: When used, the value will represent the index of the selected entry. If no entry is selected, -1 will be transfered. If more than one entry is selected, will be transfered.
    9. sequences of strings: When used, the strings in the sequence present the texts -- cgit