Bug 101814 - Saving ODT as DOCX or DOC exports wrong footer as first-page footer
Summary: Saving ODT as DOCX or DOC exports wrong footer as first-page footer
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4.0.0.alpha0+ Master
Hardware: x86-64 (AMD64) All
: high major
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:5.3.0 target:5.2.4
Keywords: bibisected, bisected, dataLoss, filter:doc, filter:docx, regression
Depends on:
Blocks:
 
Reported: 2016-08-31 11:30 UTC by Fabien08FR
Modified: 2016-10-26 11:11 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Buggy and debuggued files (58.11 KB, application/x-7z-compressed)
2016-08-31 11:30 UTC, Fabien08FR
Details
sample (50.62 KB, application/vnd.oasis.opendocument.text)
2016-10-23 11:25 UTC, Xisco Faulí
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabien08FR 2016-08-31 11:30:33 UTC
Created attachment 127091 [details]
Buggy and debuggued files

When i save a one page document (used since several years) in doc or docx formats (no test with other parameters) and then open the saved file, i get an old version of the file. Same statement using Word Online. If i open the looking good ODT file in Word Online, i get a two pages document : the first with a misfunctional doc (main text missing) looking to the good odt file, the second with the old document as doc/docx file. I tried to build a new ODT file by Select All / Copy / Paste in a new ODT doc, same result. If I paste differents part of the document one by one (header, text, footer), it works well. See linked filed.

In french :
Quand je sauvegarde un document (que je modifie depuis plusieurs années) d'une page au format doc ou docx (pas testé avec d'autres formats ou paramètres comme pied de page, nombre de pages, etc.), j'obtiens des fichiers doc ou docx qui, quand je les ouvre à nouveau, avec LibO ou Word Online, sont en fait une vieille version de ce fichier. Quand j'ouvre le fichier ODT, qui apparait correctement sous Writer, avec Word Online, j'ai un fichier de deux pages : la première qui ressemble à ce que j'ai sous Writer mais bugué (pas le texte central) et une deuxième page qui est identique à celle avec les doc/docx bugués. 
J'ai essayé de faire un nouveau fichier ODT par copier/coller : avec un SelectAll, ça déconne toujours. Si je colle les éléments un par un, ça marche. Voir fichiers liés.
Comment 1 Buovjaga 2016-09-23 19:20:20 UTC Comment hidden (obsolete)
Comment 2 Fabien08FR 2016-09-24 11:46:56 UTC Comment hidden (obsolete)
Comment 3 Buovjaga 2016-10-06 11:41:55 UTC Comment hidden (obsolete)
Comment 4 Fabien08FR 2016-10-06 20:29:44 UTC Comment hidden (obsolete)
Comment 5 Aron Budea 2016-10-06 20:40:58 UTC Comment hidden (obsolete)
Comment 6 Fabien08FR 2016-10-06 20:58:59 UTC
Finally found 5.3 alpha (only looked for x64 at first but was helped by Tinderbox line) : same result :-/ . 
Perhaps i missed a detail : added text is saved after "Texte" but Header and Footer are not (with text added inside or not), they are the old one when reload after saved.

Version: 5.3.0.0.alpha0+
Build ID: f32b300c9e071c2bdee2a7b925200feb93add702
CPU Threads: 4; OS Version: Windows 6.29; UI Render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2016-10-06_05:51:08
Locale: fr-FR (fr_FR); Calc: group
Comment 7 Buovjaga 2016-10-07 04:37:57 UTC
(In reply to Fabien08FR from comment #6)
> Perhaps i missed a detail : added text is saved after "Texte" but Header and
> Footer are not (with text added inside or not), they are the old one when
> reload after saved.

Indeed, you missed an extremely important detail that would have saved a lot of time and hassle.
You also did not say, which file the problem appears in. For testers: the file is CAFCA - Modèle feuille A4 - v2015-2.odt and you can ignore the other one.

The added text to header/footer is preserved in 3.6, so regression.

Arch Linux 64-bit, KDE Plasma 5
Version: 5.3.0.0.alpha0+
Build ID: dc41255dc725dfa912326cc5d9e420bd66471c64
CPU Threads: 8; OS Version: Linux 4.7; UI Render: default; 
Locale: fi-FI (fi_FI.UTF-8); Calc: group
Built on October 1st 2016

Arch Linux 64-bit
Version 3.6.7.2 (Build ID: e183d5b)
Comment 8 Fabien08FR 2016-10-07 11:13:26 UTC
Sorry for this. I thought that change in header would be evident, i may be too used to work with this files. And perhaps, I had brought confusion with my Word Online test details. I will try to do better in my next bug reports ;-) I stay available if you need details.
Comment 9 raal 2016-10-22 19:53:01 UTC
reproducible with Version: 4.4.0.0.alpha0+; added text to footer, after save as docx and reload is text lost.
Comment 10 Xisco Faulí 2016-10-23 11:25:09 UTC
Created attachment 128188 [details]
sample
Comment 11 Xisco Faulí 2016-10-23 12:07:08 UTC
Regression introduced by:

author	Michael Stahl <mstahl@redhat.com>	2013-12-17 22:44:38 (GMT)
committer	Michael Stahl <mstahl@redhat.com>	2013-12-17 23:12:09 (GMT)
commit 22355042a6fc7aecf3caab69b3fa3be1430b697f (patch)
tree de4b9c61c1e1997bd11d6e73cf7eb8704ec5bb6f
parent 975f62aeaa0c88cca1b7926ff34df1d7afb577c4 (diff)

fdo#72452: ODF import/export: fix handling of style:page-number
Class XMLNumberWithAutoInsteadZeroPropHdl (which appears to be used only
for this attribute) needs to be adapted to the change that
"PageNumberOffset" value 0 is no longer invalid; use "void" value for
invalid instead, which appears more appropriate anyway.

Unfortunately the type of style:page-number is positiveInteger so
writing 0 would be invalid; write "auto" instead for now.

Adding Cc: to Michael Stahl
Comment 12 Michael Stahl (allotropia) 2016-10-25 15:53:40 UTC
the bugdoc contains page style "First_20_Page" with a footer and 
a separate first-page footer with subtly different content.

commit 22355042a6fc7aecf3caab69b3fa3be1430b697f fixed the problem
that the first (and only) page displayed the "footer" and not the
"first-page footer", but apparently there is another bug in the
DOCX export that lets it pick the wrong footer for the exported section.

commit dcea8ba3b4fc347e7b6d9e0d5ec2fd99bd77ce6f looks very suspicious.

fixed on master.
Comment 13 Commit Notification 2016-10-25 15:54:31 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=36e390eaa55ae302dc5a64fa7098ec43e2009748

tdf#101814 sw: MSWord export: don't override first-page with heuristics

It will be available in 5.3.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 14 Commit Notification 2016-10-26 11:11:03 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1bfa382b4af649ff2b56b988d89bada156e29078&h=libreoffice-5-2

tdf#101814 sw: MSWord export: don't override first-page with heuristics

It will be available in 5.2.4.

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.