| View previous topic :: View next topic |
| Author |
Message |
jgperrin General User


Joined: 28 Jul 2005 Posts: 10 Location: Haguenau, Alsace, France
|
Posted: Thu Aug 04, 2005 3:32 am Post subject: Calling Java from Toolbar |
|
|
Hi,
Env: OOo 1.9.122, JDK 1.4.2, Windows XP
I try to run the HelloWorld example from the toolbar, if I run it as a macro from the run macro menu, it runs ok. It also runs ok when i assign a key to it, e.g. Ctrl F5.
Now I try to assign it to the toolbar, I get an error message box:
| Quote: | A Scripting Framework error occured while running the Java script HelloWorld.printHW.
Message: StrictResolver.getProxy: Cant find method:
printHW:HelloWorld.printHW(com.sun.star.script.provider.XScriptProvider, java.lang.Short) |
Any idea what I did wrong?
Thanks
jgp
(Note the typo on "cant" too.) |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
jgperrin General User


Joined: 28 Jul 2005 Posts: 10 Location: Haguenau, Alsace, France
|
Posted: Fri Aug 05, 2005 3:59 am Post subject: |
|
|
Salut Serge,
Thanks for your answer, however, I found my issue:
| Code: | public class MyFirstLetter {
/**
* This method is inserted here to allow the call from the toolbar.
*
* @param xSc
* @param ignored
*/
public static void printMyLetter(XScriptContext xSc, Short ignored) {
printMyLetter(xSc);
}
public static void printMyLetter(XScriptContext xSc) {
// getting the text document object
XTextDocument xtextdocument = (XTextDocument) UnoRuntime
.queryInterface(XTextDocument.class, xSc.getDocument());
XText xText = xtextdocument.getText();
XTextRange xTextRange = xText.getEnd();
xTextRange.setString("Salut (in Java)");
}
}
|
By adding the dummy method:
| Code: | public static void printMyLetter(XScriptContext xSc, Short ignored) {
printMyLetter(xSc);
}
|
My code can be called by the toolbar.
(i may not have been very clear in my original post)
hih - jgp |
|
| 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
|