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_ScTableSheetObj" 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' Required for com.sun.star.sheet.Spreadsheet 38Global sStyleName As String 39 40' Required for com.sun.star.chart.XChartData 41Global oCellToChange As Object 42 43 44Sub CreateObj() 45 46'************************************************************************* 47' COMPONENT: 48' sc.ScTableSheetObj 49'************************************************************************* 50On Error Goto ErrHndl 51 Dim oStyleFamilies As Variant 52 Dim oNewPageStyle As Object 53 Dim oStyleFamily As Object 54 55 oDoc = utils.createDocument("scalc", cObjectName) 56 oObj = oDoc.sheets(0) 57 58 sStyleName = "MyStyle" 59 ' Adding new page style for Spreadsheet service testing 60 oStyleFamilies = oDoc.StyleFamilies 61 oStyleFamily = oStyleFamilies.getByName("PageStyles") 62 oNewPageStyle = oDoc.createInstance("com.sun.star.style.PageStyle") 63 oStyleFamily.insertByName(sStyleName, oNewPageStyle) 64 65 oCellToChange = oObj.getCellByPosition(2, 2) 66 67Exit Sub 68ErrHndl: 69 Test.Exception() 70End Sub 71Function modifyDescriptor(descr As Variant) As Variant 72On Error Goto ErrHndl 73 Dim i As Integer, n as Integer 74 Dim oCell As Object 75 Dim vFields(0) as new com.sun.star.table.TableSortField 76 77 for i = 0 to 10 - 1 78 oCell = oObj.getCellByPosition(0, i) 79 oCell.String = "" + (10 - i) 80 oCell.setFormula(10 - i) 81 next i 82 'ShowNameValuePair(descr) 83 vFields(0).IsCaseSensitive = false 84 vFields(0).IsAscending = true 85 vFields(0).FieldType = com.sun.star.table.TableSortFieldType.ALPHANUMERIC 86 for i = 0 to ubound(descr) 87 if descr(i).Name = "IsSortColumns" then descr(i).Value = false 88 if descr(i).Name = "SortFields" then descr(i).Value = vFields() 89 next i 90 91 modifyDescriptor() = descr 92Exit Function 93ErrHndl: 94 Out.Log("Exception in ScTableSheetObj.modifyDescriptor() :") 95 Test.Exception() 96end Function 97 98Function checkSort() As Boolean 99On Error Goto ErrHndl 100 Dim i As Integer, oCell As Object 101 Dim bOK As Boolean 102 103 bOK = true 104 for i = 0 to 10 - 1 105 oCell = oObj.getCellByPosition(0,i) 106 bOK = bOK AND oCell.String = "" + (i + 1) 107 out.dbg(oCell.String + ":" + (i+1)) 108 next i 109 110 checkSort() = bOK 111Exit Function 112ErrHndl: 113 Out.Log("Exception in ScTableSheetObj.checkSort() :") 114 Test.Exception() 115end Function 116 117 118</script:module> 119