Bug 143475 - FILEOPEN DOCX Word 2007 rotated image has wrong distance to text
Summary: FILEOPEN DOCX Word 2007 rotated image has wrong distance to text
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.3.0
Keywords:
Depends on:
Blocks: DOCX-Images
  Show dependency treegraph
 
Reported: 2021-07-21 13:01 UTC by Regina Henschel
Modified: 2021-08-09 15:20 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
The example document in Word and Writer (341.35 KB, image/png)
2021-07-22 12:10 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2021-07-21 13:01:17 UTC
Open attachment 111363 [details] from bug 73797. The second image should be on the first page. It moves to second page because the top and bottom distance to text is too large.

The error was reported in bug 143455.

Considering the effectExtent at all (for to get distance for glow and shadow) was introduced with commit https://cgit.freedesktop.org/libreoffice/core/commit/?id=3262fc5ef3bde5b158909d11ccb008161ea95519. It needs some more fine tuning.
Comment 1 Xisco Faulí 2021-07-21 21:54:39 UTC
Moving to NEW
Comment 2 NISZ LibreOffice Team 2021-07-22 12:10:04 UTC
Created attachment 173772 [details]
The example document in Word and Writer

Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 0d4cbdbc9cd4ab06056cec66cffd292b41615b6e
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: en-US
Calc: CL
Comment 3 Regina Henschel 2021-07-22 17:47:36 UTC
It seems, that a compatibility handling inside Word is involved. If I save the test document so, that I uncheck "keep compatibility with previous versions", then the document is rendered in Word the same as now in LibreOffice.

In "compatible mode" Word adds the effectExtent to the unrotated image and has a space in the content of the line as large as the unrotated image. In non-compatible mode it adds the effectExent to the rotated image, and use the space of the rotated shape.

From my experiments I guess the older behavior is for version <=14 and the newer behavior for version >=15.

The example document uses 90deg rotation. ToDo: Examine whether there is a change in behavior at the 45deg threshold.
Comment 4 Regina Henschel 2021-07-25 16:16:36 UTC
Word 2007 (=version 12) has the special feature, that for images, which are rotated between 45deg and 135deg or between 235deg and 315deg, the effectExtent values are based on an rectangle without swapped width and height.
Because the current code assumes swapped width and height - as usual for newer versions and other objects - it calculates wrong wrap margins.

That results in too large top and bottom margin in the example document, which leads to a page break, because the image has not enough space on the first page.

The problem is not only with inline anchored images, but with other anchor types too.

I have started work on a patch in https://gerrit.libreoffice.org/c/core/+/119482.
Comment 5 Commit Notification 2021-07-26 23:34:24 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/67f2a99229101757af4f40118f4d3c83ba38648b

tdf#143475 consider Word 2007 rotated image speciality

It will be available in 7.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 6 Xisco Faulí 2021-08-09 15:20:14 UTC
Verified in

Version: 7.3.0.0.alpha0+ / LibreOffice Community
Build ID: 6e53e03f752c2f85283c4d47efaaf0683299783c
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

@Regina, thanks for fixing this issue!!