1<!--***********************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements.  See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership.  The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License.  You may obtain a copy of the License at
10 *
11 *   http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied.  See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 ***********************************************************-->
21<HTML>
22<HEAD>
23<META NAME="GENERATOR" Content="Microsoft Developer Studio">
24<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
25<TITLE>Document Title</TITLE>
26</HEAD>
27<BODY id=theBody>
28
29<script language="JScript">
30function Main( id)
31{
32var  objServiceManager= new ActiveXObject("com.sun.star.ServiceManager");
33
34var objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop");
35
36var args= new Array();
37
38var objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);
39
40var listener;
41if( id == 0)
42  listener= new XEventListener_Impl();
43else if(id == 1)
44  listener= new ActiveXObject("EventListener.EvtListener");
45objDocument.addEventListener( listener);
46}
47
48
49function XEventListener_Impl()
50{
51	this._environment= "JScript";
52	this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener");
53
54	//XEventListener
55	this.disposing= XEventListener_disposing;
56}
57
58function XEventListener_disposing( source)
59{
60 alert("JScript Event Listener \n The document was closed");
61}
62</script>
63
64<script language="VBScript">
65SUB MainVB( id)
66Set objServiceManager= CreateObject("com.sun.star.ServiceManager")
67
68Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
69
70Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")
71
72'Open a new empty writer document
73Dim args()
74Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)
75
76Dim eventListener
77select case id
78  case 0
79    Set eventListener= CreateObject("EventListener.EvtListener")
80  case 1
81    Set eventListener= CreateObject("VBasicEventListener.VBEventListener")
82end select
83
84objDocument.addEventListener eventlistener
85END SUB
86
87</script>
88<p>
89The script on this page creates a new StarOffice document and connects an event listener
90to it. When the document is closed then the XEventListener::disposing method is called on the
91listener object. How the listener is set up depends on the button being clicked.
92</p>
93<p>
94The button will run JScript code that and adds an JScript event listener to the document.
95The listener is also implemented in JScript an is on this page..
96</p>
97<button onclick='Main(0)'>JScript go</Button>
98<p>
99
100The button runs JScript code that creates the ActiveX component EventListener.EvtListener that
101is written in C++ and housed in a dll. Then the event listener is added to the document.
102</p>
103<button onclick='Main( 1)'>JScript go</Button>
104<p>
105The button runs VBScript code that creates the components EventListener.EvtListener and adds it
106to the document.
107</p>
108<button onclick='MainVB(0)'>VBScript</Button>
109<p>
110Runs VBScript code that creates VBasicEventListener.VBEventListener ActiveX component which was
111written with VB
112</p>
113<button onclick='MainVB(1)'>VBScript</Button>
114
115</body>
116</html>
117
118
119