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