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