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