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="ucb_XDataContainer" 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
41Sub RunTest()
42
43'*************************************************************************
44' INTERFACE:
45' com.sun.star.ucb.XDataContainer
46'*************************************************************************
47On Error Goto ErrHndl
48    Dim bOK As Boolean
49    Dim i As Integer
50
51
52    Test.StartMethod("setContentType()")
53    Test.StartMethod("getContentType()")
54
55    Dim aContType As String
56    Dim objContType As String
57    Dim newContType As String
58
59    bOK = true
60    aContType = oObj.getContentType()
61    Out.Log("Current content type is: '" + aContType + "'")
62    newContType = "text/html"
63
64    if (newContType = aContType) then
65        newContType = "text/plain"
66    end if
67
68    Out.Log("Trying to change type to " + newContType)
69    oObj.setContentType(newContType)
70
71    objContType = oObj.getContentType()
72    Out.Log("Actual content type is: '" + objContType + "'")
73    bOK = bOK AND objContType = newContType
74    Out.Log("Change type back to original...")
75    oObj.setContentType(aContType)
76
77    Test.MethodTested("getContentType()", bOK)
78    Test.MethodTested("setContentType()", bOK)
79
80
81    Test.StartMethod("getData()")
82    bOK = true
83
84    Dim Data As Variant
85
86    Data = oObj.getData()
87    Out.Log("getData returned array with ubound = " + ubound(Data))
88    bOK = bOK AND ubound(Data) &gt;= -1
89    for i  = 0 to ubound(Data)
90        Out.Log("" + Data(i) + " " + chr(Data(i)))
91    next i
92    Test.MethodTested("getData()", bOK)
93
94    Test.StartMethod("setData()")
95    bOK = true
96
97    Dim DataToSet As Variant
98    DataToSet = DimArray(ubound(Data()))
99
100    for i = 0 to ubound(DataToSet())
101        DataToSet(i) = Data(i) + 1
102    next i
103
104    oObj.setData(DataToSet)
105    Data = oObj.getData()
106    Out.Log("after setData() call: getData returned array with ubound = " + ubound(Data))
107    bOK = bOK AND (ubound(Data) = ubound(DataToSet))
108    if (bOK) then
109        for i  = 0 to ubound(Data)
110            Out.Log("" + Data(i) + " " + chr(Data(i)))
111            bOK = bOK AND (DataToSet(i) = Data(i))
112        next i
113    end if
114
115    Test.MethodTested("setData()", bOK)
116
117    Test.StartMethod("getDataURL()")
118    Test.StartMethod("setDataURL()")
119
120
121    Dim aDataURL As String
122    Dim objDataURL As String
123    Dim newDataURL As String
124
125    bOK = true
126    aDataURL = oObj.getDataURL()
127    Out.Log("Current data URL is: '" + aDataURL + "'")
128    newDataURL = "http://www.sun.com"
129    if (newDataURL = aDataURL) then
130        newDataURL = "http://www.openoffice.org"
131    end if
132
133    Out.Log("Trying to change data URL to " + newDataURL)
134    oObj.setDataURL(newDataURL)
135
136    objDataURL = oObj.getDataURL()
137    Out.Log("Actual data URL is: '" + objDataURL + "'")
138    bOK = bOK AND objDataURL = newDataURL
139    Out.Log("Change data URL back to original...")
140    oObj.setDataURL(aDataURL)
141
142    Out.Log("Methods getDataURL() and setDataURL() are DEPRICATED. The result of test is ALWAYS true!")
143
144    bOK = true
145
146    Test.MethodTested("getDataURL()", bOK)
147    Test.MethodTested("setDataURL()", bOK)
148
149Exit Sub
150ErrHndl:
151    Test.Exception()
152    bOK = false
153    resume next
154End Sub
155</script:module>
156