xref: /AOO41X/main/svl/source/fsstor/ostreamcontainer.hxx (revision 39a19a47feaddbaa21988da8c7bf801707fd3d48)
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 _OSTREAMCONTAINER_HXX_
25 #define _OSTREAMCONTAINER_HXX_
26 
27 #include <com/sun/star/uno/XInterface.hpp>
28 #include <com/sun/star/lang/XTypeProvider.hpp>
29 #include <com/sun/star/embed/XExtendedStorageStream.hpp>
30 #include <com/sun/star/io/XSeekable.hpp>
31 #include <com/sun/star/io/XTruncate.hpp>
32 #include <com/sun/star/io/XInputStream.hpp>
33 #include <com/sun/star/io/XOutputStream.hpp>
34 #include <com/sun/star/io/XStream.hpp>
35 #include "com/sun/star/io/XAsyncOutputMonitor.hpp"
36 #include <cppuhelper/weak.hxx>
37 #include <cppuhelper/typeprovider.hxx>
38 #include <cppuhelper/interfacecontainer.h>
39 #include <osl/mutex.hxx>
40 
41 class OFSStreamContainer : public cppu::OWeakObject,
42                      public ::com::sun::star::lang::XTypeProvider,
43                      public ::com::sun::star::embed::XExtendedStorageStream,
44                      public ::com::sun::star::io::XSeekable,
45                      public ::com::sun::star::io::XInputStream,
46                      public ::com::sun::star::io::XOutputStream,
47                      public ::com::sun::star::io::XTruncate,
48                      public ::com::sun::star::io::XAsyncOutputMonitor
49 {
50     ::osl::Mutex m_aMutex;
51 
52     ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream >               m_xStream;
53     ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable >             m_xSeekable;
54     ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >          m_xInputStream;
55     ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream >         m_xOutputStream;
56     ::com::sun::star::uno::Reference< ::com::sun::star::io::XTruncate >             m_xTruncate;
57     ::com::sun::star::uno::Reference< ::com::sun::star::io::XAsyncOutputMonitor >   m_xAsyncOutputMonitor;
58 
59     sal_Bool m_bDisposed;
60     sal_Bool m_bInputClosed;
61     sal_Bool m_bOutputClosed;
62 
63     ::cppu::OInterfaceContainerHelper* m_pListenersContainer; // list of listeners
64     ::cppu::OTypeCollection* m_pTypeCollection;
65 
66 public:
67     OFSStreamContainer( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xStream );
68     virtual ~OFSStreamContainer();
69 
70     // XInterface
71     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType )
72         throw( ::com::sun::star::uno::RuntimeException );
73     virtual void SAL_CALL acquire() throw();
74     virtual void SAL_CALL release() throw();
75 
76     //  XTypeProvider
77     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
78         throw( ::com::sun::star::uno::RuntimeException );
79     virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId()
80         throw( ::com::sun::star::uno::RuntimeException );
81 
82     // XStream
83     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  ) throw (::com::sun::star::uno::RuntimeException);
84     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  ) throw (::com::sun::star::uno::RuntimeException);
85 
86     // XComponent
87     virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
88     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
89     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
90 
91     // XSeekable
92     virtual void SAL_CALL seek( sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
93     virtual sal_Int64 SAL_CALL getPosition() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
94     virtual sal_Int64 SAL_CALL getLength() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
95 
96     // XInputStream
97     virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
98         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
99     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);
100     virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip )
101         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
102     virtual sal_Int32 SAL_CALL available(  )
103         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
104     virtual void SAL_CALL closeInput(  )
105         throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
106 
107     // XOutputStream
108     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);
109     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);
110     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);
111 
112     // XTruncate
113     virtual void SAL_CALL truncate() throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
114 
115     // XAsyncOutputMonitor
116     virtual void SAL_CALL waitForCompletion(  ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
117 
118 };
119 
120 #endif
121 
122