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="forms_OGridControlModel" 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' Required for XPersistObject 44Global oPersistInstance As Object 45 46' Required for XComponent 47Global oComponentInstance As Object ' it will be disposed 48 49' Requiered for com.sun.star.container.XNameContainer 50 Global oInstance As Object 'instance to insert 51 52' Requiered for com.sun.star.view.XSelectionSupplier 53 Global SelectableObj1 As Variant 54 Global SelectableObj2 As Variant 55 56' Requiered for com.sun.star.container.XNameReplace 57 Global cNameToReplace As String 'name of instance to be replased 58 Global oReplaceInstance As Object 'instance, that will be inserted 59 'instead old one 60 61' Requiered for com.sun.star.container.XIndexReplace 62 Global oIdxReplaceInstance As Object 63 64' Requiered for XContainer 65 Global oElementToInsert As Object 66 67 68Sub CreateObj() 69 70'************************************************************************* 71' COMPONENT: 72' forms.OGridControlModel 73'************************************************************************* 74On Error Goto ErrHndl 75 Dim bOK As Boolean, i As Integer 76 Dim oShape As Object, oGridColumn As Object 77 78 bOK = true 79 80 oDoc = utils.createDocument("swriter", cObjectName) 81 82 oShape = toolkittools.addControlToDefaultForm("GridControl", 1000, 1000, 3000, 3000) 83 oObj = oShape.getControl() 84 oShape = toolkittools.addControlToDefaultForm("GridControl", 1000, 5000, 500, 500) 85 oComponentInstance = oShape.getControl() 86 oShape = toolkittools.addControlToDefaultForm("GridControl", 1000, 9000, 500, 500) 87 oPersistInstance = oShape.getControl() 88 89 'insert Columns into Grid 90 for i = 0 to 10 91 oGridColumn = oObj.createColumn("TextField") 92 oGridColumn.Label = "Label" + Str(i) 93 oGridColumn.DataField = "Data" + Str(i) 94 oObj.insertByName("Field" + i , oGridColumn) 95 96 next i 97 98 SelectableObj1 = oObj.getByName("Field" + 7) 99 SelectableObj2 = oObj.getByName("Field" + 5) 100 101 'for XNameContainer 102 oInstance = oObj.createColumn("TextField") 103 oInstance.Label = "LabelInstance" 104 oInstance.DataField = "DataInstance" 105 106 oElementToInsert = oObj.createColumn("TextField") 107 oElementToInsert.Label = "LabelInstance" 108 oElementToInsert.DataField = "DataInstance" 109 110 'for XNameReplace 111 cNameToReplace = "Field2" 112 oReplaceInstance = oObj.createColumn("TextField") 113 oReplaceInstance.Label = "LabelReplace" 114 oReplaceInstance.DataField = "LabelReplace" 115 116 'for XIndexReplace 117 oIdxReplaceInstance = oObj.createColumn("TextField") 118 oIdxReplaceInstance.Label = "LabelIndexReplace" 119 120Exit Sub 121ErrHndl: 122 Test.Exception() 123End Sub 124</script:module> 125