Apache OpenOffice (AOO) Bugzilla – Issue 73568
inserting textcontent into the anchor of a collapsed bookmark doesn't extend the bookmark
Last modified: 2013-02-24 21:08:56 UTC
There is a document insertIntoCollapsedBookmark.odt attached that contains two bookmarks. The first one (named "collapsed") is collapsed and the other one (named "notCollapsed") has some textcontent. when running the code Sub Main bookmark = ThisComponent.getBookmarks().getByName("collapsed") bookmark.Anchor.setString("foo") bookmark = ThisComponent.getBookmarks().getByName("notCollapsed") bookmark.Anchor.setString("bar") End Sub the bookmark "collapsed" doesn't get extended with the new textcontent and is still collapsed, while the other bookmark "notCollapsed" is extended correctly. So selecting the bookmark "collapsed" in the navigator does not select the word "foo", while selecting the bookmark "notCollapsed" selects the word "bar". so here is how to reproduce: 1) open insertIntoCollapsedBookmark.odt 2) run the included macro "main" 3) open the navigator and select the bookmark "collapsed" and look at the selected content 4) select the bookmark "notCollapsed" and look at the selected content For me a collapsed bookmark is a bookmark where bookmark.Anchor.getStart() == bookmark.Anchor.getEnd(). There seems to be two ways of representing such bookmarks internally: Type A) The collapsed bookmark is represented by two objects ob Type XTextContent. The first one has the attributes IsStart==true and IsCollapsed==false, the last one has the attribute IsStart == false. There is no other textcontent between the start mark and the end mark, so the bookmark is empty (or collapsed). The XML-Representation of such a bookmark is: <text:bookmark-start text:name="collapsed"/><text:bookmark-end text:name="collapsed"/> Type B) The collapsed bookmark is represented by only one object of type XTextContent. The object has the properties IsStart==true and IsCollapsed==true. The XML representation of such a bookmark is (please note: it's a different XML-element!!): <text:bookmark text:name="collapsed"/> The bookmark "collapsed" with the incorrect behaviour is of Type B! So I manually changed the representation of the bookmark in the content.xml to get a bookmark of type A. The document insertIntoCollapsedBookmark_patchedContentXML.odt contains the result and shows, that bookmarks of type A behave correct. so here is how to reproduce the correct bahaviour of type A bookmarks: 1) open insertIntoCollapsedBookmark_patchedContentXML.odt 2) run the included macro "main" 3) open the navigator and select the bookmark "collapsed" and look at the selected content 4) select the bookmark "notCollapsed" and look at the selected content Please note: this in a very serious issue for us since our letterhead system relies in the fact, that bookmarks always contain the correct content.
Created attachment 42239 [details] Contains a collapsed bookmark of type B where the issue occures
Created attachment 42240 [details] Contains a collapsed bookmark of type A where the issue DOES NOT occure
jsc -> tl: can you please check this
The behaviour of collapsed bookmarks is intended. They do not expand and they should not. Otherwise they would also expand if the text is inserted via user interface. To get what you need you have to remove the bookmark and insert it again over the inserted text.
closing