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