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