connectivity/source/commontools/FValue.cxx | 8 +-- forms/source/component/ListBox.cxx | 76 ++++++++++++++++++++++------- forms/source/component/ListBox.hxx | 11 +++- 3 files changed, 74 insertions(+), 21 deletions(-)
New commits: commit c55d050400139a270f5b3b620db4845001db017d Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Feb 16 13:24:58 2012 +0100 fdo#46163 convert bound values to bound column's type diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 2453ebc..eb8c6c9 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -326,7 +326,7 @@ namespace frm // propagate if ( m_eListSourceType == ListSourceType_VALUELIST ) { - m_aBoundValues = m_aListSourceValues; + setBoundValues(m_aListSourceValues); } else { @@ -556,7 +556,7 @@ namespace frm OSL_FAIL("OListBoxModel::read : invalid (means unknown) version !"); ValueList().swap(m_aListSourceValues); m_aBoundColumn <<= (sal_Int16)0; - ValueList().swap(m_aBoundValues); + clearBoundValues(); m_eListSourceType = ListSourceType_VALUELIST; m_aDefaultSelectSeq.realloc(0); defaultCommonProperties(); @@ -674,7 +674,7 @@ namespace frm // outta here if we don't have all pre-requisites if ( !xConnection.is() || sListSource.isEmpty() ) { - ValueList().swap(m_aBoundValues); + clearBoundValues(); return; } @@ -924,7 +924,7 @@ namespace frm m_nNULLPos = 0; } - m_aBoundValues = aValueList; + setBoundValues(aValueList); setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( lcl_convertToStringSequence( aDisplayList ) ) ); } @@ -948,7 +948,7 @@ namespace frm { if ( m_eListSourceType != ListSourceType_VALUELIST ) { - ValueList().swap(m_aBoundValues); + clearBoundValues(); m_nNULLPos = -1; m_nBoundColumnType = DataType::SQLNULL; @@ -960,19 +960,63 @@ namespace frm } //------------------------------------------------------------------------------ + void OListBoxModel::setBoundValues(const ValueList &l) + { + m_aConvertedBoundValues.clear(); + m_aBoundValues = l; + } + + //------------------------------------------------------------------------------ + void OListBoxModel::clearBoundValues() + { + ValueList().swap(m_aConvertedBoundValues); + ValueList().swap(m_aBoundValues); + } + + //------------------------------------------------------------------------------ + void OListBoxModel::convertBoundValues(const sal_Int32 nFieldType) const + { + 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; + dst->setTypeKind(nFieldType); + } + m_nConvertedBoundValuesType = nFieldType; + OSL_ENSURE(dst == m_aConvertedBoundValues.end(), "OListBoxModel::convertBoundValues expected to have overwritten all of m_aConvertedBoundValues, but did not."); + } + //------------------------------------------------------------------------------ + sal_Int32 OListBoxModel::getValueType() const + { + return impl_hasBoundComponent() ? m_nBoundColumnType : getFieldType(); + } + //------------------------------------------------------------------------------ ValueList OListBoxModel::impl_getValues() const { + const sal_Int32 nFieldType = getValueType(); + + if ( !m_aConvertedBoundValues.empty() && m_nConvertedBoundValuesType == nFieldType ) + return m_aConvertedBoundValues; + if ( !m_aBoundValues.empty() ) - return m_aBoundValues; + { + convertBoundValues(nFieldType); + return m_aConvertedBoundValues; + } Sequence< ::rtl::OUString > aStringItems( getStringItemList() ); ValueList aValues( aStringItems.getLength() ); - ::std::copy( - aStringItems.getConstArray(), - aStringItems.getConstArray() + aStringItems.getLength(), - aValues.begin() - ); - + ValueList::iterator dst = aValues.begin(); + const ::rtl::OUString *src (aStringItems.getConstArray()); + const ::rtl::OUString * const end = src + aStringItems.getLength(); + for (; src < end; ++src, ++dst ) + { + *dst = *src; + dst->setTypeKind(nFieldType); + } return aValues; } //------------------------------------------------------------------------------ @@ -1045,7 +1089,7 @@ namespace frm Sequence< sal_Int16 > aSelectionIndicies; ORowSetValue aCurrentValue; - aCurrentValue.fill( impl_hasBoundComponent() ? m_nBoundColumnType : getFieldType(), m_xColumn ); + aCurrentValue.fill( getValueType(), m_xColumn ); // reset selection for NULL values if ( aCurrentValue.isNull() ) diff --git a/forms/source/component/ListBox.hxx b/forms/source/component/ListBox.hxx index cd1302c..d64a5a8 100644 --- a/forms/source/component/ListBox.hxx +++ b/forms/source/component/ListBox.hxx @@ -79,7 +79,9 @@ class OListBoxModel :public OBoundControlModel ::com::sun::star::form::ListSourceType m_eListSourceType; // type der list source ::com::sun::star::uno::Any m_aBoundColumn; ValueList m_aListSourceValues; - ValueList m_aBoundValues; + ValueList m_aBoundValues; // do not write directly; use setBoundValues() + mutable ValueList m_aConvertedBoundValues; + mutable sal_Int32 m_nConvertedBoundValuesType; ::com::sun::star::uno::Sequence<sal_Int16> m_aDefaultSelectSeq; // DefaultSelected // </properties> @@ -181,8 +183,15 @@ private: */ void impl_refreshDbEntryList( bool _bForce ); + void setBoundValues(const ValueList&); + void clearBoundValues(); + ValueList impl_getValues() const; + sal_Int32 getValueType() const; + + void convertBoundValues(sal_Int32 nType) const; + bool impl_hasBoundComponent() const { return m_nBoundColumnType != ::com::sun::star::sdbc::DataType::SQLNULL; } }; commit fc593ac601469a5d69274bbec539e58ad466fd67 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Feb 16 09:29:54 2012 +0100 correct indentation diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 9d947aa..2453ebc 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -896,9 +896,9 @@ namespace frm } } break; - default: - OSL_FAIL( "OListBoxModel::loadData: unreachable!" ); - break; + default: + OSL_FAIL( "OListBoxModel::loadData: unreachable!" ); + break; } } catch(const SQLException& eSQL) commit aef29c37fbe2bf2d248048c699972fb9e0ac2b4e Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Feb 16 09:06:26 2012 +0100 ORowSetValue::setTypeKind: correctly convert to (C)LOB/OBJECT/OTHER as opposed to crashing diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index 93a8c9d..acd1ef0 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -254,10 +254,10 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType) case DataType::CLOB: case DataType::OBJECT: case DataType::OTHER: - (*this) = getAny(); + (*this) = makeAny(); break; default: - (*this) = getAny(); + (*this) = makeAny(); OSL_FAIL("ORowSetValue::setTypeKind(): UNSUPPORTED TYPE!"); } } commit 05b294cbc14422f9c5897c0830eda57d141f78a3 Author: Lionel Elie Mamane <lio...@mamane.lu> Date: Thu Feb 16 09:11:08 2012 +0100 typo & copy/paste error in error message diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index bfa3b12..93a8c9d 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -258,7 +258,7 @@ void ORowSetValue::setTypeKind(sal_Int32 _eType) break; default: (*this) = getAny(); - OSL_FAIL("ORowSetValue:operator==(): UNSPUPPORTED TYPE!"); + OSL_FAIL("ORowSetValue::setTypeKind(): UNSUPPORTED TYPE!"); } } @@ -895,7 +895,7 @@ bool ORowSetValue::operator==(const ORowSetValue& _rRH) const break; default: bRet = false; - OSL_FAIL("ORowSetValue::operator==(): UNSPUPPORTED TYPE!"); + OSL_FAIL("ORowSetValue::operator==(): UNSUPPORTED TYPE!"); break; } return bRet; _______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits