Bug 80555 - FILEOPEN: DOCX: incorrect position of pictures
Summary: FILEOPEN: DOCX: incorrect position of pictures
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: filters and storage (show other bugs)
Version:
(earliest affected)
4.3.0.1 rc
Hardware: Other All
: medium normal
Assignee: Jacobo Aragunde Pérez
URL:
Whiteboard: target:4.4.0 target:4.3.0
Keywords: regression
Depends on:
Blocks:
 
Reported: 2014-06-26 12:54 UTC by Jacobo Aragunde Pérez
Modified: 2017-06-02 11:10 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Test case (755.15 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2014-06-26 12:54 UTC, Jacobo Aragunde Pérez
Details
Side-by-side comparison (4.2 vs 4.3) (287.86 KB, image/png)
2014-06-26 12:56 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 2014-06-26 12:54:54 UTC
Created attachment 101798 [details]
Test case

Pictures in the attached document aren't rendered in the correct position. This is a regression in 4.3, it used to work in 4.2.
Comment 1 Jacobo Aragunde Pérez 2014-06-26 12:56:39 UTC
Created attachment 101799 [details]
Side-by-side comparison (4.2 vs 4.3)
Comment 2 Damien Chambe 2014-06-30 21:27:00 UTC
Confirm wrong position of pictures with  4.3.0.1 and 4.4.0.0 alpha 0

in 4.2, graphics are rendered as pictures,
in 4.3 / 4.4 they are no more simple pictures, when image artistic effects applied

when OOXML object source contains :

...
<a:ext uri="{BEBA8EAE-BF5A-486C-A8C5-ECC9F3942E4B}">
<a14:imgProps xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main">
<a14:imgLayer r:embed="rId7">
<a14:imgEffect>
<a14:artisticGlowEdges/>
</a14:imgEffect>
</a14:imgLayer>
</a14:imgProps>
</a:ext>


When saving as ODT, pictures with artistic effect is rendered with :
<text:p text:style-name="P1">
<draw:frame text:anchor-type="paragraph" draw:z-index="1" draw:name="Picture 1" draw:style-name="gr1" draw:text-style-name="P3" svg:width="4.938cm" svg:height="5.677cm" svg:x="0cm" svg:y="0cm">
<draw:image xlink:href="Pictures/10000201000001AC000001EC6FDB73BD.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad">
<text:p/>
</draw:image>
</draw:frame>
</text:p>

When no image artistic effect is applied, it is rendered correctly with :
<text:p text:style-name="P2">
<draw:frame draw:style-name="fr1" draw:name="Picture 1" text:anchor-type="char" svg:x="2.164cm" svg:y="0.041cm" svg:width="4.937cm" svg:height="5.676cm" draw:z-index="0">
<draw:image xlink:href="Pictures/10000201000001AC000001ECCD78BB4D.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>
</text:p>
Comment 3 Jacobo Aragunde Pérez 2014-07-01 08:30:29 UTC
(In reply to comment #2)
> Confirm wrong position of pictures with  4.3.0.1 and 4.4.0.0 alpha 0
> 
> in 4.2, graphics are rendered as pictures,
> in 4.3 / 4.4 they are no more simple pictures, when image artistic effects
> applied
> 

You are right, this is the cause of the bug. This simple change works it around, although it breaks the preservation of artistic filters:

diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index cf3da2a..933ae3f 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -655,8 +655,7 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
 {
     // if the shape contains effects in the grab bag, we should not transform it
     // in a XTextContent so those effects can be preserved
-    if( aGrabBag[i].Name == "EffectProperties" || aGrabBag[i].Name == "3DEffectProperties" ||
-            aGrabBag[i].Name == "ArtisticEffectProperties" )
+    if( aGrabBag[i].Name == "EffectProperties" || aGrabBag[i].Name == "3DEffectProperties" )
         bContainsEffects = true;
 }
Comment 4 Jacobo Aragunde Pérez 2014-07-01 15:55:46 UTC
It looks like the code in GraphicImport::lcl_attribute adjust the position of the objects calling GraphicImport_Impl::applyPosition and applyRelativePosition, which set the attributes HoriOrient, HoriOrientPosition, HoriOrientRelation, etc. These attributes can be applied to pictures but not to shapes, according to the api:

Pictures: http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1text_1_1TextGraphicObject.html

Shapes: http://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1drawing_1_1GraphicObjectShape.html
Comment 5 Commit Notification 2014-07-03 12:07:19 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=816542b2bdd23423625ad4c2f0e706d5558b8ba9

fdo#80555: Set position of GraphicObjectShape objects correctly



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 6 Commit Notification 2014-07-05 12:49:43 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "libreoffice-4-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1cacd685bf7c3230d3cdff964503adaedd025418&h=libreoffice-4-3

fdo#80555: Set position of GraphicObjectShape objects correctly


It will be available in LibreOffice 4.3.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 7 Commit Notification 2014-07-10 14:16:52 UTC
Jacobo Aragunde Perez committed a patch related to this issue.
It has been pushed to "libreoffice-4-3-0":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=627d1722892b2969373836c74c84f25995c4b112&h=libreoffice-4-3-0

fdo#80555: Set position of GraphicObjectShape objects correctly


It will be available already in LibreOffice 4.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 vihsa 2017-06-02 11:10:37 UTC
verified

Version: 5.5.0.0.alpha0+
Build ID: 066665644b398a882e6cded98af5bb060af41d76
TinderBox: Android-ARM@24-Bytemark-Hosting, Branch: Master, Time: 2017-06-01 00:30:43