lok: vcl: fix multiple floatwin removal case more robustly.
[LibreOffice.git] / unotools / source / ucbhelper / ucblockbytes.hxx
blob164c551d8dbff7a1363e676fcf3f8b84e942e9d2
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_UCBLOCKBYTES_HXX
20 #define INCLUDED_UNOTOOLS_UCBLOCKBYTES_HXX
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <com/sun/star/uno/Sequence.hxx>
24 #include <com/sun/star/ucb/XContent.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <osl/thread.hxx>
28 #include <osl/conditn.hxx>
29 #include <osl/mutex.hxx>
30 #include <rtl/ustring.hxx>
31 #include <tools/stream.hxx>
32 #include <tools/link.hxx>
33 #include <vcl/errcode.hxx>
34 #include <tools/datetime.hxx>
36 namespace com
38 namespace sun
40 namespace star
42 namespace task
44 class XInteractionHandler;
46 namespace io
48 class XStream;
49 class XInputStream;
50 class XOutputStream;
51 class XSeekable;
53 namespace ucb
55 class XContent;
57 namespace beans
59 struct PropertyValue;
65 namespace utl
67 class UcbLockBytes;
68 typedef tools::SvRef<UcbLockBytes> UcbLockBytesRef;
70 class UcbLockBytes : public virtual SvLockBytes
72 osl::Condition m_aInitialized;
73 osl::Condition m_aTerminated;
74 osl::Mutex m_aMutex;
76 OUString m_aContentType;
77 OUString m_aRealURL;
78 DateTime m_aExpireDate;
80 css::uno::Reference < css::io::XInputStream > m_xInputStream;
81 css::uno::Reference < css::io::XOutputStream > m_xOutputStream;
82 css::uno::Reference < css::io::XSeekable > m_xSeekable;
84 ErrCode m_nError;
86 bool m_bTerminated;
87 bool m_bDontClose;
88 bool m_bStreamValid;
90 UcbLockBytes();
91 protected:
92 virtual ~UcbLockBytes() override;
94 public:
95 // properties: Referer, PostMimeType
96 static UcbLockBytesRef CreateLockBytes( const css::uno::Reference < css::ucb::XContent >& xContent,
97 const css::uno::Sequence < css::beans::PropertyValue >& rProps,
98 StreamMode eMode,
99 const css::uno::Reference < css::task::XInteractionHandler >& xInter );
101 static UcbLockBytesRef CreateInputLockBytes( const css::uno::Reference < css::io::XInputStream >& xContent );
102 static UcbLockBytesRef CreateLockBytes( const css::uno::Reference < css::io::XStream >& xContent );
104 // SvLockBytes
105 virtual ErrCode ReadAt(sal_uInt64 nPos, void *pBuffer, std::size_t nCount, std::size_t *pRead) const override;
106 virtual ErrCode WriteAt(sal_uInt64, const void*, std::size_t, std::size_t *pWritten) override;
107 virtual ErrCode Flush() const override;
108 virtual ErrCode SetSize(sal_uInt64) override;
109 virtual ErrCode Stat ( SvLockBytesStat *pStat, SvLockBytesStatFlag) const override;
111 void SetError( ErrCode nError )
112 { m_nError = nError; }
114 ErrCode const & GetError() const
115 { return m_nError; }
117 // calling this method delegates the responsibility to call closeinput to the caller!
118 css::uno::Reference < css::io::XInputStream > getInputStream();
120 bool setInputStream_Impl( const css::uno::Reference < css::io::XInputStream > &rxInputStream,
121 bool bSetXSeekable = true );
122 void setStream_Impl( const css::uno::Reference < css::io::XStream > &rxStream );
123 void terminate_Impl();
125 css::uno::Reference < css::io::XInputStream > getInputStream_Impl() const
127 osl::MutexGuard aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
128 return m_xInputStream;
131 css::uno::Reference < css::io::XOutputStream > getOutputStream_Impl() const
133 osl::MutexGuard aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
134 return m_xOutputStream;
137 css::uno::Reference < css::io::XSeekable > getSeekable_Impl() const
139 osl::MutexGuard aGuard( const_cast< UcbLockBytes* >(this)->m_aMutex );
140 return m_xSeekable;
143 void setDontClose_Impl()
144 { m_bDontClose = true; }
146 void SetContentType_Impl( const OUString& rType ) { m_aContentType = rType; }
147 void SetRealURL_Impl( const OUString& rURL ) { m_aRealURL = rURL; }
148 void SetExpireDate_Impl( const DateTime& rDateTime ) { m_aExpireDate = rDateTime; }
149 void SetStreamValid_Impl();
154 #endif
156 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */