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