| View previous topic :: View next topic |
| Author |
Message |
Shine.P General User

Joined: 02 Jul 2009 Posts: 13
|
Posted: Thu Jul 02, 2009 5:13 am Post subject: Need help with event handler. |
|
|
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 |
|
 |
Shine.P General User

Joined: 02 Jul 2009 Posts: 13
|
Posted: Fri Jul 03, 2009 1:17 am Post subject: |
|
|
| Need some help please!! |
|
| Back to top |
|
 |
B Marcelly Super User

Joined: 12 May 2004 Posts: 1414 Location: France
|
Posted: Fri Jul 03, 2009 1:47 am Post subject: |
|
|
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 |
|
 |
Shine.P General User

Joined: 02 Jul 2009 Posts: 13
|
Posted: Fri Jul 03, 2009 2:56 am Post subject: |
|
|
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 |
|
 |
Chriz Newbie

Joined: 08 Sep 2009 Posts: 4
|
Posted: Mon Oct 12, 2009 11:23 pm Post subject: |
|
|
Hi Shine,
I've got the same problem.Have you solved it or could anybody give a solution? _________________ Chris |
|
| Back to top |
|
 |
vinod.excel General User

Joined: 29 Sep 2011 Posts: 12
|
Posted: Thu Mar 15, 2012 2:13 pm Post subject: |
|
|
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 |
|
 |
|