On 12/25/10 7:25 AM, gintare statkute wrote:
> *
> 
> 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?
such an ID dos not exists

> 
> 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
> 
you should have a cursor when you have find the text. Move this cursor
to the end of the text/word and insert your bookmark. You can check the
SDK text API examples to see how to move cursor (navigate in a document)
and how to insert bookmarks etc.

Juergen


> 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
> 


-- 
Oracle <http://www.oracle.com>
Jürgen Schmidt | Principal Software Engineer
Oracle Office GBU

ORACLE Deutschland B.V. & Co. KG | Nagelsweg 55 | 20097 Hamburg

ORACLE Deutschland B.V. & Co. KG
Hauptverwaltung: Riesstr. 25, D-80992 München
Registergericht: Amtsgericht München, HRA 95603

Komplementärin: ORACLE Deutschland Verwaltung B.V.
Rijnzathe 6, 3454PV De Meern, Niederlande
Handelsregister der Handelskammer Midden-Niederlande, Nr. 30143697
Geschäftsführer: Jürgen Kunz, Marcel van de Molen, Alexander van der Ven

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to