Bug 142398

Summary: FILESAVE DOCX Several Writer shapes textbox saved incorrectly
Product: LibreOffice Reporter: NISZ LibreOffice Team <libreoffice>
Component: WriterAssignee: Attila Bakos (NISZ) <bakos.attilakaroly>
Status: RESOLVED DUPLICATE    
Severity: normal CC: bakos.attilakaroly, nemeth, rb.henschel, varga.balazs3
Priority: medium Keywords: filter:docx
Version: Inherited From OOo   
Hardware: All   
OS: All   
See Also: https://bugs.documentfoundation.org/show_bug.cgi?id=92525
https://bugs.documentfoundation.org/show_bug.cgi?id=92473
https://bugs.documentfoundation.org/show_bug.cgi?id=122898
https://bugs.documentfoundation.org/show_bug.cgi?id=100391
https://bugs.documentfoundation.org/show_bug.cgi?id=148342
Whiteboard: target:7.3.0 target:7.2.0.0.beta2
Crash report or crash signature: Regression By:
Bug Depends on:    
Bug Blocks: 136358    
Attachments: Example file from Writer with shapes and added text
The original file saved by Writer to docx
Screenshot of the original and exported document side by side in Writer – page 1
Screenshot of the original and exported document side by side in Writer – page 2
Screenshot of the original and exported document side by side in Writer – page 3

Description NISZ LibreOffice Team 2021-05-20 13:08:26 UTC
Created attachment 172202 [details]
Example file from Writer with shapes and added text

The attached example file contains Writer shapes that were found to be exported incorrectly to docx: their textbox used to be inside their area, but after save they are resized to the bounding rectangles size.
Steps to reproduce:
    1. Open attached example Writer  file. The shapes contain some text written on them.
    3. Save as .docx, reopen files

Actual results:
In docx, the shapes textboxes size and consequently their texts position is incorrect.

Expected results:
Docx shapes should look like the original .odt shapes.

LibreOffice details:
Version: 7.2.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: 91330c503b7eb91d777978018b66890af87cf8f5
CPU threads: 8; OS: Windows 10.0 Build 18363; UI render: Skia/Raster; VCL: win
Locale: hu-HU (hu_HU); UI: en-GB
Calc: threaded
Comment 1 NISZ LibreOffice Team 2021-05-20 13:08:53 UTC
Created attachment 172203 [details]
The original file saved by Writer to docx
Comment 2 NISZ LibreOffice Team 2021-05-20 13:09:10 UTC
Created attachment 172204 [details]
Screenshot of the original and exported document side by side in Writer – page 1
Comment 3 NISZ LibreOffice Team 2021-05-20 13:09:31 UTC
Created attachment 172205 [details]
Screenshot of the original and exported document side by side in Writer – page 2
Comment 4 NISZ LibreOffice Team 2021-05-20 13:09:49 UTC
Created attachment 172206 [details]
Screenshot of the original and exported document side by side in Writer – page 3
Comment 5 Regina Henschel 2021-05-21 00:38:23 UTC
The example shapes do not have a text box, but a simple label text. The segment is not a custom shape at all.

In case a custGeom is written, a <a:rect ...> has to be generated. For to get the correct rectangle, it is needed to get the property "TextFrames" from "Path" in CustomGeomety. But currently only the preset shape types l, t, r, b are written:
https://opengrok.libreoffice.org/xref/core/oox/source/export/drawingml.cxx?r=af16aa62#3768
https://opengrok.libreoffice.org/xref/core/oox/source/export/drawingml.cxx?r=af16aa62&fi=WriteCustomGeometry#3557

In case of prstGeom there is no need for a <a:rect ...> element. So writing a shape as ooxml-foo (if possible), would solve the <a:rect...> problem. But it has the downside, that reload and export to binary MS formats will loose the shape. And some of our mso-foo shapes do not have a directly corresponding ooxml-shape.

It might help to sort the shapes currently in the floater in the UI in categories
a) work with l, t, r, b
b) do not work with l, t, r, b, but have exactly corresponding ooxml preset shape
c) do not work with l, t, r, b and need ooxml custGeom.
Comment 6 Commit Notification 2021-06-23 10:58:15 UTC
Attila Bakos (NISZ) committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/63cd67e5e18f01aca303131e148c80398a181a41

tdf#92525 tdf#142398: fix export of simple custom shapes

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 7 Attila Bakos (NISZ) 2021-06-23 11:30:25 UTC

*** This bug has been marked as a duplicate of bug 92525 ***
Comment 8 Commit Notification 2021-06-24 08:34:59 UTC
Attila Bakos (NISZ) committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/0cfa76c0a1883289f8406551d0494cc2a30df926

tdf#92525 tdf#142398: fix export of simple custom shapes

It will be available in 7.2.0.0.beta2.

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.