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="sheet_XSheetCellCursor" 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
36Sub RunTest()
37
38'*************************************************************************
39' INTERFACE:
40' com.sun.star.sheet.XSheetCellCursor
41'*************************************************************************
42On Error Goto ErrHndl
43    Dim bOK As Boolean
44    Dim nCols As Integer, nRows As Long
45    Dim ResetCols As Integer, ResetRows As Long
46    Dim oRange As Variant
47
48    ResetCols = oObj.getColumns().getCount()
49    ResetRows = oObj.getRows().getCount()
50
51    Test.StartMethod("collapseToCurrentRegion()")
52    bOK = true
53    oObj.collapseToCurrentRegion()
54    nCols = oObj.getColumns().getCount()
55    nRows = oObj.getRows().getCount()
56    bOK = bOK AND (nCols &gt; 0) AND (nRows &gt; 0)
57    Out.Log("collapseToCurrentRegion(): nCols = " &amp; nCols &amp; "(&gt;0) nRows = " &amp; nRows &amp; "(&gt;0)")
58    Test.MethodTested("collapseToCurrentRegion()", bOK)
59
60    'collapseToMergedArea goes into the area. But you must be insite
61    ' of one cell of these area
62    Test.StartMethod("collapseToMergedArea()")
63    bOK = true
64    oObj.collapseToSize(5,6)
65    oRange = oObj.getCellRangeByPosition(0,0,2,2)
66    oRange.merge(true)
67    oObj.gotoStart()
68    oObj.collapseToMergedArea()
69    nCols = oObj.getColumns().getCount()
70    nRows = oObj.getRows().getCount()
71    bOK = bOK AND (nCols = 3) AND (nRows = 3)
72    Out.Log("collapseToMergedArea(): nCols = " &amp; nCols &amp; "(3) nRows = " &amp; nRows &amp; "(3)")
73    Test.MethodTested("collapseToMergedArea()", bOK)
74    oRange.merge(false)
75
76
77    Test.StartMethod("collapseToSize()")
78    bOK = true
79    oObj.collapseToSize(5,6)
80    nCols = oObj.getColumns().getCount()
81    nRows = oObj.getRows().getCount()
82    bOK = bOK AND (nCols = 5 ) AND (nRows = 6)
83    Out.Log("collapseToSize(): nCols = " &amp; nCols &amp; "(5) nRows = " &amp; nRows &amp; "(6)")
84    Test.MethodTested("collapseToSize()", bOK)
85
86    Test.StartMethod("collapseToCurrentArray()")
87    oObj.collapseToSize(5,6)
88    oRange = oObj.getCellRangeByPosition(0,0,2,3)
89    oRange.setArrayFormula("A1:A3")
90    bOK = true
91    oObj.collapseToCurrentArray()
92    nCols = oObj.getColumns().getCount()
93    nRows = oObj.getRows().getCount()
94    bOK = bOK AND (nCols = 3) AND (nRows = 4)
95    Out.Log("collapseToCurrentArray(): nCols = " &amp; nCols &amp; "(3) nRows = " &amp; nRows &amp; "(4)")
96    Test.MethodTested("collapseToCurrentArray()", bOK)
97    oRange.setArrayFormula("")
98
99
100    Test.StartMethod("expandToEntireColumns()")
101    bOK = true
102    oObj.collapseToSize(1,1)
103    oObj.expandToEntireColumns()
104    nCols = oObj.getColumns().getCount()
105    nRows = oObj.getRows().getCount()
106    bOK = bOK AND (nCols = 1) AND (nRows &gt;= 32000)
107    Out.Log("expandToEntireColumns(): nCols = " &amp; nCols &amp; "(1) nRows = " &amp; nRows &amp; "(&gt;=32000)")
108    Test.MethodTested("expandToEntireColumns()", bOK)
109
110    Test.StartMethod("expandToEntireRows()")
111    bOK = true
112    oObj.collapseToSize(1,1)
113    oObj.expandToEntireRows()
114    nCols = oObj.getColumns().getCount()
115    nRows = oObj.getRows().getCount()
116    bOK = bOK AND (nCols &gt;= 256) AND (nRows = 1)
117    Out.Log("expandToEntireRows(): nCols = " &amp; nCols &amp; "(&gt;=256) nRows = " &amp; nRows &amp; "(1)")
118    Test.MethodTested("expandToEntireRows()", bOK)
119
120
121    Out.Log("Reset to old range: " &amp; ResetCols &amp; "," &amp; ResetRows)
122    oObj.collapseToSize(ResetCols, ResetRows)
123
124Exit Sub
125ErrHndl:
126    Test.Exception()
127    bOK = false
128    resume next
129End Sub
130</script:module>
131