Bug 93121 - FILESAVE: Docx / Doc / RTF export of two footnote paragraphs adds a tab before the second one
Summary: FILESAVE: Docx / Doc / RTF export of two footnote paragraphs adds a tab befor...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
3.5.0 release
Hardware: Other All
: medium normal
Assignee: Justin L
URL:
Whiteboard: target:6.1.0
Keywords: difficultyInteresting, easyHack, skillCpp, topicQA
Depends on:
Blocks: RTF Footnote-Endnote DOCX
  Show dependency treegraph
 
Reported: 2015-08-04 14:49 UTC by Gabor Kelemen (allotropia)
Modified: 2018-03-26 12:30 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Screenshot of the problem in LO 5.1alpha. Note the extra tab character. (206.41 KB, image/png)
2015-08-04 14:49 UTC, Gabor Kelemen (allotropia)
Details
Correct document in ODT format (9.44 KB, application/vnd.oasis.opendocument.text)
2015-08-04 14:51 UTC, Gabor Kelemen (allotropia)
Details
Export of the ODT document to DOCX (6.10 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2015-08-04 14:52 UTC, Gabor Kelemen (allotropia)
Details
Export of the ODT document to DOC (12.00 KB, application/msword)
2015-08-04 14:52 UTC, Gabor Kelemen (allotropia)
Details
Export of the ODT document to RTF (5.83 KB, application/rtf)
2015-08-04 14:52 UTC, Gabor Kelemen (allotropia)
Details
tdf93121_tabBeforeFootnoteWhenResaved.docx: created in Word 2013 (13.85 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-03-14 05:38 UTC, Justin L
Details
footnote-twoparagraphs.odt: LO authored documents with margin need a tab (16.22 KB, application/vnd.oasis.opendocument.text)
2018-03-21 07:56 UTC, Justin L
Details
tdf93131_footnoteHangingIndent.docx: word2003 highlighting fundamental difference (11.32 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-03-21 07:59 UTC, Justin L
Details
tdf93131_footnoteHangingIndent.pdf: How it looks in Word 2003 (7.20 KB, application/pdf)
2018-03-21 08:02 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2015-08-04 14:49:54 UTC
Created attachment 117643 [details]
Screenshot of the problem in LO 5.1alpha. Note the extra tab character.

1, Add a footnote to a text document in LO 5.1 alpha.
2, Write two paragraphs into the footnote.
3, Save as DOCX or DOC or RTF. You get a warning that the document contains formatting that is not supported and may be lost.
4, Close the document, reopen with LO 5.1 alpha.
5, Now there is a tab character added after the first paragraph sign that was not there at saving. This happens all the same in the DOCX, DOC, RTF case. 

There should be no tab character added. 
If I save to ODT format, the formatting is preserved correctly: no extra tab.
Comment 1 Gabor Kelemen (allotropia) 2015-08-04 14:51:32 UTC
Created attachment 117644 [details]
Correct document in ODT format
Comment 2 Gabor Kelemen (allotropia) 2015-08-04 14:52:11 UTC
Created attachment 117645 [details]
Export of the ODT document to DOCX
Comment 3 Gabor Kelemen (allotropia) 2015-08-04 14:52:33 UTC
Created attachment 117646 [details]
Export of the ODT document to DOC
Comment 4 Gabor Kelemen (allotropia) 2015-08-04 14:52:59 UTC
Created attachment 117647 [details]
Export of the ODT document to RTF
Comment 5 Gabor Kelemen (allotropia) 2015-08-05 06:39:59 UTC
Seems like this issue was earlier detected in bug 39205.
Comment 6 raal 2015-08-06 15:41:56 UTC
I can confirm with Version: 5.1.0.0.alpha1+ (x64)
Build ID: e92a8b92072284fd7c37d7bb3e1e8fe72a185f35
TinderBox: Win-x86_64@62-TDF, Branch:MASTER, Time: 2015-07-22_21:46:26
Comment 7 QA Administrators 2016-09-20 10:21:03 UTC Comment hidden (obsolete)
Comment 8 Gabor Kelemen (allotropia) 2016-09-20 10:55:45 UTC
Still the same in LO 5.2.1 on Ubuntu. An extra tab is added to the saved docx file.
Comment 9 m_a_riosv 2017-10-04 22:44:10 UTC
*** Bug 112886 has been marked as a duplicate of this bug. ***
Comment 10 Jackson Sul 2017-10-04 22:53:25 UTC
Note that with .docx files (I can't reproduce with .doc) a tab is added in each single-paragraph footnote at the very beginning. So no need to make two paragraphs in the footnotes: each and every one will get that tab character regardless. At least with 5.4.1.2 on Ubuntu 16.04.

Is there any workaround for this? It's really annoying when you are editing and adding comments to a colleague's paper and they wonder why the hell you added a bunch of tabs to their work.
Comment 11 Justin L 2017-11-02 16:31:53 UTC
According to bibisect-43all, this tabstop has been added as far back as I can go (LO3.5). Over time, there have been extra CRs added or deleted, but the tab on the second paragraph has always been there.

The most recent change was to fix a removed CR in LO 5.1 by Miklos Vajna on 2015-07-06 09:57:11 (GMT) commit 519b34300f73b1e08f6194d6ba49d4fc010cf186
   tdf#90611 DOCX import: fix missing paragraph style on footnotes

The best inspiration should come from this patch from LO 4.3. Before that the first paragraph also start with a tab. See commit b38629ae210b204a6d24d6e9c5c62eaaf563d494 from Miklos Vajna on  Thu Dec 5 11:50:42 2013 +0100
   cp#1000017 DOCX/RTF import: avoid fake tab char in footnotes
   Word wants this, so it's added by the exporter to the document, but on
   import we should ignore it.
https://cgit.freedesktop.org/libreoffice/core/commit/?id=b38629ae210b204a6d24d6e9c5c62eaaf563d494
Comment 12 Justin L 2017-11-02 19:00:54 UTC
The tab is added in wrtw8nds.cxx ::OutputTextNode - look for 0x09.
Comment 13 Justin L 2017-11-03 16:16:23 UTC
Marking as an easy hack since I've given a lot of pointers. This will require a lot of testing - to ensure that no regressions happen.  Many changes have occurred to footnotes - perhaps the tab is no longer necessary at all, but certainly it should be removed for extra paragraphs.

Especially take note of related bug 112886, which is not really a duplicate and presents some non-standard issues.

My target is that this should be fixed for LO 6.1.
Comment 14 Justin L 2018-03-14 05:38:52 UTC
Created attachment 140627 [details]
tdf93121_tabBeforeFootnoteWhenResaved.docx: created in Word 2013

It looks good when opened in LO, but after a round-trip, tabs are inserted in all three footnote paragraphs.  Word also sees these tabs in the RT file.  Since this bug report starts with an ODT, it indicates an export bug, not import bug.
Comment 15 Justin L 2018-03-20 10:55:34 UTC
proposed fix: https://gerrit.libreoffice.org/51628
Comment 16 Justin L 2018-03-21 07:56:35 UTC
Created attachment 140766 [details]
footnote-twoparagraphs.odt: LO authored documents with margin need a tab

LibreOffice seems to automatically start the footnote paragraph at the paragraph margin, and only the footnote character follows the first line margin.  Word doesn't do such a thing, so that is why a tab is inserted.
Comment 17 Justin L 2018-03-21 07:59:31 UTC
Created attachment 140767 [details]
tdf93131_footnoteHangingIndent.docx: word2003 highlighting fundamental difference

LO's footnote implementation is fundamentally different from Word in regard to where the footnote paragraph starts.
Comment 18 Justin L 2018-03-21 08:02:39 UTC
Created attachment 140768 [details]
tdf93131_footnoteHangingIndent.pdf: How it looks in Word 2003

In MS Word, the footnote paragraph starts one space after the footnote character, not at the paragraph margin.
Comment 20 Justin L 2018-03-26 12:30:55 UTC
I noticed the missing # in the fixing commit's subject line, but since it still linked the this bug from gerrit, I didn't bother to fix that.  Now I know it has implications on automatic comments for bugzilla.

Not planning to backport - too much chance for unanticipated regressions in this area of "emulating behaviour".