1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _TOOLKIT_HELPER_UNOMEMORYSTREAM_HXX_ 25 #define _TOOLKIT_HELPER_UNOMEMORYSTREAM_HXX_ 26 27 28 #include <com/sun/star/io/XInputStream.hpp> 29 #include <cppuhelper/weak.hxx> 30 #include <osl/mutex.hxx> 31 32 #include <tools/stream.hxx> 33 34 // ---------------------------------------------------- 35 // class UNOMEMORYSTREAM 36 // ---------------------------------------------------- 37 38 class UnoMemoryStream : public SvMemoryStream, 39 public ::com::sun::star::io::XInputStream, 40 public ::cppu::OWeakObject 41 { 42 private: 43 ::osl::Mutex maMutex; 44 45 protected: GetMutex()46 ::osl::Mutex& GetMutex() { return maMutex; } 47 48 49 public: 50 UnoMemoryStream( sal_uInt32 nInitSize = 0x3FFF, sal_uInt32 nResize = 0x3FFFF ); 51 52 // ::com::sun::star::uno::XInterface 53 ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException); acquire()54 void SAL_CALL acquire() throw() { OWeakObject::acquire(); } release()55 void SAL_CALL release() throw() { OWeakObject::release(); } 56 57 // ::com::sun::star::io::XInputStream 58 sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 59 sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 60 void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 61 sal_Int32 SAL_CALL available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 62 void SAL_CALL closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 63 }; 64 65 66 67 68 #endif // _TOOLKIT_HELPER_UNOMEMORYSTREAM_HXX_ 69 70