Bug 130076 - Flip from file format ignores angles in section, arc and cut shape
Summary: Flip from file format ignores angles in section, arc and cut shape
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Draw (show other bugs)
Version:
(earliest affected)
7.0.0.0.alpha0+
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:7.4.0 target:7.3.0.2
Keywords: difficultyMedium, easyHack, skillCpp, topicDebug
Depends on:
Blocks:
 
Reported: 2020-01-18 21:42 UTC by Regina Henschel
Modified: 2022-01-10 16:17 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
File to reproduce the error (13.30 KB, application/vnd.oasis.opendocument.graphics)
2020-01-18 21:42 UTC, Regina Henschel
Details
Examples with small sector (13.28 KB, application/vnd.oasis.opendocument.graphics)
2022-01-03 01:36 UTC, Regina Henschel
Details
Example for comment in gerrit (9.38 KB, application/vnd.oasis.opendocument.spreadsheet)
2022-01-03 13:43 UTC, Regina Henschel
Details
Before vs After the fix (92.02 KB, image/png)
2022-01-10 10:47 UTC, Xisco Faulí
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2020-01-18 21:42:10 UTC
Created attachment 157246 [details]
File to reproduce the error

The file format has a draw:transform attribute, which can express horizontal and vertical flip. It can be done with values scale() or matrix(), see attached file.
In case an ellipse or a circle of kind "arc", "cut" or "section" is used, the start- and the end-angle needs to be flipped too. That works without problems, if flipping is done via UI. But is fails, if flipping is part of the file.

In the attached file, the right, green shape should be a horizontal flip of the red shape; and the lower, blue shape should be a vertical flip of the red shape.

The error is in file
 https://opengrok.libreoffice.org/xref/core/xmloff/source/draw/ximpshap.cxx
The transformation is applied before the kind of circle or ellipse is set. Therefore the methods of SdrCircObj get the default kind SdrCircKind::Full and skip all calculating on angles.

A unit test can go to /core/svx/qa/unit/classicshapes.cxx.

Re-Saving will change the draw:transform attribute. LibreOffice does not write flipping as draw:transform attribute, but writes the changed angles. So be careful to use a file similar to the attached file for testing.

The attached file contains only the kind "section", but you can change it in file to "cut" or "arc" for the other cases.

I propose it as easyHack. In case you think it is not suitable, remove the keyword.
Comment 1 Xisco Faulí 2020-01-20 18:50:21 UTC
Moving to NEW
Comment 2 Dhiraj Holden 2022-01-02 12:32:33 UTC
I have run into the following problem working on this. If the call to SetTransformation() is moved to after the circle section properties are set, this causes problems. In particular, test Tdf99497_keepAppearanceOfCircleKind in sd/qa/unit/export-tests-ooxml3.cxx (CppunitTest_sd_export_tests-ooxml3) fails because the size and shape of some circle sections, cuts, and arcs changes. I will try to figure out what is going on here.
Comment 3 Regina Henschel 2022-01-03 01:36:30 UTC
Created attachment 177257 [details]
Examples with small sector

The examples have angles in a way, that the actual outline rectangle is smaller than width x height.

(BTW, the fact that the text is rotated 180deg in case of vertical flip is no error but intended.)
Comment 4 Regina Henschel 2022-01-03 13:43:52 UTC
Created attachment 177280 [details]
Example for comment in gerrit

This is an example, why the change to SdrCircObj::NbcSetSnapRect in https://gerrit.libreoffice.org/c/core/+/127853 will not work.
Comment 5 Commit Notification 2022-01-05 14:32:53 UTC
Dhiraj Holden committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/207d202ed2f1f44e5b62157b5a92ee5e8cc2c3e5

tdf#130076 Fixed flip not working properly from file

It will be available in 7.4.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í 2022-01-10 10:47:42 UTC
Created attachment 177426 [details]
Before vs After the fix
Comment 7 Xisco Faulí 2022-01-10 10:48:10 UTC
Verified in

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

@Dhiraj Holden, thanks for fixing this issue!!
Comment 8 Commit Notification 2022-01-10 16:17:30 UTC
Dhiraj Holden committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/7c51b1129c67b2c8bc85a4560b36555b83adeeb3

tdf#130076 Fixed flip not working properly from file

It will be available in 7.3.0.2.

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.