1*39a19a47SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*39a19a47SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*39a19a47SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*39a19a47SAndrew Rist  * distributed with this work for additional information
6*39a19a47SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*39a19a47SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*39a19a47SAndrew Rist  * "License"); you may not use this file except in compliance
9*39a19a47SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*39a19a47SAndrew Rist  *
11*39a19a47SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*39a19a47SAndrew Rist  *
13*39a19a47SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*39a19a47SAndrew Rist  * software distributed under the License is distributed on an
15*39a19a47SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*39a19a47SAndrew Rist  * KIND, either express or implied.  See the License for the
17*39a19a47SAndrew Rist  * specific language governing permissions and limitations
18*39a19a47SAndrew Rist  * under the License.
19*39a19a47SAndrew Rist  *
20*39a19a47SAndrew Rist  *************************************************************/
21*39a19a47SAndrew Rist 
22*39a19a47SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _OSTREAMCONTAINER_HXX_
25cdf0e10cSrcweir #define _OSTREAMCONTAINER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp>
28cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp>
29cdf0e10cSrcweir #include <com/sun/star/embed/XExtendedStorageStream.hpp>
30cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp>
31cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp>
32cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp>
33cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
34cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp>
35cdf0e10cSrcweir #include "com/sun/star/io/XAsyncOutputMonitor.hpp"
36cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
37cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
38cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>
39cdf0e10cSrcweir #include <osl/mutex.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir class OFSStreamContainer : public cppu::OWeakObject,
42cdf0e10cSrcweir 					 public ::com::sun::star::lang::XTypeProvider,
43cdf0e10cSrcweir 					 public ::com::sun::star::embed::XExtendedStorageStream,
44cdf0e10cSrcweir 					 public ::com::sun::star::io::XSeekable,
45cdf0e10cSrcweir 					 public ::com::sun::star::io::XInputStream,
46cdf0e10cSrcweir 					 public ::com::sun::star::io::XOutputStream,
47cdf0e10cSrcweir 					 public ::com::sun::star::io::XTruncate,
48cdf0e10cSrcweir 					 public ::com::sun::star::io::XAsyncOutputMonitor
49cdf0e10cSrcweir {
50cdf0e10cSrcweir 	::osl::Mutex m_aMutex;
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >				m_xStream;
53cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable >				m_xSeekable;
54cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >			m_xInputStream;
55cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >			m_xOutputStream;
56cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XTruncate >				m_xTruncate;
57cdf0e10cSrcweir 	::com::sun::star::uno::Reference< ::com::sun::star::io::XAsyncOutputMonitor >	m_xAsyncOutputMonitor;
58cdf0e10cSrcweir 
59cdf0e10cSrcweir 	sal_Bool m_bDisposed;
60cdf0e10cSrcweir 	sal_Bool m_bInputClosed;
61cdf0e10cSrcweir 	sal_Bool m_bOutputClosed;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 	::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
64cdf0e10cSrcweir 	::cppu::OTypeCollection* m_pTypeCollection;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir public:
67cdf0e10cSrcweir 	OFSStreamContainer( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream );
68cdf0e10cSrcweir 	virtual ~OFSStreamContainer();
69cdf0e10cSrcweir 
70cdf0e10cSrcweir 	// XInterface
71cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
72cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
73cdf0e10cSrcweir 	virtual void SAL_CALL acquire() throw();
74cdf0e10cSrcweir 	virtual void SAL_CALL release() throw();
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 	//	XTypeProvider
77cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
78cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
79cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
80cdf0e10cSrcweir 		throw( ::com::sun::star::uno::RuntimeException );
81cdf0e10cSrcweir 
82cdf0e10cSrcweir 	// XStream
83cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  ) throw (::com::sun::star::uno::RuntimeException);
84cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  ) throw (::com::sun::star::uno::RuntimeException);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	// XComponent
87cdf0e10cSrcweir     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
88cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
89cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 	// XSeekable
92cdf0e10cSrcweir     virtual void SAL_CALL seek( sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
93cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getPosition() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
94cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getLength() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 	// XInputStream
97cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
98cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir     virtual 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);
100cdf0e10cSrcweir     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
101cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
102cdf0e10cSrcweir     virtual sal_Int32 SAL_CALL available(  )
103cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
104cdf0e10cSrcweir     virtual void SAL_CALL closeInput(  )
105cdf0e10cSrcweir 		throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 	// XOutputStream
108cdf0e10cSrcweir     virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
109cdf0e10cSrcweir     virtual void SAL_CALL flush(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir     virtual void SAL_CALL closeOutput(  ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
111cdf0e10cSrcweir 
112cdf0e10cSrcweir 	// XTruncate
113cdf0e10cSrcweir     virtual void SAL_CALL truncate() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	// XAsyncOutputMonitor
116cdf0e10cSrcweir     virtual void SAL_CALL waitForCompletion(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir 
118cdf0e10cSrcweir };
119cdf0e10cSrcweir 
120cdf0e10cSrcweir #endif
121cdf0e10cSrcweir 
122