[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - forms/source svx/source wizards/com xmloff/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Nov 9 16:17:57 UTC 2018


 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(-)

New commits:
commit 17c87566e84ac433645f264a9bee4cb5ddbd23a5
Author:     Lionel Elie Mamane <lionel at mamane.lu>
AuthorDate: Tue Nov 6 18:43:03 2018 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Nov 9 17:15:47 2018 +0100

    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/62968
    Tested-by: Lionel Elie Mamane <lionel at mamane.lu>
    Tested-by: Tamás Bunth <btomi96 at gmail.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/forms/source/component/FormComponent.cxx b/forms/source/component/FormComponent.cxx
index 05ed6dc5018d..89b02f5f215d 100644
--- a/forms/source/component/FormComponent.cxx
+++ b/forms/source/component/FormComponent.cxx
@@ -1136,7 +1136,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)
@@ -1169,7 +1169,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 )
@@ -1675,7 +1675,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 f3a10ee3c0da..0ae665b4e4eb 100644
--- a/svx/source/form/formcontroller.cxx
+++ b/svx/source/form/formcontroller.cxx
@@ -301,7 +301,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 3ba0762e9623..4bf3e1c2c205 100644
--- a/xmloff/source/forms/elementexport.cxx
+++ b/xmloff/source/forms/elementexport.cxx
@@ -837,7 +837,7 @@ namespace xmloff
                 OAttributeMetaData::getDatabaseAttributeNamespace(),
                 OAttributeMetaData::getDatabaseAttributeName( DAFlags::InputRequired ),
                 PROPERTY_INPUT_REQUIRED,
-                BoolAttrFlags::DefaultTrue
+                BoolAttrFlags::DefaultFalse
             );
             RESET_BIT( nIncludeDatabase, DAFlags::InputRequired );
         }


More information about the Libreoffice-commits mailing list