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="sdbcx_XRowLocate" 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 33Sub RunTest() 34 35'************************************************************************* 36' INTERFACE: 37' com.sun.star.sdbcx.XRowLocate 38'************************************************************************* 39On Error Goto ErrHndl 40 Dim bOK As Boolean 41 Dim oBM1 As Variant 42 Dim oBM2 As Variant 43 Dim oBM3 As Variant 44 Dim oBM4 As Variant 45 Dim cDscr1 As String 46 Dim cDscr2 As String 47 48 ReCreateObj() 49 50 oObj.first() 51 52 Test.StartMethod("getBookmark()") 53 bOK = true 54 oBM1 = oObj.getBookmark() 55 cDscr1 = oObj.getString(1) 56 Out.Log("Set bookmark to row " + cDscr1) 57 bOK = bOK AND NOT isNULL(oBM1) 58 Test.MethodTested("getBookmark()", bOK) 59 60 Test.StartMethod("moveToBookmark()") 61 bOK = true 62 oObj.next() 63 cDscr2 = oObj.getString(1) 64 Out.Log("Now on " + cDscr2) 65 oObj.moveToBookmark(oBM1) 66 Out.Log("After movment on " + oObj.getString(1)) 67 bOK = bOK AND oObj.getString(1) = cDscr1 68 Test.MethodTested("moveToBookmark()", bOK) 69 70 Test.StartMethod("moveRelativeToBookmark()") 71 bOK = true 72 oObj.moveRelativeToBookmark(oBM1, 1) 73 Out.Log("After movment on " + oObj.getString(1)) 74 bOK = bOK AND oObj.getString(1) = cDscr2 75 Test.MethodTested("moveRelativeToBookmark()", bOK) 76 77 oBM2 = oObj.getBookmark() 78 79 Test.StartMethod("compareBookmarks()") 80 bOK = true 81 ' if database driver supports ordered marks then 82 ' compareBookmarks should return values CompareBookmark::LESS or 83 ' CompareBookmark::GREATER in case when bookmarks are not equal 84 ' otherwise this method returnes only CompareBookmark::NOT_EQUAL 85 86 if (oObj.hasOrderedBookmarks()) then 87 bOK = bOK AND oObj.compareBookmarks(oBM1, oBM1) = com.sun.star.sdbcx.CompareBookmark.EQUAL 88 bOK = bOK AND oObj.compareBookmarks(oBM1, oBM2) = com.sun.star.sdbcx.CompareBookmark.LESS 89 bOK = bOK AND oObj.compareBookmarks(oBM2, oBM1) = com.sun.star.sdbcx.CompareBookmark.GREATER 90 else 91 bOK = bOK AND oObj.compareBookmarks(oBM1, oBM1) = com.sun.star.sdbcx.CompareBookmark.EQUAL 92 bOK = bOK AND oObj.compareBookmarks(oBM1, oBM2) = com.sun.star.sdbcx.CompareBookmark.NOT_EQUAL 93 bOK = bOK AND oObj.compareBookmarks(oBM2, oBM1) = com.sun.star.sdbcx.CompareBookmark.NOT_EQUAL 94 end if 95 Test.MethodTested("compareBookmarks()", bOK) 96 97 Test.StartMethod("hasOrderedBookmarks()") 98 bOK = true 99 bOK = bOK AND oObj.hasOrderedBookmarks() 100 Test.MethodTested("hasOrderedBookmarks()", bOK) 101 102 Test.StartMethod("hashBookmark()") 103 bOK = true 104 105 oObj.last() 106 oBM3 = oObj.getBookmark() 107 oObj.first() 108 oBM4 = oObj.getBookmark() 109 110 bOK = bOK AND oObj.hashBookmark(oBM1) <> oObj.hashBookmark(oBM2) 111 bOK = bOK AND oObj.hashBookmark(oBM1) <> oObj.hashBookmark(oBM3) 112 bOK = bOK AND oObj.hashBookmark(oBM3) <> oObj.hashBookmark(oBM2) 113 bOK = bOK AND oObj.hashBookmark(oBM1) = oObj.hashBookmark(oBM4) 114 Test.MethodTested("hashBookmark()", bOK) 115 116 117Exit Sub 118ErrHndl: 119 Test.Exception() 120 bOK = false 121 resume next 122End Sub 123</script:module> 124