Bug 153000 - FILEOPEN DOCX file types MSO_SPT=25 to 31 are wrongly rendered
Summary: FILEOPEN DOCX file types MSO_SPT=25 to 31 are wrongly rendered
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.6.0.0 alpha0+
Hardware: x86-64 (AMD64) Windows (All)
: medium minor
Assignee: Not Assigned
URL:
Whiteboard: target:7.6.0 target:7.5.1
Keywords: implementationError
Depends on:
Blocks:
 
Reported: 2023-01-13 00:25 UTC by Regina Henschel
Modified: 2023-01-16 08:40 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
shapes and screenshots (205.61 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-01-13 00:25 UTC, Regina Henschel
Details
Side by side how the attached looks with word vs writer (368.09 KB, image/png)
2023-01-13 16:47 UTC, m_a_riosv
Details
patch (3.75 KB, patch)
2023-01-13 17:17 UTC, Julien Nabet
Details
similar file in RichTextFormat (864.74 KB, application/msword)
2023-01-13 17:30 UTC, Regina Henschel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Regina Henschel 2023-01-13 00:25:12 UTC
Created attachment 184625 [details]
shapes and screenshots

Open attached files. It contains the preset text warp shapes from index 24 to 31 and to each one a screenshot how it looks in Word.

The shapes are imported with a correct Type value, but they are wrongly rendered. The error is likely in mso_CustomShape* GetCustomShapeContent( MSO_SPT eSpType ) method in https://opengrok.libreoffice.org/xref/core/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx?r=4cfe4699#8350
That method maps the MSO_SPT number to the mso_CustomShape shape description.
For the shapes in question you see the comment
// Don't know, simply mapping to TextSimple

The shapes are specified in https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-odraw/9c0c5c01-9e90-41aa-ba15-477dacb4cc8e
The shapes here are special, as they will not be correctly rendered in Word 2010 and earlier, see the comments in the above given link for these shapes.

The specification shows only images but has no exact path description. Comparing the results in Word shows, that Word maps these shapes in this way:
(24) msosptTextSimple -> (136) msosptTextPlainText
(25) msosptTextOctagon -> (137) msosptTextStop
(26) msosptTextHexagon -> (138) msosptTextTriangle 
(27) msosptTextCurve -> (175) msosptTextCanDown 
(28) msosptTextWave -> (156) msosptTextWave1
(29) msosptTextRing -> (148) msosptTextArchUpPour
(30) msosptTextOnCurve -> (175) msosptTextCanDown
(31) msosptTextOnRing ->(144) msosptTextArchUpCurve

So we should do the same.

The shapes (24)..(31) are not available in the UI. Therefore "Minor" severity. But they can be created with XEnhancedCustomShapeDefaulter interface.

The attached file was created by Word from a manually changed .rtf file.
Comment 1 m_a_riosv 2023-01-13 16:47:12 UTC
Created attachment 184635 [details]
Side by side how the attached looks with word vs writer

With 
Microsoft® Word para Microsoft 365 MSO (versión 2212 compilación 16.0.15928.20196) de 64 bits 
vs
Version: 7.4.4.2 (x64) / LibreOffice Community
Build ID: 85569322deea74ec9134968a29af2df5663baa21
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Vulkan; VCL: win
Locale: es-ES (es_ES); UI: en-US Calc: CL

BTW seems t24 it's only a size issue.
Comment 2 Julien Nabet 2023-01-13 17:17:27 UTC
Created attachment 184638 [details]
patch

On pc Debian x86-64 with master sources updated today, I could reproduce this.

I attached a patch, is it what you meant or did I miss something? (except the 3D rendering).
Comment 3 Regina Henschel 2023-01-13 17:30:26 UTC
Created attachment 184640 [details]
similar file in RichTextFormat

The wrong size is a different problem and is specific for docx.
Import von RTF has the correct size, but the handle position is wrong.
Both problems should go to new bugreports.

BTW, the shapes are in VML format in docx.
Comment 4 Julien Nabet 2023-01-13 17:41:46 UTC
I gave a try on the rtf file with the patch, it's not perfect but it's far better.
Comment 5 Regina Henschel 2023-01-13 17:47:36 UTC
(In reply to Julien Nabet from comment #2)
> I attached a patch, is it what you meant or did I miss something? (except
> the 3D rendering).

That is exactly what I meant.
Comment 6 Julien Nabet 2023-01-13 18:12:12 UTC
Ok then I've submitted the patch here:
https://gerrit.libreoffice.org/c/core/+/145491

As I indicated in it, you're the one who did the work! :-)
Comment 7 Commit Notification 2023-01-13 20:20:55 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/11319f419988443af85cf3c60dbed12d67fc183f

tdf#153000: file types MSO_SPT=25 to 31 are wrongly rendered

It will be available in 7.6.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 8 Julien Nabet 2023-01-13 22:35:22 UTC
Is it ok now and I can cherry-pick this on 7.5 or is there still something to do here?
Comment 9 Regina Henschel 2023-01-14 00:41:32 UTC
In this place is nothing more to do. The wrong size in docx and the wrong handle position in rtf have to be solved somewhere else.

Unit test will come, but I first need to update and build my repository, which takes some time.
Comment 10 Commit Notification 2023-01-14 14:09:15 UTC
Regina Henschel committed a patch related to this issue.
It has been pushed to "master":

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

tdf#153000 Unittest file types MSO_SPT=25 to 31

It will be available in 7.6.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 11 Commit Notification 2023-01-16 08:40:27 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-5":

https://git.libreoffice.org/core/commit/115ea63a67c8d8e9efffd95450922902171cb1a8

tdf#153000: file types MSO_SPT=25 to 31 are wrongly rendered

It will be available in 7.5.1.

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.