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