From fec8c14e960fbcd639a04d6c3354caff2d0bd365 Mon Sep 17 00:00:00 2001 From: Lionel Elie Mamane Date: Tue, 6 Nov 2018 18:43:03 +0100 Subject: tdf#121188 form controls should have InputRequired false by default Unless the underlying column is not nullable and has no default value this is only a guess, form designer can change it Change-Id: Ifa403e00b21fdaf86aef383503d54879b25ac62b Reviewed-on: https://gerrit.libreoffice.org/62969 Reviewed-by: Lionel Elie Mamane Tested-by: Lionel Elie Mamane --- forms/source/component/FormComponent.cxx | 6 +++--- svx/source/form/formcontroller.cxx | 2 +- wizards/com/sun/star/wizards/common/PropertyNames.java | 3 +++ wizards/com/sun/star/wizards/form/FormControlArranger.java | 4 ++++ xmloff/source/forms/elementexport.cxx | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx index 7d4078a83fb5..1ab76f31f8ef 100644 --- a/forms/source/component/FormComponent.cxx +++ b/forms/source/component/FormComponent.cxx @@ -1137,7 +1137,7 @@ OBoundControlModel::OBoundControlModel( ,m_aResetHelper( *this, m_aMutex ) ,m_aUpdateListeners(m_aMutex) ,m_aFormComponentListeners( m_aMutex ) - ,m_bInputRequired( true ) + ,m_bInputRequired( false ) ,m_pAggPropMultiplexer( nullptr ) ,m_bFormListening( false ) ,m_bLoaded(false) @@ -1170,7 +1170,7 @@ OBoundControlModel::OBoundControlModel( ,m_aUpdateListeners( m_aMutex ) ,m_aFormComponentListeners( m_aMutex ) ,m_xValidator( _pOriginal->m_xValidator ) - ,m_bInputRequired( true ) + ,m_bInputRequired( false ) ,m_pAggPropMultiplexer( nullptr ) ,m_bFormListening( false ) ,m_bLoaded( false ) @@ -1676,7 +1676,7 @@ Any OBoundControlModel::getPropertyDefaultByHandle( sal_Int32 _nHandle ) const switch ( _nHandle ) { case PROPERTY_ID_INPUT_REQUIRED: - aDefault <<= true; + aDefault <<= false; break; case PROPERTY_ID_CONTROLSOURCE: aDefault <<= OUString(); diff --git a/svx/source/form/formcontroller.cxx b/svx/source/form/formcontroller.cxx index 504158432591..7552baf7bf7a 100644 --- a/svx/source/form/formcontroller.cxx +++ b/svx/source/form/formcontroller.cxx @@ -302,7 +302,7 @@ namespace bool lcl_isInputRequired( const Reference< XPropertySet >& _rxControlModel ) { - bool bInputRequired = true; + bool bInputRequired = false; OSL_VERIFY( _rxControlModel->getPropertyValue( FM_PROP_INPUT_REQUIRED ) >>= bInputRequired ); return bInputRequired; } diff --git a/wizards/com/sun/star/wizards/common/PropertyNames.java b/wizards/com/sun/star/wizards/common/PropertyNames.java index 2d7cdd865336..5e5df5c879e1 100644 --- a/wizards/com/sun/star/wizards/common/PropertyNames.java +++ b/wizards/com/sun/star/wizards/common/PropertyNames.java @@ -20,6 +20,9 @@ package com.sun.star.wizards.common; public class PropertyNames { + public static String PROPERTY_DEFAULT_VALUE = "DefaultValue"; + public static String PROPERTY_IS_NULLABLE = "IsNullable"; + public static String PROPERTY_INPUT_REQUIRED = "InputRequired"; public static String PROPERTY_ENABLED = "Enabled"; public static String PROPERTY_HEIGHT = "Height"; public static String PROPERTY_HELPURL = "HelpURL"; diff --git a/wizards/com/sun/star/wizards/form/FormControlArranger.java b/wizards/com/sun/star/wizards/form/FormControlArranger.java index 9a46928ac045..a1eacc71366d 100644 --- a/wizards/com/sun/star/wizards/form/FormControlArranger.java +++ b/wizards/com/sun/star/wizards/form/FormControlArranger.java @@ -21,6 +21,7 @@ import com.sun.star.awt.Point; import com.sun.star.awt.Size; import com.sun.star.container.XNameContainer; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdbc.ColumnValue; import com.sun.star.sdbc.DataType; import com.sun.star.task.XStatusIndicator; import com.sun.star.uno.AnyConverter; @@ -588,6 +589,8 @@ public class FormControlArranger { String sFieldName = FieldColumns[i].getFieldName(); int nFieldType = FieldColumns[i].getFieldType(); + boolean bFieldNullable = AnyConverter.toInt(FieldColumns[i].getXColumnPropertySet().getPropertyValue(PropertyNames.PROPERTY_IS_NULLABLE)) != ColumnValue.NO_NULLS; + boolean bFieldHasDefaultValue = !AnyConverter.toString(FieldColumns[i].getXColumnPropertySet().getPropertyValue(PropertyNames.PROPERTY_DEFAULT_VALUE)).isEmpty(); Point aPoint = new Point(m_currentControlPosX, m_currentControlPosY); if (bControlsareCreated) @@ -629,6 +632,7 @@ public class FormControlArranger } checkOuterPoints(m_currentControlPosX, m_dbControlWidth, m_currentControlPosY, m_dbControlHeight, true); aDBControl.setPropertyValue(PropertyNames.PROPERTY_BORDER, NBorderType); + aDBControl.setPropertyValue(PropertyNames.PROPERTY_INPUT_REQUIRED, !(bFieldNullable || bFieldHasDefaultValue)); } catch (Exception e) { diff --git a/xmloff/source/forms/elementexport.cxx b/xmloff/source/forms/elementexport.cxx index 288b110f67f6..d0fee7480896 100644 --- a/xmloff/source/forms/elementexport.cxx +++ b/xmloff/source/forms/elementexport.cxx @@ -835,7 +835,7 @@ namespace xmloff OAttributeMetaData::getDatabaseAttributeNamespace(), OAttributeMetaData::getDatabaseAttributeName( DAFlags::InputRequired ), PROPERTY_INPUT_REQUIRED, - BoolAttrFlags::DefaultTrue + BoolAttrFlags::DefaultFalse ); RESET_BIT( nIncludeDatabase, DAFlags::InputRequired ); } -- cgit v1.2.3