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="dbaccess_ODatasourceBrowser" 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' Be sure that all variables are dimensioned: 38option explicit 39 40 41' REQUIRED VARIABLES for interface/service tests: 42 43' variable for XComponent 44Global oComponentInstance As Object 45 46' variable for XFormController 47Global otherWin As Object 48 49' variable for XDispatchProvider 50Global dispatchUrl As String 51 52' variable for frame.XController 53Global oFrameToAttach As Object 54Global oModelToAttach As Object 55Global bHasNoViewData As Boolean 56Global oObjToSuspend As Object 57Global bHasNoModel As Boolean 58 59' variables for awt.XTabController 60Global oXTabControllerModel as Object 61Global oXTabControllerContainer as Object 62 63' variable for lang.XInitialization 64Global aInitArgs As Variant 65 66 67Sub CreateObj() 68 69'************************************************************************* 70' COMPONENT: 71' dbaccess.ODatasourceBrowser 72'************************************************************************* 73On Error Goto ErrHndl 74 Dim cntrlr As Object 75 Dim frame1 As Object, frame2 As Object 76 Dim url As new com.sun.star.util.URL 77 Dim dispatcher As Object 78 Dim oShape As Object, oDrawPage As Object, oModel As Object 79 Dim oController As Object, oCtrll As Object 80 Dim params(2) as new com.sun.star.beans.PropertyValue 81 Dim list1 as object, ctrl as object 82 83' oDoc = utils.createDocument("swriter", cObjectName) 84 oDoc = StarDesktop.loadComponentFromUrl("private:factory/swriter", "_blank",0 , args()) 85 86 wait(500) 87 88 cntrlr = oDoc.getCurrentController() 89 frame1 = StarDesktop.getCurrentFrame() 90 url.Complete = ".component:DB/DataSourceBrowser" 91 dispatcher = frame1.queryDispatch(url, "_beamer", 12) 92 dispatcher.dispatch(url, DimArray()) 93 94 frame2 = frame1.findFrame("_beamer", 4) 95 frame2.setName("ODatasourceBrowser") 96 97 oObj = frame2.getController() 98 99 ' now initialize the browser to make him displaying a table in its gtrid. 100 ' This is required for activating of this control 101 params(0).Name = "DataSourceName" 102 params(0).Value = "Bibliography" 103 params(1).Name = "CommandType" 104 params(1).Value = com.sun.star.sdb.CommandType.TABLE 105 params(2).Name = "Command" 106 params(2).Value = "biblio" 107 108 oObj.initialize(params()) 109 ' waiting while data loading ... 110 wait(2000) 111 112'setting variable for XComponent 113 oComponentInstance = oObj 114 115'setting variable for XDispatchProvider 116 dispatchUrl = ".uno:DataSourceBrowser/FormLetter" 117 118'setting variable for XController 119 oFrameToAttach = frame1 120 oModelToAttach = oDoc 121 bHasNoViewData = true 122 oObjToSuspend = oObj 123 bHasNoModel = true 124 125'setting variables for awt.XTabController and for XFormController 126 oShape = toolkittools.createUNOControlShape("CommandButton", "UnoControlButton") 127 toolkittools.addShape(oShape) 128 oDrawPage = oDoc.getDrawPage() 129 130 oModel = oShape.getControl() 131 oController = oDoc.getCurrentController() 132 otherWin = oController.getControl(oModel) 133 oXTabControllerContainer = otherWin.getContext() 134 oXTabControllerModel = oDrawPage.getForms().getByIndex(0) 135 136' setting variable for lang.XInitialization 137 aInitArgs = params() 138 139Exit Sub 140ErrHndl: 141 Test.Exception() 142End Sub 143</script:module> 144