Bug 163890 - DOCX Shape is misplaced upon reload when added to document with an image anchored as character
Summary: DOCX Shape is misplaced upon reload when added to document with an image anch...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.0.3 release
Hardware: All All
: medium normal
Assignee: Jaume Pujantell
URL:
Whiteboard: target:25.8.0 target:25.2.2
Keywords: bibisected, bisected, regression
Depends on:
Blocks: OOXML-Shapes
  Show dependency treegraph
 
Reported: 2024-11-14 04:35 UTC by Aron Budea
Modified: 2025-03-03 11:49 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Sample DOCX (5.93 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2024-11-14 04:35 UTC, Aron Budea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aron Budea 2024-11-14 04:35:33 UTC
Created attachment 197607 [details]
Sample DOCX

- Open the attached simple DOCX (created in LO), with just an image in it, anchored As Character,
- Insert a shape, (note how it's anchored to page)
- Save and reload.

=> The shape is shifted (and is anchored to character, this is due to a limitation of the DOCX format). The shift is about the distance from page corner to the beginning of text area.
Interestingly, it doesn't happen when an existing ODT with such image and shape is saved as DOCX.

Either way, the shape shouldn't be created anchored to page in the first place.

This is a regression from the following commit in LO 7.4:
https://cgit.freedesktop.org/libreoffice/core/commit/?id=651527b4efe9700c8c8dff58ce5aa86ad5681f16
author		Miklos Vajna <vmiklos@collabora.com>	2022-04-26 15:40:44 +0200
committer	Miklos Vajna <vmiklos@collabora.com>	2022-04-26 17:02:15 +0200

sw: fix double-click opening frame dialog, not graphic dialog on images
Comment 1 Miklos Vajna 2024-11-14 08:18:14 UTC
Most probably the trouble is that we no longer throw away the graphic that we find for a doc coordinate: usually that's wanted (see the commit's message), but probably there is a case where where we revert to "to page" anchoring when the found node is not a text node (it's now a graphic node), and there we should go back to the old "if graphic node, go to its anchor" way.

Jaume: thanks for looking into this.
Comment 2 Commit Notification 2025-02-28 16:11:53 UTC
Jaume Pujantell committed a patch related to this issue.
It has been pushed to "master":

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

tdf#163890 sw: fix anchor inserted shape to paragraph

It will be available in 25.8.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-03-03 11:49:55 UTC
Jaume Pujantell committed a patch related to this issue.
It has been pushed to "libreoffice-25-2":

https://git.libreoffice.org/core/commit/3fb0973b7b5620e637c04b067a870fb611be4b35

tdf#163890 sw: fix anchor inserted shape to paragraph

It will be available in 25.2.2.

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.