1*bae3752eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*bae3752eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*bae3752eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*bae3752eSAndrew Rist * distributed with this work for additional information 6*bae3752eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*bae3752eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*bae3752eSAndrew Rist * "License"); you may not use this file except in compliance 9*bae3752eSAndrew Rist * with the License. You may obtain a copy of the License at 10*bae3752eSAndrew Rist * 11*bae3752eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*bae3752eSAndrew Rist * 13*bae3752eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*bae3752eSAndrew Rist * software distributed under the License is distributed on an 15*bae3752eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*bae3752eSAndrew Rist * KIND, either express or implied. See the License for the 17*bae3752eSAndrew Rist * specific language governing permissions and limitations 18*bae3752eSAndrew Rist * under the License. 19*bae3752eSAndrew Rist * 20*bae3752eSAndrew Rist *************************************************************/ 21*bae3752eSAndrew Rist 22*bae3752eSAndrew Rist 23cdf0e10cSrcweir #ifndef _XTEMPFILE_HXX_ 24cdf0e10cSrcweir #define _XTEMPFILE_HXX_ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <com/sun/star/io/XInputStream.hpp> 27cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp> 28cdf0e10cSrcweir #include <com/sun/star/io/XSeekable.hpp> 29cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp> 30cdf0e10cSrcweir #include <com/sun/star/io/XTempFile.hpp> 31cdf0e10cSrcweir #include <com/sun/star/io/XTruncate.hpp> 32cdf0e10cSrcweir #include <com/sun/star/lang/XSingleComponentFactory.hpp> 33cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 34cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 35cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx> 36cdf0e10cSrcweir #ifndef _CPPUHELPER_PROPERTYSETMIXIN_HXX_ 37cdf0e10cSrcweir #include <cppuhelper/propertysetmixin.hxx> 38cdf0e10cSrcweir #endif 39cdf0e10cSrcweir #include <osl/mutex.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir class SvStream; 42cdf0e10cSrcweir namespace utl { class TempFile; } 43cdf0e10cSrcweir 44cdf0e10cSrcweir typedef ::cppu::WeakImplHelper5< ::com::sun::star::io::XTempFile 45cdf0e10cSrcweir , ::com::sun::star::io::XInputStream 46cdf0e10cSrcweir , ::com::sun::star::io::XOutputStream 47cdf0e10cSrcweir , ::com::sun::star::io::XTruncate 48cdf0e10cSrcweir , ::com::sun::star::lang::XServiceInfo 49cdf0e10cSrcweir > 50cdf0e10cSrcweir OTempFileBase; 51cdf0e10cSrcweir 52cdf0e10cSrcweir class OTempFileService : 53cdf0e10cSrcweir public OTempFileBase, 54cdf0e10cSrcweir public ::cppu::PropertySetMixin< ::com::sun::star::io::XTempFile > 55cdf0e10cSrcweir { 56cdf0e10cSrcweir protected: 57cdf0e10cSrcweir ::utl::TempFile* mpTempFile; 58cdf0e10cSrcweir ::osl::Mutex maMutex; 59cdf0e10cSrcweir SvStream* mpStream; 60cdf0e10cSrcweir sal_Bool mbRemoveFile; 61cdf0e10cSrcweir sal_Bool mbInClosed; 62cdf0e10cSrcweir sal_Bool mbOutClosed; 63cdf0e10cSrcweir 64cdf0e10cSrcweir sal_Int64 mnCachedPos; 65cdf0e10cSrcweir sal_Bool mbHasCachedPos; 66cdf0e10cSrcweir 67cdf0e10cSrcweir void checkError () const; 68cdf0e10cSrcweir void checkConnected (); 69cdf0e10cSrcweir 70cdf0e10cSrcweir public: 71cdf0e10cSrcweir OTempFileService (::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context); 72cdf0e10cSrcweir 73cdf0e10cSrcweir //Methods 74cdf0e10cSrcweir // XInterface 75cdf0e10cSrcweir virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) 76cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 77cdf0e10cSrcweir virtual void SAL_CALL acquire( ) 78cdf0e10cSrcweir throw (); 79cdf0e10cSrcweir virtual void SAL_CALL release( ) 80cdf0e10cSrcweir throw (); 81cdf0e10cSrcweir // XTypeProvider 82cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) 83cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 84cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( ) 85cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 86cdf0e10cSrcweir 87cdf0e10cSrcweir // XTempFile 88cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL getRemoveFile() 89cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 90cdf0e10cSrcweir virtual void SAL_CALL setRemoveFile( ::sal_Bool _removefile ) 91cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 92cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getUri() 93cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 94cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getResourceName() 95cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 96cdf0e10cSrcweir 97cdf0e10cSrcweir // XInputStream 98cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) 99cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 100cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) 101cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 102cdf0e10cSrcweir virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) 103cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 104cdf0e10cSrcweir virtual ::sal_Int32 SAL_CALL available( ) 105cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 106cdf0e10cSrcweir virtual void SAL_CALL closeInput( ) 107cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 108cdf0e10cSrcweir // XOutputStream 109cdf0e10cSrcweir virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) 110cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 111cdf0e10cSrcweir virtual void SAL_CALL flush( ) 112cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 113cdf0e10cSrcweir virtual void SAL_CALL closeOutput( ) 114cdf0e10cSrcweir throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 115cdf0e10cSrcweir // XSeekable 116cdf0e10cSrcweir virtual void SAL_CALL seek( sal_Int64 location ) 117cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 118cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getPosition( ) 119cdf0e10cSrcweir throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 120cdf0e10cSrcweir virtual sal_Int64 SAL_CALL getLength( ) 121cdf0e10cSrcweir throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 122cdf0e10cSrcweir // XStream 123cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ) 124cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 125cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ) 126cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 127cdf0e10cSrcweir // XTruncate 128cdf0e10cSrcweir virtual void SAL_CALL truncate() 129cdf0e10cSrcweir throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException); 130cdf0e10cSrcweir // XServiceInfo 131cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName() 132cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 133cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 134cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 135cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() 136cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException); 137cdf0e10cSrcweir 138cdf0e10cSrcweir //::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > SAL_CALL XTempFile_createInstance( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context); 139cdf0e10cSrcweir static ::rtl::OUString getImplementationName_Static (); 140cdf0e10cSrcweir static ::com::sun::star::uno::Sequence < ::rtl::OUString > getSupportedServiceNames_Static(); 141cdf0e10cSrcweir 142cdf0e10cSrcweir static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleComponentFactory > createServiceFactory_Static( com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > const & rServiceFactory ); 143cdf0e10cSrcweir 144cdf0e10cSrcweir private: 145cdf0e10cSrcweir OTempFileService( OTempFileService & ); 146cdf0e10cSrcweir virtual ~OTempFileService (); 147cdf0e10cSrcweir 148cdf0e10cSrcweir }; 149cdf0e10cSrcweir #endif 150