Bug 70457 - FILEOPEN, FILESAVE: docx: embedded bitmaps lose rotation information on import
Summary: FILEOPEN, FILESAVE: docx: embedded bitmaps lose rotation information on import
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: Jacobo Aragunde Pérez
URL:
Whiteboard: target:4.2.0
Keywords:
: 38702 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-10-14 16:21 UTC by Jacobo Aragunde Pérez
Modified: 2016-07-14 14:55 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Test case (24.36 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2013-10-14 16:21 UTC, Jacobo Aragunde Pérez
Details
Test case as rendered by Word before the export (93.37 KB, application/pdf)
2013-10-14 16:22 UTC, Jacobo Aragunde Pérez
Details
Test case as rendered by Word after the export (93.34 KB, application/pdf)
2013-10-14 16:22 UTC, Jacobo Aragunde Pérez
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-14 16:21:45 UTC
Created attachment 87610 [details]
Test case

Steps to reproduce:

1. Open attached file. Notice that the image has a 45º rotation in the original document but that's not displayed.
2. Save as docx.
3. If you opened the saved document again with Word, you would see that the rotation information has disappeared.

I'm attaching pdfs to show how the document looks in Word before and after the export.
Comment 1 Jacobo Aragunde Pérez 2013-10-14 16:22:42 UTC
Created attachment 87611 [details]
Test case as rendered by Word before the export
Comment 2 Jacobo Aragunde Pérez 2013-10-14 16:22:59 UTC
Created attachment 87612 [details]
Test case as rendered by Word after the export
Comment 3 Jacobo Aragunde Pérez 2013-10-14 17:07:29 UTC
Bitmaps inserted in Writer are only allowed to be rotated in 90-degree steps, but when a bitmap is treated as a drawing (for example, pasting from Draw) it can be rotated to any arbitrary position.

I wonder if importing embedded bitmaps coming from docx as Draw objects would be an acceptable solution for this bug.
Comment 4 Thomas van der Meulen [retired] 2013-10-24 10:57:35 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 5 Jacobo Aragunde Pérez 2013-10-28 08:14:45 UTC
According to the linked discussion, I will try to import this kind of rotated bitmaps as Draw objects, which support free rotation.

http://lists.freedesktop.org/archives/libreoffice/2013-October/056717.html
Comment 6 Jacobo Aragunde Pérez 2013-10-29 17:59:25 UTC
Some facts about how embedded bitmaps are imported from docx documents:

* If the original document used VML, the bitmap is always imported as an XShape object and the rotation information is ignored.

* If the original document used DrawingML, the bitmap is first imported as an XShape and then transformed to an XTextContent. The rotation information is lost during the transformation.
Comment 7 Stephanie Miller 2013-11-12 20:15:22 UTC
The same is true of vml that use flip: x instead of rotating.  The transformation is not preserved on import to writer.
Comment 8 Commit Notification 2013-11-14 12:03:50 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=5c7ede91afaf334cd6faa099ae3f7c1d6cc929c8

fdo#70457: Preserve rotation of embedded bitmaps from 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 9 Owen Genat (retired) 2013-11-15 09:46:52 UTC
Jacobo, I have just tried to provide clarification for bug #61727 along with a test DOCX I created under Word Mac 2011 (original DOCX provided in that bug is a Word 2007 one and quite large). That bug also deals with a rotation issue, and while it seemed potentially related to grouping of raster graphics, my testing seemed to indicate that grouping may not be a factor and that rotation under DOCX is simply not supported.

I thought I should comment here in case your recent patch fixes the rotation issue in that bug also. If it does not, please excuse my comment. If it does, then you can probably close both bugs.
Comment 10 Pierre C 2013-11-17 18:02:30 UTC
This bug seems to be the same as this one :
https://bugs.freedesktop.org/show_bug.cgi?id=71703

is this correct ?

and does your patch work with the attached file ?
Comment 11 Maxim Monastirsky 2013-11-18 08:18:38 UTC
*** Bug 38702 has been marked as a duplicate of this bug. ***
Comment 12 Maxim Monastirsky 2013-11-18 09:06:34 UTC
(In reply to comment #10)
> This bug seems to be the same as this one :
> https://bugs.freedesktop.org/show_bug.cgi?id=71703
> 
> is this correct ?
> 
> and does your patch work with the attached file ?
No, it's only for docx.
Comment 13 Maxim Monastirsky 2013-11-18 11:37:11 UTC
Fix verified using a master build with Build ID: f7e6521efca5e5966a65e84848a1c35d71ba1a0b