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 ODMA_INPUTSTREAM_HXX 25 #define ODMA_INPUTSTREAM_HXX 26 27 #include <osl/mutex.hxx> 28 #include <com/sun/star/io/XInputStream.hpp> 29 #include <com/sun/star/io/XStream.hpp> 30 #include <com/sun/star/io/XOutputStream.hpp> 31 #include <com/sun/star/io/XTruncate.hpp> 32 #include <com/sun/star/io/XSeekable.hpp> 33 #include <cppuhelper/implbase5.hxx> 34 35 #include "rtl/ref.hxx" 36 37 namespace ucbhelper 38 { 39 class Content; 40 } 41 namespace odma 42 { 43 typedef ::cppu::WeakImplHelper5< ::com::sun::star::io::XInputStream, 44 ::com::sun::star::io::XStream, 45 ::com::sun::star::io::XTruncate, 46 ::com::sun::star::io::XSeekable, 47 ::com::sun::star::io::XOutputStream> OOdmaStreamBase; 48 49 class ContentProvider; 50 class ContentProperties; 51 class OOdmaStream : public OOdmaStreamBase 52 { 53 ::osl::Mutex m_aMutex; 54 ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream> m_xOutput; 55 ::com::sun::star::uno::Reference< ::com::sun::star::io::XTruncate> m_xTruncate; 56 ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream> m_xInput; 57 ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable> m_xInputSeek; 58 59 ::rtl::Reference<ContentProperties> m_aProp; 60 ::ucbhelper::Content* m_pContent; 61 ContentProvider* m_pProvider; 62 sal_Bool m_bInputStreamCalled; 63 sal_Bool m_bOutputStreamCalled; 64 sal_Bool m_bModified; 65 66 void ensureInputStream(); 67 void ensureOutputStream(); 68 void SAL_CALL closeStream(); 69 public: 70 OOdmaStream(::ucbhelper::Content* _pContent, 71 ContentProvider* _pProvider, 72 const ::rtl::Reference<ContentProperties>& _rProp); 73 virtual ~OOdmaStream(); 74 // com::sun::star::io::XInputStream 75 virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence<sal_Int8>& aData, sal_Int32 nBytesToRead ); 76 77 virtual sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence<sal_Int8>& aData, sal_Int32 nMaxBytesToRead ); 78 79 virtual void SAL_CALL skipBytes( sal_Int32 nBytesToSkip ); 80 81 virtual sal_Int32 SAL_CALL available( ); 82 83 virtual void SAL_CALL closeInput( ); 84 85 // com::sun::star::io::XStream 86 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL getInputStream( ); 87 virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ); 88 89 // com::sun::star::io::XOutputStream 90 void SAL_CALL writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData ); 91 92 void SAL_CALL flush(); 93 void SAL_CALL closeOutput(); 94 // XTruncate 95 virtual void SAL_CALL truncate( void ); 96 // XSeekable 97 void SAL_CALL seek(sal_Int64 location ); 98 99 sal_Int64 SAL_CALL getPosition(); 100 101 sal_Int64 SAL_CALL getLength(); 102 }; 103 } 104 #endif // ODMA_INPUTSTREAM_HXX 105