'************************************************************************* ' ' Licensed to the Apache Software Foundation (ASF) under one ' or more contributor license agreements. See the NOTICE file ' distributed with this work for additional information ' regarding copyright ownership. The ASF licenses this file ' to you under the Apache License, Version 2.0 (the ' "License"); you may not use this file except in compliance ' with the License. You may obtain a copy of the License at ' ' http://www.apache.org/licenses/LICENSE-2.0 ' ' Unless required by applicable law or agreed to in writing, ' software distributed under the License is distributed on an ' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ' KIND, either express or implied. See the License for the ' specific language governing permissions and limitations ' under the License. ' '************************************************************************* ' Be sure that all variables are dimensioned: option explicit ' REQUIRED VARIABLES for interface/service tests: ' for XComponent Global oComponentInstance As Object ' for XPersistObject Global oPersistInstance As Object Sub CreateObj() '************************************************************************* ' COMPONENT: ' forms.OHiddenModel '************************************************************************* On Error Goto ErrHndl Dim bOK As Boolean Dim oDrawPage As Object, oForm As Object bOK = true oDoc = utils.createDocument("swriter", cObjectName) addHiddenControl() addHiddenControl() addHiddenControl() addHiddenControl() addHiddenControl() 'get control from document oDrawPage = oDoc.DrawPage oForm = oDrawPage.Forms.getByIndex(0) 'for xComponent oComponentInstance = oForm.getByIndex(1) oPersistInstance = oForm.getByIndex(2) oObj = oForm.getByIndex(oForm.count - 1) Exit Sub ErrHndl: Test.Exception() End Sub Sub addHiddenControl() Dim oDrawPage as Object Dim oForm as Object, oForms as Object Dim oControl as Object, oControlShape as Object oDrawPage = oDoc.DrawPage oControlShape = oDoc.createInstance("com.sun.star.drawing.ControlShape") oControl = oDoc.createInstance("com.sun.star.form.component.HiddenControl") oForm = oDoc.createInstance("com.sun.star.form.component.Form") oforms = oDrawPage.Forms if oForms.count = 0 then oForm.Name = "Form1" oForms.insertbyindex(0,oForm) endif oForm = oForms.getByIndex(0) oForm.insertByIndex(oForm.count,oControl) End Sub