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 SVTOOLS_STRMADPT_HXX 25cdf0e10cSrcweir #define SVTOOLS_STRMADPT_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svl/svldllapi.h" 28cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 29cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 30cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp> 31cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 32cdf0e10cSrcweir #include <tools/stream.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir //============================================================================ 35cdf0e10cSrcweir class SVL_DLLPUBLIC SvOutputStreamOpenLockBytes: public SvOpenLockBytes 36cdf0e10cSrcweir { 37cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > 38cdf0e10cSrcweir m_xOutputStream; 39cdf0e10cSrcweir sal_uInt32 m_nPosition; 40cdf0e10cSrcweir 41cdf0e10cSrcweir public: 42cdf0e10cSrcweir TYPEINFO(); 43cdf0e10cSrcweir SvOutputStreamOpenLockBytes(const com::sun::star::uno::Reference<com::sun::star::io::XOutputStream> & rTheOutputStream)44cdf0e10cSrcweir SvOutputStreamOpenLockBytes( 45cdf0e10cSrcweir const com::sun::star::uno::Reference< 46cdf0e10cSrcweir com::sun::star::io::XOutputStream > & 47cdf0e10cSrcweir rTheOutputStream): 48cdf0e10cSrcweir m_xOutputStream(rTheOutputStream), m_nPosition(0) {} 49cdf0e10cSrcweir 50cdf0e10cSrcweir virtual ErrCode ReadAt(sal_uLong, void *, sal_uLong, sal_uLong *) const; 51cdf0e10cSrcweir 52cdf0e10cSrcweir virtual ErrCode WriteAt(sal_uLong nPos, const void * pBuffer, sal_uLong nCount, 53cdf0e10cSrcweir sal_uLong * pWritten); 54cdf0e10cSrcweir 55cdf0e10cSrcweir virtual ErrCode Flush() const; 56cdf0e10cSrcweir 57cdf0e10cSrcweir virtual ErrCode SetSize(sal_uLong); 58cdf0e10cSrcweir 59cdf0e10cSrcweir virtual ErrCode Stat(SvLockBytesStat * pStat, SvLockBytesStatFlag) const; 60cdf0e10cSrcweir 61cdf0e10cSrcweir virtual ErrCode FillAppend(const void * pBuffer, sal_uLong nCount, 62cdf0e10cSrcweir sal_uLong * pWritten); 63cdf0e10cSrcweir 64cdf0e10cSrcweir virtual sal_uLong Tell() const; 65cdf0e10cSrcweir 66cdf0e10cSrcweir virtual sal_uLong Seek(sal_uLong); 67cdf0e10cSrcweir 68cdf0e10cSrcweir virtual void Terminate(); 69cdf0e10cSrcweir }; 70cdf0e10cSrcweir 71cdf0e10cSrcweir //============================================================================ 72cdf0e10cSrcweir class SVL_DLLPUBLIC SvLockBytesInputStream: public cppu::OWeakObject, 73cdf0e10cSrcweir public com::sun::star::io::XInputStream, 74cdf0e10cSrcweir public com::sun::star::io::XSeekable 75cdf0e10cSrcweir { 76cdf0e10cSrcweir SvLockBytesRef m_xLockBytes; 77cdf0e10cSrcweir sal_Int64 m_nPosition; 78cdf0e10cSrcweir bool m_bDone; 79cdf0e10cSrcweir 80cdf0e10cSrcweir public: SvLockBytesInputStream(SvLockBytes * pTheLockBytes)81cdf0e10cSrcweir SvLockBytesInputStream(SvLockBytes * pTheLockBytes): 82cdf0e10cSrcweir m_xLockBytes(pTheLockBytes), m_nPosition(0), m_bDone(false) {} 83cdf0e10cSrcweir 84cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL 85cdf0e10cSrcweir queryInterface(const com::sun::star::uno::Type & rType) 86cdf0e10cSrcweir throw (com::sun::star::uno::RuntimeException); 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void SAL_CALL acquire() throw(); 89cdf0e10cSrcweir 90cdf0e10cSrcweir virtual void SAL_CALL release() throw(); 91cdf0e10cSrcweir 92cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 93cdf0e10cSrcweir readBytes(com::sun::star::uno::Sequence< sal_Int8 > & rData, 94cdf0e10cSrcweir sal_Int32 nBytesToRead) 95cdf0e10cSrcweir throw (com::sun::star::io::IOException, 96cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 97cdf0e10cSrcweir 98cdf0e10cSrcweir virtual sal_Int32 SAL_CALL 99cdf0e10cSrcweir readSomeBytes(com::sun::star::uno::Sequence< sal_Int8 > & rData, 100cdf0e10cSrcweir sal_Int32 nMaxBytesToRead) 101cdf0e10cSrcweir throw (com::sun::star::io::IOException, 102cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 103cdf0e10cSrcweir 104cdf0e10cSrcweir virtual void SAL_CALL skipBytes(sal_Int32 nBytesToSkip) 105cdf0e10cSrcweir throw (com::sun::star::io::IOException, 106cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 107cdf0e10cSrcweir 108cdf0e10cSrcweir virtual sal_Int32 SAL_CALL available() 109cdf0e10cSrcweir throw (com::sun::star::io::IOException, 110cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir 112cdf0e10cSrcweir virtual void SAL_CALL closeInput() 113cdf0e10cSrcweir throw (com::sun::star::io::IOException, 114cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 115cdf0e10cSrcweir 116cdf0e10cSrcweir virtual void SAL_CALL seek(sal_Int64 nLocation) 117cdf0e10cSrcweir throw (com::sun::star::lang::IllegalArgumentException, 118cdf0e10cSrcweir com::sun::star::io::IOException, 119cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 120cdf0e10cSrcweir 121cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getPosition() 122cdf0e10cSrcweir throw (com::sun::star::io::IOException, 123cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 124cdf0e10cSrcweir 125cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getLength() 126cdf0e10cSrcweir throw (com::sun::star::io::IOException, 127cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 128cdf0e10cSrcweir }; 129cdf0e10cSrcweir 130cdf0e10cSrcweir #endif // SVTOOLS_STRMADPT_HXX 131cdf0e10cSrcweir 132