Bug 142875 - FILEOPEN DOCX Shapes vertically aligned to line imported incorrectly
Summary: FILEOPEN DOCX Shapes vertically aligned to line imported incorrectly
Status: NEW
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:
Keywords: filter:docx
Depends on:
Blocks: DOCX-Anchor-and-Text-Wrap
  Show dependency treegraph
 
Reported: 2021-06-15 11:42 UTC by NISZ LibreOffice Team
Modified: 2022-05-22 19:44 UTC (History)
3 users (show)

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


Attachments
Example file from Word (23.54 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-06-15 11:42 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document side by side in Word and Writer (127.62 KB, image/png)
2021-06-15 11:43 UTC, NISZ LibreOffice Team
Details
to Line by Word (21.92 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2021-07-31 14:25 UTC, Regina Henschel
Details
"to Line by Word" exported as doc by Word (92.00 KB, application/msword)
2021-07-31 14:26 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 11:42:35 UTC
Created attachment 172904 [details]
Example file from Word

Attached example document contains some textboxes and shapes that are vertically aligned to line in Word: Top, Center and Bottom positioning was used (there is also inside and outside option not examined here).
When opened in Writer these vertical positions change.

Steps to reproduce:
    1. Open attached document

Actual results:
Blue textbox with Top alignment becomes Top aligned (correct setting, but a bit lower actual positioning)
Blue textbox with Centered alignment becomes Top aligned
Blue textbox with Bottom alignment becomes Top aligned

Purple triangle with Top alignment becomes Top aligned (correct setting and actual positioning as well)
Yellow triangle with Centered alignment becomes From bottom aligned by 0.01 cm
Blue triangle with Bottom alignment becomes Top aligned, but appears way above the line compared to the Top aligned purple triangle.

Expected results:
Same layout as in Word.

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
Comment 1 NISZ LibreOffice Team 2021-06-15 11:43:14 UTC
Created attachment 172905 [details]
Screenshot of the original document side by side in Word and Writer
Comment 2 Telesto 2021-06-16 04:51:34 UTC
Repro
Version: 7.2.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: 239b4bb27fd8db26e8416045b3015688a8b1b0ae
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: CL
Comment 3 Aron Budea 2021-07-31 04:56:37 UTC
This was never fine, though before 7.1 the positioning of the squares were a bit closer to Word's, from left to right, vertical positions were: mid, below, above; except in LO the differences were much larger. Probably not useful information.
Comment 4 Regina Henschel 2021-07-31 12:06:03 UTC
I see the error:
The alignment is imported as "to Line of Text". But that means relative to a line in the geometrical meaning at top of the characters. We need "to Character" here, which means the total area of the characters.

You can see the difference between "to Line of Text" and "to Character" in the red lines in the preview in the Position&Size dialog, if you use a huge font size, 48pt for example.

And I see in the Position&Size dialog always the item "Top", where it should be "Top", "Center", "Bottom". But that is likely an error of the dialog.
The dialog doesn't open at all in my build, but LO crashes. I'll test whether current daily will crash too.
Comment 5 Regina Henschel 2021-07-31 14:25:03 UTC
Created attachment 173997 [details]
to Line by Word

I see a large confusion in the import/export code in regard to vertical alignment.

Our text:RelOrientation::Char corresponds to ooxml docx alignment "to Line".

Our text:RelOrientation::TEXT_LINE does not exists in ooxml docx, but belongs to the binary doc-Format.

Open attachment "to Line by Word" in Word and save it as doc. You will notice how Word changes the alignment to that one available in doc-Format. If you then open the doc file and save it as docx in compatibility mode and reopen that, you get an alignment, which differs from the original docx document.

Our code needs to not only distinguish between docx and doc, but between ooxml docx, and compatibility mode docx to produce similar rendering. "Bottom relative to Line" is different between ooxml docx, and compatibility docx, for example.
Comment 6 Regina Henschel 2021-07-31 14:26:03 UTC
Created attachment 173998 [details]
"to Line by Word" exported as doc by Word