1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ostreamcontainer.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _OSTREAMCONTAINER_HXX_
32 #define _OSTREAMCONTAINER_HXX_
34 #include <com/sun/star/uno/XInterface.hpp>
35 #include <com/sun/star/lang/XTypeProvider.hpp>
36 #include <com/sun/star/embed/XExtendedStorageStream.hpp>
37 #include <com/sun/star/io/XSeekable.hpp>
38 #include <com/sun/star/io/XTruncate.hpp>
39 #include <com/sun/star/io/XInputStream.hpp>
40 #include <com/sun/star/io/XOutputStream.hpp>
41 #include <com/sun/star/io/XStream.hpp>
42 #include "com/sun/star/io/XAsyncOutputMonitor.hpp"
43 #include <cppuhelper/weak.hxx>
44 #include <cppuhelper/typeprovider.hxx>
45 #include <cppuhelper/interfacecontainer.h>
46 #include <osl/mutex.hxx>
48 class OFSStreamContainer
: public cppu::OWeakObject
,
49 public ::com::sun::star::lang::XTypeProvider
,
50 public ::com::sun::star::embed::XExtendedStorageStream
,
51 public ::com::sun::star::io::XSeekable
,
52 public ::com::sun::star::io::XInputStream
,
53 public ::com::sun::star::io::XOutputStream
,
54 public ::com::sun::star::io::XTruncate
,
55 public ::com::sun::star::io::XAsyncOutputMonitor
57 ::osl::Mutex m_aMutex
;
59 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XStream
> m_xStream
;
60 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XSeekable
> m_xSeekable
;
61 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> m_xInputStream
;
62 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
> m_xOutputStream
;
63 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XTruncate
> m_xTruncate
;
64 ::com::sun::star::uno::Reference
< ::com::sun::star::io::XAsyncOutputMonitor
> m_xAsyncOutputMonitor
;
67 sal_Bool m_bInputClosed
;
68 sal_Bool m_bOutputClosed
;
70 ::cppu::OInterfaceContainerHelper
* m_pListenersContainer
; // list of listeners
71 ::cppu::OTypeCollection
* m_pTypeCollection
;
74 OFSStreamContainer( const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XStream
>& xStream
);
75 virtual ~OFSStreamContainer();
78 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& rType
)
79 throw( ::com::sun::star::uno::RuntimeException
);
80 virtual void SAL_CALL
acquire() throw();
81 virtual void SAL_CALL
release() throw();
84 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Type
> SAL_CALL
getTypes()
85 throw( ::com::sun::star::uno::RuntimeException
);
86 virtual ::com::sun::star::uno::Sequence
< sal_Int8
> SAL_CALL
getImplementationId()
87 throw( ::com::sun::star::uno::RuntimeException
);
90 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> SAL_CALL
getInputStream( ) throw (::com::sun::star::uno::RuntimeException
);
91 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::io::XOutputStream
> SAL_CALL
getOutputStream( ) throw (::com::sun::star::uno::RuntimeException
);
94 virtual void SAL_CALL
dispose() throw (::com::sun::star::uno::RuntimeException
);
95 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
96 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
99 virtual void SAL_CALL
seek( sal_Int64 location
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
100 virtual sal_Int64 SAL_CALL
getPosition() throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
101 virtual sal_Int64 SAL_CALL
getLength() throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
104 virtual sal_Int32 SAL_CALL
readBytes( ::com::sun::star::uno::Sequence
< sal_Int8
>& aData
, sal_Int32 nBytesToRead
)
105 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
106 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
);
107 virtual void SAL_CALL
skipBytes( sal_Int32 nBytesToSkip
)
108 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::BufferSizeExceededException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
109 virtual sal_Int32 SAL_CALL
available( )
110 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
111 virtual void SAL_CALL
closeInput( )
112 throw(::com::sun::star::io::NotConnectedException
, ::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
115 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
);
116 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
);
117 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
);
120 virtual void SAL_CALL
truncate() throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);
122 // XAsyncOutputMonitor
123 virtual void SAL_CALL
waitForCompletion( ) throw (::com::sun::star::io::IOException
, ::com::sun::star::uno::RuntimeException
);