Bug 139835 - FILESAVE: ODT->DOCX: Cross-reference to footnote number disappears upon reopening when exporting to DOCX
Summary: FILESAVE: ODT->DOCX: Cross-reference to footnote number disappears upon reope...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
3.3.0 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: filter:docx
Depends on:
Blocks: Fields-Cross-Reference DOCX-Fields
  Show dependency treegraph
 
Reported: 2021-01-22 13:00 UTC by Bastien Dumont
Modified: 2026-06-13 18:57 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Unmodified file created by LibreOffice (5.15 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-01-22 13:00 UTC, Bastien Dumont
Details
File including the manual fixes described in the bug report (6.49 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-01-22 13:01 UTC, Bastien Dumont
Details
Same file as ODT (8.51 KB, application/vnd.oasis.opendocument.text)
2021-02-06 10:33 UTC, Bastien Dumont
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bastien Dumont 2021-01-22 13:00:10 UTC
Created attachment 169090 [details]
Unmodified file created by LibreOffice

This bug is also present in 6.4.7.

Steps to reproduce:
1. Create a new file with a footnote.
2. Add a cross-reference to the footnote: first its page number, then the footnote's number.
3. Save to DOCX.
4. Close and reopen.
Result: The reference to the footnote's number disappeared.

I investigated a little the DOCX archive. Here is the culprit in word/document.xml:

      <w:bookmarkStart w:id="0" w:name="_RefF0"/>
      <w:bookmarkStart w:id="1" w:name="_RefF0"/>
      <w:bookmarkEnd w:id="1"/>
      <w:r>
        <w:rPr>
          <w:rStyle w:val="Ancredenotedebasdepage"/>
        </w:rPr>
        <w:footnoteReference w:id="2"/>
      </w:r>

There is no <w:bookmarkEnd w:id="0"/> in any file in the archive and both bookmarks have the same name. I suppose that we should have something like this instead:

      <w:bookmarkStart w:id="1" w:name="fnRef"/>
      <w:r>
        <w:rPr>
          <w:rStyle w:val="Ancredenotedebasdepage"/>
        </w:rPr>
        <w:footnoteReference w:id="2"/>
      </w:r>
      <w:bookmarkEnd w:id="1"/>

where the bookmark elements with w:id="0" would be placed in word/footnotes.xml (at least it is what I observed in a document produced by Word 2010).

Additionally, the footnote reference is called by:

      <w:instrText> REF _RefF0 \h </w:instrText>

We should have (provided that we changed the w:name attribute):

      <w:instrText> NOTEREF fnRef \h </w:instrText>

These are only hints, and I may be mistaken at some points. I produced a modified version of the file with the fixes mentioned above. When I open it in Word 2010, it complains that it is corrupt, but if I force opening, it basically works. References are here and can be updated correctly if I modify the file.
Comment 1 Bastien Dumont 2021-01-22 13:01:55 UTC
Created attachment 169091 [details]
File including the manual fixes described in the bug report
Comment 2 Dieter 2021-02-06 09:40:27 UTC Comment hidden (obsolete)
Comment 3 Bastien Dumont 2021-02-06 10:33:06 UTC
Created attachment 169524 [details]
Same file as ODT
Comment 4 Bastien Dumont 2021-02-06 10:35:07 UTC Comment hidden (obsolete)
Comment 5 Dieter 2021-02-06 10:53:01 UTC
I confirm it with

Version: 7.2.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 396c2ad2daad6fe6a11703d0ae1593929834afe2
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: en-GB
Calc: threaded

Steps to reproduce
1. Open attachment 169524 [details]
2. Save as docx
3. Close and reopen

Actual result:
Cross reference to footnote disappears.
Comment 6 sdc.blanco 2022-03-17 14:04:17 UTC
repro

Version: 7.4.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 7ac19fbce8a35f559eebb879cd0f232bfc95e703
CPU threads: 8; OS: Windows 10.0 Build 19043; UI render: Skia/Raster; VCL: win
Locale: da-DK (da_DK); UI: en-US
Calc: CL
Comment 7 stragu 2024-03-12 14:30:50 UTC
Already the case in LO 3.3 when DOCX export first appeared. Field text disappears after a field update.
Comment 8 QA Administrators 2026-03-13 03:14:25 UTC Comment hidden (obsolete)
Comment 9 Bastien Dumont 2026-03-14 09:30:11 UTC
The bug is still present in:

Version: 26.2.1.2 (X86_64)
Build ID: 620(Build:2)
CPU threads: 8; OS: Linux 6.19; UI render: default; VCL: gtk3
Locale: fr-FR (en_US.UTF-8); UI: en-US
26.2.1-1
Calc: threaded

The bug was already present in 3.3.
Comment 10 Justin L 2026-06-13 18:57:01 UTC
Still repro in 26.8 after bug 148294 was fixed.

I don't know much about bookmarks or cross-references, but we seem to export all cross-references as bookmarks, and never import a bookmark into a cross-reference [at least that is my assumption].

A bookmark of a footnote marker doesn't actually have any 'text'. So both Word and Writer will treat a normal reference to bookmarked footnote markers as an 'empty string'. [If you think otherwise, select the reference field and then update it with F9]

IIUC, a normal 'Ref' field accesses the bookmark 'text'. So Bastien seem to be absolutely correct in the assessment that this field should be exported as a NoteRef instead of as a plain Ref.

So, I used MS Word to create a test document with NOTEREF fields. While they round-trip in LO, they seem to just be preserved, because I couldn't F9 update them. (In fact, I can't even see that they are fields in LO.)

So it seems like a lot of 'fundamentals' need to be implemented first before this bug report can be handled. Namely, DOCX import needs to import these as functional cross-references.