Bug 70838 - FILESAVE: doc: wrong size and position exporting rotated objects
Summary: FILESAVE: doc: wrong size and position exporting rotated objects
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.2.0.0.alpha0+ Master
Hardware: Other All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:4.2.0 target:4.3.0 target:6.2....
Keywords: bibisectNotNeeded, filter:doc, regression
Depends on: 118375
Blocks: DOC-Shapes
  Show dependency treegraph
 
Reported: 2013-10-24 11:46 UTC by Jacobo Aragunde Pérez
Modified: 2020-05-30 07:10 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments
Test case (29.19 KB, application/vnd.oasis.opendocument.text)
2013-10-24 11:46 UTC, Jacobo Aragunde Pérez
Details
Differences side by side (365.06 KB, image/png)
2013-10-24 11:47 UTC, Jacobo Aragunde Pérez
Details
Test case with shapes (8.19 KB, application/vnd.oasis.opendocument.text)
2013-10-25 07:11 UTC, Jacobo Aragunde Pérez
Details
Graphic description of ImplEESdrWriter::ImplFlipBoundingBox (348.49 KB, image/png)
2013-10-25 12:03 UTC, Jacobo Aragunde Pérez
Details
Side by side comparison (test case with shapes) (107.25 KB, image/png)
2014-02-28 13:30 UTC, Jacobo Aragunde Pérez
Details
Side-by-side differences (original odt vs. exported doc) (55.81 KB, image/png)
2016-11-08 12:05 UTC, Jacobo Aragunde Pérez
Details
Sample ODT with rotated ellipses (10.24 KB, application/vnd.oasis.opendocument.text)
2018-05-04 22:54 UTC, Aron Budea
Details
Side-by-side comparison (ellipses) (74.75 KB, image/png)
2018-05-04 22:55 UTC, Aron Budea
Details
tdf91687.doc: ww8export2 unit test: Watermark rotated 45 degrees, but shouldn't be swapped (23.00 KB, application/msword)
2018-06-14 08:39 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jacobo Aragunde Pérez 2013-10-24 11:46:20 UTC
Created attachment 88076 [details]
Test case

When there's a picture in a document as an embedded Draw object which is rotated in an angle different from 90, 180 or 270 degrees, saving that document as a .doc changes the position and the size of the picture.

Steps:

1. New Draw document.
2. Insert->Picture->from file.
3. Right click on picture->position and size->rotation->set 45 degrees.
4. Copy the rotated picture.
5. New Writer document.
6. Paste rotated picture.
7. Save as .doc.
8. Open the .doc with Word.

Alternatively you can open the attached test case and save as a .doc.
Comment 1 Jacobo Aragunde Pérez 2013-10-24 11:47:59 UTC
Created attachment 88077 [details]
Differences side by side

Differences between the original and the exported document side by side, opened with Writer and Word.
Comment 2 Jacobo Aragunde Pérez 2013-10-24 14:38:50 UTC
I've realized that the same happens with any kind of rotated shape. Modified bug description to reflect that.
Comment 3 Jacobo Aragunde Pérez 2013-10-25 07:11:43 UTC
Created attachment 88102 [details]
Test case with shapes

New test case using only shapes. To reproduce the bug:

1. Open this file.
2. Save as .doc or .docx
3. Open with Word or reload the file to "enjoy" the results.
Comment 4 Jacobo Aragunde Pérez 2013-10-25 12:03:57 UTC
Created attachment 88107 [details]
Graphic description of ImplEESdrWriter::ImplFlipBoundingBox

This picture has helped me to understand how ImplEESdrWriter::ImplFlipBoundingBox works, so I'm attaching it here in the hope it can be useful in the future.
Comment 5 Thomas van der Meulen [retired] 2013-10-25 13:07:36 UTC
Thank you for your bug report, I can reproduce this bug running 
Version: 4.1.3.2
Build ID: 70feb7d99726f064edab4605a8ab840c50ec57a
OS: Mac osx 10.9.
Comment 6 Commit Notification 2013-11-14 11:37:13 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "master":

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

fdo#70838: Fix size issue when exporting shapes to docx.



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 7 Commit Notification 2013-11-14 11:37:37 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "master":

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

fdo#70838: Fix position issue when exporting shapes to docx.



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 Commit Notification 2013-11-14 11:38:00 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "master":

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

fdo#70838: Add unit test for docx export



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 9 Jacobo Aragunde Pérez 2013-11-21 17:51:02 UTC
Fixed for .docx, still happens to .doc when opened with Word 2010.

Can it be a problem with how recent Office releases manage .doc files? It's strange that this bug has been unnoticed for so long.
Comment 10 Jacobo Aragunde Pérez 2014-02-28 13:28:54 UTC
Above patches fixed the issue for VML export code, but now we are using DrawingML  to export shapes and the problem has re-appeared in .docx export.
Comment 11 Jacobo Aragunde Pérez 2014-02-28 13:30:45 UTC
Created attachment 94884 [details]
Side by side comparison (test case with shapes)

Side by side comparison for the attached test case with shapes. It was fixed in 4.2 but it reappears in 4.3 (master) as we have replaced the VML export code with DrawingML.
Comment 12 Commit Notification 2014-03-05 10:07:16 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "master":

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

fdo#70838: fix size error in rotated shapes in DrawingML



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 13 Commit Notification 2014-03-22 22:59:05 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "master":

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

fdo#70838: apply rotation transformations to DML anchor position



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 2014-04-15 09:37:12 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "master":

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

fdo#70838: fix rotation transformation in DML exporter



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 15 Jacobo Aragunde Pérez 2014-04-15 10:38:30 UTC
The patches above fix the problem for docx files written by the DrawingML exporter (4.3).
Comment 16 Jacobo Aragunde Pérez 2014-10-03 08:21:21 UTC
Resetting 'assigned to' since I cannot work on this right now. Binary Word filter (.doc) still pending to fix.
Comment 17 QA Administrators 2015-10-14 19:57:29 UTC Comment hidden (obsolete)
Comment 18 Jacobo Aragunde Pérez 2015-10-30 08:59:45 UTC
Still reproducible when saving to .doc binary format. Use attachment 88102 [details] as test case for simplicity.

Version: 5.1.0.0.alpha1+
Build ID: 086aec27ddfd72dc21fffb0466cb5c815e2b4169
Comment 19 QA Administrators 2016-11-08 11:52:25 UTC Comment hidden (obsolete)
Comment 20 Jacobo Aragunde Pérez 2016-11-08 12:05:05 UTC
Created attachment 128563 [details]
Side-by-side differences (original odt vs. exported doc)

Situation has improved, but the bug is still reproducible when saving to binary .doc format. The position is right but the shape size is wrong.

Version: 5.1.6.2.0+
Build ID: 5.1.6.2-1.fc24
CPU Threads: 4; OS Version: Linux 4.8; UI Render: default; 
Locale: en-US (en_US.UTF-8); Calc: group
Comment 21 Telesto 2016-12-03 17:28:20 UTC
Export docx seems to be fine. Opens correctly in Word Viewer and LibO
Export doc is broken. In Word Viewer positioning and shape size are wrong. When (re-)opening the file with LibreOffice position, rotation and size is off.

Tested with:
Version: 5.4.0.0.alpha0+
Build ID: 33f5bc54aaa7fe7aa9335726e30f9c349155e04d
CPU Threads: 4; OS Version: Windows 6.2; UI Render: default; 
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2016-12-01_23:21:05
Locale: nl-NL (nl_NL); Calc: CL
Comment 22 Telesto 2016-12-03 17:43:45 UTC
Not found in:
Versie 4.0.0.3 (Bouw-id: 7545bee9c2a0782548772a21bc84a9dcc583b89)
Comment 23 Aron Budea 2018-05-04 22:54:29 UTC
Created attachment 141897 [details]
Sample ODT with rotated ellipses

Here's another sample ODT with 5 ellipses having different rotations: 0, 60, 120, 210 and 315 degrees.
When saved as DOC and reloaded, 3 of those appear changed.

Observed using LO 6.1 alpha1 & 5.4.0.3 / Windows 7.
In LO 5.3.0.3 and before, the ellipses look worse, almost like circles after reloading.

The following commit improved the shape of ellipses:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=d72e0cadceb0b43928a9b4f18d75c9d5d30afdda
author		Szymon Kłos <szymon.klos@collabora.com>	2017-06-19 15:32:16 +0200
committer	Andras Timar <andras.timar@collabora.com>	2017-06-28 22:38:49 +0200

Watermark: tdf#91687 correct size in the .doc
Comment 24 Aron Budea 2018-05-04 22:55:48 UTC
Created attachment 141898 [details]
Side-by-side comparison (ellipses)
Comment 25 [REDACTED] 2018-05-05 18:46:37 UTC
Hi all, I'm working on this issue.
Comment 26 [REDACTED] 2018-05-05 21:48:29 UTC
See also merge request with fix: https://gerrit.libreoffice.org/#/c/53902/
Comment 27 [REDACTED] 2018-06-09 16:43:05 UTC
I've got no feedback for merge request, so I'm not working on this issue anymore.
Comment 28 Justin L 2018-06-14 08:39:43 UTC
Created attachment 142720 [details]
tdf91687.doc: ww8export2 unit test: Watermark rotated 45 degrees, but shouldn't be swapped
Comment 29 Justin L 2018-06-14 11:57:27 UTC Comment hidden (no-value)
Comment 30 Commit Notification 2018-06-16 04:51:06 UTC
Victor Mireyev committed a patch related to this issue.
It has been pushed to "master":

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

tdf#70838 ww8export: rotate shape vertically = swap width/height

It will be available in 6.2.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 31 Commit Notification 2018-06-18 13:10:08 UTC
Victor Mireyev committed a patch related to this issue.
It has been pushed to "libreoffice-6-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=544fe73806c04762b95d0ff5bbe86aa40b873282&h=libreoffice-6-1

tdf#70838 ww8export: rotate shape vertically = swap width/height

It will be available in 6.1.0.1.

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 32 Justin L 2018-06-18 16:37:37 UTC Comment hidden (no-value)
Comment 33 Justin L 2018-06-19 06:12:50 UTC
Not fully solved for .doc export. USING WORD 2013 the positioning of all rotated objects is wrong. The positioning looks OK in LO, but not in MSO. Comment 23's test document is the best example because all four of the rotated objects are mispositioned, not just the ones rotated vertically.

And another import problem for .doc *in LO* is that the test document from comment 0 is not rotated at all (but it IS rotated properly when viewed in MSO, so the export code is working for rotation). A few spot checks suggest that has always been true (back to LO 3.5 anyway), so no regression.
Comment 34 Aron Budea 2018-06-25 15:41:19 UTC
Seems like the import part is already wrong, opened bug 118375 on that, and setting that as a dependency for this bug report.
Comment 35 Justin L 2018-06-30 09:07:53 UTC
(In reply to Commit Notification from comment #30)
> tdf#70838 ww8export: rotate shape vertically = swap width/height
This caused a regression, so it was followed up with a qualifier commit:

tdf#118421 ww8export: rotate vertically: not Lines or groups
Lines and Groups often are exceptions.
Normally, the import code swaps vertical rotations also. In the case
of lines (from the tests that I observed) lines don't have a rotation
value at that point during import, so no correction is made.
Grouping always messes things up.

https://cgit.freedesktop.org/libreoffice/core/commit/?id=1cedd88d40a26a55ce433f8b742215aea83a5382
Comment 36 Regina Henschel 2019-04-06 21:18:00 UTC
proposed patch for correct position on import and export is in https://gerrit.libreoffice.org/#/c/70152/
Comment 37 Commit Notification 2019-04-06 23:15:30 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/+/421e6fc3cd2e6fe37afbef341e2d0ad7b8edde37%5E%21

tdf#118375, tdf#70838 correct position of rotated shape in doc

It will be available in 6.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 38 Luke 2019-04-08 16:22:04 UTC
Verified FIXED in Version: 6.3.0.0.alpha0+ (x64)
Build ID: 421e6fc3cd2e6fe37afbef341e2d0ad7b8edde37

The original test case is now correctly exporting. You can verify that works by opening in Word. However, Writer still cannot read image rotation values from .doc. Created Bug 124615 for that import issue.
Comment 39 V Stuart Foote 2019-04-08 19:10:24 UTC
The export to .DOC of Image inserted to Frame of comment 0 are no longer changing size when opened in Word 2016. 

But opening the exported .DOC back to LibreOffice loses the rotation, and the image fills the frame that holds the rotated image.

OP then changed scope of BZ to include rotated Draw shape objects. Unlike images the Draw shapes are now correctly sized and positioned round trip to Writer, and in Word 2016

Setting this resolved fixed.

Remaining issue of OP for image rotation is open as bug 116371. 
The rotated image is being saved correctly to .DOC and .DOCX, and opens rotated and sized correctly in Word 2016. The .DOCX opens correctly in current master. And, just the .DOC version is not opening correctly in current master.
Comment 40 Xisco Faulí 2019-04-09 09:25:44 UTC
Original file verified in

Version: 6.3.0.0.alpha0+
Build ID: 040a54d89e8ca33171e86647ced8dc58efd85fbe
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Locale: ca-ES (ca_ES.UTF-8); UI-Language: en-US
Calc: threaded