LibreOffice Module sw (master)  1
retrievedinputstreamdata.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEDINPUTSTREAMDATA_HXX
20 #define INCLUDED_SW_SOURCE_CORE_INC_RETRIEVEDINPUTSTREAMDATA_HXX
21 
22 #include <tools/link.hxx>
23 #include <sal/types.h>
24 #include <osl/mutex.hxx>
25 #include <com/sun/star/uno/Reference.hxx>
26 
27 #include <map>
28 #include <memory>
29 
30 namespace com::sun::star::io { class XInputStream; }
31 
33 
44 {
45  public:
46 
47  typedef sal_uInt64 tDataKey;
48 
49  struct tData
50  {
51  std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
52  css::uno::Reference<css::io::XInputStream> mxInputStream;
54 
56  : mpThreadConsumer(),
57  mbIsStreamReadOnly( false )
58  {};
59 
60  tData( std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > pThreadConsumer )
61  : mpThreadConsumer( pThreadConsumer ),
62  mbIsStreamReadOnly( false )
63  {};
64  };
65 
67 
68  tDataKey ReserveData( std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > const & pThreadConsumer );
69 
70  void PushData( const tDataKey nDataKey,
71  css::uno::Reference<css::io::XInputStream> const & xInputStream,
72  const bool bIsStreamReadOnly );
73 
74  bool PopData( const tDataKey nDataKey,
75  tData& rData );
76 
77  DECL_LINK( LinkedInputStreamReady, void*, void );
78 
79  private:
80 
81  static tDataKey mnNextKeyValue;
82 
83  osl::Mutex maMutex;
84 
85  std::map< tDataKey, tData > maInputStreamData;
86 };
87 #endif
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Singleton class to manage retrieved input stream data in Writer.
bool PopData(const tDataKey nDataKey, tData &rData)
void PushData(const tDataKey nDataKey, css::uno::Reference< css::io::XInputStream > const &xInputStream, const bool bIsStreamReadOnly)
std::map< tDataKey, tData > maInputStreamData
std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer
class to provide creation of a thread to retrieve an input stream given by a URL and to consume the r...
css::uno::Reference< css::io::XInputStream > mxInputStream
static SwRetrievedInputStreamDataManager & GetManager()
tDataKey ReserveData(std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > const &pThreadConsumer)
DECL_LINK(LinkedInputStreamReady, void *, void)
tData(std::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > pThreadConsumer)