*

Q – uno.RuntimeException
*
1) Phylosophuc question:
Is it possible to define relative one object position to another object and
position in whole document context. I mean do words, commas, paragraphs,
booksmarks has some ID which shows their position in whole document? If such
ID exists, how to get it?

2)  Real question:
?? How to insert the text/bookmark to position where I found another text ??
*i need 
**XTextContent*<https://mail.google.com/mail/openoffice.org/basis3.2/sdk/docs/common/ref/com/sun/star/text/XTextContent.html>
type
variable related to the bookmark

I am searching for a "search string" in  text.odt  document and need
to create and insert bookmark after it.
later make table of contents of such bookmarks with references to positions
where i found the text.

*found=doc1.findAll(search); print '\nfound=\n', found*
*foundLen=found.getCount(); print '\n foundLen=found.getCount()=\n',
foundLen*
*for i in range(foundLen):*
*    mfoundItem=found.getByIndex(i); print
'\n\nmfoundItem=found.getByIndex(',i,')=\n',mfoundItem*
*    mbookmark=doc1.createInstance("com.sun.star.text.Bookmark")*
*    #mbookmarkAnchor=mbookmark.getAnchor() - gives error*
*   # i need 
**XTextContent*<https://mail.google.com/mail/openoffice.org/basis3.2/sdk/docs/common/ref/com/sun/star/text/XTextContent.html>
type
variable related to the bookmark
*    text1.insertTextContent(mfoundItem,
mbookmark_**XTextContent*<https://mail.google.com/mail/openoffice.org/basis3.2/sdk/docs/common/ref/com/sun/star/text/XTextContent.html>
 *, 'false')*


Code with comments:

found=doc1.findAll(search); print '\nfound=\n', found

#.....pyuno object (com.sun.star.container.XIndexAccess)....

foundLen=found.getCount(); print '\n foundLen=found.getCount()=\n', foundLen

for i in range(foundLen):

mfoundItem=found.getByIndex(i); print
'\n\nmfoundItem=found.getByIndex(',i,')=\n',mfoundItem

#....... pyuno object (com.sun.star.text.XTextRange).......


mbookmark=doc1.createInstance("com.sun.star.text.Bookmark")

#...........pyuno object (com.sun.star.uno.XInterface)..........

text1.insertTextContent(mfoundItem, mbookmark, 'false')

# according API void *insertTextContent *( [in]
*XTextRange*<https://mail.google.com/mail/openoffice.org/basis3.2/sdk/docs/common/ref/com/sun/star/text/XTextRange.html>xRange,
[in]
*XTextContent*<https://mail.google.com/mail/openoffice.org/basis3.2/sdk/docs/common/ref/com/sun/star/text/XTextContent.html>xContent,
[in] boolean bAbsorb )

# according print output mfoundItem is pyuno object .XtextRange
# the mistake is in bookmark which is not object
*XtextContent*<https://mail.google.com/mail/openoffice.org/basis3.2/sdk/docs/common/ref/com/sun/star/text/XTextContent.html>,
as required by method *insertTextContent. *Print shows that bookmark is .object
Xinterface.

# it is impossible to get
*XtextContent*<https://mail.google.com/mail/openoffice.org/basis3.2/sdk/docs/common/ref/com/sun/star/text/XTextContent.html>for
the bookmark since getAnchor() method rise error "uno.RuntimeException" WHY?
regards,
gintare statkute

Reply via email to