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