Issue 73568 - inserting textcontent into the anchor of a collapsed bookmark doesn't extend the bookmark
Summary: inserting textcontent into the anchor of a collapsed bookmark doesn't extend ...
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: App Dev
Classification: Unclassified
Component: api (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: All All
: P3 Trivial
Target Milestone: ---
Assignee: thomas.lange
QA Contact: issues@api
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-17 15:37 UTC by clutz
Modified: 2013-02-24 21:08 UTC (History)
4 users (show)

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


Attachments
Contains a collapsed bookmark of type B where the issue occures (8.50 KB, application/vnd.sun.xml.writer)
2007-01-17 15:39 UTC, clutz
no flags Details
Contains a collapsed bookmark of type A where the issue DOES NOT occure (9.21 KB, application/vnd.sun.xml.writer)
2007-01-17 15:40 UTC, clutz
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description clutz 2007-01-17 15:37:43 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.
Comment 1 clutz 2007-01-17 15:39:24 UTC
Created attachment 42239 [details]
Contains a collapsed bookmark of type B where the issue occures
Comment 2 clutz 2007-01-17 15:40:43 UTC
Created attachment 42240 [details]
Contains a collapsed bookmark of type A where the issue DOES NOT occure
Comment 3 jsc 2007-01-17 16:15:15 UTC
jsc -> tl: can you please check this
Comment 4 Oliver Specht 2007-02-09 09:39:49 UTC
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. 
Comment 5 thomas.lange 2007-08-01 10:57:32 UTC
closing