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 --- wizards/com/sun/star/wizards/common/PropertyNames.java | 3 +++ wizards/com/sun/star/wizards/form/FormControlArranger.java | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'wizards/com') 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) { -- cgit v1.2.3