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'  Licensed to the Apache Software Foundation (ASF) under one
9'  or more contributor license agreements.  See the NOTICE file
10'  distributed with this work for additional information
11'  regarding copyright ownership.  The ASF licenses this file
12'  to you under the Apache License, Version 2.0 (the
13'  "License"); you may not use this file except in compliance
14'  with the License.  You may obtain a copy of the License at
15'
16'    http://www.apache.org/licenses/LICENSE-2.0
17'
18'  Unless required by applicable law or agreed to in writing,
19'  software distributed under the License is distributed on an
20'  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21'  KIND, either express or implied.  See the License for the
22'  specific language governing permissions and limitations
23'  under the License.
24'
25'*************************************************************************
26
27
28
29
30
31' Be sure that all variables are dimensioned:
32option explicit
33
34
35' REQUIRED VARIABLES for interface/service tests:
36' Requiered for  com.sun.star.document.XFilter
37  Global oFilterDescriptor As Variant
38  Global pictureURL As String
39
40' Requiered for  com.sun.star.document.XExporter
41  Global oSrcDocument As Object
42
43
44Sub CreateObj()
45
46'*************************************************************************
47' COMPONENT:
48' svx.GraphicExporter
49'*************************************************************************
50On Error Goto ErrHndl
51
52    oDoc = utils.createDocument("sdraw", cObjectName)
53    oObj = createUnoService("com.sun.star.drawing.GraphicExportFilter")
54
55    Dim shape As Object
56    shape = oDoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
57    out.log("create com.sun.star.drawing.GraphicObjectShape : is NULL? " + IsNULL(shape))
58
59    Dim shapeSize As new com.sun.star.awt.Size
60    Dim shapePos As new com.sun.star.awt.Point
61    shapeSize.Width = 5000
62    shapeSize.Height = 5000
63    out.log("set size of shape : " + shapeSize.Width + ", " + shapeSize.Height)
64    shape.setSize(shapeSize)
65    shapePos.x = 1500
66    shapePos.y = 1000
67    out.log("set position of shape : " + shapePos.x + ", " + shapePos.y)
68    shape.setPosition(shapePos)
69    out.log("adds created shape")
70    oDoc.getDrawPages.getByIndex(0).add(shape)
71    out.log("set GraphicURL to " + utils.Path2URL(cTestDocsDir &amp; "space-metal.jpg") )
72    shape.GraphicURL = utils.Path2URL(cTestDocsDir &amp; "space-metal.jpg")
73    out.log("set shape as source document for created object")
74    oObj.setSourceDocument(shape)
75    oSrcDocument = shape
76
77    Dim _Filter(2) As New com.sun.star.beans.PropertyValue
78    _Filter(0).Name = "FilterName" : _Filter(0).Value = "JPG"
79    Dim url as new com.sun.star.util.URL
80    url.Complete = utils.getTempFileURL("picture.jpg", True)
81    pictureURL = url.Complete
82    out.log("URL descriptor : " + pictureURL)
83    _Filter(1).Name = "URL" : _Filter(1).Value = url
84    _Filter(2).Name = "MediaType" : _Filter(1).Value = "image/jpeg"
85    oFilterDescriptor = _Filter()
86
87Exit Sub
88ErrHndl:
89    Test.Exception()
90End Sub
91
92Function checkFilter() As Boolean
93    If IsNULL(soapi_test_hidewindows) Or soapi_test_hidewindows = True Then
94        out.log("all windows are hide")
95        checkFilter() = True
96    Else
97        Dim simpleFile As Object
98        simpleFile = createUnoService("com.sun.star.ucb.SimpleFileAccess")
99        out.log("creates com.sun.star.ucb.SimpleFileAccess : is NULL? " + IsNULL(SimpleFile))
100        checkFilter() = simpleFile.exists(pictureURL)
101        out.log("check existing of " + pictureURL + ": " + checkFilter)
102    EndIf
103End Function
104</script:module>
105