forms/source/xforms/binding.cxx |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

New commits:
commit aa0cbe2c82bbc2295b51357378a68da0d64a44a0
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sun May 14 13:22:07 2023 +0200
Commit:     Julien Nabet <serval2...@yahoo.fr>
CommitDate: Sun May 14 14:17:00 2023 +0200

    tdf#155121: XML Form Document: better take into account "not required"
    
    Change-Id: Ibebdbc52f2bd7d09ec7aa5f072efef364249a291
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151733
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2...@yahoo.fr>

diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx
index 57d3727c6b97..b9f111a7e49e 100644
--- a/forms/source/xforms/binding.cxx
+++ b/forms/source/xforms/binding.cxx
@@ -207,7 +207,14 @@ bool Binding::isValid() const
 {
     // TODO: determine whether node is suitable, not just whether it exists
     return maBindingExpression.getNode().is() &&
-        isValid_DataType() &&
+        (
+            // tdf#155121, validity rules should be apply when field is 
required or
+            // when the field is not required but not empty
+            // so if the field is not required and empty, do not check validity
+            (! maMIP.isRequired() && maBindingExpression.hasValue()
+               && maBindingExpression.getString().isEmpty() ) ||
+            isValid_DataType()
+        ) &&
         maMIP.isConstraint() &&
         ( ! maMIP.isRequired() ||
              ( maBindingExpression.hasValue() &&

Reply via email to