summaryrefslogtreecommitdiff
path: root/extensions/test/ole/EventListenerSample/events.htm
blob: 75f7bc1d9b07c543c514961acd1e02f3ba7c6e5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!--
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Developer Studio">
<META HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<TITLE>Document Title</TITLE>
</HEAD>
<BODY id=theBody>

<script language="JScript">
function Main( id)
{
var  objServiceManager= new ActiveXObject("com.sun.star.ServiceManager");

var objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop");

var args= new Array();

var objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args);

var listener;
if( id == 0)
  listener= new XEventListener_Impl();
else if(id == 1)
  listener= new ActiveXObject("EventListener.EvtListener");
objDocument.addEventListener( listener);
}


function XEventListener_Impl()
{
	this._environment= "JScript";
	this._implementedInterfaces= new Array( "com.sun.star.lang.XEventListener");

	//XEventListener
	this.disposing= XEventListener_disposing;
}	

function XEventListener_disposing( source)
{
 alert("JScript Event Listener \n The document was closed");
}
</script>

<script language="VBScript">
SUB MainVB( id)
Set objServiceManager= CreateObject("com.sun.star.ServiceManager")

Set objCoreReflection= objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")

Set objDesktop= objServiceManager.createInstance("com.sun.star.frame.Desktop")

'Open a new empty writer document
Dim args()
Set objDocument= objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args)

Dim eventListener
select case id
  case 0
    Set eventListener= CreateObject("EventListener.EvtListener")
  case 1
    Set eventListener= CreateObject("VBasicEventListener.VBEventListener")
end select

objDocument.addEventListener eventlistener
END SUB

</script>
<p>
The script on this page creates a new StarOffice document and connects an event listener
to it. When the document is closed then the XEventListener::disposing method is called on the
listener object. How the listener is set up depends on the button being clicked.
</p>
<p>
The button will run JScript code that and adds an JScript event listener to the document.
The listener is also implemented in JScript an is on this page..
</p>
<button onclick='Main(0)'>JScript go</Button>
<p>

The button runs JScript code that creates the ActiveX component EventListener.EvtListener that
is written in C++ and housed in a dll. Then the event listener is added to the document.
</p>
<button onclick='Main( 1)'>JScript go</Button>
<p>
The button runs VBScript code that creates the components EventListener.EvtListener and adds it
to the document.
</p>
<button onclick='MainVB(0)'>VBScript</Button>
<p>
Runs VBScript code that creates VBasicEventListener.VBEventListener ActiveX component which was
written with VB
</p>
<button onclick='MainVB(1)'>VBScript</Button>

</body>
</html>