bump product version to 6.3.0.0.beta1
[LibreOffice.git] / extensions / test / ole / EventListenerSample / events.htm
blob75f7bc1d9b07c543c514961acd1e02f3ba7c6e5f
1 <!--
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 -->
18 <HTML>
19 <HEAD>
20 <META NAME="GENERATOR" Content="Microsoft Developer Studio">
21 <META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
22 <TITLE>Document Title</TITLE>
23 </HEAD>
24 <BODY id=theBody>
26 <script language="JScript">
27 function Main( id)
29 var objServiceManager= new ActiveXObject("com.sun.star.ServiceManager");
31 var objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop");
33 var args= new Array();
35 var objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);
37 var listener;
38 if( id == 0)
39 listener= new XEventListener_Impl();
40 else if(id == 1)
41 listener= new ActiveXObject("EventListener.EvtListener");
42 objDocument.addEventListener( listener);
46 function XEventListener_Impl()
48 this._environment= "JScript";
49 this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener");
51 //XEventListener
52 this.disposing= XEventListener_disposing;
55 function XEventListener_disposing( source)
57 alert("JScript Event Listener \n The document was closed");
59 </script>
61 <script language="VBScript">
62 SUB MainVB( id)
63 Set objServiceManager= CreateObject("com.sun.star.ServiceManager")
65 Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
67 Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
69 'Open a new empty writer document
70 Dim args()
71 Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
73 Dim eventListener
74 select case id
75 case 0
76 Set eventListener= CreateObject("EventListener.EvtListener")
77 case 1
78 Set eventListener= CreateObject("VBasicEventListener.VBEventListener")
79 end select
81 objDocument.addEventListener eventlistener
82 END SUB
84 </script>
85 <p>
86 The script on this page creates a new StarOffice document and connects an event listener
87 to it. When the document is closed then the XEventListener::disposing method is called on the
88 listener object. How the listener is set up depends on the button being clicked.
89 </p>
90 <p>
91 The button will run JScript code that and adds an JScript event listener to the document.
92 The listener is also implemented in JScript an is on this page..
93 </p>
94 <button onclick='Main(0)'>JScript go</Button>
95 <p>
97 The button runs JScript code that creates the ActiveX component EventListener.EvtListener that
98 is written in C++ and housed in a dll. Then the event listener is added to the document.
99 </p>
100 <button onclick='Main( 1)'>JScript go</Button>
102 The button runs VBScript code that creates the components EventListener.EvtListener and adds it
103 to the document.
104 </p>
105 <button onclick='MainVB(0)'>VBScript</Button>
107 Runs VBScript code that creates VBasicEventListener.VBEventListener ActiveX component which was
108 written with VB
109 </p>
110 <button onclick='MainVB(1)'>VBScript</Button>
112 </body>
113 </html>