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_SdUnoPresView" 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 41' REQUIRED VARIABLES for interface/service tests: 42 43' Required for frame.XController 44Global oFrameToAttach As Object 45Global oModelToAttach As Object 46Global bHasNoViewData As Boolean 47Global oObjToSuspend As Object 48Global bHasNoModel As Boolean 49 50' Required for lang.XComponent 51Global oComponentInstance As Object 52 53' Required for frame.XDispatchProvider 54Global dispatchUrl As String 55 56' Required for drawing.XDrawView 57Global oPages As Variant 58 59' Required for awt.XWindow 60Global oXWindow As Object 61Global oCtrlShape as Object 62 63Global oSecDoc As Object 64 65 66Sub CreateObj() 67 68'************************************************************************* 69' COMPONENT: 70' sd.SdUnoPresView 71'************************************************************************* 72On Error Goto ErrHndl 73 Dim bOK As Boolean 74 Dim oDP As Object, oDP1 As Object 75 Dim oDPs As Object 76 bOK = true 77 78 oDoc = utils.createImpressDocument(cObjectName) 79 oSecDoc = utils.createImpressDocument(cObjectName+"1") 80 wait(500) 81 82 oDPs = oDoc.getDrawPages() 83 oDP = oDPs.getByIndex(0) 84 oDPs.insertNewByIndex(0) 85 oDP1 = oDPs.getByIndex(1) 86 87 addShape(oDP, 1000, 1000, "Rectangle") 88 addShape(oDP, 5000, 5000, "Ellipse") 89 90 oObj = oDoc.getCurrentController() 91 92 ' For XDrawPages 93 oPages = oDoc.getDrawPages() 94 95 ' For XComponent 96 oComponentInstance = oObj 97 98 ' For XDispatchProvider 99 dispatchUrl = "slot:27009" 100 101 ' For frame.XController 102 oFrameToAttach = StarDesktop.getCurrentFrame() 103 oModelToAttach = oSecDoc 104 bHasNoViewData = false 105 bHasNoModel = false 106 oObjToSuspend = oObj 107 108 ' For awt.XWindow 109 oXWindow = utils.at_getCurrentWindow(oSecDoc) 110 111Exit Sub 112ErrHndl: 113 Test.Exception() 114End Sub 115 116Sub DisposeObj() 117 oDoc.dispose() 118 oSecDoc.dispose() 119End Sub 120 121Sub addShape(oPage as Object, nPosX as Integer, nPosY as Integer, oType As String) 122 Dim aPoint As New com.sun.star.awt.Point 123 Dim aSize As New com.sun.star.awt.Size 124 Dim oRectangleShape As Object 125 126 aPoint.x = nPosX 127 aPoint.y = nPosY 128 aSize.Width = 2000 129 aSize.Height = 1000 130 oRectangleShape = oDoc.createInstance("com.sun.star.drawing."+oType+"Shape") 131 oRectangleShape.Size = aSize 132 oRectangleShape.Position = aPoint 133 oRectangleShape.FillColor = RGB(128, 255, 0) 134 oPage.add(oRectangleShape) 135End Sub 136 137</script:module> 138