1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: retrieveinputstreamconsumer.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_sw.hxx"
31 #include <retrieveinputstreamconsumer.hxx>
33 #include <retrieveinputstream.hxx>
34 #include <swthreadmanager.hxx>
36 /** class to provide creation of a thread to retrieve an input stream given by
37 an URL and to consume the retrieved input stream.
39 OD 2007-01-29 #i73788#
43 SwAsyncRetrieveInputStreamThreadConsumer::SwAsyncRetrieveInputStreamThreadConsumer(
45 : mrGrfNode( rGrfNode
),
50 SwAsyncRetrieveInputStreamThreadConsumer::~SwAsyncRetrieveInputStreamThreadConsumer()
52 SwThreadManager::GetThreadManager().RemoveThread( mnThreadID
);
55 void SwAsyncRetrieveInputStreamThreadConsumer::CreateThread( const String
& rURL
)
57 // Get new data container for input stream data
58 SwRetrievedInputStreamDataManager::tDataKey nDataKey
=
59 SwRetrievedInputStreamDataManager::GetManager().ReserveData(
60 mrGrfNode
.GetThreadConsumer() );
62 rtl::Reference
< ObservableThread
> pNewThread
=
63 SwAsyncRetrieveInputStreamThread::createThread( nDataKey
, rURL
);
65 // Add thread to thread manager and pass ownership of thread to thread manager.
66 mnThreadID
= SwThreadManager::GetThreadManager().AddThread( pNewThread
);
69 void SwAsyncRetrieveInputStreamThreadConsumer::ApplyInputStream(
70 com::sun::star::uno::Reference
<com::sun::star::io::XInputStream
> xInputStream
,
71 const sal_Bool bIsStreamReadOnly
)
73 mrGrfNode
.ApplyInputStream( xInputStream
, bIsStreamReadOnly
);