Bug 90816 - setString() on the text range of a bookmark looses bookmark
Summary: setString() on the text range of a bookmark looses bookmark
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.4.1.2 release
Hardware: Other All
: medium normal
Assignee: Michael Stahl (allotropia)
URL:
Whiteboard: target:5.0.0 target:4.4.4
Keywords: bibisected, bisected, regression
: 90829 (view as bug list)
Depends on:
Blocks: 96479
  Show dependency treegraph
 
Reported: 2015-04-23 15:07 UTC by Christoph Lutz
Modified: 2015-12-17 08:59 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:


Attachments
example document with macro --> can be used for reproducing the problem (13.27 KB, application/vnd.oasis.opendocument.text)
2015-04-23 15:07 UTC, Christoph Lutz
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Lutz 2015-04-23 15:07:24 UTC
Created attachment 115038 [details]
example document with macro --> can be used for reproducing the problem

In current LO 4.4 version and in master I noticed that calling setString on the text range of a bookmark looses the bookmark. This did not happen until at least LibreOffice 4.1.6 - so the behaviour has incompatibly changed somewhere inbetween --> regression! The bookmark must be kept if its text content is changed.

This code shows, what I mean:

Sub Main
  bm = ThisComponent.Bookmarks.getByName("bookmark")
  range = bm.Anchor.Text.createTextCursorByRange(bm.Anchor)
  range.setString("now, there is no more bookmark :-(")
End Sub

Here is how to reproduce:

Open the attached document "setStringOnBookmarkLoosesBookmarkExample.odt" (enable macro-execution) and follow the instructions in the document.

The practical meaning:

Munich's WollMux (www.wollmux.net) heavily uses Bookmarks as DocumentCommands. This bug direclty affects WollMux which can no longer be run with these LO versions.
Comment 1 Christoph Lutz 2015-04-23 16:49:53 UTC
This bug is caused by git commit http://cgit.freedesktop.org/libreoffice/core/commit/?id=370febbf19a5f362394d1c9e69b12dcb218f6501

mst: what do you think about this?
Comment 2 raal 2015-04-23 17:40:18 UTC
confirmed
Version: 5.0.0.0.alpha1+
Build ID: badec7478035008f514e0976a94438fe2e32dc40
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:master, Time: 2015-04-22_01:28:24

works in LibreOffice 3.5.0 Build ID: d6cde02
Comment 3 raal 2015-04-24 12:37:41 UTC
*** Bug 90829 has been marked as a duplicate of this bug. ***
Comment 4 Michael Stahl (allotropia) 2015-04-30 22:59:17 UTC
DelCntntIndex will save the bookmarks and delete those that have both pos. inside the range but not those with only one pos. inside the range

_DelBookmarks will not save the bookmarks, delete those that have both pos. inside the range and adjust the position of those with one pos. inside the range.

DelCntntIndex handles bookmarks that exactly match both start and end position *differently* than _DelBookmarks - so DelCntntIndex will not save them and _DelBookmarks then deletes them.

what a mess...

(didn't Bjoern want to refactor all of this bookmark stuff just a few years ago?)

fixed on master
Comment 5 Commit Notification 2015-04-30 22:59:29 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c7fb1d8334d2289906ac2a0a8c32946493d10e00

tdf#90816: sw: fix bookmark loss in SwUndoDelete

It will be available in 5.0.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 6 Commit Notification 2015-05-01 16:54:54 UTC
Michael Stahl committed a patch related to this issue.
It has been pushed to "libreoffice-4-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=d70174ef1bc5894fe3cd46d4bda1dfd5f6422d39&h=libreoffice-4-4

tdf#90816: sw: fix bookmark loss in SwUndoDelete

It will be available in 4.4.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Björn Michaelsen 2015-05-01 22:55:42 UTC
(In reply to Michael Stahl from comment #4)
> what a mess...
> 
> (didn't Bjoern want to refactor all of this bookmark stuff just a few years
> ago?)

Yes, and I had sw/qa/complex/writer/CheckBookmarks.java around to ensure to reproduce bug-for-bug compatibility back then for the most part -- as we used prefer than back in those days. Beyond that: Ranting about a refactoring that made bookmarks somewhat more maintainable in OOo 3.2(?) in a regression vs. LibreOffice 4.1 seems somewhat uncalled for.
Comment 8 Robinson Tryon (qubit) 2015-12-17 08:59:01 UTC
Migrating Whiteboard tags to Keywords: (bibisected)
[NinjaEdit]