1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <com/sun/star/io/XInputStream.hpp>
23 #include <com/sun/star/io/XOutputStream.hpp>
24 #include <com/sun/star/io/XTempFile.hpp>
25 #include <com/sun/star/io/XTruncate.hpp>
26 #include <com/sun/star/beans/XPropertySet.hpp>
27 #include <com/sun/star/beans/XPropertyAccess.hpp>
28 #include <com/sun/star/beans/XFastPropertySet.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <cppuhelper/implbase.hxx>
32 #include <unotools/tempfile.hxx>
34 namespace com::sun::star::uno
{ class XComponentContext
; }
37 namespace utl
{ class TempFile
; }
40 typedef ::cppu::WeakImplHelper
< css::io::XTempFile
41 , css::io::XInputStream
42 , css::io::XOutputStream
44 , css::beans::XPropertySet
45 , css::beans::XFastPropertySet
46 , css::beans::XPropertyAccess
47 , css::lang::XServiceInfo
> OTempFileBase
;
49 class OTempFileService
: public OTempFileBase
51 std::optional
<utl::TempFileNamed
> mpTempFile
;
59 void checkError () const;
60 void checkConnected ();
63 explicit OTempFileService (css::uno::Reference
< css::uno::XComponentContext
> const & context
);
67 virtual css::uno::Sequence
< css::uno::Type
> SAL_CALL
getTypes( ) override
;
70 virtual sal_Bool SAL_CALL
supportsService(const OUString
& sServiceName
) override
;
71 virtual OUString SAL_CALL
getImplementationName() override
;
72 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
75 virtual sal_Bool SAL_CALL
getRemoveFile() override
;
76 virtual void SAL_CALL
setRemoveFile( sal_Bool _removefile
) override
;
77 virtual OUString SAL_CALL
getUri() override
;
78 virtual OUString SAL_CALL
getResourceName() override
;
81 virtual ::sal_Int32 SAL_CALL
readBytes( css::uno::Sequence
< ::sal_Int8
>& aData
, ::sal_Int32 nBytesToRead
) override
;
82 virtual ::sal_Int32 SAL_CALL
readSomeBytes( css::uno::Sequence
< ::sal_Int8
>& aData
, ::sal_Int32 nMaxBytesToRead
) override
;
83 virtual void SAL_CALL
skipBytes( ::sal_Int32 nBytesToSkip
) override
;
84 virtual ::sal_Int32 SAL_CALL
available( ) override
;
85 virtual void SAL_CALL
closeInput( ) override
;
87 virtual void SAL_CALL
writeBytes( const css::uno::Sequence
< ::sal_Int8
>& aData
) override
;
88 virtual void SAL_CALL
flush( ) override
;
89 virtual void SAL_CALL
closeOutput( ) override
;
91 virtual void SAL_CALL
seek( sal_Int64 location
) override
;
92 virtual sal_Int64 SAL_CALL
getPosition( ) override
;
93 virtual sal_Int64 SAL_CALL
getLength( ) override
;
95 virtual css::uno::Reference
< css::io::XInputStream
> SAL_CALL
getInputStream( ) override
;
96 virtual css::uno::Reference
< css::io::XOutputStream
> SAL_CALL
getOutputStream( ) override
;
98 virtual void SAL_CALL
truncate() override
;
101 virtual ::css::uno::Reference
< ::css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo() override
;
102 virtual void SAL_CALL
setPropertyValue( const ::rtl::OUString
& aPropertyName
, const ::css::uno::Any
& aValue
) override
;
103 virtual ::css::uno::Any SAL_CALL
getPropertyValue( const ::rtl::OUString
& PropertyName
) override
;
104 virtual void SAL_CALL
addPropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::css::uno::Reference
< ::css::beans::XPropertyChangeListener
>& xListener
) override
;
105 virtual void SAL_CALL
removePropertyChangeListener( const ::rtl::OUString
& aPropertyName
, const ::css::uno::Reference
< ::css::beans::XPropertyChangeListener
>& aListener
) override
;
106 virtual void SAL_CALL
addVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::css::uno::Reference
< ::css::beans::XVetoableChangeListener
>& aListener
) override
;
107 virtual void SAL_CALL
removeVetoableChangeListener( const ::rtl::OUString
& PropertyName
, const ::css::uno::Reference
< ::css::beans::XVetoableChangeListener
>& aListener
) override
;
109 virtual void SAL_CALL
setFastPropertyValue( ::sal_Int32 nHandle
, const ::css::uno::Any
& aValue
) override
;
110 virtual ::css::uno::Any SAL_CALL
getFastPropertyValue( ::sal_Int32 nHandle
) override
;
112 virtual ::css::uno::Sequence
< ::css::beans::PropertyValue
> SAL_CALL
getPropertyValues() override
;
113 virtual void SAL_CALL
setPropertyValues( const ::css::uno::Sequence
< ::css::beans::PropertyValue
>& aProps
) override
;
116 virtual ~OTempFileService () override
;
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */