LibreOffice Module sw (master)  1
retrieveinputstream.cxx
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 
20 #include <retrieveinputstream.hxx>
21 
24 #include <com/sun/star/io/XStream.hpp>
25 #include <com/sun/star/beans/PropertyValue.hpp>
26 
27 /* class for a thread to retrieve an input stream given by a URL
28 
29  #i73788#
30 */
33  const OUString& rLinkedURL, const OUString& rReferer )
34 {
36  new SwAsyncRetrieveInputStreamThread( nDataKey, rLinkedURL, rReferer );
37  return pNewThread;
38 }
39 
42  const OUString& rLinkedURL,
43  const OUString& rReferer )
44  : mnDataKey( nDataKey ),
45  mrLinkedURL( rLinkedURL ),
46  mrReferer( rReferer )
47 {
48 }
49 
51 {
52 }
53 
55 {
56  osl_setThreadName("SwAsyncRetrieveInputStreamThread");
57 
58  css::uno::Sequence < css::beans::PropertyValue > xProps{
61  };
62  utl::MediaDescriptor aMedium( xProps );
63 
64  aMedium.addInputStream();
65 
66  css::uno::Reference<css::io::XInputStream> xInputStream;
67  aMedium[utl::MediaDescriptor::PROP_INPUTSTREAM] >>= xInputStream;
68  if ( !xInputStream.is() )
69  {
70  css::uno::Reference<css::io::XStream> xStream;
71  aMedium[utl::MediaDescriptor::PROP_STREAM] >>= xStream;
72  if ( xStream.is() )
73  {
74  xInputStream = xStream->getInputStream();
75  }
76  }
77 
79  xInputStream,
80  aMedium.isStreamReadOnly() );
81 }
82 
83 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
void PushData(const tDataKey nDataKey, css::uno::Reference< css::io::XInputStream > const &xInputStream, const bool bIsStreamReadOnly)
const SwRetrievedInputStreamDataManager::tDataKey mnDataKey
Reference< XInputStream > xStream
class for a thread to retrieve an input stream given by a URL
virtual void threadFunction() override
static constexpr OUStringLiteral PROP_INPUTSTREAM
virtual ~SwAsyncRetrieveInputStreamThread() override
static constexpr OUStringLiteral PROP_STREAM
static SwRetrievedInputStreamDataManager & GetManager()
bool isStreamReadOnly() const
SwAsyncRetrieveInputStreamThread(const SwRetrievedInputStreamDataManager::tDataKey nDataKey, const OUString &rLinkedURL, const OUString &rReferer)
static::rtl::Reference< ObservableThread > createThread(const SwRetrievedInputStreamDataManager::tDataKey nDataKey, const OUString &rLinkedURL, const OUString &rReferer)