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'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34
35' REQUIRED VARIABLES for interface/service tests:
36
37' Required for XPersistObject
38Global oPersistInstance As Object
39
40' Required for XComponent
41Global oComponentInstance As Object ' it will be disposed
42
43' Requiered for  com.sun.star.container.XNameContainer
44 Global oInstance As Object 'instance to insert
45
46' Requiered for  com.sun.star.view.XSelectionSupplier
47 Global SelectableObj1 As Variant
48 Global SelectableObj2 As Variant
49
50' Requiered for  com.sun.star.container.XNameReplace
51 Global cNameToReplace As String 'name of instance to be replased
52 Global oReplaceInstance As Object 'instance, that will be inserted
53                                   'instead old one
54
55' Requiered for  com.sun.star.container.XIndexReplace
56 Global oIdxReplaceInstance As Object
57
58' Requiered for XContainer
59 Global oElementToInsert As Object
60
61
62Sub CreateObj()
63
64'*************************************************************************
65' COMPONENT:
66' forms.OGridControlModel
67'*************************************************************************
68On Error Goto ErrHndl
69    Dim bOK As Boolean, i As Integer
70    Dim oShape As Object, oGridColumn As Object
71
72    bOK = true
73
74    oDoc = utils.createDocument("swriter", cObjectName)
75
76    oShape = toolkittools.addControlToDefaultForm("GridControl", 1000, 1000, 3000, 3000)
77    oObj = oShape.getControl()
78    oShape = toolkittools.addControlToDefaultForm("GridControl", 1000, 5000, 500, 500)
79    oComponentInstance = oShape.getControl()
80    oShape = toolkittools.addControlToDefaultForm("GridControl", 1000, 9000, 500, 500)
81    oPersistInstance = oShape.getControl()
82
83    'insert Columns into Grid
84    for i = 0 to 10
85        oGridColumn = oObj.createColumn("TextField")
86        oGridColumn.Label = "Label" + Str(i)
87        oGridColumn.DataField = "Data" + Str(i)
88        oObj.insertByName("Field" + i , oGridColumn)
89
90    next i
91
92    SelectableObj1 = oObj.getByName("Field" + 7)
93    SelectableObj2 = oObj.getByName("Field" + 5)
94
95    'for XNameContainer
96    oInstance = oObj.createColumn("TextField")
97    oInstance.Label = "LabelInstance"
98    oInstance.DataField = "DataInstance"
99
100    oElementToInsert = oObj.createColumn("TextField")
101    oElementToInsert.Label = "LabelInstance"
102    oElementToInsert.DataField = "DataInstance"
103
104    'for XNameReplace
105    cNameToReplace = "Field2"
106    oReplaceInstance = oObj.createColumn("TextField")
107    oReplaceInstance.Label = "LabelReplace"
108    oReplaceInstance.DataField = "LabelReplace"
109
110    'for XIndexReplace
111    oIdxReplaceInstance = oObj.createColumn("TextField")
112    oIdxReplaceInstance.Label = "LabelIndexReplace"
113
114Exit Sub
115ErrHndl:
116    Test.Exception()
117End Sub
118</script:module>
119