Bug 103982 - FILESAVE: File corrupted after DOCX roundtrip (output invalid due to negative margin)
Summary: FILESAVE: File corrupted after DOCX roundtrip (output invalid due to negative...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.3.0.0.alpha0+
Hardware: All All
: high major
Assignee: Miklos Vajna
URL:
Whiteboard: target:5.3.0 target:5.2.4
Keywords: bibisected, bisected, regression
: 103933 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-11-17 11:33 UTC by Xisco Faulí
Modified: 2016-11-28 10:41 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xisco Faulí 2016-11-17 11:33:16 UTC
1. Open attachment 62036 [details]
2. Save as a new .DOCX file
3. Open then new file in MSOffice

Observed behaviour: file is corrupted

Reproduced in 

Version: 5.3.0.0.alpha1+
Build ID: 757a60d01dd152aadab2ba3c8224252481ce8a88
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; VCL: gtk3; Layout
Engine: new; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

but not in

Version: 4.3.0.0.alpha1+
Build ID: c15927f20d4727c3b8de68497b6949e72f9e6e9e
Comment 1 Xisco Faulí 2016-11-17 11:47:14 UTC
Another file that might be related as well: attachment 46282 [details]
Comment 2 Timur 2016-11-17 16:41:25 UTC
If we check with Open XML SDK https://www.microsoft.com/en-us/download/details.aspx?id=30425:

attachment 62036 [details] "unspecified error" and it gives 6 errors like "unexpected child element", distB, distR negative "invalid value" , "charSpace has invalid value"
attachment 46282 [details] "parameter is incorrect" error and it says "charSpace has invalid value". It's  "w:charSpace="4294965247" in document.xml from RT DOCX.

So yes, it may be related.
Comment 3 raal 2016-11-18 17:55:04 UTC
This seems to have begun at the below commit.
Adding Cc: to Miklos Vajna; Could you possibly take a look at this one? Thanks

author	Miklos Vajna <vmiklos@collabora.co.uk>	2014-12-04 09:42:40 (GMT)
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2014-12-04 10:25:38 (GMT)
commit a5a836d8c43dc9cebbbf8af39bf0142de603a7c6 (patch)
tree 5211f53b880421d89cfbcf36688d6ea29dcbb7be
parent 5f0f3d4e91e9eb1d1f60b0cd073e7bbd8ea38c29 (diff)
DOCX filter: effect extent should be part of the margin
OOXML has an object size (extent) a size including effects like shadow (effect
extent) and the margin (top/bottom/left/right distance). Our doc model doesn't
have an explicit "effect extent", but to have the intended layout, we at least
need the spacing of the effect around flys (even if a number of effects are not
rendered). Fix this by adding the effect extent to the margin; if we still have
the effect extent grab-bag around, then this can be undone during export.	
 46803f14ecedac8fe35f04629ee278162efae2dd is the first bad commit
commit 46803f14ecedac8fe35f04629ee278162efae2dd
Author: Norbert Thiebaud <nthiebaud@gmail.com>
Date:   Tue May 12 02:40:06 2015 -0500
    source a5a836d8c43dc9cebbbf8af39bf0142de603a7c6
	
 git bisect log
# bad: [b7988d11e5d3751a4b366b2bfc9048f7a30e8526] source 87ac0b1e75a880a68ecb748bd4b34ae5a3d2ae98
# good: [f449493ae11ac76cc7396bddeaa624a60c565936] source 57d6b92b69a31260dea0d84fcd1fc5866ada7adb
git bisect start 'origin/master' 'oldest'
# bad: [66e2ae767eb4bb83444e3d03bcb90adcbe6d4991] source 5a308b1239a09417507b0d05090ff2d3418d5133
git bisect bad 66e2ae767eb4bb83444e3d03bcb90adcbe6d4991
# bad: [90c1dbb098a6d957f2293692716251ee5a6053ca] source 2813632238380e0bfe40c0e6404a07102cde1398
git bisect bad 90c1dbb098a6d957f2293692716251ee5a6053ca
# bad: [5b8e174eb7b3d996d6c90862d7228e1b928a9787] source 4de09a9efdb62cf90ce18662852e556cf7148e14
git bisect bad 5b8e174eb7b3d996d6c90862d7228e1b928a9787
# good: [175f015ea35c89712f927eaef03b6a77895fc1a9] source b46f781440130e6a629bf9ae14a62310d2a31021
git bisect good 175f015ea35c89712f927eaef03b6a77895fc1a9
# bad: [ff43c6fcb51631741c26c3c62ec4143a78637fa5] source 1e973a38a068dd4773b67fb5402c873ca90a3635
git bisect bad ff43c6fcb51631741c26c3c62ec4143a78637fa5
# good: [647aaf986c4371214e14b74b478b85fa21033c26] source 9ef9432536755079ad8390d3d65e0ed6089800eb
git bisect good 647aaf986c4371214e14b74b478b85fa21033c26
# good: [fc97cc0d068557464465efb8f79f7ce9153257f7] source 63ca4cd4aa5c6b52bb68aaaa1b2e30ce366eb5ee
git bisect good fc97cc0d068557464465efb8f79f7ce9153257f7
# good: [e0d28587dd9765081b43384181ba4a69750be15a] source d48668ecdb5e7523ee25a09afb76ca46b22a4fea
git bisect good e0d28587dd9765081b43384181ba4a69750be15a
# bad: [d594c9ce4f64b1d114677c46eb0dddf811fbdfc6] source 4a8c18dcca2aa4eb6b1306d6312c8a7d9d7257a9
git bisect bad d594c9ce4f64b1d114677c46eb0dddf811fbdfc6
# good: [e942a2536a02f544bd8ea960997a8982af44c9ad] source 8c2e25b3768013a19ef2371e5d7867a86226df0d
git bisect good e942a2536a02f544bd8ea960997a8982af44c9ad
# bad: [62184f7e978a939a3f93c354ef03e9331a9114d8] source 5131750da6df95643e89127349b95df33be2feb4
git bisect bad 62184f7e978a939a3f93c354ef03e9331a9114d8
# good: [8069abe3372372dbdb846b6230e35e75a6551f7f] source 5f0f3d4e91e9eb1d1f60b0cd073e7bbd8ea38c29
git bisect good 8069abe3372372dbdb846b6230e35e75a6551f7f
# bad: [46803f14ecedac8fe35f04629ee278162efae2dd] source a5a836d8c43dc9cebbbf8af39bf0142de603a7c6
git bisect bad 46803f14ecedac8fe35f04629ee278162efae2dd
# first bad commit: [46803f14ecedac8fe35f04629ee278162efae2dd] source a5a836d8c43dc9cebbbf8af39bf0142de603a7c6
Comment 4 Xisco Faulí 2016-11-18 18:05:52 UTC
*** Bug 103933 has been marked as a duplicate of this bug. ***
Comment 5 Xisco Faulí 2016-11-20 16:48:55 UTC
Another document affected by the same problem: attachment 85548 [details]
Comment 6 Xisco Faulí 2016-11-20 16:52:30 UTC
and attachment 94453 [details]
Comment 7 Commit Notification 2016-11-22 09:26:55 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "master":

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

tdf#103982 DOCX export: make sure SdrObject margin is non-negative

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 8 Miklos Vajna 2016-11-22 10:45:42 UTC
The above fixes the case when the output is invalid due to negative margin, so marking as resolved.

If there is an other input document where charSpace indeed causes Word to not accept our output, please let's deal with that in a separate bug.
Comment 9 Xisco Faulí 2016-11-22 14:13:28 UTC
Verified in

Version: 5.3.0.0.alpha1+
Build ID: 4ebf1ea7cb66fc3e6b94cd38dd233aaead69f3d5
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; VCL: gtk3; Layout Engine: new; 
Locale: ca-ES (ca_ES.UTF-8); Calc: group

However, attachment 46282 [details] still fails. Reporting this in a separate bug
Comment 10 Xisco Faulí 2016-11-22 15:16:16 UTC
follow-up bug created: bug 104115
Comment 11 Commit Notification 2016-11-23 21:02:59 UTC
Miklos Vajna committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

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

tdf#103982 DOCX export: make sure SdrObject margin is non-negative

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.
Comment 12 Timur 2016-11-28 10:35:11 UTC
Open XML Productivity Tools gives 4 errors for attachment 62036 [details] now: 3 "unexpected child element" and 1 "charSpace has invalid value".