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 _OINPUTSTREAMCONTAINER_HXX_
25 #define _OINPUTSTREAMCONTAINER_HXX_
26 
27 #include <com/sun/star/io/XInputStream.hpp>
28 #include <com/sun/star/embed/XExtendedStorageStream.hpp>
29 #include <com/sun/star/io/XSeekable.hpp>
30 
31 
32 #include <cppuhelper/implbase2.hxx>
33 #include <cppuhelper/interfacecontainer.h>
34 
35 #include <osl/mutex.hxx>
36 
37 class OFSInputStreamContainer : public cppu::WeakImplHelper2 < ::com::sun::star::io::XInputStream
38 															,::com::sun::star::embed::XExtendedStorageStream >
39 							, public ::com::sun::star::io::XSeekable
40 {
41 protected:
42 	::osl::Mutex m_aMutex;
43 
44 	::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > m_xInputStream;
45 	::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > m_xSeekable;
46 
47 	sal_Bool m_bSeekable;
48 
49 	sal_Bool m_bDisposed;
50 
51 	::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
52 
53 public:
54 	OFSInputStreamContainer( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream );
55 
56 	virtual ~OFSInputStreamContainer();
57 
58     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
59 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw( ::com::sun::star::uno::RuntimeException );
60 	virtual void SAL_CALL acquire() throw();
61 	virtual void SAL_CALL release() throw();
62 
63 	// XInputStream
64     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
65 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
66     virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
67 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
68     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
69 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
70     virtual sal_Int32 SAL_CALL available(  )
71 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
72     virtual void SAL_CALL closeInput(  )
73 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
74 
75 	//XStream
76     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  ) throw (::com::sun::star::uno::RuntimeException);
77     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  ) throw (::com::sun::star::uno::RuntimeException);
78 
79 	//XSeekable
80     virtual void SAL_CALL seek( sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
81     virtual sal_Int64 SAL_CALL getPosition() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
82     virtual sal_Int64 SAL_CALL getLength() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
83 
84 	//XComponent
85     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
86     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
87     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
88 
89 };
90 
91 #endif
92 
93