Bug 60351 - FILEOPEN: DOCX - Tight and through text wrapping incorrectly enables Auto-Contour on images
Summary: FILEOPEN: DOCX - Tight and through text wrapping incorrectly enables Auto-Con...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:5.1.0 target:6.0.0
Keywords: difficultyInteresting, easyHack
: 56351 63851 86540 95930 (view as bug list)
Depends on:
Blocks: Writer-Images DOCX-Anchor-and-Text-Wrap
  Show dependency treegraph
 
Reported: 2013-02-06 05:20 UTC by Alexander
Modified: 2018-10-10 11:36 UTC (History)
11 users (show)

See Also:
Crash report or crash signature:


Attachments
sample document (646.79 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2013-02-06 05:21 UTC, Alexander
Details
screenshot (213.29 KB, image/png)
2013-02-06 05:22 UTC, Alexander
Details
Patch that fixes the problem in the contour of the imported images (2.71 KB, patch)
2013-05-04 12:37 UTC, Anderson Cordeiro
Details
LibO 5.3 vs Word 2010 (931.15 KB, image/png)
2016-11-05 14:12 UTC, Yousuf Philips (jay) (retired)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander 2013-02-06 05:20:52 UTC
In .docx-document made with MSO 2010 images contours are wrong. MSO 2013 open it file OK.

See screenshot and sample document at pages: 2, 4, 5, 6, 8 or 9 (on screenshot).
Comment 1 Alexander 2013-02-06 05:21:39 UTC
Created attachment 74270 [details]
sample document
Comment 2 Alexander 2013-02-06 05:22:55 UTC
Created attachment 74271 [details]
screenshot
Comment 3 Rainer Bielefeld Retired 2013-02-06 06:15:22 UTC
Effect is reproducible with Server Installation of "LibreOffice 3.6.5.2 " German UI/ German Locale [Build-ID: 5b93205] {pull date 2013-01-18} on German WIN7 Home Premium (64bit).

Same with AOOo3.4.1, so I think this is inherited from OOo.

Those seem to bee strange pictures in the document. I extracted them from unzipped Дыхание - c картинками.odt, and I fail open them from WIN Explorer with IrfanView and Gimp, I get error message (can't read file header / invalid argument).

I wonder why LibO has "Contour" checked, none of the pictures is used with "Contour" in MS WORD VIEWER.

When I copy / Paste all contents of Дыхание - c картинками.docx to an empty new Writer document and correct the wrong picture links, everythin looks fine, pictures are used without any 'Contour'.

What ever tht might mean.
Comment 4 A (Andy) 2013-03-29 16:07:13 UTC
reproducible with LO 4.0.1.2 (Win7 Home, 64bit)

In addition, the last paragraph on page 1 is moved up.
Comment 5 Cédric Bosdonnat 2013-04-29 09:24:56 UTC
The problem with that one document is that the Auto-contour feature is triggered... thus overriding the proper contour polygon defined in the docx file.

The code responsible for that is located here:
http://opengrok.libreoffice.org/xref/core/writerfilter/source/dmapper/GraphicImport.cxx#875

Looks like an easy hack.
Comment 6 Anderson Cordeiro 2013-05-03 06:57:14 UTC
Hello guys, I'm working on it!

Hugs!
Comment 7 Anderson Cordeiro 2013-05-03 06:57:35 UTC Comment hidden (obsolete)
Comment 8 Anderson Cordeiro 2013-05-04 12:37:40 UTC
Created attachment 78840 [details]
Patch that fixes the problem in the contour of the imported images

This patch shows that I can understand the code and work with dedication to community LibreOffice
Comment 9 Samuel Mehrbrodt (allotropia) 2013-10-01 22:06:19 UTC
Can anyone review that patch please? It's there since five months with no response.
Comment 10 retired 2013-10-02 07:31:59 UTC
For what it's worth: MS office 2010 Word opens the file ok and shows the page in question correctly. On OS X 10.8.5 and LO 4.1.2.2 the image is displayed wrongly (as shown in the attached screenshot).

But with Version: 4.2.0.0.alpha0+
Build ID: f4d3954fc6106b3ae0ee16ab0fcde15d8cb945e3, the image is shows correctly, so I'm marking this FIXED.

Anderson, thanks for your patch.
Comment 11 retired 2013-10-03 09:15:31 UTC
@Samuel: Could you submit your patch to gerrit or the dev mailing list? I talked to moggi and he advised to not put patches into bugzilla (I guess since then changes it's getting looked at and merged are far decreased).
Comment 12 Samuel Mehrbrodt (allotropia) 2013-10-03 09:20:33 UTC
Well, that patch is not from me. But it seems that this has been fixed already (Comment 10 says that)
Comment 13 ign_christian 2013-10-03 12:25:33 UTC
Wasn't that from Anderson Cordeiro (comment 8) thats still on fire to dedicate..:) and CC-ed here

@Anderson, please confirm that.
Comment 14 Mike Kaganski 2015-11-21 07:02:35 UTC
This is not resolved yet; the improvement of display of the bugdoc affected only few of its images. The improvement was possibly due to some improvement of auto-contour feature. The actual problem is that LO ignores wrap polygon imported from DOCX when it cannot get the image metric size. Then, for imported images with contour wrap LO creates autocontour that is often non-optimal, and differs from original.

The patch from Anderson Cordeiro simply unconditionally turns off the wrap for imported images; thus, it's not a fix, because it changes formatting (and will give bad results for all cases of complex contours).

Submitted patch to gerrit:
https://gerrit.libreoffice.org/20103
Comment 15 Mike Kaganski 2015-11-21 07:02:48 UTC
*** Bug 95930 has been marked as a duplicate of this bug. ***
Comment 16 Mike Kaganski 2015-11-21 07:02:58 UTC
*** Bug 63851 has been marked as a duplicate of this bug. ***
Comment 17 Commit Notification 2015-11-23 11:34:46 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

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

tdf#60351: Use Wrap Polygon also for PROP_SIZE_PIXEL

It will be available in 5.1.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 18 Mike Kaganski 2015-12-10 08:36:58 UTC
*** Bug 56351 has been marked as a duplicate of this bug. ***
Comment 19 Robinson Tryon (qubit) 2015-12-16 05:27:25 UTC Comment hidden (obsolete)
Comment 20 Yousuf Philips (jay) (retired) 2016-11-05 13:25:43 UTC
The fix improved things, but isnt a complete fix as the contour is still enabled as can be seen in the Context Menu > Wrap as well as the 'Enable Contour' checkbox in the wrap content panel of the sidebar.
Comment 21 Yousuf Philips (jay) (retired) 2016-11-05 13:28:27 UTC
*** Bug 86540 has been marked as a duplicate of this bug. ***
Comment 22 Mike Kaganski 2016-11-05 13:29:01 UTC
(In reply to Yousuf Philips (jay) from comment #20)
> The fix improved things, but isnt a complete fix as the contour is still
> enabled as can be seen in the Context Menu > Wrap as well as the 'Enable
> Contour' checkbox in the wrap content panel of the sidebar.

??? That's the expected behavior! The contour is imported and must be present, just not autocontour. Please describe what exactly is wring.
Comment 23 Yousuf Philips (jay) (retired) 2016-11-05 13:57:24 UTC
(In reply to Mike Kaganski from comment #22)
> ??? That's the expected behavior! The contour is imported and must be
> present, just not autocontour. Please describe what exactly is wring.

The issue can be seen in attachment 74270 [details], but isnt as easy to illustrate, so i'll use attachment 69995 [details] for a screenshot. The code should be optimized so that when a contour is the exact same size of the image, contour should be disabled.
Comment 24 Mike Kaganski 2016-11-05 14:09:19 UTC
Well, that's a reasonable enhancement, but it should have its own issue.
This one had dealt with general loss of imported contour; this affected both those images that had arbitrary contours as well as that had rectangular ones equal to image size. It is solved here.
Comment 25 Yousuf Philips (jay) (retired) 2016-11-05 14:12:12 UTC
Created attachment 128514 [details]
LibO 5.3 vs Word 2010

As can be seen in the attachment of a side by side screenshot comparison of Writer vs Word, the contour is cropping parts on the right and bottom sides of the image.
Comment 26 Mike Kaganski 2016-11-05 14:12:58 UTC
By the way, if the imported contour should be discarded - and thus be lost on round-trip - is questionable.
Comment 27 Mike Kaganski 2016-11-05 14:14:06 UTC
(In reply to Yousuf Philips (jay) from comment #25)
> Created attachment 128514 [details]
> LibO 5.3 vs Word 2010
> 
> As can be seen in the attachment of a side by side screenshot comparison of
> Writer vs Word, the contour is cropping parts on the right and bottom sides
> of the image.

And this is because in writer, wrapping contour is also (unfortunately) cropping contour
Comment 28 Commit Notification 2017-08-25 12:06:26 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

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

tdf#60351 - add unit test for shape brought to foreground

It will be available in 6.0.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.