blob: 35e884b533e569728372753ccf227ce2b6f45c8f [file] [log] [blame]
<!--***********************************************************
*
* 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
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
***********************************************************-->
<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>