2010-10-14 08:30:41 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2011-03-31 10:05:04 +02:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2013-08-11 00:09:00 +02:00
|
|
|
|
2007-07-18 12:31:42 +00:00
|
|
|
#include <retrieveinputstream.hxx>
|
2013-11-13 08:52:41 +01:00
|
|
|
#include <unotools/mediadescriptor.hxx>
|
2007-07-18 12:31:42 +00:00
|
|
|
#include <com/sun/star/io/XStream.hpp>
|
|
|
|
|
2013-08-11 00:13:50 +02:00
|
|
|
/* class for a thread to retrieve an input stream given by an URL
|
2007-07-18 12:31:42 +00:00
|
|
|
|
2011-02-02 20:41:40 +09:00
|
|
|
#i73788#
|
2007-07-18 12:31:42 +00:00
|
|
|
*/
|
|
|
|
::rtl::Reference< ObservableThread > SwAsyncRetrieveInputStreamThread::createThread(
|
|
|
|
const SwRetrievedInputStreamDataManager::tDataKey nDataKey,
|
2013-10-10 13:24:52 +02:00
|
|
|
const OUString& rLinkedURL )
|
2007-07-18 12:31:42 +00:00
|
|
|
{
|
|
|
|
SwAsyncRetrieveInputStreamThread* pNewThread =
|
|
|
|
new SwAsyncRetrieveInputStreamThread( nDataKey, rLinkedURL );
|
|
|
|
return pNewThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
SwAsyncRetrieveInputStreamThread::SwAsyncRetrieveInputStreamThread(
|
|
|
|
const SwRetrievedInputStreamDataManager::tDataKey nDataKey,
|
2013-10-10 13:24:52 +02:00
|
|
|
const OUString& rLinkedURL )
|
2007-07-18 12:31:42 +00:00
|
|
|
: ObservableThread(),
|
|
|
|
mnDataKey( nDataKey ),
|
|
|
|
mrLinkedURL( rLinkedURL )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SwAsyncRetrieveInputStreamThread::~SwAsyncRetrieveInputStreamThread()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwAsyncRetrieveInputStreamThread::threadFunction()
|
|
|
|
{
|
|
|
|
com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue > xProps( 1 );
|
2013-10-31 17:16:50 +02:00
|
|
|
xProps[0].Name = "URL";
|
2013-03-01 13:50:58 +01:00
|
|
|
xProps[0].Value <<= OUString( mrLinkedURL );
|
2013-11-13 08:52:41 +01:00
|
|
|
utl::MediaDescriptor aMedium( xProps );
|
2007-07-18 12:31:42 +00:00
|
|
|
|
|
|
|
aMedium.addInputStream();
|
|
|
|
|
|
|
|
com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream;
|
2013-11-13 08:52:41 +01:00
|
|
|
aMedium[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
|
2007-07-18 12:31:42 +00:00
|
|
|
if ( !xInputStream.is() )
|
|
|
|
{
|
|
|
|
com::sun::star::uno::Reference<com::sun::star::io::XStream> xStream;
|
2013-11-13 08:52:41 +01:00
|
|
|
aMedium[utl::MediaDescriptor::PROP_STREAM()] >>= xStream;
|
2007-07-18 12:31:42 +00:00
|
|
|
if ( xStream.is() )
|
|
|
|
{
|
|
|
|
xInputStream = xStream->getInputStream();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SwRetrievedInputStreamDataManager::GetManager().PushData( mnDataKey,
|
|
|
|
xInputStream,
|
|
|
|
aMedium.isStreamReadOnly() );
|
|
|
|
}
|
2010-10-14 08:30:41 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|