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' DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9' 10' Copyright 2000, 2010 Oracle and/or its affiliates. 11' 12' OpenOffice.org - a multi-platform office productivity suite 13' 14' This file is part of OpenOffice.org. 15' 16' OpenOffice.org is free software: you can redistribute it and/or modify 17' it under the terms of the GNU Lesser General Public License version 3 18' only, as published by the Free Software Foundation. 19' 20' OpenOffice.org is distributed in the hope that it will be useful, 21' but WITHOUT ANY WARRANTY; without even the implied warranty of 22' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23' GNU Lesser General Public License version 3 for more details 24' (a copy is included in the LICENSE file that accompanied this code). 25' 26' You should have received a copy of the GNU Lesser General Public License 27' version 3 along with OpenOffice.org. If not, see 28' <http://www.openoffice.org/license.html> 29' for a copy of the LGPLv3 License. 30' 31'************************************************************************* 32***** 33'************************************************************************* 34 35 36 37' Be sure that all variables are dimensioned: 38option explicit 39 40'************************************************************************* 41' This Interface/Service test depends on the following GLOBAL variables, 42' which must be specified in the object creation: 43 44' Global oCellToChange As Object 45 46'************************************************************************* 47 48 49 50 51 52Dim nCB1Val as Integer, nCB2Val As Integer 53 54 55Sub RunTest() 56 57'************************************************************************* 58' INTERFACE: 59' com.sun.star.chart.XChartData 60'************************************************************************* 61On Error Goto ErrHndl 62 Dim bOK As Boolean 63 Dim nNumber As Double 64 Dim oListener1 As Object 65 Dim oListener2 As Object 66 67 nCB1Val = 0 68 nCB2Val = 0 69 70 71 Test.StartMethod("getNotANumber()") 72 bOK = true 73 bOK = bOK AND (VarType(oObj.getNotANumber()) = 5) 74 Test.MethodTested("getNotANumber()", bOK) 75 76 Test.StartMethod("isNotANumber()") 77 bOK = true 78 nNumber = oObj.getNotANumber() 79 bOK = bOK AND oObj.IsNotANumber(nNumber) 80 bOK = bOK AND NOT oObj.IsNotANumber(nNumber + 1) 81 Test.MethodTested("isNotANumber()", bOK) 82 83 Out.Log("create listeners...") 84 oListener1 = createUNOListener("CB1_", "com.sun.star.chart.XChartDataChangeEventListener") 85 oListener2 = createUNOListener("CB2_", "com.sun.star.chart.XChartDataChangeEventListener") 86 87 'add listeners to object if initialized 88 if NOT(isNull(oListener1)) then 89 oObj.addChartDataChangeEventListener(oListener1) 90 end if 91 if NOT(isNull(oListener2)) then 92 oObj.addChartDataChangeEventListener(oListener2) 93 end if 94 95 Test.StartMethod("addChartDataChangeEventListener()") 96 bOK = true 97 oCellToChange.Value = 100 98 wait 2000 99 bOK = bOK AND ((nCB1Val = 1) AND (nCB2Val = 1)) 100 Test.MethodTested("addChartDataChangeEventListener()", bOK) 101 102 Test.StartMethod("removeChartDataChangeEventListener()") 103 bOK = true 104 oObj.removeChartDataChangeEventListener(oListener2) 105 oCellToChange.Value = 10 106 wait 2000 107 bOK = bOK AND ((nCB1Val = 2 ) AND (nCB2Val = 1)) 108 Test.MethodTested("removeChartDataChangeEventListener()", bOK) 109 110 Out.Log("Removing last listener.") 111 oObj.removeChartDataChangeEventListener(oListener1) 112 113Exit Sub 114ErrHndl: 115 Test.Exception() 116 bOK = false 117 resume next 118End Sub 119 120' callback routine called chartDataChanged for listener1 121Sub CB1_chartDataChanged 122 Out.Log("CallBack for Listener 1 was called.") 123 nCB1Val = nCB1Val + 1 124End Sub 125 126' callback routine called chartDataChanged for listener2 127Sub CB2_chartDataChanged 128 Out.Log("CallBack for Listener 2 was called.") 129 nCB2Val = nCB2Val + 1 130End Sub 131</script:module> 132