Bug Hunting Session
Bug 121300 - Images anchored to a paragraph are lost when the parent paragraph is deleted in a DOCX file
Summary: Images anchored to a paragraph are lost when the parent paragraph is deleted ...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
6.2.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 122103 (view as bug list)
Depends on:
Blocks: DOCX-Images
  Show dependency treegraph
 
Reported: 2018-11-09 09:15 UTC by NISZ LibreOffice Team
Modified: 2019-10-07 12:35 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
The original document in ODT format. (25.49 KB, application/vnd.oasis.opendocument.text)
2018-11-09 09:16 UTC, NISZ LibreOffice Team
Details
The same document saved as DOCX. (26.83 KB, application/vnd.openxmlformats-officedocument.wordprocessingml.document)
2018-11-09 09:16 UTC, NISZ LibreOffice Team
Details
A screenshot showcasing the issue. (78.27 KB, image/png)
2018-11-09 09:17 UTC, NISZ LibreOffice Team
Details
Video showing the odt and docx with the image disappearing (4.85 MB, video/ogg)
2018-12-17 18:42 UTC, Gabor Kelemen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2018-11-09 09:15:41 UTC
Description:
There is a significant difference in how LibreOffice Writer handles images anchored to a paragraph when the parent paragraph is deleted, depending on the file format of the document:
– If the format of the document is DOCX, deleting the paragraph also deletes the image.
– If the format of the document is ODT, deleting the paragraph simply causes the image to move up one paragraph.

The issue is more apparent when the paragraph contains only one single character besides the anchor of image:
– If the format of the document is DOCX, selecting the only character in the paragraph also marks the image as selected.
– If the format of the document is ODT, selecting the only character in the paragraph doesn't mark the image as selected.


Steps to Reproduce:
1.Create a new text document in LibreOffice Writer, and add a few paragraphs of random text.
2.Create an empty paragraph somewhere in the document and insert an image by clicking on Insert > Image. Writer inserts the image anchored to paragraph by default, so there is no need to change that.
3.Save the document both as ODT and DOCX.
4.Close the document and reopen both the ODT and DOCX file in Writer.
5.Delete the paragraph containing the image in both versions of the document.


Actual Results:
The image disappears from the DOCX document, and moves up one paragraph in the ODT document

Expected Results:
The image should move up one paragraph both in the DOCX and the ODT document.


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 NISZ LibreOffice Team 2018-11-09 09:16:23 UTC
Created attachment 146475 [details]
The original document in ODT format.
Comment 2 NISZ LibreOffice Team 2018-11-09 09:16:51 UTC
Created attachment 146476 [details]
The same document saved as DOCX.
Comment 3 NISZ LibreOffice Team 2018-11-09 09:17:07 UTC
Created attachment 146477 [details]
A screenshot showcasing the issue.
Comment 4 Dieter Praas 2018-11-09 09:58:45 UTC
I can't reproduce this in

Version: 6.2.0.0.alpha1+ (x64)
Build ID: 8274c4c62df5b937b3f0bec9e1eeca85f3b219d4
CPU threads: 4; OS: Windows 10.0; UI render: GL; VCL: win; 
TinderBox: Win-x86_64@42, Branch:master, Time: 2018-10-22_01:47:50
Locale: en-US (de_DE); Calc: CL

And there is another observation: When I save the odt-file as docx and reopen, the image is anchered to character insted of paragrph (see attachment from comment 2); I couldn't find, that this bug is reported yet.
Comment 5 Gabor Kelemen 2018-12-15 10:31:54 UTC
*** Bug 122103 has been marked as a duplicate of this bug. ***
Comment 6 raal 2018-12-16 09:01:38 UTC
I can not confirm with Version: 6.3.0.0.alpha0+
Build ID: 0ad2302cf6787cacbbaca081a890a0e356a55297
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
Image is still in docx file.
Comment 7 Gabor Kelemen 2018-12-17 18:41:43 UTC
(In reply to raal from comment #6)
> I can not confirm with Version: 6.3.0.0.alpha0+
> Build ID: 0ad2302cf6787cacbbaca081a890a0e356a55297
> CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3; 
> Image is still in docx file.

Hi

I can still reproduce, but it's a bit tricky. 
There is another example file in the duplicate bug, with more straightforward steps.

Here, the paragraph you should delete is the one containing the number 5: 
place the cursor at the beginning of the paragraph and press Del twice. 
The image should disappear with a current-ish master.
Comment 8 Gabor Kelemen 2018-12-17 18:42:31 UTC
Created attachment 147629 [details]
Video showing the odt and docx with the image disappearing
Comment 9 Dieter Praas 2018-12-18 20:24:17 UTC
I can reproduce it

1. Open docx
2. Delete 5
2. Put cursor and the beginning of line "Sixth paragraph"
3. Press delete


Version: 6.2.0.0.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
Calc: threaded
Comment 10 Dieter Praas 2018-12-18 20:24:59 UTC
see also bug 122103 comment 5
Comment 11 Michael Stahl (CIB) 2019-10-07 12:35:24 UTC
the DOCX vs ODT here is a bit incidental; the real difference is the at-character vs. at-paragraph anchor.

it's just that MS Word only supports 2 anchor types (as-character / at-character), so the at-paragraph anchor necessarily becomes at-character after a round-trip in Word formats.

we have thought already about the at-character case in editing operations (see commit 28b77c89dfcafae82cf2a6d85731b643ff9290e5) so probably the way to go is to adapt the at-paragraph case to work consistently with that.

clearly the current behavior where at-paragraph fly is shown as selected but then it survives a delete operation is a bug; i disagree with the Expected Results in the description and propose instead that the fly should be deleted in both cases.