Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _RETRIEVEDINPUTSTREAMDATA_HXX
29 : : #define _RETRIEVEDINPUTSTREAMDATA_HXX
30 : :
31 : : #include <tools/link.hxx>
32 : : #include <sal/types.h>
33 : : #include <osl/mutex.hxx>
34 : : #include <rtl/instance.hxx>
35 : : #include <com/sun/star/uno/Reference.hxx>
36 : : #include <com/sun/star/io/XInputStream.hpp>
37 : :
38 : : #include <map>
39 : :
40 : : #include <boost/weak_ptr.hpp>
41 : :
42 : : class SwAsyncRetrieveInputStreamThreadConsumer;
43 : :
44 : : /** Singleton class to manage retrieved input stream data in Writer
45 : :
46 : : OD 2007-01-29 #i73788#
47 : : The instance of this class provides data container for retrieved input
48 : : stream data. The data container is accessed via a key, which the data
49 : : manager provides on creation of the data container.
50 : : When a certain data container is filled with data, an user event is submitted
51 : : to trigger the processing of with data.
52 : :
53 : : @author OD
54 : : */
55 [ + - ]: 4 : class SwRetrievedInputStreamDataManager
56 : : {
57 : : public:
58 : :
59 : : typedef sal_uInt64 tDataKey;
60 : :
61 : 64 : struct tData
62 : : {
63 : : boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > mpThreadConsumer;
64 : : com::sun::star::uno::Reference<com::sun::star::io::XInputStream> mxInputStream;
65 : : sal_Bool mbIsStreamReadOnly;
66 : :
67 : 16 : tData()
68 : : : mpThreadConsumer(),
69 : 16 : mbIsStreamReadOnly( sal_False )
70 : 16 : {};
71 : :
72 : 8 : tData( boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > pThreadConsumer )
73 : : : mpThreadConsumer( pThreadConsumer ),
74 : 8 : mbIsStreamReadOnly( sal_False )
75 : 8 : {};
76 : : };
77 : :
78 : : static SwRetrievedInputStreamDataManager& GetManager();
79 : :
80 : : tDataKey ReserveData( boost::weak_ptr< SwAsyncRetrieveInputStreamThreadConsumer > pThreadConsumer );
81 : :
82 : : void PushData( const tDataKey nDataKey,
83 : : com::sun::star::uno::Reference<com::sun::star::io::XInputStream> xInputStream,
84 : : const sal_Bool bIsStreamReadOnly );
85 : :
86 : : bool PopData( const tDataKey nDataKey,
87 : : tData& rData );
88 : :
89 : : DECL_LINK( LinkedInputStreamReady, SwRetrievedInputStreamDataManager::tDataKey* );
90 : :
91 : : private:
92 : :
93 : : static tDataKey mnNextKeyValue;
94 : :
95 : : osl::Mutex maMutex;
96 : :
97 : : std::map< tDataKey, tData > maInputStreamData;
98 : : };
99 : : #endif
100 : :
101 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|