diff options
Diffstat (limited to 'forms/source/component/ListBox.cxx')
-rw-r--r-- | forms/source/component/ListBox.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/forms/source/component/ListBox.cxx b/forms/source/component/ListBox.cxx index 3b92933fc..6fc447718 100644 --- a/forms/source/component/ListBox.cxx +++ b/forms/source/component/ListBox.cxx @@ -65,6 +65,8 @@ #include <unotools/sharedunocomponent.hxx> #include <vcl/svapp.hxx> +#include <boost/optional.hpp> + #include <algorithm> #include <functional> @@ -678,9 +680,13 @@ namespace frm return; } - sal_Int16 nBoundColumn = 0; - if (m_aBoundColumn.getValueType().getTypeClass() == TypeClass_SHORT) + ::boost::optional< sal_Int16 > aBoundColumn; + if ( m_aBoundColumn.getValueType().getTypeClass() == TypeClass_SHORT ) + { + sal_Int16 nBoundColumn( 0 ); m_aBoundColumn >>= nBoundColumn; + aBoundColumn.reset( nBoundColumn ); + } ::utl::SharedUNOComponent< XResultSet > xListCursor; try @@ -704,14 +710,14 @@ namespace frm ::rtl::OUString aFieldName; ::rtl::OUString aBoundFieldName; - if ((nBoundColumn > 0) && xFieldsByIndex.is()) + if ( !!aBoundColumn && ( *aBoundColumn >= 0 ) && xFieldsByIndex.is() ) { - if (xFieldsByIndex->getCount() <= nBoundColumn) + if ( *aBoundColumn >= xFieldsByIndex->getCount() ) break; - Reference<XPropertySet> xFieldAsSet(xFieldsByIndex->getByIndex(nBoundColumn),UNO_QUERY); + Reference<XPropertySet> xFieldAsSet(xFieldsByIndex->getByIndex( *aBoundColumn ),UNO_QUERY); xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aBoundFieldName; - nBoundColumn = 1; + aBoundColumn.reset( 1 ); xFieldAsSet.set(xFieldsByIndex->getByIndex(0),UNO_QUERY); xFieldAsSet->getPropertyValue(PROPERTY_NAME) >>= aFieldName; @@ -841,11 +847,11 @@ namespace frm // Feld der BoundColumn des ResultSets holen m_nBoundColumnType = DataType::SQLNULL; - if ( ( nBoundColumn > 0 ) && m_xColumn.is() ) + if ( !!aBoundColumn && ( *aBoundColumn >= 0 ) && m_xColumn.is() ) { // don't look for a bound column if we're not connected to a field try { - Reference< XPropertySet > xBoundField( xColumns->getByIndex( nBoundColumn ), UNO_QUERY_THROW ); + Reference< XPropertySet > xBoundField( xColumns->getByIndex( *aBoundColumn ), UNO_QUERY_THROW ); OSL_VERIFY( xBoundField->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Type") ) ) >>= m_nBoundColumnType ); } catch( const Exception& ) @@ -869,7 +875,7 @@ namespace frm if ( impl_hasBoundComponent() ) { - aBoundValue.fill( nBoundColumn + 1, m_nBoundColumnType, xCursorRow ); + aBoundValue.fill( *aBoundColumn + 1, m_nBoundColumnType, xCursorRow ); aValueList.push_back( aBoundValue ); } |