Bug 121300 - Images anchored to a paragraph are deleted inconsistently when anchored at-paragraph
Summary: Images anchored to a paragraph are deleted inconsistently when anchored at-pa...
Status: VERIFIED FIXED
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: Michael Stahl (allotropia)
URL:
Whiteboard: target:6.5.0 target:6.4.0.1
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: 2022-04-30 19:28 UTC (History)
8 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 (allotropia)
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 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 (allotropia) 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 (allotropia) 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 (allotropia) 2018-12-17 18:42:31 UTC
Created attachment 147629 [details]
Video showing the odt and docx with the image disappearing
Comment 9 Dieter 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 2018-12-18 20:24:59 UTC
see also bug 122103 comment 5
Comment 11 Michael Stahl (allotropia) 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.
Comment 12 Commit Notification 2019-12-06 12:27:15 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/91b2325808a75174f284c48c8b8afc118fad74e4

tdf#121300 sw: consistent fly at-pargraph selection

It will be available in 6.5.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 13 Michael Stahl (allotropia) 2019-12-06 12:42:36 UTC
made the at-paragraph selection consistent now; there's a small tweak to the at-character selection pending until jenkins finishes that should make both consistent with each other too.

the tweak is that if the selection is from the end of one paragraph to the start of the next one, it's probably backspace/delete key and no flys will be deleted.
Comment 14 Commit Notification 2019-12-06 13:39:30 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/98d1622b3721fe899c4e1faa0b4cc35695253014

tdf#121300 sw: adapt at-char selection to latest at-para design

It will be available in 6.5.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 15 Commit Notification 2019-12-06 13:45:44 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

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

tdf#121300 sw: consistent fly at-pargraph selection

It will be available in 6.4.0.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 16 Commit Notification 2019-12-06 14:43:40 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-6-4":

https://git.libreoffice.org/core/commit/1644fb345e41851fe9fa9d34544e7a1556e1afd6

tdf#121300 sw: adapt at-char selection to latest at-para design

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