Bug 141982 - [EMF] SetWorldTransform/ModifyWorldTransform support for non-0 m12/m21
Summary: [EMF] SetWorldTransform/ModifyWorldTransform support for non-0 m12/m21
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
4.4 all versions
Hardware: All All
: medium normal
Assignee: Bartosz
URL:
Whiteboard: target:7.2.0 target:7.1.4
Keywords: bibisected, bisected, regression
Depends on:
Blocks: EMF-WMF
  Show dependency treegraph
 
Reported: 2021-04-29 23:21 UTC by Valek Filippov
Modified: 2021-05-22 15:20 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
EMF sample with rotated rectangle (256 bytes, image/emf)
2021-04-29 23:22 UTC, Valek Filippov
Details
Screeenshot of the attached EMF with rotated rectangle sample opened in LO Draw (3.25 KB, image/png)
2021-04-29 23:22 UTC, Valek Filippov
Details
Screenshot for the file opened in MSO (7.21 KB, image/png)
2021-04-29 23:23 UTC, Valek Filippov
Details
EMF sample with rotated Ellipse (256 bytes, image/emf)
2021-04-29 23:23 UTC, Valek Filippov
Details
Screenshot for the file w rotated Ellipse opened in MSO (12.46 KB, image/png)
2021-04-29 23:25 UTC, Valek Filippov
Details
How it looks before the mentioned commit (1.36 KB, image/png)
2021-04-30 14:08 UTC, Xisco Faulí
Details
EMF sample with rotated Chord (272 bytes, image/x-emf)
2021-05-05 14:07 UTC, Valek Filippov
Details
EMF sample with rotated RounRect (264 bytes, image/x-emf)
2021-05-05 14:09 UTC, Valek Filippov
Details
Screenshot of the sample files (chord and roundrect) in MSO for mac (12.28 KB, image/png)
2021-05-05 14:21 UTC, Valek Filippov
Details
EMF sample with rotated Pie (272 bytes, image/x-emf)
2021-05-05 16:50 UTC, Valek Filippov
Details
Screenshot of the sample file in MSO for win (1.21 KB, image/png)
2021-05-05 16:52 UTC, Valek Filippov
Details
EMF sample with rotated Polyline (284 bytes, image/x-emf)
2021-05-05 21:08 UTC, Valek Filippov
Details
Screenshot for polyline sample (17.52 KB, image/png)
2021-05-05 21:09 UTC, Valek Filippov
Details
EMF sample with rotated Polygon (good in LO 7.x) (280 bytes, image/x-emf)
2021-05-05 21:24 UTC, Valek Filippov
Details
Screenshot of the sample file with polygon in MSO for win (1.59 KB, image/png)
2021-05-05 21:26 UTC, Valek Filippov
Details
EMF sample with rotated Pie (large) (272 bytes, image/x-emf)
2021-05-06 18:27 UTC, Valek Filippov
Details
Screenshot of the sample file (Pie enlarged) in MS Paint (1.70 KB, image/png)
2021-05-06 18:29 UTC, Valek Filippov
Details
EMF sample with rotated Polyline (enlarged) (284 bytes, image/x-emf)
2021-05-06 19:01 UTC, Valek Filippov
Details
Screenshot of the sample file (polyline enlarged) in MS Paint (4.58 KB, image/png)
2021-05-06 19:03 UTC, Valek Filippov
Details
EMF sample with rotated Ellipse (filled) (292 bytes, image/x-emf)
2021-05-06 19:19 UTC, Valek Filippov
Details
Screenshot of the sample file (ellipse filled) in MS Paint (4.40 KB, image/png)
2021-05-06 19:20 UTC, Valek Filippov
Details
EMF sample with xskewed pentagon (336 bytes, image/x-emf)
2021-05-06 19:41 UTC, Valek Filippov
Details
Screenshot of the sample file (xskewed pentagon) in MS Paint (3.05 KB, image/png)
2021-05-06 19:42 UTC, Valek Filippov
Details
EMF sample with rotated LineTo-ArcTo-LineTo (340 bytes, image/x-emf)
2021-05-06 20:24 UTC, Valek Filippov
Details
Screenshot of the sample file (LineTo-ArcTo-LineTo) in MS Paint (3.10 KB, image/png)
2021-05-06 20:24 UTC, Valek Filippov
Details
WMF sample intersectclip+excludeclip+ellipse (88 bytes, image/x-wmf)
2021-05-07 16:10 UTC, Valek Filippov
Details
Screenshot of the WMF sample with intersect+excludeclip+ellipse opened in MS Paint (1.34 KB, image/png)
2021-05-07 16:11 UTC, Valek Filippov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Valek Filippov 2021-04-29 23:21:19 UTC
Description:
LO seems to fail to properly apply affine transformation matrices with non-zero m12/m21 components (rotation or shearing the shapes).

For the simple case with rotated rectangle LO seems to apply transformations to top-left and bottom-right corners than draw rectangle with an updated bbox.

Steps to Reproduce:
Load attached EMF sample in LO.


Actual Results:
EMF file is not rendered properly

Expected Results:
Proper support of EMF_SETWORLDTRANSFORM and EMF_MODIFYWORLDTRANSFORM


Reproducible: Always


User Profile Reset: No



Additional Info:
More samples are available by request
Comment 1 Valek Filippov 2021-04-29 23:22:07 UTC
Created attachment 171512 [details]
EMF sample with rotated rectangle
Comment 2 Valek Filippov 2021-04-29 23:22:49 UTC
Created attachment 171513 [details]
Screeenshot of the attached EMF with rotated rectangle sample opened in LO Draw
Comment 3 Valek Filippov 2021-04-29 23:23:18 UTC
Created attachment 171514 [details]
Screenshot for the file opened in MSO
Comment 4 Valek Filippov 2021-04-29 23:23:59 UTC
Created attachment 171515 [details]
EMF sample with rotated Ellipse
Comment 5 Valek Filippov 2021-04-29 23:25:09 UTC
Created attachment 171516 [details]
Screenshot for the file w rotated Ellipse opened in MSO
Comment 6 Xisco Faulí 2021-04-30 07:22:35 UTC
Reproduced in

Version: 7.2.0.0.alpha0+ / LibreOffice Community
Build ID: 78ad3fe28321a9e2e4eaa0dcc8f1ccdaed0b1f79
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 7 Xisco Faulí 2021-04-30 07:25:26 UTC
Also reproducible in

Version: 5.4.0.0.alpha1+
Build ID: 9feb7f7039a3b59974cbf266922177e961a52dd1
CPU threads: 4; OS: Linux 5.7; UI render: default; VCL: gtk3; 
Locale: en-US (en_US.UTF-8); Calc: group

Version: 5.2.0.0.alpha0+
Build ID: 3ca42d8d51174010d5e8a32b96e9b4c0b3730a53
Threads 4; Ver: 5.7; Render: default; 

and

Version: 4.3.0.0.alpha1+
Build ID: c15927f20d4727c3b8de68497b6949e72f9e6e9e

but not in

Version 4.1.0.0.alpha0+ (Build ID: efca6f15609322f62a35619619a6d5fe5c9bd5a)
Comment 8 Xisco Faulí 2021-04-30 07:32:38 UTC
Regression introduced by:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=1281c1f52b77c4c4fb08e129542c2c4912b38555

author	Armin Le Grand <alg@apache.org>	2012-12-10 16:08:58 +0000
committer	Caolán McNamara <caolanm@redhat.com>	2013-06-08 19:27:03 +0100
commit	1281c1f52b77c4c4fb08e129542c2c4912b38555 (patch)
tree	9d359640355484084a985b738d27a3df93eee74d
parent	ec2512209d8fbf640749ab9f18b2232ac9cbf060 (diff)
Resolves: #i121382# Corrected size handling including font size handling...
for EMF/WMF imports

Bisected with: bibisect-42max

@Bartosz, I thought you might be interested in this issue...
Comment 9 Bartosz 2021-04-30 13:05:07 UTC
@Xisco Are you sure the regression was introduced by this commit?

Could you please attach screenshots of EMF files imported by LibreOffice 4.1?
Comment 10 Xisco Faulí 2021-04-30 14:08:21 UTC
Created attachment 171537 [details]
How it looks before the mentioned commit
Comment 11 Xisco Faulí 2021-04-30 14:10:50 UTC
(In reply to Bartosz from comment #9)
> @Xisco Are you sure the regression was introduced by this commit?
> 
> Could you please attach screenshots of EMF files imported by LibreOffice 4.1?

In fact, this change

--- a/emfio/source/reader/mtftools.cxx
+++ b/emfio/source/reader/mtftools.cxx
@@ -639,8 +639,8 @@ namespace emfio
             double fWidth, fHeight;
             if (bDoWorldTransform)
             {
-                fWidth = rSz.Width() * maXForm.eM11 + rSz.Height() * maXForm.eM21;
-                fHeight = rSz.Width() * maXForm.eM12 + rSz.Height() * maXForm.eM22;
+                fWidth = rSz.Width() * maXForm.eM11;
+                fHeight = rSz.Width() * maXForm.eM12;
             }


makes it to be displayed as a square again
Comment 12 Commit Notification 2021-05-05 08:24:46 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/24e71494d7d1a68b2cb5f5d34083ab02009e0982

tdf#55058 tdf#141982 EMF: Add rotation and path support for RECTANGLE record

It will be available in 7.2.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 13 Valek Filippov 2021-05-05 14:07:20 UTC
Created attachment 171645 [details]
EMF sample with rotated Chord
Comment 14 Valek Filippov 2021-05-05 14:08:05 UTC
Comment on attachment 171645 [details]
EMF sample with rotated Chord

LO shows no image
Comment 15 Valek Filippov 2021-05-05 14:09:56 UTC
Created attachment 171646 [details]
EMF sample with rotated RounRect

The shape is smashed the same way it was for rect before Bartosz' fix
Comment 16 Valek Filippov 2021-05-05 14:21:48 UTC
Created attachment 171647 [details]
Screenshot of the sample files (chord and roundrect) in MSO for mac

MSO for win seems to have a bug: roundrect is not rotated. Wordpad shows the same as MSO on mac (+terrible rasterization)
Comment 17 Valek Filippov 2021-05-05 16:50:23 UTC
Created attachment 171654 [details]
EMF sample with rotated Pie

LO shows nothing, the shape is very similar to Chord, a bit different rotation angle as per Bartosz request.
Comment 18 Valek Filippov 2021-05-05 16:52:04 UTC
Created attachment 171655 [details]
Screenshot of the sample file in MSO for win

MSO on mac and wordpad failed to do it right
Comment 19 Valek Filippov 2021-05-05 21:08:00 UTC
Created attachment 171661 [details]
EMF sample with rotated Polyline

LO shows empty object
Comment 20 Valek Filippov 2021-05-05 21:09:01 UTC
Created attachment 171662 [details]
Screenshot for polyline sample

On the left how it looks in MSO on win. On the right -- how it should look like according to the spec.
Comment 21 Valek Filippov 2021-05-05 21:24:28 UTC
Created attachment 171663 [details]
EMF sample with rotated Polygon (good in LO 7.x)

Attaching for completeness. This one is rendered properly.
Comment 22 Valek Filippov 2021-05-05 21:26:17 UTC
Created attachment 171664 [details]
Screenshot of the sample file with polygon in MSO for win
Comment 23 Commit Notification 2021-05-06 07:01:38 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/d08f1242ab3775c5f22d5624b91572c54d3fec81

tdf#55058 tdf#141982 EMF: Add rotation and path support for RECTANGLE record

It will be available in 7.1.4.

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 24 Xisco Faulí 2021-05-06 07:40:17 UTC
Hi Bartosz,
looking at https://cgit.freedesktop.org/libreoffice/core/commit/?id=24e71494d7d1a68b2cb5f5d34083ab02009e0982, you implemented the rotation for EMR_RECTANGLE. is it possible to do it for all the shapes at once or do we need to implement it for every case ?
Comment 25 Commit Notification 2021-05-06 10:13:29 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/761fdaf26dc9ed7cd0d25a7630576e7800813e2f

tdf#142004 tdf#141982 EMF Import: Add rotation and path support for EMR_ELLIPSE

It will be available in 7.2.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 26 Bartosz 2021-05-06 13:37:41 UTC
(In reply to Xisco Faulí from comment #24)
> looking at
> https://cgit.freedesktop.org/libreoffice/core/commit/
> ?id=24e71494d7d1a68b2cb5f5d34083ab02009e0982, you implemented the rotation
> for EMR_RECTANGLE. is it possible to do it for all the shapes at once or do
> we need to implement it for every case ?

I would like to avoid regression which could appear during implementation.
That's why I would like to cover every shape with separate test case.
It will simplify tracking regression in future.

I could try to implement all shapes in one go.
Comment 27 Bartosz 2021-05-06 15:21:49 UTC
Hello Valek.

Unfortunately Pie and Polyline is not displayed correctly under MS Paint (it seems that it is too small to be correctly displayed).
Please provide Pie and Polyline which are displayed correctly under MS Paint.

Summary what I need:
- rotated POLYLINE (it could be also reflected like: https://en.wikipedia.org/wiki/Transformation_matrix#/media/File:2D_affine_transformation_matrix.svg)
- rotated PIE (it could be different angle like 400 degrees)
- sheared/rotated PIETO with additional LINETO (to check if it is drawing correctly)
Comment 28 Commit Notification 2021-05-06 16:04:44 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/eb1ec67f9a479148044f3869afe461e0f4533f22

tdf#142004 tdf#141982 EMF Import: Add rotation and path support for EMR_ELLIPSE

It will be available in 7.1.4.

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 29 Valek Filippov 2021-05-06 18:27:33 UTC
Created attachment 171707 [details]
EMF sample with rotated Pie (large)
Comment 30 Valek Filippov 2021-05-06 18:29:50 UTC
Created attachment 171708 [details]
Screenshot of the sample file (Pie enlarged) in MS Paint

MS Word for win doesn't rotate Pie, wordpad does
Comment 31 Commit Notification 2021-05-06 19:00:35 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6bf2239a189423d087b2536dd7054b21df58ddc4

tdf#55058 tdf#141982 EMF: Add rotation support for ARC, ARCTO, CHORD, PIE

It will be available in 7.2.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 32 Valek Filippov 2021-05-06 19:01:33 UTC
Created attachment 171709 [details]
EMF sample with rotated Polyline (enlarged)

MS Word on win fails to rotate it
Comment 33 Valek Filippov 2021-05-06 19:03:16 UTC
Created attachment 171710 [details]
Screenshot of the sample file (polyline enlarged) in MS Paint
Comment 34 Valek Filippov 2021-05-06 19:19:15 UTC
Created attachment 171711 [details]
EMF sample with rotated Ellipse (filled)

As per Bartosz request
Comment 35 Valek Filippov 2021-05-06 19:20:42 UTC
Created attachment 171712 [details]
Screenshot of the sample file (ellipse filled) in MS Paint
Comment 36 Valek Filippov 2021-05-06 19:41:23 UTC
Created attachment 171713 [details]
EMF sample with xskewed pentagon
Comment 37 Valek Filippov 2021-05-06 19:42:08 UTC
Created attachment 171714 [details]
Screenshot of the sample file (xskewed pentagon) in MS Paint
Comment 38 Valek Filippov 2021-05-06 19:44:08 UTC
Comment on attachment 171713 [details]
EMF sample with xskewed pentagon

Opens properly in LO 7.0.5, added for test coverage completeness
Comment 39 Commit Notification 2021-05-06 20:21:50 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/6eac9d960f2bb5dae54ef6ca8e7c659e8c79d011

tdf#55058 tdf#141982 EMF: Add rotation support for ARC, ARCTO, CHORD, PIE

It will be available in 7.1.4.

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 40 Valek Filippov 2021-05-06 20:24:17 UTC
Created attachment 171715 [details]
EMF sample with rotated LineTo-ArcTo-LineTo

Doesn't render properly with LO 7.0.5
Comment 41 Valek Filippov 2021-05-06 20:24:58 UTC
Created attachment 171716 [details]
Screenshot of the sample file (LineTo-ArcTo-LineTo) in MS Paint
Comment 42 Valek Filippov 2021-05-07 16:10:25 UTC
Created attachment 171753 [details]
WMF sample intersectclip+excludeclip+ellipse

As per Bartosz request
Comment 43 Valek Filippov 2021-05-07 16:11:10 UTC
Created attachment 171754 [details]
Screenshot of the WMF sample with intersect+excludeclip+ellipse opened in MS Paint
Comment 44 Commit Notification 2021-05-07 19:02:47 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/1ef26ffe39618a745d3367310565e7eeb184a4c2

tdf#55058 tdf#141982 EMF: Add rotation support for INTERSECTCLIPRECT record

It will be available in 7.2.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 45 Valek Filippov 2021-05-07 19:25:07 UTC
https://bugs.documentfoundation.org/attachment.cgi?id=171767

Sample for XForm appplied to ExcludeClipRect.
(Added to 142037, which is about adding ExcludeClipRect)
Comment 46 Commit Notification 2021-05-10 08:11:38 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/a67a30227ef32ab9fc3026bb19e48d4447df25d1

tdf#55058 tdf#141982 EMF: Add rotation support for INTERSECTCLIPRECT record

It will be available in 7.1.4.

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 47 Xisco Faulí 2021-05-11 07:59:16 UTC
*** Bug 142206 has been marked as a duplicate of this bug. ***
Comment 48 Commit Notification 2021-05-11 16:38:34 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/f11ed681df15728abe6a0b6b7b1612f190aa1707

tdf#141982 tdf#142139 Add rotation and line width support to ROUNDRECT

It will be available in 7.2.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 49 Commit Notification 2021-05-11 20:35:53 UTC
Bartosz Kosiorek committed a patch related to this issue.
It has been pushed to "libreoffice-7-1":

https://git.libreoffice.org/core/commit/2a416c0c4a1635af8be5b1167fd1f06bdc4a2466

tdf#141982 tdf#142139 Add rotation and line width support to ROUNDRECT

It will be available in 7.1.4.

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 50 Xisco Faulí 2021-05-21 17:10:04 UTC
Hello Valek,
Could you please confirm the issue is fixed in a master build? If you find any of the attached documents is still problematic, please create a follow-up ticket
Comment 51 Valek Filippov 2021-05-22 15:20:08 UTC
(In reply to Xisco Faulí from comment #50)
> Hello Valek,
> Could you please confirm the issue is fixed in a master build? If you find
> any of the attached documents is still problematic, please create a
> follow-up ticket

All but line-arc-line works fine. The problem with line-arc-line seems to be unrelated to XForm and looks more like 'behavior for undocumented situation'.
I will investigate that and follow-up with Bartosz in a separate ticket.