Bug 142881 - FILESAVE XLSX Some rotated shapes are vertically flipped
Summary: FILESAVE XLSX Some rotated shapes are vertically flipped
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.0.0.3 release
Hardware: All All
: medium normal
Assignee: Dániel Arató (NISZ)
URL:
Whiteboard: target:7.3.0 target:7.2.2
Keywords: filter:xlsx, implementationError
Depends on:
Blocks: XLSX-Shapes
  Show dependency treegraph
 
Reported: 2021-06-15 15:17 UTC by NISZ LibreOffice Team
Modified: 2021-09-08 11:31 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:
Regression By:


Attachments
Example file from Excel with rotated shapes (12.11 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2021-06-15 15:17 UTC, NISZ LibreOffice Team
Details
The original file saved by Calc (7.52 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2021-06-15 15:17 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document in Calc (111.87 KB, image/png)
2021-06-15 15:18 UTC, NISZ LibreOffice Team
Details
Screenshot of the exported document in Calc (83.10 KB, image/png)
2021-06-15 15:18 UTC, NISZ LibreOffice Team
Details
All shapes in A1 (9.67 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-06-16 22:10 UTC, Regina Henschel
Details
Export with current master (5.55 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2021-06-16 22:13 UTC, Regina Henschel
Details
'repaired' file (5.66 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2021-06-16 22:20 UTC, Regina Henschel
Details
proposed patch (958 bytes, patch)
2021-06-16 23:12 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2021-06-15 15:17:15 UTC
Created attachment 172920 [details]
Example file from Excel with rotated shapes

Attached example file contains rotated shapes made in Excel.
When saving this in Calc to XLSX some of them are vertically flipped.

Steps to reproduce:
    1. Open attached file
    2. Save as XLSX, reopen in Calc or Excel

Actual results:
Some shapes are vertically flipped with rotation values of 45 degrees, 135 degrees, 225 degrees and 315 degrees.

Expected results:
Rotation should be retained.

LibreOffice details:
Version: 7.2.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: 93a3e2f86c27b06062708fe788963a0e49f3a90b
CPU threads: 4; OS: Windows 10.0 Build 18363; UI render: default; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: CL

Also in 7.0, in 6.4 the rotations were not all imported correctly.
Comment 1 NISZ LibreOffice Team 2021-06-15 15:17:39 UTC
Created attachment 172921 [details]
The original file saved by Calc
Comment 2 NISZ LibreOffice Team 2021-06-15 15:18:30 UTC
Created attachment 172922 [details]
Screenshot of the original document in Calc
Comment 3 NISZ LibreOffice Team 2021-06-15 15:18:47 UTC
Created attachment 172923 [details]
Screenshot of the exported document in Calc
Comment 4 Shinji Enoki 2021-06-16 11:25:48 UTC
I reproduced in the following environment:

Version: 7.1.4.2 / LibreOffice Community
Build ID: a529a4fab45b75fefc5b6226684193eb000654f6
CPU threads: 8; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: ja-JP (ja_JP.UTF-8); UI: ja-JP
Calc: threaded
Comment 5 Regina Henschel 2021-06-16 22:08:52 UTC
I think, the shapes are not flipped, but have a wrong swapped width and height in the anchor.

If the rotation angle is larger as 45deg, MSO swaps width and height in calculating the anchor, and LO too. But it seems for exact 45deg MSO does not swap width and height, but LO does it.

To make it easier to calculate the object size from the anchor, put all shapes into one large cell. Then you can get the size as difference of the offset. If I do so, and then "repair" the document so, that the offset in the 'to' element corresponds to the not swapped width and height, the shapes will be shown correctly in Excel.
Comment 6 Regina Henschel 2021-06-16 22:10:07 UTC
Created attachment 172951 [details]
All shapes in A1

original ods file
Comment 7 Regina Henschel 2021-06-16 22:13:05 UTC
Created attachment 172952 [details]
Export with current master
Comment 8 Regina Henschel 2021-06-16 22:20:44 UTC
Created attachment 172953 [details]
'repaired' file

Here the offset in the 'to' element is set, so that from-colOff + ext.cx = to-colOff and from-rowOff + ext.cy = to-rowOff.
Comment 9 Regina Henschel 2021-06-16 23:12:47 UTC
Created attachment 172956 [details]
proposed patch

I don't know, whether such change will have any impact on export to MS binary format or to other formats than OOXML.
Comment 10 Regina Henschel 2021-06-17 23:27:13 UTC
This should be fixed together with bug 142914, because the same code part is affected.
Comment 11 NISZ LibreOffice Team 2021-06-18 09:48:50 UTC
(In reply to Regina Henschel from comment #10)
> This should be fixed together with bug 142914, because the same code part is
> affected.

Thanks for the analysis. I asked Szabolcs to take a look at this.
Comment 12 Commit Notification 2021-08-31 11:57:23 UTC
Daniel Arato (NISZ) committed a patch related to this issue.
It has been pushed to "master":

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

tdf#142881 XLSX import: fix shapes rotated exactly 45°,

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 13 Commit Notification 2021-09-01 09:32:54 UTC
Daniel Arato (NISZ) committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/30128c2fea22ccd08678744c9501ab052a1fb074

tdf#142881 XLSX import: fix shapes rotated exactly 45°,

It will be available in 7.2.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.
Comment 14 Regina Henschel 2021-09-07 00:05:46 UTC
Isn't this fixed now?
Comment 15 NISZ LibreOffice Team 2021-09-08 11:31:31 UTC
Daniel Arato (NISZ) committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/30128c2fea22ccd08678744c9501ab052a1fb074

tdf#142881 XLSX import: fix shapes rotated exactly 45°,

It will be available in 7.2.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.
Comment 16 NISZ LibreOffice Team 2021-09-08 11:31:52 UTC
Verified in:
Version: 7.3.0.0.alpha0+ (x64) / LibreOffice Community
Build ID: 8151f3a1d99ab740d2affdccc7115faa156bf3ad
CPU threads: 4; OS: Windows 10.0 Build 17134; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: hu-HU
Calc: threaded