summaryrefslogtreecommitdiff
path: root/forms
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-10-14 17:59:10 +0200
committerLionel Elie Mamane <lionel@mamane.lu>2013-10-16 18:45:22 +0200
commitffff47459274d6187bb0ea6533f5acc0e7b7ed92 (patch)
tree721770583045fad6a5dc218aac4d08c449483021 /forms
parentd9eac2ceb8c75c7219e7a6f50a3d774be311228b (diff)
respect reference values in checkboxes
Change-Id: Ifd0953f779f530af6b190425794f009a891f0afb
Diffstat (limited to 'forms')
-rw-r--r--forms/source/component/CheckBox.cxx37
-rw-r--r--forms/source/component/CheckBox.hxx1
2 files changed, 34 insertions, 4 deletions
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 );