1cdf0e10cSrcweir<?xml version="1.0" encoding="UTF-8"?>
2cdf0e10cSrcweir<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
3cdf0e10cSrcweir<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sdbcx_XRowLocate" script:language="StarBasic">
4cdf0e10cSrcweir
5cdf0e10cSrcweir
6cdf0e10cSrcweir'*************************************************************************
7cdf0e10cSrcweir'
8eebed415SAndrew Rist'  Licensed to the Apache Software Foundation (ASF) under one
9eebed415SAndrew Rist'  or more contributor license agreements.  See the NOTICE file
10eebed415SAndrew Rist'  distributed with this work for additional information
11eebed415SAndrew Rist'  regarding copyright ownership.  The ASF licenses this file
12eebed415SAndrew Rist'  to you under the Apache License, Version 2.0 (the
13eebed415SAndrew Rist'  "License"); you may not use this file except in compliance
14eebed415SAndrew Rist'  with the License.  You may obtain a copy of the License at
15eebed415SAndrew Rist'
16eebed415SAndrew Rist'    http://www.apache.org/licenses/LICENSE-2.0
17eebed415SAndrew Rist'
18eebed415SAndrew Rist'  Unless required by applicable law or agreed to in writing,
19eebed415SAndrew Rist'  software distributed under the License is distributed on an
20eebed415SAndrew Rist'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21eebed415SAndrew Rist'  KIND, either express or implied.  See the License for the
22eebed415SAndrew Rist'  specific language governing permissions and limitations
23eebed415SAndrew Rist'  under the License.
24cdf0e10cSrcweir'
25cdf0e10cSrcweir'*************************************************************************
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweir
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31eebed415SAndrew Rist
32eebed415SAndrew Rist
33cdf0e10cSrcweirSub RunTest()
34cdf0e10cSrcweir
35cdf0e10cSrcweir'*************************************************************************
36cdf0e10cSrcweir' INTERFACE:
37cdf0e10cSrcweir' com.sun.star.sdbcx.XRowLocate
38cdf0e10cSrcweir'*************************************************************************
39cdf0e10cSrcweirOn Error Goto ErrHndl
40cdf0e10cSrcweir    Dim bOK As Boolean
41cdf0e10cSrcweir    Dim oBM1 As Variant
42cdf0e10cSrcweir    Dim oBM2 As Variant
43cdf0e10cSrcweir    Dim oBM3 As Variant
44cdf0e10cSrcweir    Dim oBM4 As Variant
45cdf0e10cSrcweir    Dim cDscr1 As String
46cdf0e10cSrcweir    Dim cDscr2 As String
47cdf0e10cSrcweir
48cdf0e10cSrcweir    ReCreateObj()
49cdf0e10cSrcweir
50cdf0e10cSrcweir    oObj.first()
51cdf0e10cSrcweir
52cdf0e10cSrcweir    Test.StartMethod("getBookmark()")
53cdf0e10cSrcweir    bOK = true
54cdf0e10cSrcweir    oBM1 = oObj.getBookmark()
55cdf0e10cSrcweir    cDscr1 = oObj.getString(1)
56cdf0e10cSrcweir    Out.Log("Set bookmark to row " + cDscr1)
57cdf0e10cSrcweir    bOK = bOK AND NOT isNULL(oBM1)
58cdf0e10cSrcweir    Test.MethodTested("getBookmark()", bOK)
59cdf0e10cSrcweir
60cdf0e10cSrcweir    Test.StartMethod("moveToBookmark()")
61cdf0e10cSrcweir    bOK = true
62cdf0e10cSrcweir    oObj.next()
63cdf0e10cSrcweir    cDscr2 = oObj.getString(1)
64cdf0e10cSrcweir    Out.Log("Now on " + cDscr2)
65cdf0e10cSrcweir    oObj.moveToBookmark(oBM1)
66*bb6af6bcSPedro Giffuni    Out.Log("After movement on " + oObj.getString(1))
67cdf0e10cSrcweir    bOK = bOK AND oObj.getString(1) = cDscr1
68cdf0e10cSrcweir    Test.MethodTested("moveToBookmark()", bOK)
69cdf0e10cSrcweir
70cdf0e10cSrcweir    Test.StartMethod("moveRelativeToBookmark()")
71cdf0e10cSrcweir    bOK = true
72cdf0e10cSrcweir    oObj.moveRelativeToBookmark(oBM1, 1)
73*bb6af6bcSPedro Giffuni    Out.Log("After movement on " + oObj.getString(1))
74cdf0e10cSrcweir    bOK = bOK AND oObj.getString(1) = cDscr2
75cdf0e10cSrcweir    Test.MethodTested("moveRelativeToBookmark()", bOK)
76cdf0e10cSrcweir
77cdf0e10cSrcweir    oBM2 = oObj.getBookmark()
78cdf0e10cSrcweir
79cdf0e10cSrcweir    Test.StartMethod("compareBookmarks()")
80cdf0e10cSrcweir    bOK = true
81cdf0e10cSrcweir    ' if database driver supports ordered marks then
82cdf0e10cSrcweir    ' compareBookmarks should return values CompareBookmark::LESS or
83cdf0e10cSrcweir    ' CompareBookmark::GREATER in case when bookmarks are not equal
84cdf0e10cSrcweir    ' otherwise this method returnes only CompareBookmark::NOT_EQUAL
85cdf0e10cSrcweir
86cdf0e10cSrcweir    if (oObj.hasOrderedBookmarks()) then
87cdf0e10cSrcweir        bOK = bOK AND oObj.compareBookmarks(oBM1, oBM1) = com.sun.star.sdbcx.CompareBookmark.EQUAL
88cdf0e10cSrcweir        bOK = bOK AND oObj.compareBookmarks(oBM1, oBM2) = com.sun.star.sdbcx.CompareBookmark.LESS
89cdf0e10cSrcweir        bOK = bOK AND oObj.compareBookmarks(oBM2, oBM1) = com.sun.star.sdbcx.CompareBookmark.GREATER
90cdf0e10cSrcweir    else
91cdf0e10cSrcweir        bOK = bOK AND oObj.compareBookmarks(oBM1, oBM1) = com.sun.star.sdbcx.CompareBookmark.EQUAL
92cdf0e10cSrcweir        bOK = bOK AND oObj.compareBookmarks(oBM1, oBM2) = com.sun.star.sdbcx.CompareBookmark.NOT_EQUAL
93cdf0e10cSrcweir        bOK = bOK AND oObj.compareBookmarks(oBM2, oBM1) = com.sun.star.sdbcx.CompareBookmark.NOT_EQUAL
94cdf0e10cSrcweir    end if
95cdf0e10cSrcweir    Test.MethodTested("compareBookmarks()", bOK)
96cdf0e10cSrcweir
97cdf0e10cSrcweir    Test.StartMethod("hasOrderedBookmarks()")
98cdf0e10cSrcweir    bOK = true
99cdf0e10cSrcweir    bOK = bOK AND oObj.hasOrderedBookmarks()
100cdf0e10cSrcweir    Test.MethodTested("hasOrderedBookmarks()", bOK)
101cdf0e10cSrcweir
102cdf0e10cSrcweir    Test.StartMethod("hashBookmark()")
103cdf0e10cSrcweir    bOK = true
104cdf0e10cSrcweir
105cdf0e10cSrcweir    oObj.last()
106cdf0e10cSrcweir    oBM3 = oObj.getBookmark()
107cdf0e10cSrcweir    oObj.first()
108cdf0e10cSrcweir    oBM4 = oObj.getBookmark()
109cdf0e10cSrcweir
110cdf0e10cSrcweir    bOK = bOK AND oObj.hashBookmark(oBM1) &lt;&gt; oObj.hashBookmark(oBM2)
111cdf0e10cSrcweir    bOK = bOK AND oObj.hashBookmark(oBM1) &lt;&gt; oObj.hashBookmark(oBM3)
112cdf0e10cSrcweir    bOK = bOK AND oObj.hashBookmark(oBM3) &lt;&gt; oObj.hashBookmark(oBM2)
113cdf0e10cSrcweir    bOK = bOK AND oObj.hashBookmark(oBM1) = oObj.hashBookmark(oBM4)
114cdf0e10cSrcweir    Test.MethodTested("hashBookmark()", bOK)
115cdf0e10cSrcweir
116cdf0e10cSrcweir
117cdf0e10cSrcweirExit Sub
118cdf0e10cSrcweirErrHndl:
119cdf0e10cSrcweir    Test.Exception()
120cdf0e10cSrcweir    bOK = false
121cdf0e10cSrcweir    resume next
122cdf0e10cSrcweirEnd Sub
123cdf0e10cSrcweir</script:module>
124