1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _FILSTR_HXX_ 28 #define _FILSTR_HXX_ 29 30 #include <osl/mutex.hxx> 31 #include <rtl/ustring.hxx> 32 #include <cppuhelper/weak.hxx> 33 #include <ucbhelper/macros.hxx> 34 #include <com/sun/star/uno/XInterface.hpp> 35 #include <com/sun/star/lang/XTypeProvider.hpp> 36 #include <com/sun/star/io/XSeekable.hpp> 37 #include <com/sun/star/io/XTruncate.hpp> 38 #include <com/sun/star/io/XInputStream.hpp> 39 #include <com/sun/star/io/XOutputStream.hpp> 40 #include <com/sun/star/io/XStream.hpp> 41 #include "com/sun/star/io/XAsyncOutputMonitor.hpp" 42 #include <com/sun/star/ucb/XContentProvider.hpp> 43 44 #include "filrec.hxx" 45 46 namespace fileaccess { 47 48 // forward: 49 class shell; 50 class XInputStreamForStream; 51 class XOutputStreamForStream; 52 53 class XStream_impl 54 : public cppu::OWeakObject, 55 public com::sun::star::lang::XTypeProvider, 56 public com::sun::star::io::XStream, 57 public com::sun::star::io::XSeekable, 58 public com::sun::star::io::XInputStream, 59 public com::sun::star::io::XOutputStream, 60 public com::sun::star::io::XTruncate, 61 public com::sun::star::io::XAsyncOutputMonitor 62 { 63 friend class XInputStreamForStream; 64 friend class XOutputStreamForStream; 65 66 public: 67 68 XStream_impl( shell* pMyShell,const rtl::OUString& aUncPath, sal_Bool bLock ); 69 70 /** 71 * Returns an error code as given by filerror.hxx 72 */ 73 74 sal_Int32 SAL_CALL CtorSuccess(); 75 sal_Int32 SAL_CALL getMinorError(); 76 77 virtual ~XStream_impl(); 78 79 80 // OWeakObject 81 82 virtual com::sun::star::uno::Any SAL_CALL 83 queryInterface( 84 const com::sun::star::uno::Type& rType ) 85 throw( com::sun::star::uno::RuntimeException); 86 87 virtual void SAL_CALL 88 acquire( 89 void ) 90 throw(); 91 92 virtual void SAL_CALL 93 release( 94 void ) 95 throw(); 96 97 98 // XTypeProvider 99 100 XTYPEPROVIDER_DECL() 101 102 103 // XStream 104 105 virtual com::sun::star::uno::Reference< com::sun::star::io::XInputStream > SAL_CALL 106 getInputStream( ) 107 throw( com::sun::star::uno::RuntimeException ); 108 109 virtual com::sun::star::uno::Reference< com::sun::star::io::XOutputStream > SAL_CALL 110 getOutputStream( ) 111 throw( com::sun::star::uno::RuntimeException ); 112 113 114 // XTruncate 115 116 virtual void SAL_CALL truncate( void ) 117 throw( com::sun::star::io::IOException, 118 com::sun::star::uno::RuntimeException ); 119 120 121 // XInputStream 122 123 sal_Int32 SAL_CALL 124 readBytes( 125 com::sun::star::uno::Sequence< sal_Int8 >& aData, 126 sal_Int32 nBytesToRead ) 127 throw( com::sun::star::io::NotConnectedException, 128 com::sun::star::io::BufferSizeExceededException, 129 com::sun::star::io::IOException, 130 com::sun::star::uno::RuntimeException); 131 132 sal_Int32 SAL_CALL 133 readSomeBytes( 134 com::sun::star::uno::Sequence< sal_Int8 >& aData, 135 sal_Int32 nMaxBytesToRead ) 136 throw( com::sun::star::io::NotConnectedException, 137 com::sun::star::io::BufferSizeExceededException, 138 com::sun::star::io::IOException, 139 com::sun::star::uno::RuntimeException); 140 141 142 void SAL_CALL 143 skipBytes( 144 sal_Int32 nBytesToSkip ) 145 throw( com::sun::star::io::NotConnectedException, 146 com::sun::star::io::BufferSizeExceededException, 147 com::sun::star::io::IOException, 148 com::sun::star::uno::RuntimeException ); 149 150 sal_Int32 SAL_CALL 151 available( 152 void ) 153 throw( com::sun::star::io::NotConnectedException, 154 com::sun::star::io::IOException, 155 com::sun::star::uno::RuntimeException ); 156 157 void SAL_CALL 158 closeInput( 159 void ) 160 throw( com::sun::star::io::NotConnectedException, 161 com::sun::star::io::IOException, 162 com::sun::star::uno::RuntimeException ); 163 164 // XSeekable 165 166 void SAL_CALL 167 seek( 168 sal_Int64 location ) 169 throw( com::sun::star::lang::IllegalArgumentException, 170 com::sun::star::io::IOException, 171 com::sun::star::uno::RuntimeException ); 172 173 sal_Int64 SAL_CALL 174 getPosition( 175 void ) 176 throw( com::sun::star::io::IOException, 177 com::sun::star::uno::RuntimeException ); 178 179 sal_Int64 SAL_CALL 180 getLength( 181 void ) 182 throw( com::sun::star::io::IOException, 183 com::sun::star::uno::RuntimeException ); 184 185 186 // XOutputStream 187 188 void SAL_CALL 189 writeBytes( const com::sun::star::uno::Sequence< sal_Int8 >& aData ) 190 throw( com::sun::star::io::NotConnectedException, 191 com::sun::star::io::BufferSizeExceededException, 192 com::sun::star::io::IOException, 193 com::sun::star::uno::RuntimeException); 194 195 196 197 void SAL_CALL 198 flush() 199 throw( com::sun::star::io::NotConnectedException, 200 com::sun::star::io::BufferSizeExceededException, 201 com::sun::star::io::IOException, 202 com::sun::star::uno::RuntimeException); 203 204 205 void SAL_CALL 206 closeOutput( 207 void ) 208 throw( com::sun::star::io::NotConnectedException, 209 com::sun::star::io::IOException, 210 com::sun::star::uno::RuntimeException ); 211 212 virtual void SAL_CALL waitForCompletion() 213 throw ( 214 com::sun::star::io::IOException, 215 com::sun::star::uno::RuntimeException); 216 217 private: 218 219 osl::Mutex m_aMutex; 220 bool m_bInputStreamCalled,m_bOutputStreamCalled; 221 222 shell* m_pMyShell; 223 com::sun::star::uno::Reference< com::sun::star::ucb::XContentProvider > m_xProvider; 224 sal_Bool m_nIsOpen; 225 226 sal_Bool m_bLock; 227 228 ReconnectingFile m_aFile; 229 230 sal_Int32 m_nErrorCode; 231 sal_Int32 m_nMinorErrorCode; 232 233 // Implementation methods 234 235 void SAL_CALL 236 closeStream( 237 void ) 238 throw( com::sun::star::io::NotConnectedException, 239 com::sun::star::io::IOException, 240 com::sun::star::uno::RuntimeException ); 241 242 }; 243 244 } // end namespace XStream_impl 245 246 #endif 247