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