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>
22 #include <com/sun/star/io/XStream.hpp>
23 #include <com/sun/star/beans/PropertyValue.hpp>
24 
25 /* class for a thread to retrieve an input stream given by a URL
26 
27  #i73788#
28 */
31  const OUString& rLinkedURL, const OUString& rReferer )
32 {
34  new SwAsyncRetrieveInputStreamThread( nDataKey, rLinkedURL, rReferer );
35  return pNewThread;
36 }
37 
40  const OUString& rLinkedURL,
41  const OUString& rReferer )
42  : mnDataKey( nDataKey ),
43  mrLinkedURL( rLinkedURL ),
44  mrReferer( rReferer )
45 {
46 }
47 
49 {
50 }
51 
53 {
54  osl_setThreadName("SwAsyncRetrieveInputStreamThread");
55 
56  css::uno::Sequence < css::beans::PropertyValue > xProps( 2 );
57  xProps[0].Name = "URL";
58  xProps[0].Value <<= mrLinkedURL;
59  xProps[1].Name = "Referer";
60  xProps[1].Value <<= mrReferer;
61  utl::MediaDescriptor aMedium( xProps );
62 
63  aMedium.addInputStream();
64 
65  css::uno::Reference<css::io::XInputStream> xInputStream;
66  aMedium[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
67  if ( !xInputStream.is() )
68  {
69  css::uno::Reference<css::io::XStream> xStream;
70  aMedium[utl::MediaDescriptor::PROP_STREAM()] >>= xStream;
71  if ( xStream.is() )
72  {
73  xInputStream = xStream->getInputStream();
74  }
75  }
76 
78  xInputStream,
79  aMedium.isStreamReadOnly() );
80 }
81 
82 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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
static const OUString & PROP_STREAM()
virtual void threadFunction() override
virtual ~SwAsyncRetrieveInputStreamThread() override
static SwRetrievedInputStreamDataManager & GetManager()
bool isStreamReadOnly() const
SwAsyncRetrieveInputStreamThread(const SwRetrievedInputStreamDataManager::tDataKey nDataKey, const OUString &rLinkedURL, const OUString &rReferer)
static const OUString & PROP_INPUTSTREAM()
static::rtl::Reference< ObservableThread > createThread(const SwRetrievedInputStreamDataManager::tDataKey nDataKey, const OUString &rLinkedURL, const OUString &rReferer)