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 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_ucbhelper.hxx" 30 31 /************************************************************************** 32 TODO 33 ************************************************************************** 34 35 *************************************************************************/ 36 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 37 #include <com/sun/star/lang/XComponent.hpp> 38 #include <com/sun/star/ucb/XContentIdentifierFactory.hpp> 39 #include <com/sun/star/ucb/XContentProvider.hpp> 40 #include <com/sun/star/ucb/XContentProviderManager.hpp> 41 #include <osl/mutex.hxx> 42 #include <ucbhelper/commandenvironmentproxy.hxx> 43 44 using namespace com::sun::star::lang; 45 using namespace com::sun::star::task; 46 using namespace com::sun::star::ucb; 47 using namespace com::sun::star::uno; 48 using namespace rtl; 49 50 namespace ucbhelper 51 { 52 53 //========================================================================= 54 //========================================================================= 55 // 56 // struct CommandEnvironmentProxy_Impl. 57 // 58 //========================================================================= 59 //========================================================================= 60 61 struct CommandEnvironmentProxy_Impl 62 { 63 osl::Mutex m_aMutex; 64 Reference< XCommandEnvironment > m_xEnv; 65 Reference< XInteractionHandler > m_xInteractionHandler; 66 Reference< XProgressHandler > m_xProgressHandler; 67 sal_Bool m_bGotInteractionHandler; 68 sal_Bool m_bGotProgressHandler; 69 70 CommandEnvironmentProxy_Impl( 71 const Reference< XCommandEnvironment >& rxEnv ) 72 : m_xEnv( rxEnv ), m_bGotInteractionHandler( sal_False ), 73 m_bGotProgressHandler( sal_False ) {} 74 }; 75 76 //========================================================================= 77 //========================================================================= 78 // 79 // CommandEnvironmentProxy Implementation. 80 // 81 //========================================================================= 82 //========================================================================= 83 84 CommandEnvironmentProxy::CommandEnvironmentProxy( 85 const Reference< XCommandEnvironment >& rxEnv ) 86 { 87 m_pImpl = new CommandEnvironmentProxy_Impl( rxEnv ); 88 } 89 90 //========================================================================= 91 // virtual 92 CommandEnvironmentProxy::~CommandEnvironmentProxy() 93 { 94 delete m_pImpl; 95 } 96 97 //========================================================================= 98 // 99 // XInterface methods 100 // 101 //========================================================================= 102 103 XINTERFACE_IMPL_2( CommandEnvironmentProxy, 104 XTypeProvider, 105 XCommandEnvironment ); 106 107 //========================================================================= 108 // 109 // XTypeProvider methods 110 // 111 //========================================================================= 112 113 XTYPEPROVIDER_IMPL_2( CommandEnvironmentProxy, 114 XTypeProvider, 115 XCommandEnvironment ); 116 117 //========================================================================= 118 // 119 // XCommandEnvironemnt methods. 120 // 121 //========================================================================= 122 123 // virtual 124 Reference< XInteractionHandler > SAL_CALL 125 CommandEnvironmentProxy::getInteractionHandler() 126 throw ( RuntimeException ) 127 { 128 if ( m_pImpl->m_xEnv.is() ) 129 { 130 if ( !m_pImpl->m_bGotInteractionHandler ) 131 { 132 osl::MutexGuard aGuard( m_pImpl->m_aMutex ); 133 if ( !m_pImpl->m_bGotInteractionHandler ) 134 { 135 m_pImpl->m_xInteractionHandler 136 = m_pImpl->m_xEnv->getInteractionHandler(); 137 m_pImpl->m_bGotInteractionHandler = sal_True; 138 } 139 } 140 } 141 return m_pImpl->m_xInteractionHandler; 142 } 143 144 //========================================================================= 145 // virtual 146 Reference< XProgressHandler > SAL_CALL 147 CommandEnvironmentProxy::getProgressHandler() 148 throw ( RuntimeException ) 149 { 150 if ( m_pImpl->m_xEnv.is() ) 151 { 152 if ( !m_pImpl->m_bGotProgressHandler ) 153 { 154 osl::MutexGuard aGuard( m_pImpl->m_aMutex ); 155 if ( !m_pImpl->m_bGotProgressHandler ) 156 { 157 m_pImpl->m_xProgressHandler 158 = m_pImpl->m_xEnv->getProgressHandler(); 159 m_pImpl->m_bGotProgressHandler = sal_True; 160 } 161 } 162 } 163 return m_pImpl->m_xProgressHandler; 164 } 165 166 } /* namespace ucbhelper */ 167 168