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="text_XTextTableCursor" 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
32
33Sub RunTest()
34
35'*************************************************************************
36' INTERFACE:
37' com.sun.star.text.XTextTableCursor
38'*************************************************************************
39On Error Goto ErrHndl
40    Dim bOK As Boolean
41
42    Test.StartMethod("gotoStart()")
43    bOK = true
44    oObj.gotoStart(false)
45    bOK = bOK AND Expected("A1")
46    Test.MethodTested("gotoStart()", bOK)
47
48    Test.StartMethod("getRangeName()")
49    bOK = true
50    cName = oObj.getRangeName()
51    bOK = bOK AND NOT isNULL(cName)
52    Test.MethodTested("getRangeName()", bOK)
53
54    Test.StartMethod("gotoCellByName()")
55    bOK = true
56    bOK = bOK AND oObj.gotoCellByName("B2", true)
57    bOK = bOK AND Expected("A1:B2")
58    Test.MethodTested("gotoCellByName()", bOK)
59
60    Test.StartMethod("goLeft()")
61    bOK = true
62    bOK = bOK AND oObj.goLeft(1, false)
63    bOK = bOK AND Expected("A2")
64    Test.MethodTested("goLeft()", bOK)
65
66    Test.StartMethod("goRight()")
67    bOK = true
68    bOK = bOK AND oObj.goRight(3, true)
69    bOK = bOK AND Expected("A2:D2")
70    Test.MethodTested("goRight()", bOK)
71
72    Test.StartMethod("goUp()")
73    bOK = true
74    bOK = bOK AND oObj.goUp(1, true)
75    bOK = bOK AND Expected("A2:D1")
76    Test.MethodTested("goUp()", bOK)
77
78    Test.StartMethod("goDown()")
79    bOK = true
80    bOK = bOK AND oObj.goDown(3, false)
81    bOK = bOK AND Expected("D4")
82    Test.MethodTested("goDown()", bOK)
83
84    Test.StartMethod("gotoEnd()")
85    bOK = true
86    oObj.gotoEnd(true)
87    bOK = bOK AND Expected("D4:E5")
88    Test.MethodTested("gotoEnd()", bOK)
89
90    Test.StartMethod("mergeRange()")
91    bOK = true
92    oObj.gotoStart(false)
93    oObj.gotoEnd(true)
94    bOK = bOK AND oObj.mergeRange()
95    bOK = bOK AND Expected("A1")
96    Test.MethodTested("mergeRange()", bOK)
97
98    Test.StartMethod("splitRange()")
99    bOK = true
100    bOK = bOK AND oObj.splitRange(3, true)
101    oObj.gotoEnd(true)
102    bOK = bOK AND Expected("A1.1.1:A1.1.4")
103	oObj.gotoStart(false)
104    bOK = bOK AND oObj.splitRange(2, false)
105    oObj.goRight(2, true)
106    bOK = bOK AND Expected("A1.1.1:A1.3.1")
107    Test.MethodTested("splitRange()", bOK)
108
109Exit Sub
110ErrHndl:
111    Test.Exception()
112    bOK = false
113    resume next
114End Sub
115Function Expected(cName As String) As Boolean
116	Dim bOK As Boolean
117	Dim cRangeName As String
118	Dim cAltName As String
119	Dim dPos As Integer
120
121	cRangeName = oObj.getRangeName()
122
123	dPos = inStr(1, cName, ":")
124	if (dPos &gt; 0) then
125		cAltName = Mid(cName, dPos + 1) &amp; ":" &amp; Left(cName, dPos - 1)
126		bOK = (cRangeName = cName) OR (cAltName = cRangeName)
127	else
128		bOK = cRangeName = cName
129	end if
130
131	if (NOT bOK) then
132		Out.Log("Expected RangeName is '" &amp; cName &amp; "' and actual is '" &amp; cRangeName &amp; "'")
133	end if
134
135	Expected() = bOK
136End Function
137</script:module>
138