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

Need help with event handler.

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


Joined: 02 Jul 2009
Posts: 13

PostPosted: Thu Jul 02, 2009 5:13 am    Post subject: Need help with event handler. Reply with quote

Hi ,

I am new to Basic, Can someone guide me here ->
I need an eventhandler which looks for onSave event and it should call another function and not save.

I want to use the interface XEventHandler of :: com :: sun :: star :: awt ::
and need to use the function handleEvent.

The code fails @thisComponent.currentController.addEventHandler(oEventHandler)

sub main
AddEventHandler
end sub


Option Explicit
Global oEventHandler
Sub AddEventHandler
dim oDoc

oEventHandler = CreateUnoListener( "EventHandler_","com.sun.star.awt.XEventHandler" )
thisComponent.currentController.addEventHandler(oEventHandler)


End Sub

sub EventHandler_handleEvent( oEvent )
Msgbox "Yes"
end sub

Also using notifyEvent for the listener Interface doesnt pick up the onPrint event.?
Any clue why?
Back to top
View user's profile Send private message
Shine.P
General User
General User


Joined: 02 Jul 2009
Posts: 13

PostPosted: Fri Jul 03, 2009 1:17 am    Post subject: Reply with quote

Need some help please!!
Back to top
View user's profile Send private message
B Marcelly
Super User
Super User


Joined: 12 May 2004
Posts: 1453
Location: France

PostPosted: Fri Jul 03, 2009 1:47 am    Post subject: Reply with quote

Hi,
You can manually assign a macro to the On Save event, via menu Tools > Customize > Events.
This is much easier than assigning by program, if you are new to OpenOffice.

Quote:
The code fails @thisComponent.currentController.addEventHandler(oEventHandler)

There is no such method as addEventHandler.
You probably mean addEventListener, which is available from the document itself.
You must always add a routine for the disposing event, this routine can be empty but must exist.
______
Bernard
Back to top
View user's profile Send private message Visit poster's website
Shine.P
General User
General User


Joined: 02 Jul 2009
Posts: 13

PostPosted: Fri Jul 03, 2009 2:56 am    Post subject: Reply with quote

Hi Bernard,

Thanks for the reply

I have got the listener to work and i use notify event to notify of onSave. I plan to deploy the letter in HTML format with the mimetype of an .sxw file and use SDONLOAD to load the macros written in basic.

I just need to find a way to write the opened/edited document to a database or place in the server using the event onSave. Does anyone have any links or documents on this or a function?

I am a java programmer, very new to BASIC. Thanks
Back to top
View user's profile Send private message
Chriz
Newbie
Newbie


Joined: 08 Sep 2009
Posts: 4

PostPosted: Mon Oct 12, 2009 11:23 pm    Post subject: Reply with quote

Hi Shine,

I've got the same problem.Have you solved it or could anybody give a solution?
_________________
Chris
Back to top
View user's profile Send private message
vinod.excel
General User
General User


Joined: 29 Sep 2011
Posts: 13

PostPosted: Thu Mar 15, 2012 2:13 pm    Post subject: Reply with quote

Hi Shine,

Is it possible to cancel/stop the Save operataion if I want. because in my requirement at OnSave my macro (calc/star basic) performs some validation if validation fails then macro has to quit from execution.

Best Regards,
Vins
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