Apache OpenOffice (AOO) Bugzilla – Issue 101283
uncollapsed bookmark with zero length is self-expanding
Last modified: 2017-05-20 11:15:39 UTC
The attached document contains a bookmark called "WM(CMD 'insertFormValue' ID 'GABetrag')" that is NOT collapsed but has a length of zero. Behind the bookmark, there is a text "text behind". The XML-Representation of this bookmark and the text looks like this (you can see that the bookmark really ends before the text): [...]<text:p text:style-name="Standard"><text:bookmark-start text:name="WM(CMD 'insertFormValue' ID 'GABetrag')
"/><text:bookmark-end text:name="WM(CMD 'insertFormValue' ID 'GABetrag')
"/>text behind</text:p>[...] If you open the document in OOo and select the bookmark via navigator, the viewcursor does not point to a single position in the text (as expected) but also selects the text "text behind". The bookmark is self-expanding.
Created attachment 61736 [details] the document with the self-expanding bookmark - open it and select the bookmark. there is more selected than expected.
@b_michaelsen: Please have a look.
I encountered the same issue recently. The issue is particularly bad because you save a document in one state (with bookmark in front of text), you close the document, open it again and it is in a different state (text lies inside of bookmark) without you changing anything in the document. Obviously the internal state of the document and what is written in the content.xml do not correspond correctly. I attached a simplified test document below. Do the following: 1. Look at the content.xml in simplifiedSelfExpandingBookmark.odt. The important part is the following: <text:bookmark-start text:name="test"/><text:bookmark-end text:name="test"/>def Notice that the text "def" comes AFTER the bookmark. 2. Open simplifiedSelfExpandingBookmark.odt in writer. 3. Save the document under a different name with "Save as.." 4. Look at the content.xml in the new document. Magically the content.xml has changed to: <text:bookmark-start text:name="test"/>def<text:bookmark-end text:name="test"/> So now the text "def" is INSIDE of the bookmark even though I didn't change a thing in the document before saving it again. It should be obvious why this is pretty bad, but just to iterate further consider the following example where you have a macro which looks something like this: Sub Main bookmark = ThisComponent.getBookmarks().getByName("test") bookmark.getAnchor().setString("abc") End Sub And now do the following: 1. Open a new writer document 2. Enter the text "abcdef" 3. Select "abc" 4. Insert a bookmark on "abc" using Insert->Bookmark. Name the bookmark "test". 5. Open the navigator (F5) 6. Select the bookmark "test" using the navigator. 7. Hit Del, thus deleting "abc" (The bookmark "test" is still there). 8. Save the document. We now have exactly the case shown in simplifiedSelfExpandingBookmark.odt where in content.xml the "test"-Bookmark comes before the text "def". If we now call our macro everything works as expected. The text "abc" gets inserted inside the bookmark "test", and the document now contains the string "abcdef". But if we close the document first and open it again (or just reload it with File->Reload), the macro has a different effect! It deletes the text "def" and the document now only contains the string "abc". So even though we theoretically have the exact same document the same macro does different things to it after a reload of the document (without changing anything to the document).
Created attachment 63595 [details] simplified test document; open it and save it under different name => content.xml has changed
retargeting 3.3
pls. reassign or close issues. Thx.
set target 3.x since not relevant for 3.4 release.
Created attachment 77381 [details] Patch for OOo 3.2.1 This is a patch, I wrote for OOo 3.2.1m19. It adds special handling for collapsed bookmarks.
Reset assigne to the default "issues@openoffice.apache.org".