Bug 120224 - Reference field to text field in DOCX becomes broken after save
Summary: Reference field to text field in DOCX becomes broken after save
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:6.2.0 target:6.4.0 target:25.2...
Keywords: filter:docx
Depends on:
Blocks: DOCX-ActiveX-Legacy Fields-Cross-Reference DOCX-Fields
  Show dependency treegraph
 
Reported: 2018-10-01 02:41 UTC by Aron Budea
Modified: 2024-10-04 07:25 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
Sample DOCX (15.97 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-10-01 02:41 UTC, Aron Budea
Details
Roundtripped broken DOCX (10.35 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-10-01 02:43 UTC, Aron Budea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2018-10-01 02:41:50 UTC
Created attachment 145284 [details]
Sample DOCX

The attached DOCX file contains a Text Form Field (Legacy Form control), which has a bookmark (Text1). It also contains a cross reference (field of type Ref) referencing the bookmark. The document is protected, only filling in the form is allowed.
If the text field is filled, when previewing Print, the reference is updated (in Writer this has to be the Print dialog, Print Preview doesn't have the same effect; alternatively press F9).

- In Writer, fill the text field, and press F9.
- Save and reopen file.
- Type something else in the text field, press F9.

=> Referencing field becomes empty, which means the cross reference got broken during save.
Same effect if the changed file is opened in Word, after updating fields, the referencing field becomes empty.

Observed using LO 6.2 daily build (2018-09-2, 8b1501d80dc9d3f42c351c6e026fa737e116cae5), 4.0.0.3 / Windows 7.
In 3.5.0.3 the behavior is worse.
Comment 1 Aron Budea 2018-10-01 02:43:44 UTC
Created attachment 145285 [details]
Roundtripped broken DOCX
Comment 2 Thomas Lendo 2018-10-01 07:50:35 UTC
Reproduced with 6.2.0.0.alpha0+ (x64)
Build ID: 89a60912bba7ffd6f65ea99f4664f343c5025c95
CPU threads: 8; OS: Windows 10.0; UI render: GL; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-10-01_03:18:33
Locale: de-AT (de_AT); Calc: CL

For me there is no difference if I edit the docx file (e.g. to force field updated with F9) or to only open the docx and save it without doing anything.

After reopening, pressing F9 makes the reference field empty.

BTW the Text Form Field (Legacy Form control) isn't editable in Writer.
Comment 3 Justin L 2018-10-05 06:36:43 UTC
confirmed likely inherited from OOo based on bibisect-43all. Spot checks suggest this has never worked.

To play around with this document, you can unprotect it via tools-options-Writer-Compatibility and unchecking Protect Form.

It appears that the bookmark (or whatever terminology is correct) is still there, because if I Insert->CrossReference->Type=Bookmark,InsertRefTo=Reference,Selection=Text111
then I again get the contents of the text form field (and this time it is preserved across round-trips, although two more bookmarks are again added...)
Comment 4 Justin L 2018-10-10 12:47:23 UTC
The commit comments clearly show that I am not at all confident in working on this bug. But the results of these patches work very nicely on this test document, and don't break any of the two existing unit tests featuring text controls (fdo53985.docx and tdf111964.docx) - which is all I have to work with.

https://gerrit.libreoffice.org/61615 tdf120224 writerfilter: consume excess bookmark from fields
https://gerrit.libreoffice.org/61616 tdf120224 docx export: don't double up field bookmarks
Comment 5 Justin L 2018-10-12 06:50:44 UTC
fixed in 6.2 with commits 579c0749bef8c980507229439715e72060c1b077 and 0a452b5005744d96f37fcb29b37a84e23a04bf8e.
Comment 6 Commit Notification 2019-10-23 11:05:41 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

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

tdf#120224 writerfilter: don't suppress all bookmarks inside fields

It will be available in 6.4.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 7 Commit Notification 2024-09-28 18:47:43 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7f84c993d3d2b5f05b18e740fea960901da57f80

tdf#163154 revert "tdf120224 writerfilter: consume excess bookmark

It will be available in 25.2.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 8 Commit Notification 2024-09-30 10:25:38 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-24-8":

https://git.libreoffice.org/core/commit/9eacd3d6dda69b7c7c22c5168508287a10204b57

tdf#163154 revert "tdf120224 writerfilter: consume excess bookmark

It will be available in 24.8.3.

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 9 Commit Notification 2024-10-04 07:25:59 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-24-2":

https://git.libreoffice.org/core/commit/1a4baa7d2907a9a3317b25762cbe11ae27389fea

tdf#163154 revert "tdf120224 writerfilter: consume excess bookmark

It will be available in 24.2.7.

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.