Bug 109169 - [FILESAVE DOCX] Some shapes are not correctly preserved when saved as DOCX
Summary: [FILESAVE DOCX] Some shapes are not correctly preserved when saved as DOCX
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: Not Assigned
URL:
Whiteboard: target:7.4.0 target:7.3.4
Keywords: filter:docx
Depends on:
Blocks: Shape-ODF-OOXML-export
  Show dependency treegraph
 
Reported: 2017-07-17 14:08 UTC by Gabor Kelemen (allotropia)
Modified: 2022-04-26 19:14 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Original odt with the shapes (37.78 KB, application/vnd.oasis.opendocument.text)
2017-07-17 14:08 UTC, Gabor Kelemen (allotropia)
Details
Same file exported to docx (15.28 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2017-07-17 14:08 UTC, Gabor Kelemen (allotropia)
Details
Screenshot of the original document in LO 5.4 and Word 2013 (103.63 KB, image/png)
2017-07-17 14:10 UTC, Gabor Kelemen (allotropia)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gabor Kelemen (allotropia) 2017-07-17 14:08:02 UTC
Created attachment 134686 [details]
Original odt with the shapes

Issue with drawings created in LibreOffice and saved as DOCX: Several shapes are not correctly preserved. The shapes affected are the following:
Circle Segment, Arc, Octagon Bevel, Diamond Bevel.

Steps to reproduce:
1. Create an empty text document in LibreOffice
2. Insert any of the shapes listed above
3. Save the file both as ODT and DOCX in LibreOffice
4. Compare the ODT and the DOCX file

Actual results:
The shapes listed above appear different in the ODT and the DOCX document

Expected results:
The shapes should have the same appearance when opening the ODT and the DOCX file
Comment 1 Gabor Kelemen (allotropia) 2017-07-17 14:08:38 UTC
Created attachment 134687 [details]
Same file exported to docx
Comment 2 Gabor Kelemen (allotropia) 2017-07-17 14:10:00 UTC
Created attachment 134688 [details]
Screenshot of the original document in LO 5.4 and Word 2013
Comment 3 Jacques Guilleron 2017-07-18 09:51:33 UTC
Hello,

I reproduce with
LO 6.0.0.0.alpha0+ Build ID: 643da8ec4e721d33dfdf8d78bedd50a915f1188d
CPU threads: 2; OS: Windows 6.1; UI render: default; 
TinderBox: Win-x86@42, Branch:master, Time: 2017-06-26_01:24:22
Locale: fr-FR (fr_FR); Calc: CL
Comment 4 QA Administrators 2018-07-25 02:40:20 UTC Comment hidden (obsolete)
Comment 5 Regina Henschel 2019-03-10 17:29:47 UTC
The error still exists in Version: 6.3.0.0.alpha0+ (x64)
Build ID: 9c5dbbe4b0a62ff1af009beb00f1fc45318dad79
CPU threads: 8; OS: Windows 10.0; UI render: default; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2019-02-27_20:03:12
Locale: de-DE (en_US); UI-Language: en-US
Calc: threaded

It might be better to divide the problem. The segment and the arc belong to the 'legacy' shapes. There exist no equivalent to that in DrawingML and they have to be converted into something similar.

The two 'Bevel'-shapes are custom shapes and direct writing in DrawingML would be possible.
Comment 6 Regina Henschel 2019-08-18 23:23:50 UTC
Diamond Bevel and Octagon Bevel are custom shapes with a foreign value in Type attribute. Therefore they are not handled like our own shapes or shapes from OOXML import. They are treated as type "non-primitive" and for such shapes LibreOffice has no export filter to OOXML.

A generic filter would be necessary. But such filter is complex, because the formula syntax of OOXML is strange with lot of operators with three arguments and unusual operators.

The export of the circle segment and arc will be fixed soon. I have already a principle solution.
Comment 7 Regina Henschel 2021-08-08 17:11:22 UTC
Circle Segment and Arc look good in LO 7.3.

The problem with Diamond Bevel and Octagon Bevel remains.
Comment 8 Regina Henschel 2022-03-25 22:30:00 UTC
The shapes "Diamond Bevel" and "Octagon Bevel" are difficult:
(A)
These shapes have neither a counterpart in the OOXML preset shapes nor in shapes of the binary versions of MS Office. So they need to be exported to an element "custGeom". That export is done in method WriteCustomGeometry. This method cannot export equations or handles, but only exports the current state of the shape outline. Export of equations and handles into "custGeom" is very hard and will not be implemented in the foreseeable future. So we will loose the handles.
(B)
Because they have no counterpart in the OOXML preset shapes, it will not be possible to recreate them, when the pptx file will be reopened by LO. They will be of type "ooxml-non-primitive". That means the next save to pptx will use WriteCustomGeometry anyway.
(C)
The export in WriteCustomGeometry is in the meantime (current master!) able to export the lighten/darken commands of the enhanced-path. But the shapes "Diamond Bevel" and "Octagon Bevel" are not implement the same way as the shapes from binary MS Office. "Diamond Bevel" and "Octagon Bevel" shapes are inserted from private://gallery/hidden/imgppt. That Gallery theme is so old, that is does not know anything about the lighten/darken commands. Their lighten/darken is different from the lighten/darken in other shapes. The path does not contain commands for lighten/darken. The shapes are stored in binary format in the Gallery theme so there is no way to add the needed commands.
(D)
The export to binary MS Office formats does not export them to a shape but to a WMF image. That keeps lighten/darken but looses handles same as export by WriteCustomGeometry. Using WMF image drops the possibility to edit a text in the shape. 

We could move the two shapes from the list in lcl_IsOnDenylist in /oox/source/export/shapes.cxx to the list in lcl_IsOnAllowlist. That way they would be exported by method WriteCustomGeometry. Currently an export as preset shape is tried and because that fails the default preset shape "rect" is used.

Using WriteCustomGeometry would preserve outline and editable text but looses darken/lighten. Using WMF image preserves outline and darken/lighten but you can no longer edit text. Both ways loose handles.

@Gabor: What do you think we should do?
Comment 9 Commit Notification 2022-04-15 20:17:27 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

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

tdf#109169 use custGeom for Octagon Bevel shape

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 10 Regina Henschel 2022-04-15 20:25:34 UTC
This is a first step. Now the geometry is correct. Still missing are shading and handle.

Shading cannot be exported identical to LO, because OOXML has only four grades of shading, whereas shapes of type "col-..." can have up to 14 grades of shading. But before finding a suitable emulation the rendering in LO needs to be fixed, see bug 148501.
Comment 11 Commit Notification 2022-04-18 11:28:47 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

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

tdf#109169 use custGeom for Octagon Bevel shape

It will be available in 7.3.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 12 Commit Notification 2022-04-21 10:54:51 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/5168d06b1302c43a305d0f670ee65079f21063b5

tdf#109169 export Type encoded shading to OOXML

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 13 Regina Henschel 2022-04-21 11:23:51 UTC
I think, that more is currently not possible because we have no general export of handles and equations. If we would export handles and equations of "Octagon Bevel" and "Diamond Bevel" they would be lost on next opening and save. So it is not worth to implement it.

The solution here exports the static shape as given by the current position of the handle. It still allows the user to change fill and line style and to change the text in the shape.

The missing general export of handles and equations should be tracked in a new bug. There is currently bug 59019, but that covers only the special case of a polar handle.
Comment 14 Commit Notification 2022-04-26 19:14:58 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "libreoffice-7-3":

https://git.libreoffice.org/core/commit/02c59c79f30705450224fdb6eb3b001da457f81e

tdf#109169 export Type encoded shading to OOXML

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