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_SdXImpressDocument" 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' Requiered for  com.sun.star.lang.XMultiServiceFactory
43  Global cServiceName As String ' ex. "com.sun.star.drawing.RectangleShape"
44  Global bCreateInstanceWithoutArguments As Boolean
45  Global aArguments() As Variant
46
47' Requiered for  com.sun.star.drawing.XDrawPageDuplicator
48  Global oCollection As Object ' = oDoc.DrawPages(0)
49
50' com.sun.star.frame.XModel
51  Global oXModelController as Object
52  Global oXModelSel as Object
53  Global oXModelToSel as Object
54
55
56  Global oComponentInstance As Object
57Sub CreateObj()
58
59'*************************************************************************
60' COMPONENT:
61' sd.SdXImpressDocument
62'*************************************************************************
63On Error Goto ErrHndl
64    Dim oControllerDoc as Object
65    Dim oRectangleShape as Object
66    Dim oPage as Object
67
68    oDoc = utils.createImpressDocument(cObjectName)
69    oControllerDoc = utils.createImpressDocument(cObjectName + "XModel")
70    oComponentInstance = utils.createImpressDocument(cObjectName + "XComponent")
71
72    oCollection = oDoc.DrawPages(0)
73    oObj = oDoc
74
75    cServiceName = "com.sun.star.drawing.RectangleShape"
76    bCreateInstanceWithoutArguments = true
77    aArguments() = noargs()
78
79    oRectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape")
80    oPage = oDoc.getDrawPages().getByIndex(0)
81    oPage.add(oRectangleShape)
82
83    oXModelToSel = oRectangleShape
84    oXModelController = oControllerDoc.getCurrentController()
85    oXModelSel = oDoc.getCurrentController()
86
87Exit Sub
88ErrHndl:
89    Test.Exception()
90End Sub
91
92Sub DisposeObj()
93    if NOT isNULL(oComponentInstance) then oComponentInstance.dispose()
94
95    ' To successfully dispose oControllerDoc re-open it first.
96    Dim oControllerDoc As Object
97    oControllerDoc = utils.createDocument(cObjectName + "XModel")
98    oControllerDoc.dispose()
99End Sub
100</script:module>
101