1*9877b273SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9877b273SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9877b273SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9877b273SAndrew Rist * distributed with this work for additional information 6*9877b273SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9877b273SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9877b273SAndrew Rist * "License"); you may not use this file except in compliance 9*9877b273SAndrew Rist * with the License. You may obtain a copy of the License at 10*9877b273SAndrew Rist * 11*9877b273SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*9877b273SAndrew Rist * 13*9877b273SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9877b273SAndrew Rist * software distributed under the License is distributed on an 15*9877b273SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9877b273SAndrew Rist * KIND, either express or implied. See the License for the 17*9877b273SAndrew Rist * specific language governing permissions and limitations 18*9877b273SAndrew Rist * under the License. 19*9877b273SAndrew Rist * 20*9877b273SAndrew Rist *************************************************************/ 21*9877b273SAndrew Rist 22*9877b273SAndrew Rist 23cdf0e10cSrcweir #ifndef _COMPHELPER_STREAM_OSLFILEWRAPPER_HXX_ 24cdf0e10cSrcweir #define _COMPHELPER_STREAM_OSLFILEWRAPPER_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <osl/mutex.hxx> 27cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 28cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 29cdf0e10cSrcweir #include <cppuhelper/implbase1.hxx> 30cdf0e10cSrcweir #include <osl/file.hxx> 31cdf0e10cSrcweir #include "comphelper/comphelperdllapi.h" 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace comphelper 34cdf0e10cSrcweir { 35cdf0e10cSrcweir namespace stario = ::com::sun::star::io; 36cdf0e10cSrcweir namespace staruno = ::com::sun::star::uno; 37cdf0e10cSrcweir 38cdf0e10cSrcweir //================================================================== 39cdf0e10cSrcweir // FmUnoIOStream, 40cdf0e10cSrcweir // stream zum schreiben un lesen von Daten, basieren auf File 41cdf0e10cSrcweir //================================================================== 42cdf0e10cSrcweir struct InputStreamWrapper_Base : public ::cppu::WeakImplHelper1<stario::XInputStream> 43cdf0e10cSrcweir {}; 44cdf0e10cSrcweir 45cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OSLInputStreamWrapper : public InputStreamWrapper_Base 46cdf0e10cSrcweir { 47cdf0e10cSrcweir ::osl::Mutex m_aMutex; 48cdf0e10cSrcweir ::osl::File* m_pFile; 49cdf0e10cSrcweir sal_Bool m_bFileOwner : 1; 50cdf0e10cSrcweir 51cdf0e10cSrcweir public: 52cdf0e10cSrcweir OSLInputStreamWrapper(::osl::File& _rStream); 53cdf0e10cSrcweir OSLInputStreamWrapper(::osl::File* pStream, sal_Bool bOwner=sal_False); 54cdf0e10cSrcweir virtual ~OSLInputStreamWrapper(); 55cdf0e10cSrcweir 56cdf0e10cSrcweir // stario::XInputStream 57cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); 58cdf0e10cSrcweir virtual sal_Int32 SAL_CALL readSomeBytes(staruno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); 59cdf0e10cSrcweir virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); 60cdf0e10cSrcweir virtual sal_Int32 SAL_CALL available() throw(stario::NotConnectedException, staruno::RuntimeException); 61cdf0e10cSrcweir virtual void SAL_CALL closeInput() throw(stario::NotConnectedException, staruno::RuntimeException); 62cdf0e10cSrcweir }; 63cdf0e10cSrcweir 64cdf0e10cSrcweir //================================================================== 65cdf0e10cSrcweir // FmUnoOutStream, 66cdf0e10cSrcweir // Datensenke fuer Files 67cdf0e10cSrcweir //================================================================== 68cdf0e10cSrcweir struct OutputStreamWrapper_Base : public ::cppu::WeakImplHelper1<stario::XOutputStream> 69cdf0e10cSrcweir {}; 70cdf0e10cSrcweir 71cdf0e10cSrcweir class COMPHELPER_DLLPUBLIC OSLOutputStreamWrapper : public OutputStreamWrapper_Base 72cdf0e10cSrcweir { 73cdf0e10cSrcweir ::osl::File& rFile; 74cdf0e10cSrcweir 75cdf0e10cSrcweir public: OSLOutputStreamWrapper(::osl::File & _rFile)76cdf0e10cSrcweir OSLOutputStreamWrapper(::osl::File& _rFile) :rFile(_rFile) { } 77cdf0e10cSrcweir 78cdf0e10cSrcweir // stario::XOutputStream 79cdf0e10cSrcweir virtual void SAL_CALL writeBytes(const staruno::Sequence< sal_Int8 >& aData) throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); 80cdf0e10cSrcweir virtual void SAL_CALL flush() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); 81cdf0e10cSrcweir virtual void SAL_CALL closeOutput() throw(stario::NotConnectedException, stario::BufferSizeExceededException, staruno::RuntimeException); 82cdf0e10cSrcweir }; 83cdf0e10cSrcweir 84cdf0e10cSrcweir } // namespace comphelper 85cdf0e10cSrcweir 86cdf0e10cSrcweir 87cdf0e10cSrcweir #endif // _COMPHELPER_STREAM_OSLFILEWRAPPER_HXX_ 88cdf0e10cSrcweir 89