diff options
-rw-r--r-- | connectivity/source/commontools/FValue.cxx | 2 | ||||
-rw-r--r-- | connectivity/source/commontools/dbtools.cxx | 2 | ||||
-rw-r--r-- | forms/source/component/CheckBox.cxx | 37 | ||||
-rw-r--r-- | forms/source/component/CheckBox.hxx | 1 |
4 files changed, 37 insertions, 5 deletions
diff --git a/connectivity/source/commontools/FValue.cxx b/connectivity/source/commontools/FValue.cxx index c6c038f72c19..46fe62fdc3d5 100644 --- a/connectivity/source/commontools/FValue.cxx +++ b/connectivity/source/commontools/FValue.cxx @@ -26,6 +26,8 @@ #include <comphelper/extract.hxx> #include <com/sun/star/io/XInputStream.hpp> #include <rtl/ustrbuf.hxx> +#include <boost/type_traits.hpp> +#include <boost/static_assert.hpp> using namespace ::dbtools; using namespace ::com::sun::star::sdbc; diff --git a/connectivity/source/commontools/dbtools.cxx b/connectivity/source/commontools/dbtools.cxx index 6ba64ddff9ed..e54ab300f17a 100644 --- a/connectivity/source/commontools/dbtools.cxx +++ b/connectivity/source/commontools/dbtools.cxx @@ -1905,7 +1905,7 @@ void setObjectWithInfo(const Reference<XParameters>& _xParams, break; case DataType::BIT: case DataType::BOOLEAN: - _xParams->setBoolean(parameterIndex,_rValue); + _xParams->setBoolean(parameterIndex,static_cast<bool>(_rValue)); break; case DataType::TINYINT: if ( _rValue.isSigned() ) diff --git a/forms/source/component/CheckBox.cxx b/forms/source/component/CheckBox.cxx index 67751f218f53..9d352f08d382 100644 --- a/forms/source/component/CheckBox.cxx +++ b/forms/source/component/CheckBox.cxx @@ -203,6 +203,13 @@ void SAL_CALL OCheckBoxModel::read(const Reference<stario::XObjectInputStream>& resetNoBroadcast(); } +bool OCheckBoxModel::DbUseBool() +{ + if ( ! (getReferenceValue().isEmpty() && getNoCheckReferenceValue().isEmpty()) ) + return false; + return true; +} + //------------------------------------------------------------------------------ Any OCheckBoxModel::translateDbColumnToControlValue() { @@ -210,7 +217,21 @@ Any OCheckBoxModel::translateDbColumnToControlValue() ////////////////////////////////////////////////////////////////// // Set value in ControlModel - sal_Bool bValue = m_xColumn->getBoolean(); + bool bValue; + if(DbUseBool()) + { + bValue = m_xColumn->getBoolean(); + } + else + { + const OUString sVal(m_xColumn->getString()); + if (sVal == getReferenceValue()) + bValue = true; + else if (sVal == getNoCheckReferenceValue()) + bValue = false; + else + aValue <<= static_cast<sal_Int16>(getDefaultChecked()); + } if ( m_xColumn->wasNull() ) { sal_Bool bTriState = sal_True; @@ -218,8 +239,10 @@ Any OCheckBoxModel::translateDbColumnToControlValue() m_xAggregateSet->getPropertyValue( PROPERTY_TRISTATE ) >>= bTriState; aValue <<= (sal_Int16)( bTriState ? STATE_DONTKNOW : getDefaultChecked() ); } - else + else if ( !aValue.hasValue() ) + { aValue <<= (sal_Int16)( bValue ? STATE_CHECK : STATE_NOCHECK ); + } return aValue; } @@ -241,10 +264,16 @@ sal_Bool OCheckBoxModel::commitControlValueToDbColumn( bool /*_bPostReset*/ ) m_xColumnUpdate->updateNull(); break; case STATE_CHECK: - m_xColumnUpdate->updateBoolean( sal_True ); + if (DbUseBool()) + m_xColumnUpdate->updateBoolean( sal_True ); + else + m_xColumnUpdate->updateString( getReferenceValue() ); break; case STATE_NOCHECK: - m_xColumnUpdate->updateBoolean( sal_False ); + if (DbUseBool()) + m_xColumnUpdate->updateBoolean( sal_False ); + else + m_xColumnUpdate->updateString( getNoCheckReferenceValue() ); break; default: OSL_FAIL("OCheckBoxModel::commitControlValueToDbColumn: invalid value !"); diff --git a/forms/source/component/CheckBox.hxx b/forms/source/component/CheckBox.hxx index c44ed5b0d696..8cc95234d11a 100644 --- a/forms/source/component/CheckBox.hxx +++ b/forms/source/component/CheckBox.hxx @@ -33,6 +33,7 @@ class OCheckBoxModel :public OReferenceValueComponent { protected: sal_Int16 getState(const ::com::sun::star::uno::Any& rValue); + bool DbUseBool(); public: DECLARE_DEFAULT_LEAF_XTOR( OCheckBoxModel ); |