Bug 167770 - FILEOPEN DOCX: image/shape left/right margin (aka text wrap) should be zero when left/right aligned
Summary: FILEOPEN DOCX: image/shape left/right margin (aka text wrap) should be zero w...
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: Justin L
URL:
Whiteboard: target:26.2.0 target:25.8.1
Keywords: bisected, filter:docx
Depends on:
Blocks: DOCX-Anchor-and-Text-Wrap
  Show dependency treegraph
 
Reported: 2025-08-01 20:16 UTC by Justin L
Modified: 2025-08-04 15:19 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
marginLeftRight.docx: containing both image and shapes with 2cm margins (31.32 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2025-08-01 20:16 UTC, Justin L
Details
marginLeftRight.pdf: how it looks in Word 2010 and LO 25.8.0 (112.47 KB, application/pdf)
2025-08-01 20:24 UTC, Justin L
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Justin L 2025-08-01 20:16:43 UTC
Created attachment 202140 [details]
marginLeftRight.docx: containing both image and shapes with 2cm margins

When a floating object is aligned to the "left" of the page/paragraph, then it should hug that left position, and not have a "text wrap" gap.

At least that is how MS Word lays it out (which makes sense). LibreOffice calls it a "margin" and always applies it. So during import, just force the margin to zero. (This is what has already been done since OOo, but not all cases were handled.)

Cases already handled:
-pictures: FRAME (paragraph) and PAGE_PRINT_AREA (page margin)
-shapes: PAGE_PRINT_AREA (left only)

PRINT_AREA (paragraph margin) became an exposed issue with
24.8 commit eacf8dc7ab850f2d00bd4b327f830c55cf2a0d92
Author: Justin Luth on Tue Mar 5 19:22:34 2024 -0500
    tdf#160049 dml import: use margins with left/right HoriOrientRelation
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164443
Comment 1 Justin L 2025-08-01 20:24:58 UTC
Created attachment 202141 [details]
marginLeftRight.pdf: how it looks in Word 2010 and LO 25.8.0
Comment 2 Commit Notification 2025-08-02 19:29:52 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/7adcf969978eb8e5fb218ce42d707539843bebf6

tdf#167770 writerfilter: zero out margin if left/right aligned

It will be available in 26.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.
Comment 3 Commit Notification 2025-08-04 10:05:57 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "libreoffice-25-8":

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

tdf#167770 writerfilter: zero out margin if left/right aligned

It will be available in 25.8.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.
Comment 4 Commit Notification 2025-08-04 15:19:53 UTC
Justin Luth committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/188fc004c3e1448ed68b6e1a96932886da04bc82

related tdf#167770 docx import/export: support INSIDE/OUTSIDE

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