1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?> 2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="chart_XChartData" script:language="StarBasic"> 4cdf0e10cSrcweir 5cdf0e10cSrcweir 6cdf0e10cSrcweir'************************************************************************* 7cdf0e10cSrcweir' 8*3709053cSAndrew Rist' Licensed to the Apache Software Foundation (ASF) under one 9*3709053cSAndrew Rist' or more contributor license agreements. See the NOTICE file 10*3709053cSAndrew Rist' distributed with this work for additional information 11*3709053cSAndrew Rist' regarding copyright ownership. The ASF licenses this file 12*3709053cSAndrew Rist' to you under the Apache License, Version 2.0 (the 13*3709053cSAndrew Rist' "License"); you may not use this file except in compliance 14*3709053cSAndrew Rist' with the License. You may obtain a copy of the License at 15*3709053cSAndrew Rist' 16*3709053cSAndrew Rist' http://www.apache.org/licenses/LICENSE-2.0 17*3709053cSAndrew Rist' 18*3709053cSAndrew Rist' Unless required by applicable law or agreed to in writing, 19*3709053cSAndrew Rist' software distributed under the License is distributed on an 20*3709053cSAndrew Rist' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21*3709053cSAndrew Rist' KIND, either express or implied. See the License for the 22*3709053cSAndrew Rist' specific language governing permissions and limitations 23*3709053cSAndrew Rist' under the License. 24cdf0e10cSrcweir' 25cdf0e10cSrcweir'************************************************************************* 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir 29*3709053cSAndrew Rist 30*3709053cSAndrew Rist 31cdf0e10cSrcweir' Be sure that all variables are dimensioned: 32cdf0e10cSrcweiroption explicit 33cdf0e10cSrcweir 34cdf0e10cSrcweir'************************************************************************* 35cdf0e10cSrcweir' This Interface/Service test depends on the following GLOBAL variables, 36cdf0e10cSrcweir' which must be specified in the object creation: 37cdf0e10cSrcweir 38cdf0e10cSrcweir' Global oCellToChange As Object 39cdf0e10cSrcweir 40cdf0e10cSrcweir'************************************************************************* 41cdf0e10cSrcweir 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir 46cdf0e10cSrcweirDim nCB1Val as Integer, nCB2Val As Integer 47cdf0e10cSrcweir 48cdf0e10cSrcweir 49cdf0e10cSrcweirSub RunTest() 50cdf0e10cSrcweir 51cdf0e10cSrcweir'************************************************************************* 52cdf0e10cSrcweir' INTERFACE: 53cdf0e10cSrcweir' com.sun.star.chart.XChartData 54cdf0e10cSrcweir'************************************************************************* 55cdf0e10cSrcweirOn Error Goto ErrHndl 56cdf0e10cSrcweir Dim bOK As Boolean 57cdf0e10cSrcweir Dim nNumber As Double 58cdf0e10cSrcweir Dim oListener1 As Object 59cdf0e10cSrcweir Dim oListener2 As Object 60cdf0e10cSrcweir 61cdf0e10cSrcweir nCB1Val = 0 62cdf0e10cSrcweir nCB2Val = 0 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir Test.StartMethod("getNotANumber()") 66cdf0e10cSrcweir bOK = true 67cdf0e10cSrcweir bOK = bOK AND (VarType(oObj.getNotANumber()) = 5) 68cdf0e10cSrcweir Test.MethodTested("getNotANumber()", bOK) 69cdf0e10cSrcweir 70cdf0e10cSrcweir Test.StartMethod("isNotANumber()") 71cdf0e10cSrcweir bOK = true 72cdf0e10cSrcweir nNumber = oObj.getNotANumber() 73cdf0e10cSrcweir bOK = bOK AND oObj.IsNotANumber(nNumber) 74cdf0e10cSrcweir bOK = bOK AND NOT oObj.IsNotANumber(nNumber + 1) 75cdf0e10cSrcweir Test.MethodTested("isNotANumber()", bOK) 76cdf0e10cSrcweir 77cdf0e10cSrcweir Out.Log("create listeners...") 78cdf0e10cSrcweir oListener1 = createUNOListener("CB1_", "com.sun.star.chart.XChartDataChangeEventListener") 79cdf0e10cSrcweir oListener2 = createUNOListener("CB2_", "com.sun.star.chart.XChartDataChangeEventListener") 80cdf0e10cSrcweir 81cdf0e10cSrcweir 'add listeners to object if initialized 82cdf0e10cSrcweir if NOT(isNull(oListener1)) then 83cdf0e10cSrcweir oObj.addChartDataChangeEventListener(oListener1) 84cdf0e10cSrcweir end if 85cdf0e10cSrcweir if NOT(isNull(oListener2)) then 86cdf0e10cSrcweir oObj.addChartDataChangeEventListener(oListener2) 87cdf0e10cSrcweir end if 88cdf0e10cSrcweir 89cdf0e10cSrcweir Test.StartMethod("addChartDataChangeEventListener()") 90cdf0e10cSrcweir bOK = true 91cdf0e10cSrcweir oCellToChange.Value = 100 92cdf0e10cSrcweir wait 2000 93cdf0e10cSrcweir bOK = bOK AND ((nCB1Val = 1) AND (nCB2Val = 1)) 94cdf0e10cSrcweir Test.MethodTested("addChartDataChangeEventListener()", bOK) 95cdf0e10cSrcweir 96cdf0e10cSrcweir Test.StartMethod("removeChartDataChangeEventListener()") 97cdf0e10cSrcweir bOK = true 98cdf0e10cSrcweir oObj.removeChartDataChangeEventListener(oListener2) 99cdf0e10cSrcweir oCellToChange.Value = 10 100cdf0e10cSrcweir wait 2000 101cdf0e10cSrcweir bOK = bOK AND ((nCB1Val = 2 ) AND (nCB2Val = 1)) 102cdf0e10cSrcweir Test.MethodTested("removeChartDataChangeEventListener()", bOK) 103cdf0e10cSrcweir 104cdf0e10cSrcweir Out.Log("Removing last listener.") 105cdf0e10cSrcweir oObj.removeChartDataChangeEventListener(oListener1) 106cdf0e10cSrcweir 107cdf0e10cSrcweirExit Sub 108cdf0e10cSrcweirErrHndl: 109cdf0e10cSrcweir Test.Exception() 110cdf0e10cSrcweir bOK = false 111cdf0e10cSrcweir resume next 112cdf0e10cSrcweirEnd Sub 113cdf0e10cSrcweir 114cdf0e10cSrcweir' callback routine called chartDataChanged for listener1 115cdf0e10cSrcweirSub CB1_chartDataChanged 116cdf0e10cSrcweir Out.Log("CallBack for Listener 1 was called.") 117cdf0e10cSrcweir nCB1Val = nCB1Val + 1 118cdf0e10cSrcweirEnd Sub 119cdf0e10cSrcweir 120cdf0e10cSrcweir' callback routine called chartDataChanged for listener2 121cdf0e10cSrcweirSub CB2_chartDataChanged 122cdf0e10cSrcweir Out.Log("CallBack for Listener 2 was called.") 123cdf0e10cSrcweir nCB2Val = nCB2Val + 1 124cdf0e10cSrcweirEnd Sub 125cdf0e10cSrcweir</script:module> 126