[api-dev] Adding text to a TitleTextShape on an XDrawPage

2009-05-30 Thread Jeremy Trudel
I am trying to Create an impress document with one XDrawPage. I'm trying to
create a TitleTextShape on that XDrawPage and

Add some text to it. I have been able to do everything up until the add
text to it part. From the documentation, it says that you can call
setString() on a XText object, but I have been unable to get that to work.
My code creates the document, the slide and the title object, but the text
never gets added. I tried creating an XTextCursor from the XText object, but
any method I call on it raises a com.sun.star.lang.DisposedException
exception. Here is a snippet of my code.

 

XComponent document = jComponentLoader.loadComponentFromURL(

private:factory/simpress, _blank, 0, loadProps);

XDrawPagesSupplier xDrawPagesSupplier =

(XDrawPagesSupplier)UnoRuntime.queryInterface(

 XDrawPagesSupplier.class, document);

XDrawPages xDrawPages = xDrawPagesSupplier.getDrawPages();

Object newPage = xDrawPages.getByIndex(0);

XDrawPage xNewPage =
(XDrawPage)UnoRuntime.queryInterface(XDrawPage.class, newPage);

XMultiServiceFactory factory = (XMultiServiceFactory)UnoRuntime

.queryInterface(XMultiServiceFactory.class, document);

 



Object title =
factory.createInstance(com.sun.star.presentation.TitleTextShape);

XShape xTitle = (XShape)UnoRuntime.queryInterface(XShape.class,
title);

XText xText = (XText)UnoRuntime.queryInterface(XText.class,
xTitle);

xText.setString(Some Text); 

xNewPage.add(xTitle);

 

I then procede to storeToURL using the MS PowerPoint 97 conversionFilter.
When I open the generated ppt, the title object gets created fine, but with
no text.

 

I then tried to create an XTextCursor:

 

XTextCursor cursor = xText.createTextCursor();

 

But, any method call on this object raises a
com.sun.star.lang.DisposedException. I read somewhere that:

 

The problem here is the lifetime concept of UNO in general, and of

statements and result sets in particular. First (and in short), in UNO an
object is not necessarily alive just because you have a reference to it
Instead, objects can become disfunctional if they're disposed.

 

I'm not really sure what this means, but any help or clarification would be
much appreciated.

 

 

 

 

 

 

 



Re: [api-dev] Adding text to a TitleTextShape on an XDrawPage

2009-05-30 Thread Bernard Marcelly

Hi Jeremy,
First add the form on the draw page.
Then setString.

Regards
  Bernard


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



Re: [api-dev] Adding text to a TitleTextShape on an XDrawPage

2009-05-30 Thread Cor Nouws

[adding Jeremy to cc]

Jeremy, if you want to be sure to see replies, pls subscribe to the mail 
list via dev-subscr...@api.openoffice.org


Regards - Cor

Bernard Marcelly wrote (30-5-2009 14:11)

Hi Jeremy,
First add the form on the draw page.
Then setString.



--
Cor Nouws-nl.OpenOffice.org marketing contact
= 2009 - Develop OOo   =   www.nieuwsteoffice.nl  =

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