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