Issue 101283 - uncollapsed bookmark with zero length is self-expanding
Summary: uncollapsed bookmark with zero length is self-expanding
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: programming (show other issues)
Version: OOo 3.0.1
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-22 17:55 UTC by clutz
Modified: 2017-05-20 11:15 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
the document with the self-expanding bookmark - open it and select the bookmark. there is more selected than expected. (8.12 KB, text/plain)
2009-04-22 17:56 UTC, clutz
no flags Details
simplified test document; open it and save it under different name => content.xml has changed (6.96 KB, application/vnd.oasis.opendocument.text)
2009-07-17 08:31 UTC, Daniel Benkmann
no flags Details
Patch for OOo 3.2.1 (1.14 KB, patch)
2012-03-27 07:32 UTC, eymux2009
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description clutz 2009-04-22 17:55:08 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
&apos;insertFormValue&apos; ID &apos;GABetrag&apos;)&#x0a;"/><text:bookmark-end
text:name="WM(CMD &apos;insertFormValue&apos; ID
&apos;GABetrag&apos;)&#x0a;"/>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.
Comment 1 clutz 2009-04-22 17:56:08 UTC
Created attachment 61736 [details]
the document with the self-expanding bookmark - open it and select the bookmark. there is more selected than expected.
Comment 2 eric.savary 2009-04-22 21:13:39 UTC
@b_michaelsen: Please have a look.
Comment 3 Daniel Benkmann 2009-07-17 08:27:16 UTC
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).
Comment 4 Daniel Benkmann 2009-07-17 08:31:49 UTC
Created attachment 63595 [details]
simplified test document; open it and save it under different name => content.xml has changed
Comment 5 bjoern.michaelsen 2009-08-28 18:08:20 UTC
retargeting 3.3
Comment 6 hans_werner67 2011-02-03 12:08:22 UTC
pls. reassign or close issues.
Thx.
Comment 7 Martin Hollmichel 2011-03-16 11:42:33 UTC
set target 3.x since not relevant for 3.4 release.
Comment 8 eymux2009 2012-03-27 07:32:53 UTC
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.
Comment 9 Marcus 2017-05-20 11:15:39 UTC
Reset assigne to the default "issues@openoffice.apache.org".