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(); 59 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& rType ); 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 virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ); 66 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ); 67 virtual sal_Int32 SAL_CALL available( ); 68 virtual void SAL_CALL closeInput( ); 69 70 //XStream 71 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ); 72 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ); 73 74 //XSeekable 75 virtual void SAL_CALL seek( sal_Int64 location ); 76 virtual sal_Int64 SAL_CALL getPosition(); 77 virtual sal_Int64 SAL_CALL getLength(); 78 79 //XComponent 80 virtual void SAL_CALL dispose(); 81 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ); 82 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ); 83 84 }; 85 86 #endif 87