Kaydet (Commit) 88df38f4 authored tarafından Frank Schönheit's avatar Frank Schönheit

#i109081# translateDbColumnToControlValue: force the current value to be the…

#i109081# translateDbColumnToControlValue: force the current value to be the same type as our bound field (if we have one), since the values we will compare it with will also have this type
üst 51a5e616
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
/** === begin UNO includes === **/ /** === begin UNO includes === **/
#include <com/sun/star/util/XNumberFormatTypes.hpp> #include <com/sun/star/util/XNumberFormatTypes.hpp>
#include <com/sun/star/sdbc/XRowSet.hpp> #include <com/sun/star/sdbc/XRowSet.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
#include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/container/XIndexAccess.hpp>
#include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp> #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
#include <com/sun/star/sdb/XQueriesSupplier.hpp> #include <com/sun/star/sdb/XQueriesSupplier.hpp>
...@@ -167,7 +166,7 @@ namespace frm ...@@ -167,7 +166,7 @@ namespace frm
,OErrorBroadcaster( OComponentHelper::rBHelper ) ,OErrorBroadcaster( OComponentHelper::rBHelper )
,m_aListRowSet( getContext() ) ,m_aListRowSet( getContext() )
,m_nNULLPos(-1) ,m_nNULLPos(-1)
,m_bBoundComponent(sal_False) ,m_nBoundColumnType( DataType::SQLNULL )
{ {
DBG_CTOR(OListBoxModel,NULL); DBG_CTOR(OListBoxModel,NULL);
...@@ -189,7 +188,7 @@ namespace frm ...@@ -189,7 +188,7 @@ namespace frm
,m_aBoundValues( _pOriginal->m_aBoundValues ) ,m_aBoundValues( _pOriginal->m_aBoundValues )
,m_aDefaultSelectSeq( _pOriginal->m_aDefaultSelectSeq ) ,m_aDefaultSelectSeq( _pOriginal->m_aDefaultSelectSeq )
,m_nNULLPos(-1) ,m_nNULLPos(-1)
,m_bBoundComponent(sal_False) ,m_nBoundColumnType( DataType::SQLNULL )
{ {
DBG_CTOR(OListBoxModel,NULL); DBG_CTOR(OListBoxModel,NULL);
} }
...@@ -629,7 +628,7 @@ namespace frm ...@@ -629,7 +628,7 @@ namespace frm
DBG_ASSERT( !hasExternalListSource(), "OListBoxModel::loadData: cannot load from DB when I have an external list source!" ); DBG_ASSERT( !hasExternalListSource(), "OListBoxModel::loadData: cannot load from DB when I have an external list source!" );
m_nNULLPos = -1; m_nNULLPos = -1;
m_bBoundComponent = sal_False; m_nBoundColumnType = DataType::SQLNULL;
// pre-requisites: // pre-requisites:
// PRE1: connection // PRE1: connection
...@@ -832,20 +831,19 @@ namespace frm ...@@ -832,20 +831,19 @@ namespace frm
::dbtools::FormattedColumnValue aValueFormatter( getContext(), m_xCursor, xDataField ); ::dbtools::FormattedColumnValue aValueFormatter( getContext(), m_xCursor, xDataField );
// Feld der BoundColumn des ResultSets holen // Feld der BoundColumn des ResultSets holen
sal_Int32 nBoundColumnType = DataType::SQLNULL; m_nBoundColumnType = DataType::SQLNULL;
if ( ( nBoundColumn > 0 ) && m_xColumn.is() ) if ( ( nBoundColumn > 0 ) && m_xColumn.is() )
{ // don't look for a bound column if we're not connected to a field { // don't look for a bound column if we're not connected to a field
try try
{ {
Reference< XPropertySet > xBoundField( xColumns->getByIndex( nBoundColumn ), UNO_QUERY_THROW ); Reference< XPropertySet > xBoundField( xColumns->getByIndex( nBoundColumn ), UNO_QUERY_THROW );
OSL_VERIFY( xBoundField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= nBoundColumnType ); OSL_VERIFY( xBoundField->getPropertyValue( ::rtl::OUString::createFromAscii( "Type" ) ) >>= m_nBoundColumnType );
} }
catch( const Exception& ) catch( const Exception& )
{ {
DBG_UNHANDLED_EXCEPTION(); DBG_UNHANDLED_EXCEPTION();
} }
} }
m_bBoundComponent = ( nBoundColumnType != DataType::SQLNULL );
// Ist die LB an ein Feld gebunden und sind Leereintraege zulaessig // Ist die LB an ein Feld gebunden und sind Leereintraege zulaessig
// dann wird die Position fuer einen Leereintrag gemerkt // dann wird die Position fuer einen Leereintrag gemerkt
...@@ -860,9 +858,9 @@ namespace frm ...@@ -860,9 +858,9 @@ namespace frm
aStr = aValueFormatter.getFormattedValue(); aStr = aValueFormatter.getFormattedValue();
aDisplayList.push_back( aStr ); aDisplayList.push_back( aStr );
if ( m_bBoundComponent ) if ( impl_hasBoundComponent() )
{ {
aBoundValue.fill( nBoundColumn + 1, nBoundColumnType, xCursorRow ); aBoundValue.fill( nBoundColumn + 1, m_nBoundColumnType, xCursorRow );
aValueList.push_back( aBoundValue ); aValueList.push_back( aBoundValue );
} }
...@@ -907,7 +905,7 @@ namespace frm ...@@ -907,7 +905,7 @@ namespace frm
// NULL eintrag hinzufuegen // NULL eintrag hinzufuegen
if (bUseNULL && m_nNULLPos == -1) if (bUseNULL && m_nNULLPos == -1)
{ {
if ( m_bBoundComponent ) if ( impl_hasBoundComponent() )
aValueList.insert( aValueList.begin(), ORowSetValue() ); aValueList.insert( aValueList.begin(), ORowSetValue() );
aDisplayList.insert( aDisplayList.begin(), ORowSetValue( ::rtl::OUString() ) ); aDisplayList.insert( aDisplayList.begin(), ORowSetValue( ::rtl::OUString() ) );
...@@ -940,7 +938,7 @@ namespace frm ...@@ -940,7 +938,7 @@ namespace frm
{ {
ValueList().swap(m_aBoundValues); ValueList().swap(m_aBoundValues);
m_nNULLPos = -1; m_nNULLPos = -1;
m_bBoundComponent = sal_False; m_nBoundColumnType = DataType::SQLNULL;
if ( !hasExternalListSource() ) if ( !hasExternalListSource() )
setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( StringSequence() ) ); setFastPropertyValue( PROPERTY_ID_STRINGITEMLIST, makeAny( StringSequence() ) );
...@@ -1035,7 +1033,7 @@ namespace frm ...@@ -1035,7 +1033,7 @@ namespace frm
Sequence< sal_Int16 > aSelectionIndicies; Sequence< sal_Int16 > aSelectionIndicies;
ORowSetValue aCurrentValue; ORowSetValue aCurrentValue;
aCurrentValue.fill( getFieldType(), m_xColumn ); aCurrentValue.fill( impl_hasBoundComponent() ? m_nBoundColumnType : getFieldType(), m_xColumn );
// reset selection for NULL values // reset selection for NULL values
if ( aCurrentValue.isNull() ) if ( aCurrentValue.isNull() )
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <com/sun/star/awt/XFocusListener.hpp> #include <com/sun/star/awt/XFocusListener.hpp>
#include <com/sun/star/awt/XListBox.hpp> #include <com/sun/star/awt/XListBox.hpp>
#include <com/sun/star/form/XChangeBroadcaster.hpp> #include <com/sun/star/form/XChangeBroadcaster.hpp>
#include <com/sun/star/sdbc/DataType.hpp>
/** === end UNO includes === **/ /** === end UNO includes === **/
#include <comphelper/asyncnotification.hxx> #include <comphelper/asyncnotification.hxx>
...@@ -82,7 +83,7 @@ class OListBoxModel :public OBoundControlModel ...@@ -82,7 +83,7 @@ class OListBoxModel :public OBoundControlModel
// </properties> // </properties>
sal_Int16 m_nNULLPos; // position of the NULL value in our list sal_Int16 m_nNULLPos; // position of the NULL value in our list
sal_Bool m_bBoundComponent : 1; sal_Int32 m_nBoundColumnType;
private: private:
::connectivity::ORowSetValue getFirstSelectedValue() const; ::connectivity::ORowSetValue getFirstSelectedValue() const;
...@@ -177,6 +178,8 @@ private: ...@@ -177,6 +178,8 @@ private:
void impl_refreshDbEntryList( bool _bForce ); void impl_refreshDbEntryList( bool _bForce );
ValueList impl_getValues() const; ValueList impl_getValues() const;
bool impl_hasBoundComponent() const { return m_nBoundColumnType != ::com::sun::star::sdbc::DataType::SQLNULL; }
}; };
//================================================================== //==================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment