Bug 120225 - FILEOPEN Reference field to text field in DOC is broken
Summary: FILEOPEN Reference field to text field in DOC is broken
Status: VERIFIED 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
Keywords: filter:doc
Depends on:
Blocks: Fields-Cross-Reference DOC-Forms 121067 121099
  Show dependency treegraph
 
Reported: 2018-10-01 02:51 UTC by Aron Budea
Modified: 2018-11-01 17:07 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample DOC (26.50 KB, application/msword)
2018-10-01 02:51 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:51:20 UTC
Created attachment 145286 [details]
Sample DOC

The attached DOC 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).

- Open the document in Writer.

=> Referencing field reads "Error: Reference source not found", ie. reference is broken upon import.

Observed using LO 6.2 daily build (2018-09-22, 8b1501d80dc9d3f42c351c6e026fa737e116cae5), 3.3.0 / Windows 7.
Comment 1 Thomas Lendo 2018-10-01 07:42:43 UTC
Confirmed 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

STR:
1. Open MSO Word.
2. Activate the 'Developer tools' ribbon. (Click the File tab. Click Options. Click Customize Ribbon. Under Customize the Ribbon and under Main Tabs, select the Developer check box.)
3. In the Controls group (German: Steuerlemente) click 'Legacy Tools' (German: Vorversionstools) and then click the Text Form Field tool (German: 'Textfeld (Formularsteuerelement)').
4. Right-click (or double-click) the form field just entered and choose Properties. In the Text Form Field Options dialog, type something in the 'Default text' field and click OK.
5. Insert a text mark reference into the document. (The reference should show the same text as the text form field does.)
6. Save the file as doc.
7. Open LibreOffice.
8. Open the saved file.

Actual result:
The reference shows 'Error: Reference source not found'.

Expected result:
Same text in the reference as in the text form field.
Comment 2 Justin L 2018-10-04 08:19:40 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.
Comment 3 Justin L 2018-10-09 04:36:34 UTC
A bookmark is not created when the it comes from a FORMTEXT (type == BOOK_FIELD). https://cgit.freedesktop.org/libreoffice/core/commit/?id=c535a76dcb550f6b9e98268f49cec1a7c8986156

If I did my back-tracing correctly, this is related to OOo bug
https://bz.apache.org/ooo/show_bug.cgi?id=33737 which didn't suggest any great insights into this particular bug, but does indicate that this is a difficult and contentious area to play around in, especially for corporate customers.

Setting the type to BOOK_NORMAL [instead of ww8par3.cxx pB->SetStatus(bkmFindIdx, BOOK_FIELD)] allows the imported reference to work, but exporting breaks ww8export's testBnc636128 somehow - probably because it turns this "fake" bookmark into a real one.

All of that is probably irrelevant though, since the name of the control form is not even used at all for creating the fieldmark - only an auto-generated __Fieldmark__ name is assigned which obviously does not tie back to the original bookmark name. (This has been true since inception commit df6d312ca5374.)

The example document loads and round-trips OK with patch https://gerrit.libreoffice.org/61565
Comment 4 Justin L 2018-10-09 18:19:58 UTC
Note that the round-tripped file does not open well in Word 2016, even though LO seems to handle it fine, and it isn't nearly that bad in Word 2003.  In 2016, the entire reference section is missing.

Considering all the corporate desire mentioned in the 2013 wiki announcement of inline forms (https://wiki.openoffice.org/wiki/Writer/Input_Fields) this area sure has lousy interoperability, but I guess that is not surprising given MS lack of performance on the same document.
Comment 5 Commit Notification 2018-10-11 03:54:17 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=4af4a473daf8b2530e6b6f5e49c7f4e3413f8378

tdf#120225 ww8import: keep textform name

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2018-10-11 05:17:38 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=9943f37e8a80f2c4df6d58da4c50f3e7f3d6f3ce

related tdf#120225 ww8export: save PROTECT_FORM

It will be available in 6.2.0.

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

Affected users are encouraged to test the fix and report feedback.
Comment 7 Justin L 2018-10-11 06:32:55 UTC
This round-trips OK in LO, but in Word (especially 2016) it is really messed up. Closing this as fixed since MSO isn't consistent and the problem was not caused by these patches.
Comment 8 BogdanB 2018-10-13 10:33:15 UTC
Fixed. Tested on
Version: 6.2.0.0.alpha0+
Build ID: 144da6d5079bcd435e6637cb5cf95305f3ec1306
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk2; 
TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2018-10-12_02:13:01
Locale: ro-RO (ro_RO.UTF-8); Calc: threaded
Comment 9 Aron Budea 2018-10-30 19:08:45 UTC
(In reply to Justin L from comment #7)
> This round-trips OK in LO, but in Word (especially 2016) it is really messed
> up. Closing this as fixed since MSO isn't consistent and the problem was not
> caused by these patches.
Thanks for this fix, Justin! I found a related bug, and opened bug 121067 on that (and there's the unrelated bug 108772 that affected the RTed document).