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

Calling Java from Toolbar

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


Joined: 28 Jul 2005
Posts: 10
Location: Haguenau, Alsace, France

PostPosted: Thu Aug 04, 2005 3:32 am    Post subject: Calling Java from Toolbar Reply with quote

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
View user's profile Send private message
SergeM
Super User
Super User


Joined: 09 Sep 2003
Posts: 3211
Location: Troyes France

PostPosted: Thu Aug 04, 2005 7:18 am    Post subject: Reply with quote

What you try to do is named add-on. I think there are examples of add-on in SDK.
_________________
Linux & Windows OOo3.0
UNO & C++ : WIKI
http://wiki.services.openoffice.org/wiki/Using_Cpp_with_the_OOo_SDK
In French
http://wiki.services.openoffice.org/wiki/Documentation/FR/Cpp_Guide
Back to top
View user's profile Send private message Visit poster's website
jgperrin
General User
General User


Joined: 28 Jul 2005
Posts: 10
Location: Haguenau, Alsace, France

PostPosted: Fri Aug 05, 2005 3:59 am    Post subject: Reply with quote

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
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