1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _OINPUTSTREAMCONTAINER_HXX_
29 #define _OINPUTSTREAMCONTAINER_HXX_
30 
31 #include <com/sun/star/io/XInputStream.hpp>
32 #include <com/sun/star/embed/XExtendedStorageStream.hpp>
33 #include <com/sun/star/io/XSeekable.hpp>
34 
35 
36 #include <cppuhelper/implbase2.hxx>
37 #include <cppuhelper/interfacecontainer.h>
38 
39 #include <osl/mutex.hxx>
40 
41 class OFSInputStreamContainer : public cppu::WeakImplHelper2 < ::com::sun::star::io::XInputStream
42 															,::com::sun::star::embed::XExtendedStorageStream >
43 							, public ::com::sun::star::io::XSeekable
44 {
45 protected:
46 	::osl::Mutex m_aMutex;
47 
48 	::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > m_xInputStream;
49 	::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > m_xSeekable;
50 
51 	sal_Bool m_bSeekable;
52 
53 	sal_Bool m_bDisposed;
54 
55 	::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
56 
57 public:
58 	OFSInputStreamContainer( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xStream );
59 
60 	virtual ~OFSInputStreamContainer();
61 
62     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException);
63 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ) throw( ::com::sun::star::uno::RuntimeException );
64 	virtual void SAL_CALL acquire() throw();
65 	virtual void SAL_CALL release() throw();
66 
67 	// XInputStream
68     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
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 readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead )
71 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
72     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
73 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
74     virtual sal_Int32 SAL_CALL available(  )
75 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
76     virtual void SAL_CALL closeInput(  )
77 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
78 
79 	//XStream
80     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  ) throw (::com::sun::star::uno::RuntimeException);
81     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  ) throw (::com::sun::star::uno::RuntimeException);
82 
83 	//XSeekable
84     virtual void SAL_CALL seek( sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
85     virtual sal_Int64 SAL_CALL getPosition() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
86     virtual sal_Int64 SAL_CALL getLength() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
87 
88 	//XComponent
89     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
90     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
91     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
92 
93 };
94 
95 #endif
96 
97