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

Java program that open a template

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





PostPosted: Wed Jan 28, 2004 11:41 pm    Post subject: Java program that open a template Reply with quote

Hi, Im a newbie in OO. I like to make a java program that open a writer template and search for a string and replace that. Can enyone help med with that.

1.Open a writer template. DONE
2. Search and replace a string Failed
Back to top
Faust
Guest





PostPosted: Fri Jan 30, 2004 6:05 am    Post subject: Reply with quote

Hi!

First of all: be sure that you're opened template is not read-only ;o)

I replaced a string the following way:

1) get a XReplaceable interface for the component (document). It looks like this:

XReplaceable xRepl = (XReplaceable) UnoRuntime.queryInterface(XReplaceable.class, component);

2) get a replace descriptor:

XReplaceDescriptor xReplDes = xRepl.createReplaceDescriptor();

3) set the search string (the string that you want to replace):

xReplDes.setSearchString(searchStr);

4) set the replace string (the string with which you want to replace):

xReplDes.setReplaceString(replStr);

5) replace ...

xRepl.replaceAll(replDes);

this will replace ALL occurences of the search string, I don't remember, but I think there
should be other methods that replace only single occurences (just look up the
XReplaceable interface in the OO API)

Hope that helps ...

Faust
Back to top
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