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_XParagraphCursor" 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' This Interface/Service test depends on the following GLOBAL variables, 36' which must be specified in the object creation: 37 38' - Global oText As Object 39 40'************************************************************************* 41 42 43 44 45 46Sub RunTest() 47 48'************************************************************************* 49' INTERFACE: 50' com.sun.star.text.XParagraphCursor 51'************************************************************************* 52On Error Goto ErrHndl 53 Dim bOK As Boolean 54 Dim i As Integer 55 56 for i = 0 to 2 57 oText.insertString(oObj, "" + i +"Start of paragraph.", false) 58 oText.insertString(oObj, Chr(10) + cObjectName + " " + cIfcShortName + Chr(10), false) 59 oText.insertString(oObj, "Paragraph's end." + i, false) 60 oText.insertControlCharacter(oObj, com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK, false) 61 next i 62 63 oObj.gotoStart(false) 64 65 Test.StartMethod("gotoStartOfParagraph()") 66 bOK = true 67 oObj.gotoStartOfParagraph(false) 68 oText.insertString(oObj, "1", false) 69 bOK = bOK AND inStr(1, oText.String, "10Start") <> 0 70 Test.MethodTested("gotoStartOfParagraph()", bOK) 71 72 Test.StartMethod("gotoEndOfParagraph()") 73 bOK = true 74 oObj.gotoEndOfParagraph(false) 75 oText.insertString(oObj, "2", false) 76 bOK = bOK AND inStr(1, oText.String, "end.02") <> 0 77 Test.MethodTested("gotoEndOfParagraph()", bOK) 78 79 Test.StartMethod("gotoNextParagraph()") 80 bOK = true 81 oObj.gotoNextParagraph(false) 82 oObj.gotoNextParagraph(false) 83 oObj.gotoEndOfParagraph(false) 84 oText.insertString(oObj, "3", false) 85 bOK = bOK AND inStr(1, oText.String, "end.23") <> 0 86 Test.MethodTested("gotoNextParagraph()", bOK) 87 88 Test.StartMethod("gotoPreviousParagraph()") 89 bOK = true 90 oObj.gotoPreviousParagraph(false) 91 oObj.gotoEndOfParagraph(false) 92 oText.insertString(oObj, "4", false) 93 bOK = bOK AND inStr(1, oText.String, "end.14") <> 0 94 Test.MethodTested("gotoPreviousParagraph()", bOK) 95 96 Test.StartMethod("isStartOfParagraph()") 97 bOK = true 98 oObj.gotoStartOfParagraph(false) 99 bOK = bOK AND oObj.isStartOfParagraph() 100 bOK = bOK AND NOT oObj.isEndOfParagraph() 101 Test.MethodTested("isStartOfParagraph()", bOK) 102 103 Test.StartMethod("isEndOfParagraph()") 104 bOK = true 105 oObj.gotoEndOfParagraph(false) 106 bOK = bOK AND oObj.isEndOfParagraph() 107 bOK = bOK AND NOT oObj.isStartOfParagraph() 108 Test.MethodTested("isEndOfParagraph()", bOK) 109 110Exit Sub 111ErrHndl: 112 Test.Exception() 113 bOK = false 114 resume next 115End Sub 116</script:module> 117