Hi Ann,

Maybe I should explain more what I am trying to do. I have an impress
document and have added a com.sun.star.drawing.TextShape to it (This is
the "xShape" in my example). Within the text of that shape, I would like
to create a hyperlink. From the UI, when I am in a text box in
OpenOffice.org, it looks like I can choose "Insert -> Hyperlink". So it
seems that I should be able to do this in the code as well. Am I taking
the wrong approach?

Here is a little more context for my sample code:

XMultiServiceFactory xFactory =
(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class,
                        xDrawDoc);
Object xObj = xFactory.createInstance("com.sun.star.drawing.TextShape");
xShape = (XShape)UnoRuntime.queryInterface(XShape.class, xObj);
XText xText = (XText)UnoRuntime.queryInterface(XText.class, xShape);
XTextCursor xTextCursor = xText.createTextCursor();
XPropertySet propCursor = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
propCursor.setPropertyValue("HyperLinkURL", "http://www.openoffice.org";);

The shades of confusion start to lift ;-)

"HyperLinkURL" is a optional CharacterProperty which isn't avalable at the text of a shape.

What the "insert-Hyperlink" does is inserting a textfield ... something like

----------------
Object o = xFactory.createInstance("com.sun.star.textfield.URL");
XTextContent xTC = (XTextContent)
        UnoRuntime.queryInterface(XTextContent.class, o);
XPropertySet xPS = (XPropertySet)
        UnoRuntime.queryInterface(XPropertySet.class, o);
xPS.setPropertyValue("URL","http://www.openoffice.org";);

xText.insertTextContent(xTextCursor, xTC, false);
----------------

should do the trick.

Hope that helps

Regards

Stephan

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

Reply via email to