Hello,

I would like to retrieve the paragraph just before the selected image in Writer. My goal is to insert a frame after this paragraph, and anchor the image to this frame, (exactly what appends when a caption is added to an image)

My code is:

oSelectedObject = ThisComponent.getCurrentSelection()
   ' if the selected object is an image
if oSelectedObject.supportsService("com.sun.star.text.TextGraphicObject") Then

*        *' there is already a frame around the image
if oSelectedObject.getAnchor.Text.supportsService("com.sun.star.text.TextFrame") then
            ' do something
        else
' no frame, I have to create a new frame just before the image and anchor the image to it oViewCursor = ThisComponent.getCurrentController().getViewCursor()
            oViewCursor.goUp(1, False)

=> it raises a RuntimeException , with the message "no text selection"

When I create a new TextCursor, like this:

oCursor = oSelectedObject.getAnchor().Text.createTextCursor()

The cursor is positioned at the document's start and I don't know how I can move this cursor to the paragraph before the selected image.

Does somebody have an idea ?

Thanks

Benoit.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to