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_XWordCursor" 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
37
38
39Sub RunTest()
40
41'*************************************************************************
42' INTERFACE:
43' com.sun.star.text.XWordCursor
44'*************************************************************************
45On Error Goto ErrHndl
46    Dim bOK As Boolean
47
48    oObj.Text.string = "1Word1: 2Word2, 3Word3."
49    oObj.gotoStart(false)
50
51    Test.StartMethod("gotoStartOfWord()")
52    bOK = true
53    oObj.gotoStartOfWord(false)
54    oObj.String = "1"
55    bOK = bOK AND inStr(1, oObj.Text.String, "11W") &lt;&gt; 0
56    Test.MethodTested("gotoStartOfWord()", bOK)
57
58    Test.StartMethod("gotoEndOfWord()")
59    bOK = true
60    oObj.gotoEndOfWord(false)
61    oObj.String = "2"
62    bOK = bOK AND inStr(1, oObj.Text.String, "d12") &lt;&gt; 0
63    Test.MethodTested("gotoEndOfWord()", bOK)
64
65    Test.StartMethod("gotoNextWord()")
66    bOK = true
67    oObj.gotoNextWord(false)
68    oObj.gotoNextWord(false)
69    oObj.gotoEndOfWord(false)
70    oObj.String = "3"
71    bOK = bOK AND inStr(1, oObj.Text.String, "d33") &lt;&gt; 0
72    Test.MethodTested("gotoNextWord()", bOK)
73
74    Test.StartMethod("gotoPreviousWord()")
75    bOK = true
76    oObj.gotoPreviousWord(false)
77    oObj.gotoStartOfWord(false)
78    oObj.String = "4"
79    bOK = bOK AND inStr(1, oObj.Text.String, "42W") &lt;&gt; 0
80    Test.MethodTested("gotoPreviousWord()", bOK)
81
82    Test.StartMethod("isStartOfWord()")
83    bOK = true
84    oObj.gotoStartOfWord(false)
85    bOK = bOK AND oObj.isStartOfWord()
86    Test.MethodTested("isStartOfWord()", bOK)
87
88    Test.StartMethod("isEndOfWord()")
89    bOK = true
90    oObj.gotoEndOfWord(false)
91    bOK = bOK AND oObj.isEndOfWord()
92    Test.MethodTested("isEndOfWord()", bOK)
93
94Exit Sub
95ErrHndl:
96    Test.Exception()
97    bOK = false
98    resume next
99End Sub
100</script:module>
101