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' Be sure that all variables are dimensioned:
37option explicit
38
39'*************************************************************************
40' This Interface/Service test depends on the following GLOBAL variables,
41' which must be specified in the object creation:
42
43'     Global oCellToChange As Object
44
45'*************************************************************************
46
47
48
49
50
51Dim nCB1Val as Integer, nCB2Val As Integer
52
53
54Sub RunTest()
55
56'*************************************************************************
57' INTERFACE:
58' com.sun.star.chart.XChartData
59'*************************************************************************
60On Error Goto ErrHndl
61    Dim bOK As Boolean
62    Dim nNumber As Double
63    Dim oListener1 As Object
64    Dim oListener2 As Object
65
66    nCB1Val = 0
67    nCB2Val = 0
68
69
70    Test.StartMethod("getNotANumber()")
71    bOK = true
72    bOK = bOK AND (VarType(oObj.getNotANumber()) = 5)
73    Test.MethodTested("getNotANumber()", bOK)
74
75    Test.StartMethod("isNotANumber()")
76    bOK = true
77    nNumber = oObj.getNotANumber()
78    bOK = bOK AND oObj.IsNotANumber(nNumber)
79    bOK = bOK AND NOT oObj.IsNotANumber(nNumber + 1)
80    Test.MethodTested("isNotANumber()", bOK)
81
82    Out.Log("create listeners...")
83    oListener1 = createUNOListener("CB1_", "com.sun.star.chart.XChartDataChangeEventListener")
84    oListener2 = createUNOListener("CB2_", "com.sun.star.chart.XChartDataChangeEventListener")
85
86    'add listeners to object if initialized
87    if NOT(isNull(oListener1)) then
88        oObj.addChartDataChangeEventListener(oListener1)
89    end if
90    if NOT(isNull(oListener2)) then
91        oObj.addChartDataChangeEventListener(oListener2)
92    end if
93
94    Test.StartMethod("addChartDataChangeEventListener()")
95    bOK = true
96    oCellToChange.Value = 100
97    wait 2000
98    bOK = bOK AND ((nCB1Val = 1) AND (nCB2Val = 1))
99    Test.MethodTested("addChartDataChangeEventListener()", bOK)
100
101    Test.StartMethod("removeChartDataChangeEventListener()")
102    bOK = true
103    oObj.removeChartDataChangeEventListener(oListener2)
104    oCellToChange.Value = 10
105    wait 2000
106    bOK = bOK AND ((nCB1Val = 2 ) AND (nCB2Val = 1))
107    Test.MethodTested("removeChartDataChangeEventListener()", bOK)
108
109    Out.Log("Removing last listener.")
110    oObj.removeChartDataChangeEventListener(oListener1)
111
112Exit Sub
113ErrHndl:
114    Test.Exception()
115    bOK = false
116    resume next
117End Sub
118
119' callback routine called chartDataChanged for listener1
120Sub CB1_chartDataChanged
121    Out.Log("CallBack for Listener 1 was called.")
122    nCB1Val = nCB1Val + 1
123End Sub
124
125' callback routine called chartDataChanged for listener2
126Sub CB2_chartDataChanged
127    Out.Log("CallBack for Listener 2 was called.")
128    nCB2Val = nCB2Val + 1
129End Sub
130</script:module>
131