On Thu, 27 Apr 2006 17:10:13 -0400, Ann Van <[EMAIL PROTECTED]>
wrote:
Stephan,
Thanks for all the pointers. I am no longer getting any errors in running
the code. However, I am not seeing any links in the resulting document.
Could it be because I am using OpenOffice.org 1.1, or that I am trying
also to output it as a PowerPoint file?
Here is a code snippet:
// xPresentation is an impress presentation
XDrawPage xDrawPage = PageHelper.getDrawPageByIndex(xPresentation, 0);
XMultiServiceFactory xFactory =
(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class,
xPresentation);
Object xObj = xFactory.createInstance("com.sun.star.drawing.TextShape");
XShape xShape = (XShape)UnoRuntime.queryInterface(XShape.class, xObj);
xShape.setPosition(aPos);
xShape.setSize(aSize);
XText xText = (XText)UnoRuntime.queryInterface(XText.class, xShape);
XTextCursor xTextCursor = xText.createTextCursor();
Object o = xFactory.createInstance("com.sun.star.text.TextField.URL");
XTextContent xTC = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, o);
XPropertySet xPS = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xTC);
xPS.setPropertyValue("URL","http://www.openoffice.org");
xText.insertTextContent(xTextCursor, xTC, true);
xDrawPage.add(xShape);
As you can see, I have a presentation document where I am trying to add a
URL to a TextShape. However, the resulting document doesn't show the URL
at all, either as a link or even as text. If I add text to the end of the
TextShape that is not a URL (using ShapeHelper.addPortion), then I can
see
the text fine. Any ideas I so I can get the URL to show and link
correctly? Or so that I can debug further?
Thanks,
Ann
Andrew's Document point a snippet on how to insert URL to text, he does
mention that this is for writer which stores the URL as a porperty of the
text, I am not sure if there is a difference on impress. Also this snippet
is for 2.0 and yes there could be lots of difference starting with the
dispatcher and also the way to call the services.
1.1. Inserting a URL into a Write document
Although a Calc document stores URLs in a URL text field, as shown
elsewhere in this document, Write documents identify contained URLs based
on character properties. A link becomes a link, when the HyperLinkURL
property is set.
Sub InsertURLAtTextCursor
Dim oText 'Text object for the current object
Dim oVCursor 'Current view cursor
oVCursor = ThisComponent.getCurrentController().getViewCursor()
oText = oVCursor.getText()
oText.insertString(oVCursor, "[EMAIL PROTECTED]", True)
oVCursor.HyperLinkTarget = "mailto:[EMAIL PROTECTED]"
oVCursor.HyperLinkURL = "[EMAIL PROTECTED]"
End Sub
--
Alexandro Colorado
CoLeader of OpenOffice.org ES
http://es.openoffice.org
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]