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="sd_SdUnoDrawView" 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' Be sure that all variables are dimensioned: 37option explicit 38 39 40' REQUIRED VARIABLES for interface/service tests: 41 42' Required for drawing.XDrawView 43Global oPages As Object 44 45' Required for frame.XController 46Global oFrameToAttach As Object 47Global oModelToAttach As Object 48Global bHasNoViewData As Boolean 49Global oObjToSuspend As Object 50Global bHasNoModel As Boolean 51 52' Required for lang.XComponent 53Global oComponentInstance As Object 54 55' Required for frame.XDispatchProvider 56Global dispatchUrl As String 57 58' Required for view.XSelectionSupplier 59Global SelectableObj1 As Object 60Global SelectableObj2 As Object 61 62Global oSecDoc As Object 63 64 65Sub CreateObj() 66 67'************************************************************************* 68' COMPONENT: 69' sd.SdUnoDrawView 70'************************************************************************* 71On Error Goto ErrHndl 72 Dim bOK As Boolean 73 bOK = true 74 75 oDoc = utils.createDocument("sdraw", cObjectName) 76 77 oObj = oDoc.getCurrentController() 78 79 oPages = oDoc.getDrawPages() 80 81 oSecDoc = utils.createDocument("sdraw", "For frame.XController") 82 bHasNoViewData = false 83 bHasNoModel = false 84 oObjToSuspend = oObj 85 oFrameToAttach = StarDesktop.getCurrentFrame() 86 oModelToAttach = oSecDoc 87 88 oComponentInstance = oObj 89 90 dispatchUrl = "slot:27009" 91 92 Dim page As Object 93 page = oPages.getByIndex(0) 94 AddShape(page, 100, 100) 95 AddShape(page, 12000, 100) 96 97 SelectableObj1 = page.getByIndex(0) 98 SelectableObj2 = page.getByIndex(1) 99Exit Sub 100ErrHndl: 101 Test.Exception() 102End Sub 103 104Sub DisposeObj() 105 oSecDoc.dispose() 106End Sub 107 108sub AddShape(oPage as Object, nPosX as Integer, nPosY as Integer) 109 Dim aPoint As New com.sun.star.awt.Point 110 Dim aSize As New com.sun.star.awt.Size 111 Dim oRectangleShape As Object 112 113 aPoint.x = nPosX 114 aPoint.y = nPosY 115 aSize.Width = 10000 116 aSize.Height = 10000 117 oRectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape") 118 oRectangleShape.Size = aSize 119 oRectangleShape.Position = aPoint 120 oRectangleShape.FillColor = RGB(255, 0, 0) 121 oPage.add(oRectangleShape) 122End Sub 123</script:module> 124