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="frame_XModel" 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' Be sure that all variables are dimensioned: 37option explicit 38 39'************************************************************************* 40' This Interface/Service test depends on the following GLOBAL variables, 41' which must be specified in the object creation: 42 43' - Global oXModelController as Object 44' - Global oXModelSel as Object 45' - Global oXModelToSel as Object 46 47'************************************************************************* 48 49 50 51 52 53 54Sub RunTest() 55 56'************************************************************************* 57' INTERFACE: 58' com.sun.star.frame.XModel 59'************************************************************************* 60On Error Goto ErrHndl 61 Dim bOK As Boolean 62 63 Dim oController As Object 64 Dim oSelection As Object 65 Dim aArgs(0 to 0) As Variant 66 Dim oCursor As Object 67 Dim cURL As String 68 Dim i As Integer 69 Dim args1(0) As New com.sun.star.beans.PropertyValue 70 71 Test.StartMethod("attachResource()") 72 args1(0).Name = "XModel" 73 bOK = oObj.attachResource(".component:DB/DataSourceBrowser", args1()) 74 Test.MethodTested("attachResource()", bOK) 75 76 Test.StartMethod("getURL()") 77 bOK = true 78 cURL = oObj.getURL() 79 bOK = bOK AND (cURL = ".component:DB/DataSourceBrowser") 80 Test.MethodTested("getURL()", bOK) 81 82 Test.StartMethod("getArgs()") 83 bOK = true 84 aArgs() = oObj.Args 85 bOK = bOK AND NOT isNull(aArgs()) '(0).Name = "XModel" 86 Test.MethodTested("getArgs()", bOK) 87 88 Test.StartMethod("getCurrentController()") 89 bOK = true 90 Dim oCurrCtrl As Object 91 oCurrCtrl = oObj.getCurrentController() 92 bOK = bOK AND isObject(oCurrCtrl) 93 bOK = bOK AND hasUnoInterfaces(oCurrCtrl, "com.sun.star.frame.XController") 94 Test.MethodTested("getCurrentController()", bOK) 95 96 Test.StartMethod("getCurrentSelection()") 97 bOK = true 98 Dim oCurrSelection As Object 99 oXModelSel.select(oXModelToSel) 100 oCurrSelection = oObj.getCurrentSelection() 101 bOK = bOK AND hasUnoInterfaces(oCurrSelection, "com.sun.star.uno.XInterface") 102 Test.MethodTested("getCurrentSelection()", bOK) 103 104 Test.StartMethod("hasControllersLocked()") 105 bOK = true 106 ' there should no controllers be locked 107 bOK = bOK AND NOT oObj.hasControllersLocked() 108 Test.MethodTested("hasControllersLocked()", bOK) 109 110 ' now lock controllers 111 Test.StartMethod("lockControllers()") 112 bOK = true 113 oObj.lockControllers() 114 ' controllers should be locked 115 bOK = bOK AND oObj.hasControllersLocked() 116 Test.MethodTested("lockControllers()", bOK) 117 118 ' unlock controllers and check success 119 Test.StartMethod("unlockControllers()") 120 bOK = true 121 oObj.unlockControllers() 122 bOK = bOK AND NOT oObj.hasControllersLocked() 123 Test.MethodTested("unlockControllers()", bOK) 124 125 Test.StartMethod("connectController()") 126 oObj.connectController(oXModelController) 127 Test.MethodTested("connectController()", bOK) 128 129 Test.StartMethod("disconnectController()") 130 oObj.disconnectController(oXModelController) 131 oObj.connectController(oCurrCtrl) 132 Test.MethodTested("disconnectController()", bOK) 133 134 Test.StartMethod("setCurrentController()") 135 oObj.setCurrentController(oCurrCtrl) 136 Test.MethodTested("setCurrentController()", bOK) 137 138 139Exit Sub 140ErrHndl: 141 Test.Exception() 142 bOK = false 143 resume next 144End Sub 145</script:module> 146