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_XChartDataArray" 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 nTableH As Integer
44'      Global nTableW As Integer
45
46'*************************************************************************
47
48
49
50
51
52Sub RunTest()
53
54'*************************************************************************
55' INTERFACE:
56' com.sun.star.chart.XChartDataArray
57'*************************************************************************
58On Error Goto ErrHndl
59
60    Dim bOK As Boolean
61    Dim i As Integer, j As Integer
62    Dim objRowDsc As Variant, objColDsc As Variant
63    Dim objEl As Variant, newEl As Variant
64    Dim chData As Variant
65
66    Out.Log("Object is '" + cObjectName + "'")
67    if (cObjectName = "sw.SwXTextTable") then
68        Out.Log("Object is 'SwXTextTable'. First, remove labels.")
69        oObj.setPropertyValue("ChartRowAsLabel", false)
70        oObj.setPropertyValue("ChartColumnAsLabel", false)
71    end if
72
73    Test.StartMethod("getData()")
74    bOK = true
75
76    Dim oData As Object
77    oData = oObj.getData()
78    bOK = bOK AND NOT isNULL(oData)
79    Test.MethodTested("getData()", bOK)
80
81    Test.StartMethod("setData()")
82    bOK = true
83
84    Dim newData(nTableH - 1) As Variant
85    Dim a(nTableW - 1) As Double
86
87    for i = 0 to nTableH - 1
88        ReDim a(nTableW - 1) As Double
89        for j = 0 to nTableW - 1
90            a(j) = ((nTableW * 4) / (i + 2) + j * 2) + 16
91        next j
92        newData(i) = a()
93    next i
94
95    oObj.setData(newData())
96    chData = oObj.getData()
97
98    bOK = bOK AND ubound(oObj.getRowDescriptions()) = nTableH - 1
99    bOK = bOK AND ubound(oObj.getColumnDescriptions()) = nTableW - 1
100
101    for i = 0 to nTableH - 1
102        objEl = chData(i)
103        newEl = newData(i)
104        for j = 0 to nTableW - 1
105            bOK = bOK AND objEl(j) = newEl(j)
106        next j
107    next i
108
109    Test.MethodTested("setData()", bOK)
110
111    if (cObjectName = "sw.SwXTextTable") then
112        Out.Log("Object is 'SwXTextTable'. Initialize labels.")
113        oObj.setPropertyValue("ChartRowAsLabel", true)
114        oObj.setPropertyValue("ChartColumnAsLabel", true)
115    end if
116
117    Test.StartMethod("getRowDescriptions()")
118    bOK = true
119
120    Dim oRowDsc() As String
121    oRowDsc = oObj.getRowDescriptions()
122    bOK = bOK AND NOT isNULL(oRowDsc)
123    Test.MethodTested("getRowDescriptions()", bOK)
124
125    Test.StartMethod("setRowDescriptions()")
126    bOK = true
127
128    Dim newRowDsc(nTableH - 2) As String
129    for i = 0 to nTableH - 2 ' -1 for 0-index and -1 for columns labels
130        newRowDsc(i) = "RowDsc " + i
131    next i
132
133    oObj.setRowDescriptions(newRowDsc())
134
135    objRowDsc = oObj.getRowDescriptions()
136
137    for i = 0 to nTableH - 2
138        bOK = bOK AND newRowDsc(i) = objRowDsc(i)
139    next i
140
141    Test.MethodTested("setRowDescriptions()", bOK)
142
143    Test.StartMethod("getColumnDescriptions()")
144    bOK = true
145    bOK = bOK AND NOT isNULL(oObj.getColumnDescriptions())
146    Test.MethodTested("getColumnDescriptions()", bOK)
147
148    Test.StartMethod("setColumnDescriptions()")
149    bOK = true
150
151    Dim newColDsc(nTableW - 2) As String
152    for i = 0 to nTableW - 2
153        newColDsc(i) = "ColDsc " + i
154    next i
155
156    oObj.setColumnDescriptions(newColDsc())
157
158    objColDsc = oObj.getColumnDescriptions()
159
160    for i = 0 to nTableW - 2
161        bOK = bOK AND newColDsc(i) = objColDsc(i)
162    next i
163
164    if (cObjectName = "sw.SwXTextTable") then
165        Out.Log("Object is 'SwXTextTable'. Remove labels finally.")
166        oObj.setPropertyValue("ChartRowAsLabel", false)
167        oObj.setPropertyValue("ChartColumnAsLabel", false)
168    end if
169
170    Test.MethodTested("setColumnDescriptions()", bOK)
171
172
173Exit Sub
174ErrHndl:
175    Test.Exception()
176    bOK = false
177    resume next
178End Sub
179</script:module>
180