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="svx_GraphicExporter" 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' Requiered for  com.sun.star.document.XFilter
42  Global oFilterDescriptor As Variant
43  Global pictureURL As String
44
45' Requiered for  com.sun.star.document.XExporter
46  Global oSrcDocument As Object
47
48
49Sub CreateObj()
50
51'*************************************************************************
52' COMPONENT:
53' svx.GraphicExporter
54'*************************************************************************
55On Error Goto ErrHndl
56
57    oDoc = utils.createDocument("sdraw", cObjectName)
58    oObj = createUnoService("com.sun.star.drawing.GraphicExportFilter")
59
60    Dim shape As Object
61    shape = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
62    out.log("create com.sun.star.drawing.GraphicObjectShape : is NULL? " + IsNULL(shape))
63
64    Dim shapeSize As new com.sun.star.awt.Size
65    Dim shapePos As new com.sun.star.awt.Point
66    shapeSize.Width = 5000
67    shapeSize.Height = 5000
68    out.log("set size of shape : " + shapeSize.Width + ", " + shapeSize.Height)
69    shape.setSize(shapeSize)
70    shapePos.x = 1500
71    shapePos.y = 1000
72    out.log("set position of shape : " + shapePos.x + ", " + shapePos.y)
73    shape.setPosition(shapePos)
74    out.log("adds created shape")
75    oDoc.getDrawPages.getByIndex(0).add(shape)
76    out.log("set GraphicURL to " + utils.Path2URL(cTestDocsDir &amp; "space-metal.jpg") )
77    shape.GraphicURL = utils.Path2URL(cTestDocsDir &amp; "space-metal.jpg")
78    out.log("set shape as source document for created object")
79    oObj.setSourceDocument(shape)
80    oSrcDocument = shape
81
82    Dim _Filter(2) As New com.sun.star.beans.PropertyValue
83    _Filter(0).Name = "FilterName" : _Filter(0).Value = "JPG"
84    Dim url as new com.sun.star.util.URL
85    url.Complete = utils.getTempFileURL("picture.jpg", True)
86    pictureURL = url.Complete
87    out.log("URL descriptor : " + pictureURL)
88    _Filter(1).Name = "URL" : _Filter(1).Value = url
89    _Filter(2).Name = "MediaType" : _Filter(1).Value = "image/jpeg"
90    oFilterDescriptor = _Filter()
91
92Exit Sub
93ErrHndl:
94    Test.Exception()
95End Sub
96
97Function checkFilter() As Boolean
98    If IsNULL(soapi_test_hidewindows) Or soapi_test_hidewindows = True Then
99        out.log("all windows are hide")
100        checkFilter() = True
101    Else
102        Dim simpleFile As Object
103        simpleFile = createUnoService("com.sun.star.ucb.SimpleFileAccess")
104        out.log("creates com.sun.star.ucb.SimpleFileAccess : is NULL? " + IsNULL(SimpleFile))
105        checkFilter() = simpleFile.exists(pictureURL)
106        out.log("check existing of " + pictureURL + ": " + checkFilter)
107    EndIf
108End Function
109</script:module>
110