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

New commits:
commit be01da8c3020fec008307ab76b6cc89992381f02
Author:     Julien Nabet <serval2...@yahoo.fr>
AuthorDate: Sun May 14 13:22:07 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Wed May 17 12:23:26 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>
    (cherry picked from commit aa0cbe2c82bbc2295b51357378a68da0d64a44a0)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151780
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/forms/source/xforms/binding.cxx b/forms/source/xforms/binding.cxx
index 4341daa7331f..a28388c64c72 100644
--- a/forms/source/xforms/binding.cxx
+++ b/forms/source/xforms/binding.cxx
@@ -208,7 +208,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