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