Update ooo320-m1
[ooovba.git] / ucbhelper / source / provider / commandenvironmentproxy.cxx
blobfae6efe5dcdbdba6065f296639e3413de3696b51
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: commandenvironmentproxy.cxx,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucbhelper.hxx"
34 /**************************************************************************
35 TODO
36 **************************************************************************
38 *************************************************************************/
39 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
40 #include <com/sun/star/lang/XComponent.hpp>
41 #include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
42 #include <com/sun/star/ucb/XContentProvider.hpp>
43 #include <com/sun/star/ucb/XContentProviderManager.hpp>
44 #include <osl/mutex.hxx>
45 #include <ucbhelper/commandenvironmentproxy.hxx>
47 using namespace com::sun::star::lang;
48 using namespace com::sun::star::task;
49 using namespace com::sun::star::ucb;
50 using namespace com::sun::star::uno;
51 using namespace rtl;
53 namespace ucbhelper
56 //=========================================================================
57 //=========================================================================
59 // struct CommandEnvironmentProxy_Impl.
61 //=========================================================================
62 //=========================================================================
64 struct CommandEnvironmentProxy_Impl
66 osl::Mutex m_aMutex;
67 Reference< XCommandEnvironment > m_xEnv;
68 Reference< XInteractionHandler > m_xInteractionHandler;
69 Reference< XProgressHandler > m_xProgressHandler;
70 sal_Bool m_bGotInteractionHandler;
71 sal_Bool m_bGotProgressHandler;
73 CommandEnvironmentProxy_Impl(
74 const Reference< XCommandEnvironment >& rxEnv )
75 : m_xEnv( rxEnv ), m_bGotInteractionHandler( sal_False ),
76 m_bGotProgressHandler( sal_False ) {}
79 //=========================================================================
80 //=========================================================================
82 // CommandEnvironmentProxy Implementation.
84 //=========================================================================
85 //=========================================================================
87 CommandEnvironmentProxy::CommandEnvironmentProxy(
88 const Reference< XCommandEnvironment >& rxEnv )
90 m_pImpl = new CommandEnvironmentProxy_Impl( rxEnv );
93 //=========================================================================
94 // virtual
95 CommandEnvironmentProxy::~CommandEnvironmentProxy()
97 delete m_pImpl;
100 //=========================================================================
102 // XInterface methods
104 //=========================================================================
106 XINTERFACE_IMPL_2( CommandEnvironmentProxy,
107 XTypeProvider,
108 XCommandEnvironment );
110 //=========================================================================
112 // XTypeProvider methods
114 //=========================================================================
116 XTYPEPROVIDER_IMPL_2( CommandEnvironmentProxy,
117 XTypeProvider,
118 XCommandEnvironment );
120 //=========================================================================
122 // XCommandEnvironemnt methods.
124 //=========================================================================
126 // virtual
127 Reference< XInteractionHandler > SAL_CALL
128 CommandEnvironmentProxy::getInteractionHandler()
129 throw ( RuntimeException )
131 if ( m_pImpl->m_xEnv.is() )
133 if ( !m_pImpl->m_bGotInteractionHandler )
135 osl::MutexGuard aGuard( m_pImpl->m_aMutex );
136 if ( !m_pImpl->m_bGotInteractionHandler )
138 m_pImpl->m_xInteractionHandler
139 = m_pImpl->m_xEnv->getInteractionHandler();
140 m_pImpl->m_bGotInteractionHandler = sal_True;
144 return m_pImpl->m_xInteractionHandler;
147 //=========================================================================
148 // virtual
149 Reference< XProgressHandler > SAL_CALL
150 CommandEnvironmentProxy::getProgressHandler()
151 throw ( RuntimeException )
153 if ( m_pImpl->m_xEnv.is() )
155 if ( !m_pImpl->m_bGotProgressHandler )
157 osl::MutexGuard aGuard( m_pImpl->m_aMutex );
158 if ( !m_pImpl->m_bGotProgressHandler )
160 m_pImpl->m_xProgressHandler
161 = m_pImpl->m_xEnv->getProgressHandler();
162 m_pImpl->m_bGotProgressHandler = sal_True;
166 return m_pImpl->m_xProgressHandler;
169 } /* namespace ucbhelper */