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="sc_ScCellRangeObj" script:language="StarBasic"> 4 5 6'************************************************************************* 7' 8' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31' Be sure that all variables are dimensioned: 32option explicit 33 34 35' REQUIRED VARIABLES for interface/service tests: 36 37'com.sun.star.sheet.XCellSeries 38Global aCellSeries(2) as Integer 39 40 41'Required for com.sun.star.chart.XChartData 42Global oCellToChange As Object 43 44' com.sun.star.sheet.XCellRangeData 45Global newData As Variant 46 47Sub CreateObj() 48 49'************************************************************************* 50' COMPONENT: 51' sc.ScCellRangeObj 52'************************************************************************* 53On Error Goto ErrHndl 54 Dim oSheet, oRange As Object 55 56 oDoc = utils.createDocument("scalc", cObjectName) 57 oSheet = oDoc.Sheets(0) 58 oCellToChange = oSheet.getCellByPosition(0, 0) 59 oRange = oSheet.getCellRangeByPosition(0, 0, 10, 10) 60 oObj = oRange 61 62 aCellSeries(0) = 10 63 aCellSeries(1) = 10 64 65 'Required for XCellRangeData 66 newData = Array(_ 67 Array(2.5, 5.0, 2.5, 5.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0),_ 68 Array(4.0, 9.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 2.5, 5.0),_ 69 Array(2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0, 2.5, 5.0),_ 70 Array(4.0, 9.0, 2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0),_ 71 Array(2.5, 5.0, 2.5, 5.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0),_ 72 Array(4.0, 9.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 2.5, 5.0),_ 73 Array(2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0, 2.5, 5.0),_ 74 Array(4.0, 9.0, 2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0),_ 75 Array(2.5, 5.0, 2.5, 5.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0),_ 76 Array(4.0, 9.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 2.5, 5.0),_ 77 Array(2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0, 2.5, 5.0)) 78 79Exit Sub 80ErrHndl: 81 Test.Exception() 82End Sub 83 84Function modifyDescriptor(descr As Variant) As Variant 85On Error Goto ErrHndl 86 Dim i As Integer, n as Integer 87 Dim oCell As Object 88 Dim vFields(0) as new com.sun.star.table.TableSortField 89 90 for i = 0 to aCellSeries(0) - 1 91 oCell = oObj.getCellByPosition(0, i) 92 oCell.String = "" + (aCellSeries(0) - i) 93 oCell.setFormula(aCellSeries(0) - i) 94 next i 95 'ShowNameValuePair(descr) 96 vFields(0).IsCaseSensitive = false 97 vFields(0).IsAscending = true 98 vFields(0).FieldType = com.sun.star.table.TableSortFieldType.ALPHANUMERIC 99 for i = 0 to ubound(descr) 100 if descr(i).Name = "IsSortColumns" then descr(i).Value = false 101 if descr(i).Name = "SortFields" then descr(i).Value = vFields() 102 next i 103 104 modifyDescriptor() = descr 105Exit Function 106ErrHndl: 107 Out.Log("Exception in ScCellRangeObj.modifyDescriptor() :") 108 Test.Exception() 109end Function 110 111Function checkSort() As Boolean 112On Error Goto ErrHndl 113 Dim i As Integer, oCell As Object 114 Dim bOK As Boolean 115 116 bOK = true 117 for i = 0 to aCellSeries(0) - 1 118 oCell = oObj.getCellByPosition(0,i) 119 bOK = bOK AND oCell.String = "" + (i + 1) 120 out.dbg(oCell.String + ":" + (i+1)) 121 next i 122 123 checkSort() = bOK 124Exit Function 125ErrHndl: 126 Out.Log("Exception in ScCellRangeObj.checkSort() :") 127 Test.Exception() 128end Function 129 130</script:module> 131