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