1*b1cdbd2cSJim Jagielski<?xml version="1.0" encoding="UTF-8"?> 2*b1cdbd2cSJim Jagielski<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3*b1cdbd2cSJim Jagielski<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sdb_XRowSetApproveBroadcaster" script:language="StarBasic"> 4*b1cdbd2cSJim Jagielski 5*b1cdbd2cSJim Jagielski 6*b1cdbd2cSJim Jagielski'************************************************************************* 7*b1cdbd2cSJim Jagielski' 8*b1cdbd2cSJim Jagielski' Licensed to the Apache Software Foundation (ASF) under one 9*b1cdbd2cSJim Jagielski' or more contributor license agreements. See the NOTICE file 10*b1cdbd2cSJim Jagielski' distributed with this work for additional information 11*b1cdbd2cSJim Jagielski' regarding copyright ownership. The ASF licenses this file 12*b1cdbd2cSJim Jagielski' to you under the Apache License, Version 2.0 (the 13*b1cdbd2cSJim Jagielski' "License"); you may not use this file except in compliance 14*b1cdbd2cSJim Jagielski' with the License. You may obtain a copy of the License at 15*b1cdbd2cSJim Jagielski' 16*b1cdbd2cSJim Jagielski' http://www.apache.org/licenses/LICENSE-2.0 17*b1cdbd2cSJim Jagielski' 18*b1cdbd2cSJim Jagielski' Unless required by applicable law or agreed to in writing, 19*b1cdbd2cSJim Jagielski' software distributed under the License is distributed on an 20*b1cdbd2cSJim Jagielski' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21*b1cdbd2cSJim Jagielski' KIND, either express or implied. See the License for the 22*b1cdbd2cSJim Jagielski' specific language governing permissions and limitations 23*b1cdbd2cSJim Jagielski' under the License. 24*b1cdbd2cSJim Jagielski' 25*b1cdbd2cSJim Jagielski'************************************************************************* 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski 28*b1cdbd2cSJim Jagielski 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielski 31*b1cdbd2cSJim Jagielski 32*b1cdbd2cSJim JagielskiDim iApproveCursorMove1 As Integer 33*b1cdbd2cSJim JagielskiDim iApproveCursorMove2 As Integer 34*b1cdbd2cSJim JagielskiDim iApproveRowChange1 As Integer 35*b1cdbd2cSJim JagielskiDim iApproveRowChange2 As Integer 36*b1cdbd2cSJim JagielskiDim iApproveRowSetChange1 As Integer 37*b1cdbd2cSJim JagielskiDim iApproveRowSetChange2 As Integer 38*b1cdbd2cSJim Jagielski 39*b1cdbd2cSJim Jagielski 40*b1cdbd2cSJim JagielskiSub RunTest() 41*b1cdbd2cSJim Jagielski 42*b1cdbd2cSJim Jagielski'************************************************************************* 43*b1cdbd2cSJim Jagielski' INTERFACE: 44*b1cdbd2cSJim Jagielski' com.sun.star.sdb.XRowSetApproveBroadcaster 45*b1cdbd2cSJim Jagielski'************************************************************************* 46*b1cdbd2cSJim JagielskiOn Error Goto ErrHndl 47*b1cdbd2cSJim Jagielski Dim bOK As Boolean 48*b1cdbd2cSJim Jagielski 49*b1cdbd2cSJim Jagielski Dim oListener1 As Object 50*b1cdbd2cSJim Jagielski Dim oListener2 As Object 51*b1cdbd2cSJim Jagielski Dim cOrigStr As String 52*b1cdbd2cSJim Jagielski Dim cPrevStr As String 53*b1cdbd2cSJim Jagielski 54*b1cdbd2cSJim Jagielski oObj.first() 55*b1cdbd2cSJim Jagielski cOrigStr = oObj.getString(1) 56*b1cdbd2cSJim Jagielski 57*b1cdbd2cSJim Jagielski Out.Log("Creating two XRowSetApproveListeners") 58*b1cdbd2cSJim Jagielski oListener1 = createUnoListener("CB1_", "com.sun.star.sdb.XRowSetApproveListener") 59*b1cdbd2cSJim Jagielski oListener2 = createUnoListener("CB2_", "com.sun.star.sdb.XRowSetApproveListener") 60*b1cdbd2cSJim Jagielski 61*b1cdbd2cSJim Jagielski ResetCounters() 62*b1cdbd2cSJim Jagielski 63*b1cdbd2cSJim Jagielski Test.StartMethod("addRowSetApproveListener()") 64*b1cdbd2cSJim Jagielski bOK = true 65*b1cdbd2cSJim Jagielski oObj.addRowSetApproveListener(oListener1) 66*b1cdbd2cSJim Jagielski oObj.addRowSetApproveListener(oListener2) 67*b1cdbd2cSJim Jagielski 68*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(0, 0, 0, 0, 0, 0) 69*b1cdbd2cSJim Jagielski 70*b1cdbd2cSJim Jagielski Out.Log("Call oObj.execute() - change RowSet") 71*b1cdbd2cSJim Jagielski oObj.execute() 72*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(0, 0, 0, 0, 1, 1) 73*b1cdbd2cSJim Jagielski 74*b1cdbd2cSJim Jagielski ResetCounters() 75*b1cdbd2cSJim Jagielski Out.Log("Call oObj.next() - move cursor") 76*b1cdbd2cSJim Jagielski oObj.next() 77*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(1, 1, 0, 0, 0, 0) 78*b1cdbd2cSJim Jagielski 79*b1cdbd2cSJim Jagielski Out.Log("Call oObj.updateString() - updating RowSet") 80*b1cdbd2cSJim Jagielski oObj.first() 81*b1cdbd2cSJim Jagielski ResetCounters() 82*b1cdbd2cSJim Jagielski cPrevStr = oObj.getString(1) 83*b1cdbd2cSJim Jagielski Out.Log(cPrevStr) 84*b1cdbd2cSJim Jagielski oObj.updateString(1, cPrevStr + "+") 85*b1cdbd2cSJim Jagielski oObj.updateRow() 86*b1cdbd2cSJim Jagielski Out.Log(oObj.getString(1)) 87*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(0, 0, 1, 1, 0, 0) 88*b1cdbd2cSJim Jagielski bOK = bOK AND oObj.getString(1) = cPrevStr + "+" 89*b1cdbd2cSJim Jagielski 90*b1cdbd2cSJim Jagielski Test.MethodTested("addRowSetApproveListener()", bOK) 91*b1cdbd2cSJim Jagielski 92*b1cdbd2cSJim Jagielski ResetCounters() 93*b1cdbd2cSJim Jagielski 94*b1cdbd2cSJim Jagielski Test.StartMethod("removeRowSetApproveListener()") 95*b1cdbd2cSJim Jagielski bOK = true 96*b1cdbd2cSJim Jagielski Out.Log("Removing only first listener") 97*b1cdbd2cSJim Jagielski oObj.removeRowSetApproveListener(oListener1) 98*b1cdbd2cSJim Jagielski 99*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(0, 0, 0, 0, 0, 0) 100*b1cdbd2cSJim Jagielski 101*b1cdbd2cSJim Jagielski Out.Log("Call oObj.execute() - change RowSet") 102*b1cdbd2cSJim Jagielski oObj.execute() 103*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(0, 0, 0, 0, 0, 1) 104*b1cdbd2cSJim Jagielski 105*b1cdbd2cSJim Jagielski ResetCounters() 106*b1cdbd2cSJim Jagielski Out.Log("Call oObj.next() - move cursor") 107*b1cdbd2cSJim Jagielski oObj.next() 108*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(0, 1, 0, 0, 0, 0) 109*b1cdbd2cSJim Jagielski 110*b1cdbd2cSJim Jagielski ResetCounters() 111*b1cdbd2cSJim Jagielski Out.Log("Call oObj.updateString() - updating RowSet") 112*b1cdbd2cSJim Jagielski oObj.first() 113*b1cdbd2cSJim Jagielski cPrevStr = oObj.getString(1) 114*b1cdbd2cSJim Jagielski Out.Log(cPrevStr) 115*b1cdbd2cSJim Jagielski oObj.updateString(1, cPrevStr + "+") 116*b1cdbd2cSJim Jagielski oObj.updateRow() 117*b1cdbd2cSJim Jagielski Out.Log(oObj.getString(1)) 118*b1cdbd2cSJim Jagielski bOK = bOK AND Expected(0, 0, 0, 1, 0, 0) 119*b1cdbd2cSJim Jagielski bOK = bOK AND oObj.getString(1) = cPrevStr + "+" 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski Test.MethodTested("removeRowSetApproveListener()", bOK) 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielski Out.Log("Removing last listener") 124*b1cdbd2cSJim Jagielski oObj.removeRowSetApproveListener(oListener2) 125*b1cdbd2cSJim Jagielski 126*b1cdbd2cSJim Jagielski Out.Log("Returning first row back...") 127*b1cdbd2cSJim Jagielski oObj.first() 128*b1cdbd2cSJim Jagielski oObj.updateString(1, cOrigStr) 129*b1cdbd2cSJim Jagielski oObj.updateRow() 130*b1cdbd2cSJim Jagielski 131*b1cdbd2cSJim JagielskiExit Sub 132*b1cdbd2cSJim JagielskiErrHndl: 133*b1cdbd2cSJim Jagielski Test.Exception() 134*b1cdbd2cSJim Jagielski bOK = false 135*b1cdbd2cSJim Jagielski resume next 136*b1cdbd2cSJim JagielskiEnd Sub 137*b1cdbd2cSJim JagielskiFunction CB1_approveCursorMove(oEvent As Object) As Boolean 138*b1cdbd2cSJim Jagielski Out.Log("callback function approveCursorMove() for Listener1 was called!") 139*b1cdbd2cSJim Jagielski iApproveCursorMove1 = iApproveCursorMove1 + 1 140*b1cdbd2cSJim Jagielski CB1_approveCursorMove() = true 141*b1cdbd2cSJim JagielskiEnd Function 142*b1cdbd2cSJim Jagielski 143*b1cdbd2cSJim JagielskiFunction CB2_approveCursorMove(oEvent As Object) As Boolean 144*b1cdbd2cSJim Jagielski Out.Log("callback function approveCursorMove() for Listener2 was called!") 145*b1cdbd2cSJim Jagielski iApproveCursorMove2 = iApproveCursorMove2 + 1 146*b1cdbd2cSJim Jagielski CB2_approveCursorMove() = true 147*b1cdbd2cSJim JagielskiEnd Function 148*b1cdbd2cSJim Jagielski 149*b1cdbd2cSJim JagielskiFunction CB1_approveRowChange(oEvent As Object) As Boolean 150*b1cdbd2cSJim Jagielski Out.Log("callback function approveRowChange() for Listener1 was called!") 151*b1cdbd2cSJim Jagielski iApproveRowChange1 = iApproveRowChange1 + 1 152*b1cdbd2cSJim Jagielski CB1_approveRowChange() = true 153*b1cdbd2cSJim JagielskiEnd Function 154*b1cdbd2cSJim Jagielski 155*b1cdbd2cSJim JagielskiFunction CB2_approveRowChange(oEvent As Object) As Boolean 156*b1cdbd2cSJim Jagielski Out.Log("callback function approveRowChange() for Listener2 was called!") 157*b1cdbd2cSJim Jagielski iApproveRowChange2 = iApproveRowChange2 + 1 158*b1cdbd2cSJim Jagielski CB2_approveRowChange() = true 159*b1cdbd2cSJim JagielskiEnd Function 160*b1cdbd2cSJim Jagielski 161*b1cdbd2cSJim JagielskiFunction CB1_approveRowSetChange(oEvent As Object) As Boolean 162*b1cdbd2cSJim Jagielski Out.Log("callback function approveRowSetChange() for Listener1 was called!") 163*b1cdbd2cSJim Jagielski iApproveRowSetChange1 = iApproveRowSetChange1 + 1 164*b1cdbd2cSJim Jagielski CB1_approveRowSetChange() = true 165*b1cdbd2cSJim JagielskiEnd Function 166*b1cdbd2cSJim Jagielski 167*b1cdbd2cSJim JagielskiFunction CB2_approveRowSetChange(oEvent As Object) As Boolean 168*b1cdbd2cSJim Jagielski Out.Log("callback function approveRowSetChange() for Listener2 was called!") 169*b1cdbd2cSJim Jagielski iApproveRowSetChange2 = iApproveRowSetChange2 + 1 170*b1cdbd2cSJim Jagielski CB2_approveRowSetChange() = true 171*b1cdbd2cSJim JagielskiEnd Function 172*b1cdbd2cSJim Jagielski 173*b1cdbd2cSJim JagielskiSub ResetCounters() 174*b1cdbd2cSJim Jagielski Out.Log("Reset counters...") 175*b1cdbd2cSJim Jagielski iApproveCursorMove1 = 0 176*b1cdbd2cSJim Jagielski iApproveCursorMove2 = 0 177*b1cdbd2cSJim Jagielski iApproveRowChange1 = 0 178*b1cdbd2cSJim Jagielski iApproveRowChange2 = 0 179*b1cdbd2cSJim Jagielski iApproveRowSetChange1 = 0 180*b1cdbd2cSJim Jagielski iApproveRowSetChange2 = 0 181*b1cdbd2cSJim JagielskiEnd Sub 182*b1cdbd2cSJim Jagielski 183*b1cdbd2cSJim JagielskiFunction Expected(iApprCursorMove1 As Integer, iApprCursorMove2 As Integer, _ 184*b1cdbd2cSJim Jagielski iApprRowChange1 As Integer, iApprRowChange2 As Integer, _ 185*b1cdbd2cSJim Jagielski iApprRowSetChange1 As Integer, iApprRowSetChange2 As Integer) As Boolean 186*b1cdbd2cSJim JagielskiDim bOK As Boolean 187*b1cdbd2cSJim Jagielski bOK = true 188*b1cdbd2cSJim Jagielski 189*b1cdbd2cSJim Jagielski bOK = bOK AND Expected1("approveCursorMove()", 1, iApproveCursorMove1, iApprCursorMove1) 190*b1cdbd2cSJim Jagielski bOK = bOK AND Expected1("approveCursorMove()", 2, iApproveCursorMove2, iApprCursorMove2) 191*b1cdbd2cSJim Jagielski bOK = bOK AND Expected1("approveRowChange()", 1, iApproveRowChange1, iApprRowChange1) 192*b1cdbd2cSJim Jagielski bOK = bOK AND Expected1("approveRowChange()", 2, iApproveRowChange2, iApprRowChange2) 193*b1cdbd2cSJim Jagielski bOK = bOK AND Expected1("apprRowSetChange()", 1, iApproveRowSetChange1, iApprRowSetChange1) 194*b1cdbd2cSJim Jagielski bOK = bOK AND Expected1("apprRowSetChange()", 2, iApproveRowSetChange2, iApprRowSetChange2) 195*b1cdbd2cSJim Jagielski Expected() = bOK 196*b1cdbd2cSJim JagielskiEnd Function 197*b1cdbd2cSJim Jagielski 198*b1cdbd2cSJim JagielskiFunction Expected1(fname As String, ln As Integer, val1 As Integer, val2 As Integer) As Boolean 199*b1cdbd2cSJim Jagielski Dim bOK As Integer 200*b1cdbd2cSJim Jagielski 201*b1cdbd2cSJim Jagielski bOK = true 202*b1cdbd2cSJim Jagielski if (val1 <> val2) then 203*b1cdbd2cSJim Jagielski Out.Log(fname + " of Listener" + ln + " was called " + val1 + " time(s), "_ 204*b1cdbd2cSJim Jagielski + "but it should be called " + val2 + " time(s).") 205*b1cdbd2cSJim Jagielski bOK = false 206*b1cdbd2cSJim Jagielski end if 207*b1cdbd2cSJim Jagielski Expected1() = bOK 208*b1cdbd2cSJim JagielskiEnd Function 209*b1cdbd2cSJim Jagielski</script:module> 210