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="datatransfer_XDataFormatTranslator" 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
32
33Sub RunTest()
34
35'*************************************************************************
36' INTERFACE:
37' com.sun.star.datatransfer.XDataFormatTranslator
38'*************************************************************************
39On Error Goto ErrHndl
40    Dim bOK As Boolean
41    Dim dataFlavor As new com.sun.star.datatransfer.DataFlavor
42    Dim oCoreRefl As Object
43    Dim sysDataType As Variant
44    Dim sysDataFlavour As Variant
45
46    oCoreRefl = createUNOService("com.sun.star.reflection.CoreReflection")
47
48    Test.StartMethod("getSystemDataTypeFromDataFlavor()")
49    bOK = true
50    dataFlavor.MimeType = "text/plain"
51    dataFlavor.HumanPresentableName = "MyDataFlavor"
52
53    sysDataType = oObj.getSystemDataTypeFromDataFlavor(dataFlavor)
54
55    bOK = bOK AND NOT isNULL(sysDataType)
56    bOK = bOK AND NOT isEmpty(sysDataType)
57
58    if (bOK) then
59        Out.Log("Type of SystemDataType is: " &amp; oCoreRefl.getType(sysDataType).Name)
60    else
61        Out.Log("Can't get system data type.")
62    end if
63
64    Test.MethodTested("getSystemDataTypeFromDataFlavor()", bOK)
65
66    Test.StartMethod("getDataFlavorFromSystemDataType()")
67    if (NOT bOK) then
68        Out.Log("Can't test getDataFlavorFromSystemDataType() without getSystemDataTypeFromDataFlavor()")
69    else
70        sysDataFlavour = oObj.getDataFlavorFromSystemDataType(sysDataType)
71
72        bOK = bOK AND NOT isNULL(sysDataFlavour)
73        bOK = bOK AND NOT isEmpty(sysDataFlavour)
74
75        if (bOK) then
76            Out.Log("Type of DataFlavor is: " &amp; oCoreRefl.getType(sysDataFlavour).Name)
77            bOK = bOK AND oCoreRefl.getType(sysDataFlavour).Name = "com.sun.star.datatransfer.DataFlavor"
78        else
79            Out.Log("Can't get data flavor.")
80        end if
81        Test.MethodTested("getDataFlavorFromSystemDataType()", bOK)
82    end if
83
84Exit Sub
85ErrHndl:
86    Test.Exception()
87    bOK = false
88    resume next
89End Sub
90</script:module>
91