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