Bug 109382

Summary: [FILEOPEN DOCX/RTF] multicharacter custom foot/endnote markers are not imported or formatted properly
Product: LibreOffice Reporter: Justin L <jluth>
Component: WriterAssignee: Not Assigned <libreoffice-bugs>
Status: NEW ---    
Severity: normal CC: jluth, mikekaganski, vsfoote, xiscofauli
Priority: medium Keywords: filter:docx, filter:rtf
Version: Inherited From OOo   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=121441
Whiteboard:
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 97895, 104450, 109195    
Attachments: customFootnotes.docx: the custom mark is duplicated in the footnote.
customFootnotes.rtf: first character is duplicated for multi-character marks
customFootnotes_word2003.pdf: how it looks in MSO 2003
tdf109382_customFootnote.rtf: hand-crafted, minimal RTF with complex custom footnote anchors
tdf109382_customFootnote.docx: minimal DOCX with complex custom footnote anchor
tdf109382_customFootnote.docx view in MSO 2023-02 and LO7.5.2.2 (footnotes on second page).png

Description Justin L 2017-07-26 14:05:46 UTC
Created attachment 134874 [details]
customFootnotes.docx: the custom mark is duplicated in the footnote.

When inserting a footnote in Word, there is a choice of a "custom mark" which can be multi-character. LO doesn't handle custom marks well.
-DOCX: the mark is duplicated entirely in the footnote.
-RTF:  for multi-character marks, the first character is duplicated in the footnote. (For single-character marks, it seems to work OK.)

1.) Open the document and look at the footnote and endnote
2.) The first instance of "CUSTOM" and "FANCY" is a link and the second contains the character formatting.

Inherited from OOo likely.  Occurs in the oldest bibisect43all available to Ubuntu x64 16.04.
Comment 1 Justin L 2017-07-26 14:07:44 UTC
Created attachment 134875 [details]
customFootnotes.rtf: first character is duplicated for multi-character marks
Comment 2 Justin L 2017-07-26 14:10:10 UTC
Created attachment 134876 [details]
customFootnotes_word2003.pdf: how it looks in MSO 2003

These DOCX and RTF documents were composed/saved by MS Word 2003.
Comment 3 Xisco FaulĂ­ 2017-07-26 14:33:00 UTC
Confirmed in

Version: 6.0.0.0.alpha0+
Build ID: e0b6a4a2d2dec4e9614f27fc03f84b1c578028ec
CPU threads: 4; OS: Linux 4.8; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group
Comment 4 V Stuart Foote 2017-07-26 15:13:45 UTC
@Justin, *

What does MS Word's own Save-as ODF .odt do with them? 

And is that format maintained with filter opening into LO Writer?
Comment 5 Justin L 2017-07-28 12:33:42 UTC
Created attachment 134932 [details]
tdf109382_customFootnote.rtf: hand-crafted, minimal RTF with complex custom footnote anchors

RTF: The current implementation completely depends on the existence of \super (setting pCurrentBuffer = &m_aSuperBuffer) before the custom anchor. MSWord doesn't require \super, as demonstrated by this unit test example.

This will require a creative solution. (The previous solution was already pretty creative...) If you can get this document to work properly, you probably have the correct implementation.
Comment 6 Justin L 2017-07-28 12:38:18 UTC
RTF: the original 2011-06-29 implementation has changed slightly, but the general logic still holds.
https://cgit.freedesktop.org/libreoffice/core/commit/?id=fbdc98489973a33af4ef3f6ae072abe51716c564 RTF_FOOTNOTE: support custom marks
Comment 7 Justin L 2017-07-28 18:13:32 UTC
Created attachment 134949 [details]
tdf109382_customFootnote.docx: minimal DOCX with complex custom footnote anchor

LO seems to automatically use the same mark for both the in-text and footnote. Of course, MSO normally does this too, but it doesn't seem to be an absolute requirement. Clicking in this DOCX's bottom mark links to the top one - but only on inside the first 6 characters which matches the size of the in-text anchor.

These will be tough to fix since MS duplicates the mark in both formats.
Comment 8 Justin L 2017-08-11 18:35:18 UTC
RTF: potential fix started at https://gerrit.libreoffice.org/41061
Comment 9 Justin L 2017-11-07 18:12:11 UTC
(In reply to Justin L from comment #8)
> RTF: potential fix started at https://gerrit.libreoffice.org/41061

and abandoned. It doesn't handle some edge cases.
Comment 10 QA Administrators 2018-11-08 04:07:24 UTC Comment hidden (obsolete)
Comment 11 Roman Kuznetsov 2018-11-08 07:29:40 UTC
still repro in

Version: 6.2.0.0.alpha1+
Build ID: 6896f39ffd8a6c4b32b8f601a6a93678247456bd
CPU threads: 4; OS: Windows 6.1; UI render: default; VCL: win; 
TinderBox: Win-x86@42, Branch:master, Time: 2018-11-05_22:40:18
Locale: ru-RU (ru_RU); Calc: threaded
Comment 12 QA Administrators 2019-11-09 03:53:11 UTC Comment hidden (obsolete, spam)
Comment 13 NISZ LibreOffice Team 2020-12-03 16:37:19 UTC
*** Bug 135883 has been marked as a duplicate of this bug. ***
Comment 14 QA Administrators 2022-12-04 03:49:55 UTC Comment hidden (obsolete)
Comment 15 Piotr Osada 2023-04-01 09:54:06 UTC
Created attachment 186392 [details]
tdf109382_customFootnote.docx view in MSO 2023-02 and LO7.5.2.2 (footnotes on second page).png

Version: 7.5.2.2 (X86_64) / LibreOffice Community
Build ID: 53bb9681a964705cf672590721dbc85eb4d0c3a2
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: pl-PL (pl_PL); UI: en-GB
Calc: threaded

There are still differences between Microsoft Office and LibreOffice:
1) Footnotes do not have a separating line between the text region and footnote area.
2) The footnote is moved to the next page.
3) This additional page is in default orientation (vertical).
4) Custom footnote mark 'custom' in text is duplicated as superscript and normal size.
5) HandCrafted Anchor goes in addition with footnote mark 'custom'