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="stm_MarkableOutputStream" 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: 36Global cFileName As String 37Global oFileAcc As Object 38Global oInputStream As Object 39Global oOutputStream As Object 40Global bInputStream As Boolean 41Global bOutputStream As Boolean 42 43 44Sub CreateObj() 45 46'************************************************************************* 47' COMPONENT: 48' stm.MarkableOutputStream 49'************************************************************************* 50On Error Goto ErrHndl 51 52 bInputStream = false 53 bOutputStream = false 54 cFileName = utils.getTempFileURL("BasicMarkableIOStream.dat") 55 oFileAcc = createUnoService("com.sun.star.ucb.SimpleFileAccess") 56 57 oObj = createUnoService("com.sun.star.io.MarkableOutputStream") 58 59 ResetStreams() 60Exit Sub 61ErrHndl: 62 Test.Exception() 63End Sub 64 65Function getOutStream() As Object 66On Error Goto ErrHndl 67 CloseStreams() 68 oOutputStream = oFileAcc.openFileWrite(cFileName) 69 bOutputStream = true 70 oObj.setOutputStream(oOutputStream) 71 getOutStream() = oOutputStream 72Exit Function 73ErrHndl: 74 Test.Exception() 75 getOutStream() = NULL_OBJECT 76End Function 77 78Function getInStream() As Object 79On Error Goto ErrHndl 80 Dim oFI As Object 81 82 CloseStreams() 83 oInputStream = createUnoService("com.sun.star.io.MarkableInputStream") 84 oFI = oFileAcc.openFileRead(cFileName) 85 oInputStream.setInputStream(oFI) 86 bInputStream = true 87 getInStream() = oInputStream 88 89Exit Function 90ErrHndl: 91 Test.Exception() 92 getInStream() = NULL_OBJECT 93End Function 94 95Sub ResetStreams() 96On Error goto ErrHndl 97 CloseStreams() 98 oFileAcc.Kill(cFileName) 99 oOutputStream = oFileAcc.openFileWrite(cFileName) 100 bOutputStream = true 101 oObj.setOutputStream(oOutputStream) 102Exit Sub 103ErrHndl: 104 Test.Exception() 105 resume next 106End Sub 107 108Sub CloseStreams() 109 if bOutputStream then 110 oObj.closeOutput() 111 bOutputStream = false 112 end if 113 if bInputStream then 114 oInputStream.closeInput() 115 bInputStream = false 116 end if 117End Sub 118 119Sub DisposeObj() 120 if NOT isNULL(oObj) then oObj.closeOutput() 121End Sub 122</script:module> 123