Update ooo320-m1
[ooovba.git] / extensions / test / ole / EventListenerSample / events.htm
blob973a2152864388b441429dd5087f0ea9a1817e92
1 <HTML>
2 <HEAD>
3 <META NAME="GENERATOR" Content="Microsoft Developer Studio">
4 <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
5 <TITLE>Document Title</TITLE>
6 </HEAD>
7 <BODY id=theBody>
9 <script language="JScript">
10 function Main( id)
12 var objServiceManager= new ActiveXObject("com.sun.star.ServiceManager");
14 var objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop");
16 var args= new Array();
18 var objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);
20 var listener;
21 if( id == 0)
22 listener= new XEventListener_Impl();
23 else if(id == 1)
24 listener= new ActiveXObject("EventListener.EvtListener");
25 objDocument.addEventListener( listener);
29 function XEventListener_Impl()
31 this._environment= "JScript";
32 this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener");
34 //XEventListener
35 this.disposing= XEventListener_disposing;
38 function XEventListener_disposing( source)
40 alert("JScript Event Listener \n The document was closed");
42 </script>
44 <script language="VBScript">
45 SUB MainVB( id)
46 Set objServiceManager= CreateObject("com.sun.star.ServiceManager")
48 Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
50 Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
52 'Open a new empty writer document
53 Dim args()
54 Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
56 Dim eventListener
57 select case id
58 case 0
59 Set eventListener= CreateObject("EventListener.EvtListener")
60 case 1
61 Set eventListener= CreateObject("VBasicEventListener.VBEventListener")
62 end select
64 objDocument.addEventListener eventlistener
65 END SUB
67 </script>
68 <p>
69 The script on this page creates a new StarOffice document and connects an event listener
70 to it. When the document is closed then the XEventListener::disposing method is called on the
71 listener object. How the listener is set up depends on the button being clicked.
72 </p>
73 <p>
74 The button will run JScript code that and adds an JScript event listener to the document.
75 The listener is also implemented in JScript an is on this page..
76 </p>
77 <button onclick='Main(0)'>JScript go</Button>
78 <p>
80 The button runs JScript code that creates the ActiveX component EventListener.EvtListener that
81 is written in C++ and housed in a dll. Then the event listener is added to the document.
82 </p>
83 <button onclick='Main( 1)'>JScript go</Button>
84 <p>
85 The button runs VBScript code that creates the components EventListener.EvtListener and adds it
86 to the document.
87 </p>
88 <button onclick='MainVB(0)'>VBScript</Button>
89 <p>
90 Runs VBScript code that creates VBasicEventListener.VBEventListener ActiveX component which was
91 written with VB
92 </p>
93 <button onclick='MainVB(1)'>VBScript</Button>
95 </body>
96 </html>