| View previous topic :: View next topic |
| Author |
Message |
Unoade Guest
|
Posted: Wed Jan 28, 2004 11:41 pm Post subject: Java program that open a template |
|
|
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
|
Posted: Fri Jan 30, 2004 6:05 am Post subject: |
|
|
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 |
|
 |
|
|
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
|