'************************************************************************* ' ' Licensed to the Apache Software Foundation (ASF) under one ' or more contributor license agreements. See the NOTICE file ' distributed with this work for additional information ' regarding copyright ownership. The ASF licenses this file ' to you under the Apache License, Version 2.0 (the ' "License"); you may not use this file except in compliance ' with the License. You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, ' software distributed under the License is distributed on an ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ' KIND, either express or implied. See the License for the ' specific language governing permissions and limitations ' under the License. ' '************************************************************************* ' Be sure that all variables are dimensioned: option explicit Sub RunTest() '************************************************************************* ' INTERFACE: ' com.sun.star.util.XTextSearch '************************************************************************* On Error Goto ErrHndl Dim bOK As Boolean Dim _Locale As new com.sun.star.lang.Locale _Locale.Country = "US" _Locale.Language = "en" Test.StartMethod("setOptions()") bOK = true Dim aSearchOptions As new com.sun.star.util.SearchOptions aSearchOptions.algorithmType = com.sun.star.util.SearchAlgorithms.REGEXP aSearchOptions.searchFlag = com.sun.star.util.SearchFlags.ALL_IGNORE_CASE aSearchOptions.searchString = "h[ae](k|l|j)+o" 'Should work because of ALL_IGNORE_CASE! aSearchOptions.Locale = _Locale oObj.setOptions(aSearchOptions) Test.MethodTested("setOptions()", bOK) Test.StartMethod("searchForward()") bOK = true Dim _string As String Dim _result As Variant _string = "String with 'Hello' and 'Hallo'." _result = oObj.searchForward(_string, 0, len(_string)) if (ubound(_result.startOffset()) >= 0) then bOK = bOK AND _result.startOffset(0) = 13 bOK = bOK AND _result.endOffset(0) = 18 _result = oObj.searchForward(_string, 18, len(_string)) bOK = bOK AND _result.startOffset(0) = 25 bOK = bOK AND _result.endOffset(0) = 30 else Out.Log("No matches were found!") bOK = false end if Test.MethodTested("searchForward()", bOK) Test.StartMethod("searchBackward()") bOK = true _result = oObj.searchBackward(_string, len(_string), 0) if (ubound(_result.startOffset()) >= 0) then bOK = bOK AND _result.startOffset(0) = 30 bOK = bOK AND _result.endOffset(0) = 25 _result = oObj.searchBackward(_string, _result.endOffset(0), 0) bOK = bOK AND _result.startOffset(0) = 18 bOK = bOK AND _result.endOffset(0) = 13 else Out.Log("No matches were found!") bOK = false end if Test.MethodTested("searchBackward()", bOK) Exit Sub ErrHndl: Test.Exception() bOK = false resume next End Sub