OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Insert TextDocument in Java

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
wumpfreak
General User
General User


Joined: 25 Sep 2003
Posts: 7

PostPosted: Fri Nov 21, 2003 8:29 am    Post subject: Insert TextDocument in Java Reply with quote

Hi all,

I'm trying to insert a sxw document in another one using uno and java. Unfortunately the insertDocumentFromURL method has no example in the DevGuide Crying or Very sad It is only said that the text cursor supports the com.sun.star.document.XDocumentInsertable interface. So I tried the following: (some calls like this.getXTextViewCursor() are self programmed methods)

Code:

try {
   XTextViewCursor lXTextViewCursor = this.getXTextViewCursor();
   XText lXText = lXTextViewCursor.getText();
   XTextCursor lXTextCursor = lXText.createTextCursorByRange(lXTextViewCursor.getStart());
   lXTextCursor.gotoEnd(false);
         
   XDocumentInsertable lXDocInsertable = (XDocumentInsertable)UnoRuntime.queryInterface(XDocumentInsertable.class, lXTextCursor);
      
   PropertyValue[] lLoadProperties = new PropertyValue[1];
   lLoadProperties[0] = new PropertyValue();
   lLoadProperties[0].Name = "Hidden";
   lLoadProperties[0].Value = new Boolean(false);
      
   lXDocInsertable.insertDocumentFromURL(lPathToDoc, lLoadProperties);
} catch (Exception ex) {
   ex.printStackTrace();
}


This code produces an IllegalArgumentException at the call of insertDocumentFromURL.

Can anybody help?

Thanks!

Stephan
Back to top
View user's profile Send private message
DannyB
Moderator
Moderator


Joined: 02 Apr 2003
Posts: 3991
Location: Lawrence, Kansas, USA

PostPosted: Fri Nov 21, 2003 8:49 am    Post subject: Reply with quote

Hidden may not be a valid property to insertDocumentFromURL. It is valid to loadComponentFromURL, but may not be valid here.

There are only two parameters, the URL, and a set of PropertyValue's. Are you sure your URL is good, just to get that out of the way? What if you try passing an empty array of PropertyValue.

new PropertyValue[ 0 ]
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
wumpfreak
General User
General User


Joined: 25 Sep 2003
Posts: 7

PostPosted: Fri Nov 21, 2003 9:07 am    Post subject: THANK YOU! Reply with quote

Hello DannyB!

The "new PropertyValue[ 0 ]" trick did it! Very Happy

Thank you!

Stephan
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group