Line data Source code
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 : #include <retrieveinputstream.hxx>
20 : #include <comphelper/mediadescriptor.hxx>
21 : #include <com/sun/star/io/XStream.hpp>
22 :
23 : /** class for a thread to retrieve an input stream given by an URL
24 :
25 : #i73788#
26 :
27 : @author OD
28 : */
29 0 : ::rtl::Reference< ObservableThread > SwAsyncRetrieveInputStreamThread::createThread(
30 : const SwRetrievedInputStreamDataManager::tDataKey nDataKey,
31 : const String& rLinkedURL )
32 : {
33 : SwAsyncRetrieveInputStreamThread* pNewThread =
34 0 : new SwAsyncRetrieveInputStreamThread( nDataKey, rLinkedURL );
35 0 : return pNewThread;
36 : }
37 :
38 0 : SwAsyncRetrieveInputStreamThread::SwAsyncRetrieveInputStreamThread(
39 : const SwRetrievedInputStreamDataManager::tDataKey nDataKey,
40 : const String& rLinkedURL )
41 : : ObservableThread(),
42 : mnDataKey( nDataKey ),
43 0 : mrLinkedURL( rLinkedURL )
44 : {
45 0 : }
46 :
47 0 : SwAsyncRetrieveInputStreamThread::~SwAsyncRetrieveInputStreamThread()
48 : {
49 0 : }
50 :
51 0 : void SwAsyncRetrieveInputStreamThread::threadFunction()
52 : {
53 0 : com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > xProps( 1 );
54 0 : xProps[0].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"));
55 0 : xProps[0].Value <<= ::rtl::OUString( mrLinkedURL );
56 0 : comphelper::MediaDescriptor aMedium( xProps );
57 :
58 0 : aMedium.addInputStream();
59 :
60 0 : com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream;
61 0 : aMedium[comphelper::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
62 0 : if ( !xInputStream.is() )
63 : {
64 0 : com::sun::star::uno::Reference<com::sun::star::io::XStream> xStream;
65 0 : aMedium[comphelper::MediaDescriptor::PROP_STREAM()] >>= xStream;
66 0 : if ( xStream.is() )
67 : {
68 0 : xInputStream = xStream->getInputStream();
69 0 : }
70 : }
71 :
72 0 : SwRetrievedInputStreamDataManager::GetManager().PushData( mnDataKey,
73 : xInputStream,
74 0 : aMedium.isStreamReadOnly() );
75 0 : }
76 :
77 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|