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' 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' REQUIRED VARIABLES for interface/service tests: 41 42'com.sun.star.sheet.XCellSeries 43Global aCellSeries(2) as Integer 44 45 46'Required for com.sun.star.chart.XChartData 47Global oCellToChange As Object 48 49' com.sun.star.sheet.XCellRangeData 50Global newData As Variant 51 52Sub CreateObj() 53 54'************************************************************************* 55' COMPONENT: 56' sc.ScCellRangeObj 57'************************************************************************* 58On Error Goto ErrHndl 59 Dim oSheet, oRange As Object 60 61 oDoc = utils.createDocument("scalc", cObjectName) 62 oSheet = oDoc.Sheets(0) 63 oCellToChange = oSheet.getCellByPosition(0, 0) 64 oRange = oSheet.getCellRangeByPosition(0, 0, 10, 10) 65 oObj = oRange 66 67 aCellSeries(0) = 10 68 aCellSeries(1) = 10 69 70 'Required for XCellRangeData 71 newData = Array(_ 72 Array(2.5, 5.0, 2.5, 5.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0),_ 73 Array(4.0, 9.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 2.5, 5.0),_ 74 Array(2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0, 2.5, 5.0),_ 75 Array(4.0, 9.0, 2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0),_ 76 Array(2.5, 5.0, 2.5, 5.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0),_ 77 Array(4.0, 9.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 2.5, 5.0),_ 78 Array(2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0, 2.5, 5.0),_ 79 Array(4.0, 9.0, 2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0),_ 80 Array(2.5, 5.0, 2.5, 5.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0),_ 81 Array(4.0, 9.0, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 2.5, 5.0),_ 82 Array(2.5, 3.5, 8.7, 9.9, 0.3, 1.2, 3, 0, 5.0, 2.5, 5.0)) 83 84Exit Sub 85ErrHndl: 86 Test.Exception() 87End Sub 88 89Function modifyDescriptor(descr As Variant) As Variant 90On Error Goto ErrHndl 91 Dim i As Integer, n as Integer 92 Dim oCell As Object 93 Dim vFields(0) as new com.sun.star.table.TableSortField 94 95 for i = 0 to aCellSeries(0) - 1 96 oCell = oObj.getCellByPosition(0, i) 97 oCell.String = "" + (aCellSeries(0) - i) 98 oCell.setFormula(aCellSeries(0) - i) 99 next i 100 'ShowNameValuePair(descr) 101 vFields(0).IsCaseSensitive = false 102 vFields(0).IsAscending = true 103 vFields(0).FieldType = com.sun.star.table.TableSortFieldType.ALPHANUMERIC 104 for i = 0 to ubound(descr) 105 if descr(i).Name = "IsSortColumns" then descr(i).Value = false 106 if descr(i).Name = "SortFields" then descr(i).Value = vFields() 107 next i 108 109 modifyDescriptor() = descr 110Exit Function 111ErrHndl: 112 Out.Log("Exception in ScCellRangeObj.modifyDescriptor() :") 113 Test.Exception() 114end Function 115 116Function checkSort() As Boolean 117On Error Goto ErrHndl 118 Dim i As Integer, oCell As Object 119 Dim bOK As Boolean 120 121 bOK = true 122 for i = 0 to aCellSeries(0) - 1 123 oCell = oObj.getCellByPosition(0,i) 124 bOK = bOK AND oCell.String = "" + (i + 1) 125 out.dbg(oCell.String + ":" + (i+1)) 126 next i 127 128 checkSort() = bOK 129Exit Function 130ErrHndl: 131 Out.Log("Exception in ScCellRangeObj.checkSort() :") 132 Test.Exception() 133end Function 134 135</script:module> 136