Description: I have a document with bookmarks. Each bookmark has text. There is a macro that makes the bookmark text empty. After running the macro, some bookmarks disappear. Those bookmarks that consist of one paragraph completely disappear. Steps to Reproduce: 1.Open document 'whereIsMyBookmark' 2.Look at the bookmarks (Insert->Bookmark) 3.Run macro 'Main' 4.Look at the bookmarks again Actual Results: Not only the bookmark text disappears, but also the bookmark itself Expected Results: The bookmark should not disappear Reproducible: Always User Profile Reset: No Additional Info: 1. A bookmark whose text consists of a paragraph disappears. 2. A bookmark whose text consists of a word does not disappear. But a bookmark created immediately without text and one created by a macro look different.
Created attachment 190812 [details] Document showing the disappearance of a bookmark
In the previous version it works as it should: Version: 7.4.2.3 / LibreOffice Community Build ID: 40(Build:3) CPU threads: 4; OS: FreeBSD 13.1; UI render: default; VCL: qt5 (cairo+xcb) Locale: en-US (en_EN.UTF-8); UI: en-US Calc: threaded
I think I can reproduce it on my MacOS as well. However, if I add more text before the {PARAGRAPH} bookmark, all the bookmarks remain. Can you confirm @JBrown?
Created attachment 190879 [details] add-text-before-bookmark
Created attachment 190880 [details] Reproducible-MacOS
(In reply to ToanTran from comment #3) That is exactly what JBrown reported, isn't it? Are you asking JBrown to confirm comment 0?
thinking the basic problem here is that the API only has this "setString" method, but no way to indicate whether the intent is to *delete* or to *replace* text. these are different operations: deleting means that things like objects anchored in the deletion range and bookmarks should be deleted too, while replacing means that the current text should be deleted but the anchored objects should remain. so the best idea i had is that setString("") would be interpreted as *delete* and any other setString call as *replace*. the behavior when selecting an entire paragraph was changed in commit baf8d2c1c16cb3bdc4edad2560f95fea807a034f because in this situation it was actually quite difficult to get rid of the bookmark if the user does want to delete it, as no selection that is larger than the bookmark is possible inside the paragraph (and there may be no preceding or following paragraph). so i'm going to call the new behavior a feature not a bug, but of course i'm biased...
(In reply to Michael Stahl (allotropia) from comment #7) > > the behavior when selecting an entire paragraph was changed in commit > baf8d2c1c16cb3bdc4edad2560f95fea807a034f => bibisectNotNeeded