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  : ObservableThread(),
43  mnDataKey( nDataKey ),
44  mrLinkedURL( rLinkedURL ),
45  mrReferer( rReferer )
46 {
47 }
48 
50 {
51 }
52 
54 {
55  osl_setThreadName("SwAsyncRetrieveInputStreamThread");
56 
57  css::uno::Sequence < css::beans::PropertyValue > xProps( 2 );
58  xProps[0].Name = "URL";
59  xProps[0].Value <<= mrLinkedURL;
60  xProps[1].Name = "Referer";
61  xProps[1].Value <<= mrReferer;
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: */
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 an observable thread
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)