Bug 155121 - XML Form Document: Impossible to create a user defined data type and set field as "not required"
Summary: XML Form Document: Impossible to create a user defined data type and set fiel...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Julien Nabet
URL:
Whiteboard: target:7.6.0 target:7.5.4
Keywords:
Depends on:
Blocks: XML_Form
  Show dependency treegraph
 
Reported: 2023-05-02 09:55 UTC by Robert Großkopf
Modified: 2023-05-17 10:23 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
XML form document with two fields, user defined data (72.65 KB, application/vnd.oasis.opendocument.text)
2023-05-02 09:55 UTC, Robert Großkopf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2023-05-02 09:55:52 UTC
Created attachment 187049 [details]
XML form document with two fields, user defined data

Open the attached XML form document.
There are 2 form fields.
Both fields haven't filled with content.
Both fields will appear with red border.
First field will change color with 5 digits, second field will need 5 characters (also digits possible).

Now have a look at the properties for this fields. You could get them from the bindings, the entry in Instance 1 or direct from the properties of the form control.
Data → Required isn't set.
But there is set for both field a user create data type.
The control will always react as if Data → Required is set.

So it is impossible to set something like "let it blank or put 5 digits for a postcode".

Bug appears in all LO versions here.
Comment 1 Buovjaga 2023-05-12 14:42:06 UTC
The red border indication only appears with 4829a85d0753c93419bd46b1d50bcfa6f0f3f1da
tdf#154734: XML Form doc: all binded fields will be shown as fields...

Julien: maybe you are interested in this.
Comment 2 Julien Nabet 2023-05-14 11:26:22 UTC
I gave a try with https://gerrit.libreoffice.org/c/core/+/151733
Comment 3 Julien Nabet 2023-05-14 11:30:51 UTC
Remark: I noticed that to set the field as required, you must put "1" (without quotes in the field). I thought that putting "true" would be the right way.
Comment 4 Commit Notification 2023-05-14 12:17:16 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/aa0cbe2c82bbc2295b51357378a68da0d64a44a0

tdf#155121: XML Form Document: better take into account "not required"

It will be available in 7.6.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 5 Julien Nabet 2023-05-14 12:18:47 UTC
Robert: not sure it's completely ok (I mean perhaps it has some negative impact I didn't see) so before I cherry-pick this for 7.5 branch, would it be possible you give it a try once a daily build will be available with the commit?
Comment 6 Robert Großkopf 2023-05-14 12:27:11 UTC
(In reply to Julien Nabet from comment #3)
> Remark: I noticed that to set the field as required, you must put "1"
> (without quotes in the field). I thought that putting "true" would be the
> right way.

If I set required in Binding or Instance of a field it will appear as "true()" in control properties → data → Required. But I don't want to set this for user defined data.

The red border will also appear in older versions of LO. Had appeared when I wrote the first description for xml form documents in LO 6.0. Could see this red border for user defined data type in LO 5.4.6.2 here also. 

I will have a look at the daily build, which includes this patch.
Comment 7 Julien Nabet 2023-05-14 18:41:08 UTC
(In reply to Robert Großkopf from comment #6)
> (In reply to Julien Nabet from comment #3)
> > Remark: I noticed that to set the field as required, you must put "1"
> > (without quotes in the field). I thought that putting "true" would be the
> > right way.
> 
> If I set required in Binding or Instance of a field it will appear as
> "true()" in control properties → data → Required. But I don't want to set
> this for user defined data.
No pb, it was just a remark during some local tests I did.

> 
> The red border will also appear in older versions of LO. Had appeared when I
> wrote the first description for xml form documents in LO 6.0. Could see this
> red border for user defined data type in LO 5.4.6.2 here also. 
Quite expected since the patch https://git.libreoffice.org/core/+/4829a85d0753c93419bd46b1d50bcfa6f0f3f1da%5E%21 shows that logic was just  reversed.
Comment 8 Robert Großkopf 2023-05-16 13:30:14 UTC
Tested with
Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 22950a9b008e1bb22fa9e54b5d45715e25fee764
CPU threads: 6; OS: Linux 5.14; UI render: default; VCL: kf5 (cairo+xcb)
Locale: de-DE (de_DE.UTF-8); UI: en-US
Calc: threaded

(2023-05-16)

It will work now as expected. Great!
Set this one to RESOLVED → FIXED
Comment 9 Julien Nabet 2023-05-16 16:28:42 UTC
(In reply to Robert Großkopf from comment #8)
> Tested with
> Version: 7.6.0.0.alpha1+ (X86_64) / LibreOffice Community
> Build ID: 22950a9b008e1bb22fa9e54b5d45715e25fee764
> CPU threads: 6; OS: Linux 5.14; UI render: default; VCL: kf5 (cairo+xcb)
> Locale: de-DE (de_DE.UTF-8); UI: en-US
> Calc: threaded
> 
> (2023-05-16)
> 
> It will work now as expected. Great!
> Set this one to RESOLVED → FIXED

Thank you Robert for the feedback! :-)
Comment 10 Julien Nabet 2023-05-16 16:29:56 UTC
Here's the cherry-pick for 7.5 branch:
https://gerrit.libreoffice.org/c/core/+/151780

Now, it needs to be reviewed by a dev.
Comment 11 Commit Notification 2023-05-17 10:23:50 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/be01da8c3020fec008307ab76b6cc89992381f02

tdf#155121: XML Form Document: better take into account "not required"

It will be available in 7.5.4.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.