forms/source/component/FormComponent.cxx | 1 forms/source/component/ListBox.cxx | 37 +++++++++++++++++++++---------- forms/source/component/ListBox.hxx | 5 +++- 3 files changed, 30 insertions(+), 13 deletions(-)
New commits: commit 0331fa6a904d3f923cb80d7104e74ea6f2958179 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Tue Jan 13 14:56:23 2015 +0100 ListBox with value list: consider first empty value as NULL Change-Id: I15c040b481b7f03720d0227ba5d2fcd2ccc78386 diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index d6eb7cf..72ce587 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -79,6 +79,8 @@ namespace frm using ::connectivity::ORowSetValue; + const ::connectivity::ORowSetValue OListBoxModel::s_aEmptyValue; + const ::connectivity::ORowSetValue OListBoxModel::s_aEmptyStringValue = OUString(); //= helper @@ -1007,12 +1009,12 @@ namespace frm void OListBoxModel::onDisconnectedDbColumn() { + clearBoundValues(); + m_nNULLPos = -1; + m_nBoundColumnType = DataType::SQLNULL; + if ( m_eListSourceType != ListSourceType_VALUELIST ) { - clearBoundValues(); - m_nNULLPos = -1; - m_nBoundColumnType = DataType::SQLNULL; - if ( !hasExternalListSource() ) setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( StringSequence() ) ); @@ -1037,13 +1039,25 @@ namespace frm void OListBoxModel::convertBoundValues(const sal_Int32 nFieldType) const { + assert(s_aEmptyValue.isNull()); + m_nNULLPos = -1; m_aConvertedBoundValues.resize(m_aBoundValues.size()); ValueList::const_iterator src = m_aBoundValues.begin(); const ValueList::const_iterator end = m_aBoundValues.end(); ValueList::iterator dst = m_aConvertedBoundValues.begin(); for (; src != end; ++src, ++dst ) { - *dst = *src; + if(m_nNULLPos == -1 && + !isRequired() && + (*src == s_aEmptyStringValue || *src == s_aEmptyValue || src->isNull()) ) + { + m_nNULLPos = src - m_aBoundValues.begin(); + dst->setNull(); + } + else + { + *dst = *src; + } dst->setTypeKind(nFieldType); } m_nConvertedBoundValuesType = nFieldType; @@ -1090,21 +1104,19 @@ namespace frm ORowSetValue OListBoxModel::getFirstSelectedValue() const { - static const ORowSetValue s_aEmptyVaue; - DBG_ASSERT( m_xAggregateFastSet.is(), "OListBoxModel::getFirstSelectedValue: invalid aggregate!" ); if ( !m_xAggregateFastSet.is() ) - return s_aEmptyVaue; + return s_aEmptyValue; Sequence< sal_Int16 > aSelectedIndices; OSL_VERIFY( m_xAggregateFastSet->getFastPropertyValue( getValuePropertyAggHandle() ) >>= aSelectedIndices ); if ( !aSelectedIndices.getLength() ) // nothing selected at all - return s_aEmptyVaue; + return s_aEmptyValue; if ( ( m_nNULLPos != -1 ) && ( aSelectedIndices[0] == m_nNULLPos ) ) // the dedicated "NULL" entry is selected - return s_aEmptyVaue; + return s_aEmptyValue; ValueList aValues( impl_getValues() ); @@ -1112,7 +1124,7 @@ namespace frm if ( selectedValue >= aValues.size() ) { SAL_WARN( "forms.component", "OListBoxModel::getFirstSelectedValue: inconsistent selection/valuelist!" ); - return s_aEmptyVaue; + return s_aEmptyValue; } return aValues[ selectedValue ]; diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index 85b380c..a1217e8 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -114,7 +114,7 @@ class OListBoxModel :public OBoundControlModel ::com::sun::star::uno::Sequence<sal_Int16> m_aDefaultSelectSeq; // DefaultSelected // </properties> - sal_Int16 m_nNULLPos; // position of the NULL value in our list + mutable sal_Int16 m_nNULLPos; // position of the NULL value in our list sal_Int32 m_nBoundColumnType; private: @@ -145,6 +145,9 @@ public: throw (::com::sun::star::lang::IllegalArgumentException) SAL_OVERRIDE; protected: + static const ::connectivity::ORowSetValue s_aEmptyValue; + static const ::connectivity::ORowSetValue s_aEmptyStringValue; + // XMultiPropertySet virtual void SAL_CALL setPropertyValues(const ::com::sun::star::uno::Sequence< OUString >& PropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE; commit 1cc29a04adb721205655091854f5ea828bb8eb11 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Tue Jan 13 14:49:07 2015 +0100 ListBox: refuse to give values before we are loaded If we are not loaded, we don't know our field type, so cannot give values with the right type Change-Id: I372b77647ec8ff7428b67cca72fdd89e5e147a32 diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 3235ffe..d6eb7cf 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -1058,6 +1058,9 @@ namespace frm ValueList OListBoxModel::impl_getValues() const { + if (!isLoaded()) + return ValueList(); + const sal_Int32 nFieldType = getValueType(); if ( !m_aConvertedBoundValues.empty() && m_nConvertedBoundValuesType == nFieldType ) commit 5cd4ab7f5cf8a288ae7941d5a1dd752bf2fc852d Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Tue Jan 13 14:46:37 2015 +0100 janitorial Change-Id: If0fcad97538556ef7be5fe5f8405ca171696502d diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index c152c7a..4fa30d5 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -1984,7 +1984,6 @@ bool OBoundControlModel::connectToField(const Reference<XRowSet>& rForm) m_bRequired = (ColumnValue::NO_NULLS == nNullableFlag); // we're optimistic: in case of ColumnValue_NULLABLE_UNKNOWN we assume nullability... } - else { SAL_WARN("forms.component", "OBoundControlModel::connectToField: property " PROPERTY_VALUE " not supported!"); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits