Created attachment 147540 [details]
Original file as odt
Attached odt file contains a few paragraphs and two images.
If this is saved as docx and reopened in Writer, deleting the empty paragraph after the first image causes the image to disappear.
1, Save attached file as docx
2, Open the docx in Writer, and delete the empty paragraph between the first image and the "Nyissuk meg a Fájl – Tulajdonságok ablakot!" sentence.
The first image disappears
The image remains.
The problem does not happen with the odt file.
Build ID: 87ac0b1e75a880a68ecb748bd4b34ae5a3d2ae98
Locale: hu-HU (hu_HU)
From bibisect-win32-5.0 but it happens with current master too.
Created attachment 147541 [details]
The same file as problematic docx
Created attachment 147542 [details]
The docx file before deleting the empty paragraph
Created attachment 147543 [details]
The docx after pressing Delete after the first image
I confirm it with
Version: 220.127.116.11.beta1 (x64)
Build ID: d1b41307be3f8c19fe6f1938cf056e7ff1eb1d18
CPU threads: 4; OS: Windows 10.0; UI render: default; VCL: win;
Locale: en-US (de_DE); UI-Language: en-GB
Some additional details we discovered regarding the issue:
– The anchoring of the image changes from “To Paragraph” to “To Character”.
– Opening the same DOCX file in Microsoft Word shows the horizontal anchoring as “To Column”.
– The word/document.xml describes the anchoring of the image as follows:
<wp:positionH relativeFrom="column"><wp:align>center</wp:align></wp:positionH><wp:positionV relativeFrom="paragraph">
This is why the image disappears when we delete the paragraph because it is anchored to the “end of paragraph” character: deleting the anchor also deletes the image, which makes totally sense – the real issue is that the image was originally anchored to the paragraph, and not the character. If we change back the anchoring of the image from “To Character” to “To Paragraph” it behaves exactly like the original ODS when the paragraph is deleted: the image is retained and the anchor moves up one paragraph.
So the root cause for this whole issue is that Word and Writer handle the anchoring of images differently:
– Microsoft Word has separate anchors for the horizontal and vertical alignment, while LibreOffice Writer has the same one for both.
– In Microsoft Word there are a few options for horizontal alignment (including Page, Margins, Character and Column) but Paragraph isn't among them.
– Anchoring to Column is not supported in LibreOffice Writer.
So, when a document with an image anchored to Paragraph is saved LibreOffice Writer as DOCX and the reopened again, the following happens:
1. The “To Paragraph” anchoring is interpreted as “Horizontal: to Column”, “Vertical: to Paragraph” when saved as DOCX.
2. When the same document is re-opened again, the anchoring is interpreted as “To Character” because “To Column” alignment doesn't exist is LibreOffice Writer.
A possible solution could be that if we see an image that is anchored to column vertically, and anchored to paragraph horizontally we interpret it as anchored to paragraph when importing a DOCX document – but there might be a reason why LibreOffice doesn't work like this right now, so we must beware of possible regressions.
I changed the bug summary.
Sorry, this is a duplicate of another one by us.
*** This bug has been marked as a duplicate of bug 121300 ***