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