1*6df1ea1fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*6df1ea1fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*6df1ea1fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*6df1ea1fSAndrew Rist * distributed with this work for additional information 6*6df1ea1fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*6df1ea1fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*6df1ea1fSAndrew Rist * "License"); you may not use this file except in compliance 9*6df1ea1fSAndrew Rist * with the License. You may obtain a copy of the License at 10*6df1ea1fSAndrew Rist * 11*6df1ea1fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*6df1ea1fSAndrew Rist * 13*6df1ea1fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*6df1ea1fSAndrew Rist * software distributed under the License is distributed on an 15*6df1ea1fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*6df1ea1fSAndrew Rist * KIND, either express or implied. See the License for the 17*6df1ea1fSAndrew Rist * specific language governing permissions and limitations 18*6df1ea1fSAndrew Rist * under the License. 19*6df1ea1fSAndrew Rist * 20*6df1ea1fSAndrew Rist *************************************************************/ 21*6df1ea1fSAndrew Rist 22*6df1ea1fSAndrew Rist 23cdf0e10cSrcweir #ifndef _FILSTR_HXX_ 24cdf0e10cSrcweir #define _FILSTR_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <osl/mutex.hxx> 27cdf0e10cSrcweir #include <rtl/ustring.hxx> 28cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 29cdf0e10cSrcweir #include <ucbhelper/macros.hxx> 30cdf0e10cSrcweir #include <com/sun/star/uno/XInterface.hpp> 31cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 32cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp> 33cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp> 34cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 35cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 36cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp> 37cdf0e10cSrcweir #include "com/sun/star/io/XAsyncOutputMonitor.hpp" 38cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProvider.hpp> 39cdf0e10cSrcweir 40cdf0e10cSrcweir #include "filrec.hxx" 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace fileaccess { 43cdf0e10cSrcweir 44cdf0e10cSrcweir // forward: 45cdf0e10cSrcweir class shell; 46cdf0e10cSrcweir class XInputStreamForStream; 47cdf0e10cSrcweir class XOutputStreamForStream; 48cdf0e10cSrcweir 49cdf0e10cSrcweir class XStream_impl 50cdf0e10cSrcweir : public cppu::OWeakObject, 51cdf0e10cSrcweir public com::sun::star::lang::XTypeProvider, 52cdf0e10cSrcweir public com::sun::star::io::XStream, 53cdf0e10cSrcweir public com::sun::star::io::XSeekable, 54cdf0e10cSrcweir public com::sun::star::io::XInputStream, 55cdf0e10cSrcweir public com::sun::star::io::XOutputStream, 56cdf0e10cSrcweir public com::sun::star::io::XTruncate, 57cdf0e10cSrcweir public com::sun::star::io::XAsyncOutputMonitor 58cdf0e10cSrcweir { 59cdf0e10cSrcweir friend class XInputStreamForStream; 60cdf0e10cSrcweir friend class XOutputStreamForStream; 61cdf0e10cSrcweir 62cdf0e10cSrcweir public: 63cdf0e10cSrcweir 64cdf0e10cSrcweir XStream_impl( shell* pMyShell,const rtl::OUString& aUncPath, sal_Bool bLock ); 65cdf0e10cSrcweir 66cdf0e10cSrcweir /** 67cdf0e10cSrcweir * Returns an error code as given by filerror.hxx 68cdf0e10cSrcweir */ 69cdf0e10cSrcweir 70cdf0e10cSrcweir sal_Int32 SAL_CALL CtorSuccess(); 71cdf0e10cSrcweir sal_Int32 SAL_CALL getMinorError(); 72cdf0e10cSrcweir 73cdf0e10cSrcweir virtual ~XStream_impl(); 74cdf0e10cSrcweir 75cdf0e10cSrcweir 76cdf0e10cSrcweir // OWeakObject 77cdf0e10cSrcweir 78cdf0e10cSrcweir virtual com::sun::star::uno::Any SAL_CALL 79cdf0e10cSrcweir queryInterface( 80cdf0e10cSrcweir const com::sun::star::uno::Type& rType ) 81cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException); 82cdf0e10cSrcweir 83cdf0e10cSrcweir virtual void SAL_CALL 84cdf0e10cSrcweir acquire( 85cdf0e10cSrcweir void ) 86cdf0e10cSrcweir throw(); 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void SAL_CALL 89cdf0e10cSrcweir release( 90cdf0e10cSrcweir void ) 91cdf0e10cSrcweir throw(); 92cdf0e10cSrcweir 93cdf0e10cSrcweir 94cdf0e10cSrcweir // XTypeProvider 95cdf0e10cSrcweir 96cdf0e10cSrcweir XTYPEPROVIDER_DECL() 97cdf0e10cSrcweir 98cdf0e10cSrcweir 99cdf0e10cSrcweir // XStream 100cdf0e10cSrcweir 101cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL 102cdf0e10cSrcweir getInputStream( ) 103cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 104cdf0e10cSrcweir 105cdf0e10cSrcweir virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL 106cdf0e10cSrcweir getOutputStream( ) 107cdf0e10cSrcweir throw( com::sun::star::uno::RuntimeException ); 108cdf0e10cSrcweir 109cdf0e10cSrcweir 110cdf0e10cSrcweir // XTruncate 111cdf0e10cSrcweir 112cdf0e10cSrcweir virtual void SAL_CALL truncate( void ) 113cdf0e10cSrcweir throw( com::sun::star::io::IOException, 114cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 115cdf0e10cSrcweir 116cdf0e10cSrcweir 117cdf0e10cSrcweir // XInputStream 118cdf0e10cSrcweir 119cdf0e10cSrcweir sal_Int32 SAL_CALL 120cdf0e10cSrcweir readBytes( 121cdf0e10cSrcweir com::sun::star::uno::Sequence< sal_Int8 >& aData, 122cdf0e10cSrcweir sal_Int32 nBytesToRead ) 123cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 124cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 125cdf0e10cSrcweir com::sun::star::io::IOException, 126cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir 128cdf0e10cSrcweir sal_Int32 SAL_CALL 129cdf0e10cSrcweir readSomeBytes( 130cdf0e10cSrcweir com::sun::star::uno::Sequence< sal_Int8 >& aData, 131cdf0e10cSrcweir sal_Int32 nMaxBytesToRead ) 132cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 133cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 134cdf0e10cSrcweir com::sun::star::io::IOException, 135cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 136cdf0e10cSrcweir 137cdf0e10cSrcweir 138cdf0e10cSrcweir void SAL_CALL 139cdf0e10cSrcweir skipBytes( 140cdf0e10cSrcweir sal_Int32 nBytesToSkip ) 141cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 142cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 143cdf0e10cSrcweir com::sun::star::io::IOException, 144cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 145cdf0e10cSrcweir 146cdf0e10cSrcweir sal_Int32 SAL_CALL 147cdf0e10cSrcweir available( 148cdf0e10cSrcweir void ) 149cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 150cdf0e10cSrcweir com::sun::star::io::IOException, 151cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 152cdf0e10cSrcweir 153cdf0e10cSrcweir void SAL_CALL 154cdf0e10cSrcweir closeInput( 155cdf0e10cSrcweir void ) 156cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 157cdf0e10cSrcweir com::sun::star::io::IOException, 158cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 159cdf0e10cSrcweir 160cdf0e10cSrcweir // XSeekable 161cdf0e10cSrcweir 162cdf0e10cSrcweir void SAL_CALL 163cdf0e10cSrcweir seek( 164cdf0e10cSrcweir sal_Int64 location ) 165cdf0e10cSrcweir throw( com::sun::star::lang::IllegalArgumentException, 166cdf0e10cSrcweir com::sun::star::io::IOException, 167cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 168cdf0e10cSrcweir 169cdf0e10cSrcweir sal_Int64 SAL_CALL 170cdf0e10cSrcweir getPosition( 171cdf0e10cSrcweir void ) 172cdf0e10cSrcweir throw( com::sun::star::io::IOException, 173cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir sal_Int64 SAL_CALL 176cdf0e10cSrcweir getLength( 177cdf0e10cSrcweir void ) 178cdf0e10cSrcweir throw( com::sun::star::io::IOException, 179cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 180cdf0e10cSrcweir 181cdf0e10cSrcweir 182cdf0e10cSrcweir // XOutputStream 183cdf0e10cSrcweir 184cdf0e10cSrcweir void SAL_CALL 185cdf0e10cSrcweir writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData ) 186cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 187cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 188cdf0e10cSrcweir com::sun::star::io::IOException, 189cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 190cdf0e10cSrcweir 191cdf0e10cSrcweir 192cdf0e10cSrcweir 193cdf0e10cSrcweir void SAL_CALL 194cdf0e10cSrcweir flush() 195cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 196cdf0e10cSrcweir com::sun::star::io::BufferSizeExceededException, 197cdf0e10cSrcweir com::sun::star::io::IOException, 198cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 199cdf0e10cSrcweir 200cdf0e10cSrcweir 201cdf0e10cSrcweir void SAL_CALL 202cdf0e10cSrcweir closeOutput( 203cdf0e10cSrcweir void ) 204cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 205cdf0e10cSrcweir com::sun::star::io::IOException, 206cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir virtual void SAL_CALL waitForCompletion() 209cdf0e10cSrcweir throw ( 210cdf0e10cSrcweir com::sun::star::io::IOException, 211cdf0e10cSrcweir com::sun::star::uno::RuntimeException); 212cdf0e10cSrcweir 213cdf0e10cSrcweir private: 214cdf0e10cSrcweir 215cdf0e10cSrcweir osl::Mutex m_aMutex; 216cdf0e10cSrcweir bool m_bInputStreamCalled,m_bOutputStreamCalled; 217cdf0e10cSrcweir 218cdf0e10cSrcweir shell* m_pMyShell; 219cdf0e10cSrcweir com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > m_xProvider; 220cdf0e10cSrcweir sal_Bool m_nIsOpen; 221cdf0e10cSrcweir 222cdf0e10cSrcweir sal_Bool m_bLock; 223cdf0e10cSrcweir 224cdf0e10cSrcweir ReconnectingFile m_aFile; 225cdf0e10cSrcweir 226cdf0e10cSrcweir sal_Int32 m_nErrorCode; 227cdf0e10cSrcweir sal_Int32 m_nMinorErrorCode; 228cdf0e10cSrcweir 229cdf0e10cSrcweir // Implementation methods 230cdf0e10cSrcweir 231cdf0e10cSrcweir void SAL_CALL 232cdf0e10cSrcweir closeStream( 233cdf0e10cSrcweir void ) 234cdf0e10cSrcweir throw( com::sun::star::io::NotConnectedException, 235cdf0e10cSrcweir com::sun::star::io::IOException, 236cdf0e10cSrcweir com::sun::star::uno::RuntimeException ); 237cdf0e10cSrcweir 238cdf0e10cSrcweir }; 239cdf0e10cSrcweir 240cdf0e10cSrcweir } // end namespace XStream_impl 241cdf0e10cSrcweir 242cdf0e10cSrcweir #endif 243