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