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

Custom Toolbar buttons and listening to assocaited events

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


Joined: 20 Feb 2005
Posts: 3

PostPosted: Sun Apr 03, 2005 1:10 am    Post subject: Custom Toolbar buttons and listening to assocaited events Reply with quote

I apologize if it is a wrong section of this forum to place my thread.

I am new to Open Office and trying to discover the enormous hidden features of OO.

Problem: How to have your own custom tool bar buttons in Open office tool bar with your own icons and own actions. How can we catch the button actions in your own custom Java application?

Details:
I am working on a Java application and it has one reporting module. Whenever user wants to write a report, he can open a new or existing document (Check in / Check out) using my Java application. The report module collaborates with several other modules of my application. I got success in opening and storing the documents using OO. However now the requirement says that at any point while writing the report if user wants to open related record in a different module of my application he may click a custom tool bar button and my application will listen to action and will process accordingly.

1- How can I place my own custom buttons in toolbar?

2- How can I listen to events associated with these buttons in Open office?

3- How can I easily switch (gain focus) in between my Java application and Open Office.

So far I am unable to find any useful resources in this regard; I am looking for some guidelines or some documents or tutorial or link to use resources to accomplish this task.

Any help in this regard is highly appreciated.

Regards

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


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

PostPosted: Mon Apr 04, 2005 6:24 am    Post subject: Reply with quote

I think you will need to write a Component and install it into the office.

You can write a component in Java (or Python or C++).

There are a couple different approaches.

1. Your toolbar button could call a Basic macro, which then invokes your component and calls methods on it. Your component can either directly implement the functionality you need, or it can "contact" some external server (i.e. a servlet maybe?) to request or initiate some action.

2. Your toolbar button could have a custom url, and your java component has installed a custom "protocol handler" that intercepts dispatches to your custom url. Similar to (1) above, your component can then contact an external program, or directly perform the requested action.

It sounds like you know how to get an external Java program to connect to the office and operate the office API. The next barrier is to learn how to write a component and install it into the office.

Seeking ideas for new Calc add-in functions
http://www.oooforum.org/forum/viewtopic.php?t=12589
The above thread has a link where to download the functions,
including source code more highly developed than the
crude example here.
http://www.oooforum.org/forum/viewtopic.php?p=49922#49922

Jar files in components
http://www.oooforum.org/forum/viewtopic.php?p=62235#62235

Development of Calc Function add ins in Java
http://www.oooforum.org/forum/viewtopic.php?t=12537
source code to early development version begins here
and continues into message which follows.
http://www.oooforum.org/forum/viewtopic.php?p=49922#49922
Problem with invocation of Java Addin method from Calc
http://www.oooforum.org/forum/viewtopic.php?t=12921

Development of Calc Function add in component in Python
http://www.oooforum.org/forum/viewtopic.php?t=8456

Python component providing XML parser
http://www.oooforum.org/forum/viewtopic.php?p=38234#38234

Python container components
http://www.oooforum.org/forum/viewtopic.php?t=9115

* Addon.xcs, custom configuration schema, accessing from code,
how to put xcs/xcu files into your component.
http://www.oooforum.org/forum/viewtopic.php?p=62655#62655
_________________
Want to make OOo Drawings like the colored flower design to the left?
Back to top
View user's profile Send private message
shaheryar
Newbie
Newbie


Joined: 20 Feb 2005
Posts: 3

PostPosted: Tue Apr 05, 2005 12:54 am    Post subject: Reply with quote

Hi Danny,

First of all I would like to thank you for prompt and detailed reply. You are absolutely a light house for all the uncertain sailors. Thank you for your detailed reply.

Well I went through the links you listed and figured out that still it will not solve the problem I am working on. Initially I was opening office through my application as standalone application and I was listening to the events of the OO. In fact only one event that is when he closes the OO. But now I think that even if I got success in listening to Macros and button events, still I won’t be able to transfer the focus in between my application and OO. To overcome the problems associated with this complex solution I started looking at Office Connection and Office Window and now embedding the OO office window as frame or panel in my application. I ran the samples and it seems it is good idea to embed the OO in my application.

Now at this point I want to bring your attention to another problem. I went through the developers guide and established the connection to OO as depicted in the Getting Started Chapter in OO SDK and used the FirstConnection.java to establish the connection to OO. But now looking at the OfficeBean examples in OO SDK the method of establishing the connection is totally different. In my existing application I am using the UnoResolver to get remote context and then get the Remote Service Manager and then I use XComponenetLoader to open a new office window.

I am not using the LocalOfficeConnection and LocalOfficeWindow and I am new to these. Is there I way I can get the OfficeConnection object by using the existing methodology i.e. UnoResolver. Because I need to call the getAWTComponent() on office connection in order to embed it to my application.

Questions
1- Is it necessary to establish LocalOfficeConnection in order to get LocalOfficeWindow ?
2- What is difference between two methodologies?
3- Can I get the AWT window by some other means other than creating a new instance of LocalOfficeConnection to create and embed the OfficeWindow in my application?

Thanks in advance for all your help and support.

Regards

Shaheryar
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