Apache OpenOffice (AOO) Bugzilla – Issue 24289
Redundant bookmarks are generated while operating with XTextCursor
Last modified: 2017-05-20 11:27:33 UTC
AFAIU, each time our program operates with an XTextCursor object, OOo creates temporary bookmarks to remember that cusrsor's current position. Usually these bookmarks are deleted after the program execution, but sometimes they are not. Let's take the following example. Suppose we have selected some text in a document (it should be longer than 2 characters), and then processed it with the following macro: Sub Test oSel = ThisComponent.getCurrentController ().getSelection ().getByIndex (0) oText = ThisComponent.Text oRange = oText.createTextCursorByRange (oSel) ' create a text cursor inside another text range oCursor = oText.createTextCursorByRange (oRange.Start) oCursor.goRight (1, False) oCursor.goRight (1, True) oRange.setString ("Replaced") End Sub Here we get an XTextRange object, then create a text cursor *inside* this range, and then just replace the string of our text range. Now simply undo the changes. Of course this restores the string we have replaced, but, unfortunately, not only the string. Go to the Insert->Bookmark dialog. You will see that the document contains a new bookmark, called "SwXTextPosition***", where *** is an arbitrary number. Suppose we have performed this operation several times (which is very vital situation). Now our document contains a growing number of redundant bookmarks, which make its xml structure more complex and iterating through its elements more difficult. So the problem is clear. I suppose each time our program deletes or modifies some text content, OOo should check if text which should be removed contains some autogenerated bookmarks and remove them first.
forwarding to responsible developer
TL->hbrinkm: According to OS the Undo always changes the removed UNO bookmarks to regular ones. According to OS either restoring of UNO bookmarks cabn be omitted because there is no need, or else it should properly restored.
setting initial target
Reset assigne to the default "issues@openoffice.apache.org".