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_XSentenceCursor" 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.text.XSentenceCursor 41'************************************************************************* 42On Error Goto ErrHndl 43 Dim bOK As Boolean 44 45 oObj.Text.String = "Sentence two. Sentence three." 46 47 oObj.gotoEnd(false) 48 49 Test.StartMethod("gotoStartOfSentence()") 50 bOK = true 51 oObj.gotoStartOfSentence(false) 52 oObj.String = "1" 53 Out.Log("Current text: '" + oObj.Text.String + "'") 54 bOK = bOK AND inStr(1, oObj.Text.String, "1Sentence three.") <> 0 55 Test.MethodTested("gotoStartOfSentence()", bOK) 56 57 Test.StartMethod("isStartOfSentence()") 58 Test.StartMethod("isEndOfSentence()") 59 bOK = true 60 oObj.gotoStartOfSentence(false) 61 bOK = bOK AND oObj.isStartOfSentence() 62 bOK = bOK AND NOT oObj.isEndOfSentence() 63 oObj.gotoEndOfSentence(false) 64 bOK = bOK AND NOT oObj.isStartOfSentence() 65 bOK = bOK AND oObj.isEndOfSentence() 66 Test.MethodTested("isStartOfSentence()", bOK) 67 Test.MethodTested("isEndOfSentence()", bOK) 68 69 70 Test.StartMethod("gotoEndOfSentence()") 71 bOK = true 72 oObj.gotoEndOfSentence(false) 73 oObj.String = "2" 74 Out.Log("Current text: '" + oObj.Text.String + "'") 75 bOK = bOK AND inStr(1, oObj.Text.String, "three.2") <> 0 76 Test.MethodTested("gotoEndOfSentence()", bOK) 77 78 Test.StartMethod("gotoPreviousSentence()") 79 bOK = true 80 oObj.gotoPreviousSentence(false) 81 oObj.String = "3" 82 Out.Log("Current text: '" + oObj.Text.String + "'") 83 bOK = bOK AND inStr(1, oObj.Text.String, "3Sentence two.") <> 0 84 Test.MethodTested("gotoPreviousSentence()", bOK) 85 86 Test.StartMethod("gotoNextSentence()") 87 bOK = true 88 oObj.gotoNextSentence(false) 89 oObj.String = "4" 90 Out.Log("Current text: '" + oObj.Text.String + "'") 91 bOK = bOK AND inStr(1, oObj.Text.String, "41") <> 0 92 Test.MethodTested("gotoNextSentence()", bOK) 93 94Exit Sub 95ErrHndl: 96 Test.Exception() 97 bOK = false 98 resume next 99End Sub 100</script:module> 101