Updated core
[LibreOffice.git] / unotools / source / ucbhelper / XTempFile.hxx
blob0f0ea21181b14d59060f37bba57515de75b92d66
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _XTEMPFILE_HXX_
20 #define _XTEMPFILE_HXX_
22 #include <com/sun/star/io/XInputStream.hpp>
23 #include <com/sun/star/io/XOutputStream.hpp>
24 #include <com/sun/star/io/XSeekable.hpp>
25 #include <com/sun/star/io/XStream.hpp>
26 #include <com/sun/star/io/XTempFile.hpp>
27 #include <com/sun/star/io/XTruncate.hpp>
28 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <cppuhelper/implbase5.hxx>
31 #include <cppuhelper/propertysetmixin.hxx>
32 #include <osl/mutex.hxx>
34 class SvStream;
35 namespace utl { class TempFile; }
37 typedef ::cppu::WeakImplHelper5< ::com::sun::star::io::XTempFile
38 , ::com::sun::star::io::XInputStream
39 , ::com::sun::star::io::XOutputStream
40 , ::com::sun::star::io::XTruncate
41 , ::com::sun::star::lang::XServiceInfo
43 OTempFileBase;
45 class OTempFileService :
46 public OTempFileBase,
47 public ::cppu::PropertySetMixin< ::com::sun::star::io::XTempFile >
49 protected:
50 ::utl::TempFile* mpTempFile;
51 ::osl::Mutex maMutex;
52 SvStream* mpStream;
53 sal_Bool mbRemoveFile;
54 sal_Bool mbInClosed;
55 sal_Bool mbOutClosed;
57 sal_Int64 mnCachedPos;
58 sal_Bool mbHasCachedPos;
60 void checkError () const;
61 void checkConnected ();
63 public:
64 OTempFileService (::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
66 //Methods
67 // XInterface
68 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
69 throw (::com::sun::star::uno::RuntimeException);
70 virtual void SAL_CALL acquire( )
71 throw ();
72 virtual void SAL_CALL release( )
73 throw ();
74 // XTypeProvider
75 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( )
76 throw (::com::sun::star::uno::RuntimeException);
77 virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId( )
78 throw (::com::sun::star::uno::RuntimeException);
80 // XTempFile
81 virtual ::sal_Bool SAL_CALL getRemoveFile()
82 throw (::com::sun::star::uno::RuntimeException);
83 virtual void SAL_CALL setRemoveFile( ::sal_Bool _removefile )
84 throw (::com::sun::star::uno::RuntimeException);
85 virtual OUString SAL_CALL getUri()
86 throw (::com::sun::star::uno::RuntimeException);
87 virtual OUString SAL_CALL getResourceName()
88 throw (::com::sun::star::uno::RuntimeException);
90 // XInputStream
91 virtual ::sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead )
92 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
93 virtual ::sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead )
94 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
95 virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip )
96 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
97 virtual ::sal_Int32 SAL_CALL available( )
98 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
99 virtual void SAL_CALL closeInput( )
100 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
101 // XOutputStream
102 virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData )
103 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
104 virtual void SAL_CALL flush( )
105 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
106 virtual void SAL_CALL closeOutput( )
107 throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
108 // XSeekable
109 virtual void SAL_CALL seek( sal_Int64 location )
110 throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
111 virtual sal_Int64 SAL_CALL getPosition( )
112 throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
113 virtual sal_Int64 SAL_CALL getLength( )
114 throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
115 // XStream
116 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( )
117 throw (::com::sun::star::uno::RuntimeException);
118 virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( )
119 throw (::com::sun::star::uno::RuntimeException);
120 // XTruncate
121 virtual void SAL_CALL truncate()
122 throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
123 // XServiceInfo
124 virtual OUString SAL_CALL getImplementationName()
125 throw (::com::sun::star::uno::RuntimeException);
126 virtual ::sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
127 throw (::com::sun::star::uno::RuntimeException);
128 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
129 throw (::com::sun::star::uno::RuntimeException);
131 //::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);
132 static OUString getImplementationName_Static ();
133 static ::com::sun::star::uno::Sequence < OUString > getSupportedServiceNames_Static();
135 static ::com::sun::star::uno::Reference < com::sun::star::lang::XSingleComponentFactory > createServiceFactory_Static();
137 private:
138 OTempFileService( OTempFileService & );
139 virtual ~OTempFileService ();
142 #endif
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */