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="sw_SwXTextView" 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 32' REQUIRED VARIABLES for interface/service tests: 33 34' Requiered for XControlAccess 35 Global oControlModel As Object 36 37' Requiered for com.sun.star.view.XSelectionSupplier 38 Global SelectableObj1 As Object 39 Global SelectableObj2 As Object 40 41 42Sub CreateObj() 43 44'************************************************************************* 45' COMPONENT: 46' sw.SwXTextView 47'************************************************************************* 48On Error Goto ErrHndl 49 50 Dim bOK As Boolean 51 bOK = true 52 53 oDoc = utils.createDocument("swriter", cObjectName) 54 55 oCursor = oDoc.Text.createTextCursor() 56 57 oCursor.gotoStart(false) 58 59 oObj = oDoc.CurrentController 60 61 oDoc.Text.String = "This is a string for " & cObjectName 62 63 SelectableObj1 = oDoc.Text.CreateTextCursor() 64 SelectableObj1.goRight(5, true) 65 66 SelectableObj2 = oDoc.Text.CreateTextCursor() 67 SelectableObj2.goRight(8, false) 68 SelectableObj2.goRight(10, true) 69 70 71 addControl(oCursor, 2000, 4000, cObjectName) 72 oControlModel = oDoc.Drawpage.Forms(0).getByName(cObjectName) 73 74 75Exit Sub 76ErrHndl: 77 Test.Exception() 78End Sub 79 80Sub addControl( oCursor as Object, nPointX as Integer, nPointY as Integer, sName as String ) 81 82 Dim oDrawPage As Object 83 Dim oForm, oForms As Object 84 Dim oControl, oControlShape As Object 85 Dim aSz As Variant 86 Dim oText As Object 87 88 oDrawPage = oDoc.DrawPage 89 oControlShape = oDoc.createInstance( "com.sun.star.drawing.ControlShape" ) 90 oControl = oDoc.createInstance( "com.sun.star.form.component.CommandButton" ) 91 oForm = oDoc.createInstance( "com.sun.star.form.component.Form" ) 92 oforms = oDrawPage.Forms 93 94 if oForms.count = 0 then 95 oForms.InsertByIndex( 0, oForm ) 96 end if 97 98 aSz = oControlShape.Size 99 aSz.Width = 2900 100 aSz.Height = 1200 101 oControlShape.Size = aSz 102 oControlShape.Control = oControl 103 104 oControlShape.TextRange = oCursor.Start 105 apoint = ocontrolshape.position 106 apoint.x = nPointX 107 aPoint.y = nPointY 108 ocontrolshape.position = aPoint 109 oDrawPage.add( oControlShape ) 110 if sName <> "" then 111 oControl.Name = sName 112 end if 113 114End Sub 115</script:module> 116