Bug 137595 - FILEOPEN DOCX shape size displayed in inches instead of cm
Summary: FILEOPEN DOCX shape size displayed in inches instead of cm
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4.0.3 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:24.2.0
Keywords: filter:docx
Depends on:
Blocks: OOXML-Shapes
  Show dependency treegraph
 
Reported: 2020-10-19 12:53 UTC by NISZ LibreOffice Team
Modified: 2023-09-11 13:42 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Word (17.50 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2020-10-19 12:53 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document side by side in Word and Writer with the original shapes settings (132.92 KB, image/png)
2020-10-19 12:54 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document side by side in Word and Writer with the copied shapes settings (123.30 KB, image/png)
2020-10-19 12:54 UTC, NISZ LibreOffice Team
Details
anchoredInCellTextbox.docx (5.14 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2023-09-08 21:08 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2020-10-19 12:53:55 UTC
Created attachment 166507 [details]
Example file from Word

Attached document was reduced from the example file of bug #100920
It contains a shape with absolute horizontal position of 10 cm right of column set in Word.
When opened in Writer the shape appears in the correct position, but its Position and Size dialog displays a 3.83 cm value “From left” to “Paragraph area” instead of 10 cm. 
Clicking OK in this dialog makes the shape jump to 3.83 cm horizontal position.
Also: 3.83 inches is 9.73 cm with a bit of conversion/rounding error, so that’s probably what we see here.
However making a copy of the shape in Word and setting the horizontal position to another value interoperates nicely, the example document has a copied shape with 2 cm position that is opened correctly.

Steps to reproduce:
1.	Open attached document
2.	Check the Position and Size dialog of the shape

Actual results:
Horizontal position is 3.83 cm.
The copied shape with less text has the correct 2 cm horizontal position.

Expected results:
Horizontal position should be 10 cm.

LibreOffice details:
Version: 7.1.0.0.alpha0+ (x64)
Build ID: c064766901722082df0d759c95434c1460fcdba5
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: default; VCL: win
Locale: en-US (hu_HU); UI: en-US
Calc: CL

Also in:
Version: 6.0.0.3
Build ID: 64a0f66915f38c6217de274f0aa8e15618924765
CPU threads: 4; OS: Windows 6.3; UI render: default; 
Locale: en-US (hu_HU); Calc: CL

Version: 5.2.0.4
Build ID: 066b007f5ebcc236395c7d282ba488bca6720265
CPU Threads: 4; OS Version: Windows 6.2; UI Render: GL; 
Locale: hu-HU (hu_HU
- before 5.3 it was 4.09 cm, still not 10

Version: 5.0.0.5
Build ID: 1b1a90865e348b492231e1c451437d7a15bb262b
Locale: en-US (hu_HU)

Version: 4.4.0.3
Build ID: de093506bcdc5fafd9023ee680b8c60e3e0645d7
Locale: hu_HU

Before in 4.3 the shape was imported as a frame and it had a correct 10 cm positioning value.

Additional Information: 
Bibisected with bibisect-win32-4.4/ to range:
https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=a595879302e26a616131aa0cab5de31bb287b37d..402e0c0a679dd4da2b1767d959be9aa364c1878d
Comment 1 NISZ LibreOffice Team 2020-10-19 12:54:20 UTC
Created attachment 166508 [details]
Screenshot of the original document side by side in Word and Writer with the original shapes settings
Comment 2 NISZ LibreOffice Team 2020-10-19 12:54:35 UTC
Created attachment 166509 [details]
Screenshot of the original document side by side in Word and Writer with the copied shapes settings
Comment 3 Aron Budea 2020-11-04 02:19:10 UTC
Confirmed using LO 7.1.0.0.alpha1+ (49a39d1abccc61b6dace3e92059ae50a6a2c298d) / Ubuntu.

The frame -> text box change in 4.4 happened with the following commit, finished bibisecting using repo bibisect-44max.
https://cgit.freedesktop.org/libreoffice/core/commit/?id=7596e26fd259ce5445212949403e7cd32303b2bd
author		Miklos Vajna <vmiklos@collabora.co.uk>	2014-06-24 17:11:25 +0200
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2014-06-24 17:47:40 +0200

"Add SwTextBoxHelper::findShapes"

The small change in size in 5.3 happened with the following commit, bibisected using repo bibisect-linux-64-5.3.
https://cgit.freedesktop.org/libreoffice/core/commit/?id=c761df1e42fd11acc5fc05b0baacd803c3788ca6
author		Miklos Vajna <vmiklos@collabora.co.uk>	2016-10-25 09:05:47 +0200
committer	Miklos Vajna <vmiklos@collabora.co.uk>	2016-10-25 09:32:01 +0000

"tdf#84678 DOCX import: fix handling of textbox margins"
Comment 4 QA Administrators 2022-11-05 03:36:05 UTC Comment hidden (obsolete, spam)
Comment 5 Justin L 2023-09-08 21:08:53 UTC
Created attachment 189441 [details]
anchoredInCellTextbox.docx

repro 24.2+

I see the same thing with my document. The textbox loads in the same position as before, but now when you look at "Position and size", the wrong distances are shown, and hitting OK moves the textbox.

I noticed that this can alter back and forth. I assume it is somehow related to the "maximum distance" allowed before hitting the edge of the page. Try changing the value to some large number (like 10cm) and notice that the UI reduces that number. Press OK, and then open the dialog again, and a different number with be shown, and quite likely a different maximum will also be allowed.
Comment 6 Justin L 2023-09-09 23:11:23 UTC
(In reply to Justin L from comment #5)
> Change the value to some large number (like 10cm) and notice that the UI
> reduces that number. 
Broken since 7.5.4. bug 157168.

Although layout code is nearly impossible to debug, the issue goes something like this:
-the code might not have noticed which fly you have opened the dialog for
-therefore the valid range where the fly can move is somewhat random.
-the current position might not fit in that valid range
-therefore the highest/lowest value might be assigned to the display/applied at OK.

Identifying the correct fly seems to be solved with https://gerrit.libreoffice.org/c/core/+/156786.
Comment 7 Commit Notification 2023-09-11 06:32:32 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/6a24155269d26d1a31a88158154bb4db0c933871

tdf#137595 sw: current fly might not be selected

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