update emoji autocorrect entries from po-files
[LibreOffice.git] / unotools / source / ucbhelper / ucblockbytes.hxx
blob2808a3a8a52935a9c4e5eceed1fb499c6ddda779
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 <tools/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 UcbLockBytesHandler : public SvRefBase
72 bool m_bActive;
73 public:
74 UcbLockBytesHandler()
75 : m_bActive( true )
78 void Activate( bool bActivate = true ) { m_bActive = bActivate; }
79 bool IsActive() const { return m_bActive; }
82 typedef tools::SvRef<UcbLockBytesHandler> UcbLockBytesHandlerRef;
84 class UcbLockBytes : public virtual SvLockBytes
86 osl::Condition m_aInitialized;
87 osl::Condition m_aTerminated;
88 osl::Mutex m_aMutex;
90 OUString m_aContentType;
91 OUString m_aRealURL;
92 DateTime m_aExpireDate;
94 ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > m_xInputStream;
95 ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > m_xOutputStream;
96 ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > m_xSeekable;
97 void* m_pCommandThread; // is alive only for compatibility reasons
98 UcbLockBytesHandlerRef m_xHandler;
100 ErrCode m_nError;
102 bool m_bTerminated;
103 bool m_bDontClose;
104 bool m_bStreamValid;
106 DECL_STATIC_LINK( UcbLockBytes, DataAvailHdl, void * );
108 UcbLockBytes( UcbLockBytesHandler* pHandler );
109 protected:
110 virtual ~UcbLockBytes();
112 public:
113 // properties: Referer, PostMimeType
114 static UcbLockBytesRef CreateLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::ucb::XContent >& xContent,
115 const ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >& rProps,
116 StreamMode eMode,
117 const ::com::sun::star::uno::Reference < ::com::sun::star::task::XInteractionHandler >& xInter,
118 UcbLockBytesHandler* pHandler=0 );
120 static UcbLockBytesRef CreateInputLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream >& xContent );
121 static UcbLockBytesRef CreateLockBytes( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream >& xContent );
123 // SvLockBytes
124 virtual void SetSynchronMode (bool bSynchron) SAL_OVERRIDE;
125 virtual ErrCode ReadAt(sal_uInt64 nPos, void *pBuffer, sal_uLong nCount, sal_uLong *pRead) const SAL_OVERRIDE;
126 virtual ErrCode WriteAt(sal_uInt64, const void*, sal_uLong, sal_uLong *pWritten) SAL_OVERRIDE;
127 virtual ErrCode Flush() const SAL_OVERRIDE;
128 virtual ErrCode SetSize(sal_uInt64) SAL_OVERRIDE;
129 virtual ErrCode Stat ( SvLockBytesStat *pStat, SvLockBytesStatFlag) const SAL_OVERRIDE;
131 void SetError( ErrCode nError )
132 { m_nError = nError; }
134 ErrCode GetError() const
135 { return m_nError; }
137 // the following properties are available when and after the first DataAvailable callback has been executed
138 OUString GetContentType() const;
139 OUString GetRealURL() const;
140 DateTime GetExpireDate() const;
142 // calling this method delegates the responsibility to call closeinput to the caller!
143 ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > getInputStream();
145 bool setInputStream_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > &rxInputStream,
146 bool bSetXSeekable = true );
147 bool setStream_Impl( const ::com::sun::star::uno::Reference < ::com::sun::star::io::XStream > &rxStream );
148 void terminate_Impl();
150 ::com::sun::star::uno::Reference < ::com::sun::star::io::XInputStream > getInputStream_Impl() const
152 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
153 return m_xInputStream;
156 ::com::sun::star::uno::Reference < ::com::sun::star::io::XOutputStream > getOutputStream_Impl() const
158 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
159 return m_xOutputStream;
162 ::com::sun::star::uno::Reference < ::com::sun::star::io::XSeekable > getSeekable_Impl() const
164 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
165 return m_xSeekable;
168 bool hasInputStream_Impl() const
170 osl::MutexGuard aGuard( (const_cast< UcbLockBytes* >(this))->m_aMutex );
171 return m_xInputStream.is();
174 void setDontClose_Impl()
175 { m_bDontClose = true; }
177 void SetContentType_Impl( const OUString& rType ) { m_aContentType = rType; }
178 void SetRealURL_Impl( const OUString& rURL ) { m_aRealURL = rURL; }
179 void SetExpireDate_Impl( const DateTime& rDateTime ) { m_aExpireDate = rDateTime; }
180 void SetStreamValid_Impl();
185 #endif
187 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */