xref: /trunk/main/unotools/source/ucbhelper/XTempFile.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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
10cdf0e10cSrcweir  *
11*bae3752eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
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/XServiceInfo.hpp>
34cdf0e10cSrcweir #include <cppuhelper/implbase5.hxx>
35cdf0e10cSrcweir #ifndef _CPPUHELPER_PROPERTYSETMIXIN_HXX_
36cdf0e10cSrcweir #include <cppuhelper/propertysetmixin.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <osl/mutex.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir class SvStream;
41cdf0e10cSrcweir namespace utl { class TempFile; }
42cdf0e10cSrcweir 
43cdf0e10cSrcweir typedef  ::cppu::WeakImplHelper5<   ::com::sun::star::io::XTempFile
44cdf0e10cSrcweir                                     ,   ::com::sun::star::io::XInputStream
45cdf0e10cSrcweir                                                 ,   ::com::sun::star::io::XOutputStream
46cdf0e10cSrcweir                                                 ,   ::com::sun::star::io::XTruncate
47cdf0e10cSrcweir                                                 ,   ::com::sun::star::lang::XServiceInfo
48cdf0e10cSrcweir                                                 >
49cdf0e10cSrcweir                                     OTempFileBase;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class OTempFileService :
52cdf0e10cSrcweir     public OTempFileBase,
53cdf0e10cSrcweir     public ::cppu::PropertySetMixin< ::com::sun::star::io::XTempFile >
54cdf0e10cSrcweir {
55cdf0e10cSrcweir protected:
56cdf0e10cSrcweir     ::utl::TempFile*    mpTempFile;
57cdf0e10cSrcweir     ::osl::Mutex        maMutex;
58cdf0e10cSrcweir     SvStream*           mpStream;
59cdf0e10cSrcweir     sal_Bool            mbRemoveFile;
60cdf0e10cSrcweir     sal_Bool            mbInClosed;
61cdf0e10cSrcweir     sal_Bool            mbOutClosed;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     sal_Int64           mnCachedPos;
64cdf0e10cSrcweir     sal_Bool            mbHasCachedPos;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir     void checkError () const;
67cdf0e10cSrcweir     void checkConnected ();
68cdf0e10cSrcweir 
69cdf0e10cSrcweir public:
70cdf0e10cSrcweir     OTempFileService (::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & context);
71cdf0e10cSrcweir 
72cdf0e10cSrcweir     //Methods
73cdf0e10cSrcweir     //  XInterface
74cdf0e10cSrcweir     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType )
75cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
76cdf0e10cSrcweir     virtual void SAL_CALL acquire(  )
77cdf0e10cSrcweir         throw ();
78cdf0e10cSrcweir     virtual void SAL_CALL release(  )
79cdf0e10cSrcweir         throw ();
80cdf0e10cSrcweir     //  XTypeProvider
81cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  )
82cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
83cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::sal_Int8 > SAL_CALL getImplementationId(  )
84cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     //  XTempFile
87cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL getRemoveFile()
88cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
89cdf0e10cSrcweir     virtual void SAL_CALL setRemoveFile( ::sal_Bool _removefile )
90cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
91cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getUri()
92cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
93cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getResourceName()
94cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
95cdf0e10cSrcweir 
96cdf0e10cSrcweir     // XInputStream
97cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead )
98cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
99cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead )
100cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
101cdf0e10cSrcweir     virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip )
102cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
103cdf0e10cSrcweir     virtual ::sal_Int32 SAL_CALL available(  )
104cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
105cdf0e10cSrcweir     virtual void SAL_CALL closeInput(  )
106cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
107cdf0e10cSrcweir     // XOutputStream
108cdf0e10cSrcweir     virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData )
109cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
110cdf0e10cSrcweir     virtual void SAL_CALL flush(  )
111cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
112cdf0e10cSrcweir     virtual void SAL_CALL closeOutput(  )
113cdf0e10cSrcweir         throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
114cdf0e10cSrcweir     // XSeekable
115cdf0e10cSrcweir     virtual void SAL_CALL seek( sal_Int64 location )
116cdf0e10cSrcweir         throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
117cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getPosition(  )
118cdf0e10cSrcweir         throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
119cdf0e10cSrcweir     virtual sal_Int64 SAL_CALL getLength(  )
120cdf0e10cSrcweir         throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
121cdf0e10cSrcweir     // XStream
122cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(  )
123cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream(  )
125cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
126cdf0e10cSrcweir     // XTruncate
127cdf0e10cSrcweir     virtual void SAL_CALL truncate()
128cdf0e10cSrcweir         throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir     // XServiceInfo
130cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName()
131cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
132cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
133cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
134cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames()
135cdf0e10cSrcweir         throw (::com::sun::star::uno::RuntimeException);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir     //::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);
138cdf0e10cSrcweir     static ::rtl::OUString getImplementationName_Static ();
139cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence < ::rtl::OUString > getSupportedServiceNames_Static();
140cdf0e10cSrcweir 
141cdf0e10cSrcweir private:
142cdf0e10cSrcweir     OTempFileService( OTempFileService & );
143cdf0e10cSrcweir     virtual ~OTempFileService ();
144cdf0e10cSrcweir 
145cdf0e10cSrcweir };
146cdf0e10cSrcweir #endif
147