nss: upgrade to release 3.73
[LibreOffice.git] / unotools / source / ucbhelper / XTempFile.hxx
blob50251312daa59303eb89f9997dc4656440514528
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 INCLUDED_UNOTOOLS_SOURCE_UCBHELPER_XTEMPFILE_HXX
20 #define INCLUDED_UNOTOOLS_SOURCE_UCBHELPER_XTEMPFILE_HXX
22 #include <memory>
23 #include <com/sun/star/io/XInputStream.hpp>
24 #include <com/sun/star/io/XOutputStream.hpp>
25 #include <com/sun/star/io/XTempFile.hpp>
26 #include <com/sun/star/io/XTruncate.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/beans/XPropertyAccess.hpp>
29 #include <com/sun/star/beans/XFastPropertySet.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 #include <cppuhelper/implbase.hxx>
32 #include <osl/mutex.hxx>
34 namespace com::sun::star::uno { class XComponentContext; }
36 class SvStream;
37 namespace utl { class TempFile; }
40 typedef ::cppu::WeakImplHelper< css::io::XTempFile
41 , css::io::XInputStream
42 , css::io::XOutputStream
43 , css::io::XTruncate
44 , css::beans::XPropertySet
45 , css::beans::XFastPropertySet
46 , css::beans::XPropertyAccess
47 , css::lang::XServiceInfo> OTempFileBase;
49 class OTempFileService : public OTempFileBase
51 protected:
52 std::unique_ptr<utl::TempFile> mpTempFile;
53 ::osl::Mutex maMutex;
54 SvStream* mpStream;
55 bool mbRemoveFile;
56 bool mbInClosed;
57 bool mbOutClosed;
59 sal_Int64 mnCachedPos;
60 bool mbHasCachedPos;
62 void checkError () const;
63 void checkConnected ();
65 public:
66 explicit OTempFileService (css::uno::Reference< css::uno::XComponentContext > const & context);
68 //Methods
69 // XTypeProvider
70 virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes( ) override;
72 // XServiceInfo
73 virtual sal_Bool SAL_CALL supportsService(const OUString& sServiceName) override;
74 virtual OUString SAL_CALL getImplementationName() override;
75 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
77 // XTempFile
78 virtual sal_Bool SAL_CALL getRemoveFile() override;
79 virtual void SAL_CALL setRemoveFile( sal_Bool _removefile ) override;
80 virtual OUString SAL_CALL getUri() override;
81 virtual OUString SAL_CALL getResourceName() override;
83 // XInputStream
84 virtual ::sal_Int32 SAL_CALL readBytes( css::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) override;
85 virtual ::sal_Int32 SAL_CALL readSomeBytes( css::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) override;
86 virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) override;
87 virtual ::sal_Int32 SAL_CALL available( ) override;
88 virtual void SAL_CALL closeInput( ) override;
89 // XOutputStream
90 virtual void SAL_CALL writeBytes( const css::uno::Sequence< ::sal_Int8 >& aData ) override;
91 virtual void SAL_CALL flush( ) override;
92 virtual void SAL_CALL closeOutput( ) override;
93 // XSeekable
94 virtual void SAL_CALL seek( sal_Int64 location ) override;
95 virtual sal_Int64 SAL_CALL getPosition( ) override;
96 virtual sal_Int64 SAL_CALL getLength( ) override;
97 // XStream
98 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream( ) override;
99 virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL getOutputStream( ) override;
100 // XTruncate
101 virtual void SAL_CALL truncate() override;
103 // XPropertySet
104 virtual ::css::uno::Reference< ::css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override;
105 virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::css::uno::Any& aValue ) override;
106 virtual ::css::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) override;
107 virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::css::uno::Reference< ::css::beans::XPropertyChangeListener >& xListener ) override;
108 virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::css::uno::Reference< ::css::beans::XPropertyChangeListener >& aListener ) override;
109 virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::css::uno::Reference< ::css::beans::XVetoableChangeListener >& aListener ) override;
110 virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::css::uno::Reference< ::css::beans::XVetoableChangeListener >& aListener ) override;
111 // XFastPropertySet
112 virtual void SAL_CALL setFastPropertyValue( ::sal_Int32 nHandle, const ::css::uno::Any& aValue ) override;
113 virtual ::css::uno::Any SAL_CALL getFastPropertyValue( ::sal_Int32 nHandle ) override;
114 // XPropertyAccess
115 virtual ::css::uno::Sequence< ::css::beans::PropertyValue > SAL_CALL getPropertyValues() override;
116 virtual void SAL_CALL setPropertyValues( const ::css::uno::Sequence< ::css::beans::PropertyValue >& aProps ) override;
119 virtual ~OTempFileService () override;
121 #endif
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */