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_XTextCursor" 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' This Interface/Service test depends on the following GLOBAL variables,
33' which must be specified in the object creation:
34
35'     - Global oCursor As Object
36' One more cursor
37
38'*************************************************************************
39
40
41
42
43
44Sub RunTest()
45
46'*************************************************************************
47' INTERFACE:
48' com.sun.star.text.XTextCursor
49'*************************************************************************
50On Error Goto ErrHndl
51    Dim bOK As Boolean
52    Dim oRange As Object
53
54    oObj.Text.String = "abcdefg"
55
56    Test.StartMethod("gotoEnd()")
57    bOK = true
58    oObj.gotoEnd(false)
59    oObj.String = "1"
60    bOK = bOK AND inStr(1, oObj.Text.String, "g1")
61    Test.MethodTested("gotoEnd()", bOK)
62
63    Test.StartMethod("gotoStart()")
64    bOK = true
65    oObj.gotoStart(false)
66    oObj.String = "2"
67    bOK = bOK AND inStr(1, oObj.Text.String, "2a")
68    Test.MethodTested("gotoStart()", bOK)
69
70    Test.StartMethod("goRight()")
71    bOK = true
72    oObj.gotoStart(false)
73    oObj.goRight(2, false)
74    oObj.String = "3"
75    bOK = bOK AND inStr(1, oObj.Text.String, "2a3")
76    Test.MethodTested("goRight()", bOK)
77
78    Test.StartMethod("goLeft()")
79    bOK = true
80    oObj.gotoEnd(false)
81    oObj.goLeft(2, false)
82    oObj.String = "4"
83    bOK = bOK AND inStr(1, oObj.Text.String, "4g1")
84    Test.MethodTested("goLeft()", bOK)
85
86    Test.StartMethod("gotoRange()")
87    bOK = true
88    oCursor.gotoEnd(false)
89    oCursor.goLeft(1, false)
90    oCursor.goLeft(2, true)
91    oObj.gotoStart(false)
92    oObj.gotoRange(oCursor, false)
93    bOK = bOK AND oObj.String = "4g"
94    Test.MethodTested("gotoRange()", bOK)
95
96    Test.StartMethod("collapseToStart()")
97    bOK = true
98    cTp = oObj.String
99    oObj.collapseToStart()
100    oObj.String = "5"
101    bOK = bOK AND inStr(1, oObj.Text.String, "5" &amp; cTp)
102    Test.MethodTested("collapseToStart()", bOK)
103
104    Test.StartMethod("collapseToEnd()")
105    bOK = true
106    oObj.gotoEnd(false)
107    oObj.goLeft(3, true)
108    cTp = oObj.String
109    oObj.collapseToEnd()
110    oObj.String = "6"
111    bOK = bOK AND inStr(1, oObj.Text.String, cTp &amp; "6")
112    Test.MethodTested("collapseToEnd()", bOK)
113
114    Test.StartMethod("isCollapsed()")
115    bOK = true
116    oObj.collapseToStart()
117    bOK = bOK AND oObj.isCollapsed()
118    oObj.gotoEnd(false)
119    oObj.goLeft(3, true)
120    bOK = bOK AND NOT oObj.isCollapsed()
121    Test.MethodTested("isCollapsed()", bOK)
122
123Exit Sub
124ErrHndl:
125    Test.Exception()
126    bOK = false
127    resume next
128End Sub
129</script:module>
130