1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_ucbhelper.hxx"
30*cdf0e10cSrcweir /**************************************************************************
31*cdf0e10cSrcweir 								TODO
32*cdf0e10cSrcweir  **************************************************************************
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir  *************************************************************************/
35*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/ucb/XPropertySetRegistry.hpp>
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir #include "osl/diagnose.h"
39*cdf0e10cSrcweir #include "osl/mutex.hxx"
40*cdf0e10cSrcweir #include <ucbhelper/contenthelper.hxx>
41*cdf0e10cSrcweir #include <ucbhelper/contentinfo.hxx>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using namespace com::sun::star;
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir //=========================================================================
46*cdf0e10cSrcweir //=========================================================================
47*cdf0e10cSrcweir //
48*cdf0e10cSrcweir // PropertySetInfo Implementation.
49*cdf0e10cSrcweir //
50*cdf0e10cSrcweir //=========================================================================
51*cdf0e10cSrcweir //=========================================================================
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir namespace ucbhelper {
54*cdf0e10cSrcweir 
55*cdf0e10cSrcweir PropertySetInfo::PropertySetInfo(
56*cdf0e10cSrcweir     const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
57*cdf0e10cSrcweir     const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv,
58*cdf0e10cSrcweir     ContentImplHelper* pContent )
59*cdf0e10cSrcweir : m_xSMgr( rxSMgr ),
60*cdf0e10cSrcweir   m_xEnv( rxEnv ),
61*cdf0e10cSrcweir   m_pProps( 0 ),
62*cdf0e10cSrcweir   m_pContent( pContent )
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir }
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir //=========================================================================
67*cdf0e10cSrcweir // virtual
68*cdf0e10cSrcweir PropertySetInfo::~PropertySetInfo()
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir 	delete m_pProps;
71*cdf0e10cSrcweir }
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir //=========================================================================
74*cdf0e10cSrcweir //
75*cdf0e10cSrcweir // XInterface methods.
76*cdf0e10cSrcweir //
77*cdf0e10cSrcweir //=========================================================================
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir XINTERFACE_IMPL_2( PropertySetInfo,
80*cdf0e10cSrcweir 				   lang::XTypeProvider,
81*cdf0e10cSrcweir 				   beans::XPropertySetInfo );
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir //=========================================================================
84*cdf0e10cSrcweir //
85*cdf0e10cSrcweir // XTypeProvider methods.
86*cdf0e10cSrcweir //
87*cdf0e10cSrcweir //=========================================================================
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( PropertySetInfo,
90*cdf0e10cSrcweir 	 		   		  lang::XTypeProvider,
91*cdf0e10cSrcweir 	 		   		  beans::XPropertySetInfo );
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir //=========================================================================
94*cdf0e10cSrcweir //
95*cdf0e10cSrcweir // XPropertySetInfo methods.
96*cdf0e10cSrcweir //
97*cdf0e10cSrcweir //=========================================================================
98*cdf0e10cSrcweir 
99*cdf0e10cSrcweir // virtual
100*cdf0e10cSrcweir uno::Sequence< beans::Property > SAL_CALL PropertySetInfo::getProperties()
101*cdf0e10cSrcweir 	throw( uno::RuntimeException )
102*cdf0e10cSrcweir {
103*cdf0e10cSrcweir 	if ( !m_pProps )
104*cdf0e10cSrcweir 	{
105*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
106*cdf0e10cSrcweir 		if ( !m_pProps )
107*cdf0e10cSrcweir 		{
108*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////
109*cdf0e10cSrcweir 			// Get info for core ( native) properties.
110*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir             try
113*cdf0e10cSrcweir             {
114*cdf0e10cSrcweir                 uno::Sequence< beans::Property > aProps
115*cdf0e10cSrcweir                     = m_pContent->getProperties( m_xEnv );
116*cdf0e10cSrcweir                 m_pProps = new uno::Sequence< beans::Property >( aProps );
117*cdf0e10cSrcweir             }
118*cdf0e10cSrcweir             catch ( uno::RuntimeException const & )
119*cdf0e10cSrcweir             {
120*cdf0e10cSrcweir                 throw;
121*cdf0e10cSrcweir             }
122*cdf0e10cSrcweir             catch ( uno::Exception const & )
123*cdf0e10cSrcweir             {
124*cdf0e10cSrcweir                 m_pProps = new uno::Sequence< beans::Property >( 0 );
125*cdf0e10cSrcweir             }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////
128*cdf0e10cSrcweir 			// Get info for additional properties.
129*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir 			uno::Reference< com::sun::star::ucb::XPersistentPropertySet >
132*cdf0e10cSrcweir                 xSet ( m_pContent->getAdditionalPropertySet( sal_False ) );
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 			if ( xSet.is() )
135*cdf0e10cSrcweir 			{
136*cdf0e10cSrcweir 				// Get property set info.
137*cdf0e10cSrcweir 				uno::Reference< beans::XPropertySetInfo > xInfo(
138*cdf0e10cSrcweir                     xSet->getPropertySetInfo() );
139*cdf0e10cSrcweir 				if ( xInfo.is() )
140*cdf0e10cSrcweir 				{
141*cdf0e10cSrcweir 					const uno::Sequence< beans::Property >& rAddProps
142*cdf0e10cSrcweir 						= xInfo->getProperties();
143*cdf0e10cSrcweir 					sal_Int32 nAddProps = rAddProps.getLength();
144*cdf0e10cSrcweir 					if ( nAddProps > 0 )
145*cdf0e10cSrcweir 					{
146*cdf0e10cSrcweir 						sal_Int32 nPos = m_pProps->getLength();
147*cdf0e10cSrcweir 						m_pProps->realloc( nPos + nAddProps );
148*cdf0e10cSrcweir 
149*cdf0e10cSrcweir 						beans::Property* pProps = m_pProps->getArray();
150*cdf0e10cSrcweir 						const beans::Property* pAddProps
151*cdf0e10cSrcweir                             = rAddProps.getConstArray();
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 						for ( sal_Int32 n = 0; n < nAddProps; ++n, ++nPos )
154*cdf0e10cSrcweir 							pProps[ nPos ] = pAddProps[ n ];
155*cdf0e10cSrcweir 					}
156*cdf0e10cSrcweir 				}
157*cdf0e10cSrcweir 			}
158*cdf0e10cSrcweir 		}
159*cdf0e10cSrcweir 	}
160*cdf0e10cSrcweir 	return *m_pProps;
161*cdf0e10cSrcweir }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir //=========================================================================
164*cdf0e10cSrcweir // virtual
165*cdf0e10cSrcweir beans::Property SAL_CALL PropertySetInfo::getPropertyByName(
166*cdf0e10cSrcweir         const rtl::OUString& aName )
167*cdf0e10cSrcweir 	throw( beans::UnknownPropertyException, uno::RuntimeException )
168*cdf0e10cSrcweir {
169*cdf0e10cSrcweir 	beans::Property aProp;
170*cdf0e10cSrcweir 	if ( queryProperty( aName, aProp ) )
171*cdf0e10cSrcweir 		return aProp;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir 	throw beans::UnknownPropertyException();
174*cdf0e10cSrcweir }
175*cdf0e10cSrcweir 
176*cdf0e10cSrcweir //=========================================================================
177*cdf0e10cSrcweir // virtual
178*cdf0e10cSrcweir sal_Bool SAL_CALL PropertySetInfo::hasPropertyByName(
179*cdf0e10cSrcweir         const rtl::OUString& Name )
180*cdf0e10cSrcweir 	throw( uno::RuntimeException )
181*cdf0e10cSrcweir {
182*cdf0e10cSrcweir 	beans::Property aProp;
183*cdf0e10cSrcweir 	return queryProperty( Name, aProp );
184*cdf0e10cSrcweir }
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir //=========================================================================
187*cdf0e10cSrcweir //
188*cdf0e10cSrcweir // Non-Interface methods.
189*cdf0e10cSrcweir //
190*cdf0e10cSrcweir //=========================================================================
191*cdf0e10cSrcweir 
192*cdf0e10cSrcweir void PropertySetInfo::reset()
193*cdf0e10cSrcweir {
194*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
195*cdf0e10cSrcweir 	delete m_pProps;
196*cdf0e10cSrcweir 	m_pProps = 0;
197*cdf0e10cSrcweir }
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir //=========================================================================
200*cdf0e10cSrcweir sal_Bool PropertySetInfo::queryProperty(
201*cdf0e10cSrcweir     const rtl::OUString& rName, beans::Property& rProp )
202*cdf0e10cSrcweir {
203*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
204*cdf0e10cSrcweir 
205*cdf0e10cSrcweir 	getProperties();
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	const beans::Property* pProps = m_pProps->getConstArray();
208*cdf0e10cSrcweir 	sal_Int32 nCount = m_pProps->getLength();
209*cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < nCount; ++n )
210*cdf0e10cSrcweir 	{
211*cdf0e10cSrcweir 		const beans::Property& rCurrProp = pProps[ n ];
212*cdf0e10cSrcweir 		if ( rCurrProp.Name == rName )
213*cdf0e10cSrcweir 		{
214*cdf0e10cSrcweir 			rProp = rCurrProp;
215*cdf0e10cSrcweir 			return sal_True;
216*cdf0e10cSrcweir 		}
217*cdf0e10cSrcweir 	}
218*cdf0e10cSrcweir 
219*cdf0e10cSrcweir 	return sal_False;
220*cdf0e10cSrcweir }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir //=========================================================================
223*cdf0e10cSrcweir //=========================================================================
224*cdf0e10cSrcweir //
225*cdf0e10cSrcweir // CommandProcessorInfo Implementation.
226*cdf0e10cSrcweir //
227*cdf0e10cSrcweir //=========================================================================
228*cdf0e10cSrcweir //=========================================================================
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir CommandProcessorInfo::CommandProcessorInfo(
231*cdf0e10cSrcweir     const uno::Reference< lang::XMultiServiceFactory >& rxSMgr,
232*cdf0e10cSrcweir     const uno::Reference< com::sun::star::ucb::XCommandEnvironment >& rxEnv,
233*cdf0e10cSrcweir     ContentImplHelper* pContent )
234*cdf0e10cSrcweir : m_xSMgr( rxSMgr ),
235*cdf0e10cSrcweir   m_xEnv( rxEnv ),
236*cdf0e10cSrcweir   m_pCommands( 0 ),
237*cdf0e10cSrcweir   m_pContent( pContent )
238*cdf0e10cSrcweir {
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir //=========================================================================
242*cdf0e10cSrcweir // virtual
243*cdf0e10cSrcweir CommandProcessorInfo::~CommandProcessorInfo()
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir 	delete m_pCommands;
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir //=========================================================================
249*cdf0e10cSrcweir //
250*cdf0e10cSrcweir // XInterface methods.
251*cdf0e10cSrcweir //
252*cdf0e10cSrcweir //=========================================================================
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir XINTERFACE_IMPL_2( CommandProcessorInfo,
255*cdf0e10cSrcweir 				   lang::XTypeProvider,
256*cdf0e10cSrcweir 				   com::sun::star::ucb::XCommandInfo );
257*cdf0e10cSrcweir 
258*cdf0e10cSrcweir //=========================================================================
259*cdf0e10cSrcweir //
260*cdf0e10cSrcweir // XTypeProvider methods.
261*cdf0e10cSrcweir //
262*cdf0e10cSrcweir //=========================================================================
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( CommandProcessorInfo,
265*cdf0e10cSrcweir 			   		  lang::XTypeProvider,
266*cdf0e10cSrcweir 			   		  com::sun::star::ucb::XCommandInfo );
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir //=========================================================================
269*cdf0e10cSrcweir //
270*cdf0e10cSrcweir // XCommandInfo methods.
271*cdf0e10cSrcweir //
272*cdf0e10cSrcweir //=========================================================================
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir // virtual
275*cdf0e10cSrcweir uno::Sequence< com::sun::star::ucb::CommandInfo > SAL_CALL
276*cdf0e10cSrcweir CommandProcessorInfo::getCommands()
277*cdf0e10cSrcweir 	throw( uno::RuntimeException )
278*cdf0e10cSrcweir {
279*cdf0e10cSrcweir 	if ( !m_pCommands )
280*cdf0e10cSrcweir 	{
281*cdf0e10cSrcweir 		osl::MutexGuard aGuard( m_aMutex );
282*cdf0e10cSrcweir 		if ( !m_pCommands )
283*cdf0e10cSrcweir 		{
284*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////
285*cdf0e10cSrcweir 			// Get info for commands.
286*cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir             try
289*cdf0e10cSrcweir             {
290*cdf0e10cSrcweir                 uno::Sequence< com::sun::star::ucb::CommandInfo > aCmds
291*cdf0e10cSrcweir                     = m_pContent->getCommands( m_xEnv );
292*cdf0e10cSrcweir                 m_pCommands
293*cdf0e10cSrcweir                     = new uno::Sequence< com::sun::star::ucb::CommandInfo >(
294*cdf0e10cSrcweir                         aCmds );
295*cdf0e10cSrcweir             }
296*cdf0e10cSrcweir             catch ( uno::RuntimeException const & )
297*cdf0e10cSrcweir             {
298*cdf0e10cSrcweir                 throw;
299*cdf0e10cSrcweir             }
300*cdf0e10cSrcweir             catch ( uno::Exception const & )
301*cdf0e10cSrcweir             {
302*cdf0e10cSrcweir                 m_pCommands
303*cdf0e10cSrcweir                     = new uno::Sequence< com::sun::star::ucb::CommandInfo >(
304*cdf0e10cSrcweir                         0 );
305*cdf0e10cSrcweir             }
306*cdf0e10cSrcweir 		}
307*cdf0e10cSrcweir 	}
308*cdf0e10cSrcweir 	return *m_pCommands;
309*cdf0e10cSrcweir }
310*cdf0e10cSrcweir 
311*cdf0e10cSrcweir //=========================================================================
312*cdf0e10cSrcweir // virtual
313*cdf0e10cSrcweir com::sun::star::ucb::CommandInfo SAL_CALL
314*cdf0e10cSrcweir CommandProcessorInfo::getCommandInfoByName(
315*cdf0e10cSrcweir         const rtl::OUString& Name )
316*cdf0e10cSrcweir 	throw( com::sun::star::ucb::UnsupportedCommandException,
317*cdf0e10cSrcweir            uno::RuntimeException )
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir 	com::sun::star::ucb::CommandInfo aInfo;
320*cdf0e10cSrcweir 	if ( queryCommand( Name, aInfo ) )
321*cdf0e10cSrcweir 		return aInfo;
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir 	throw com::sun::star::ucb::UnsupportedCommandException();
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir //=========================================================================
327*cdf0e10cSrcweir // virtual
328*cdf0e10cSrcweir com::sun::star::ucb::CommandInfo SAL_CALL
329*cdf0e10cSrcweir CommandProcessorInfo::getCommandInfoByHandle( sal_Int32 Handle )
330*cdf0e10cSrcweir 	throw( com::sun::star::ucb::UnsupportedCommandException,
331*cdf0e10cSrcweir            uno::RuntimeException )
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir 	com::sun::star::ucb::CommandInfo aInfo;
334*cdf0e10cSrcweir 	if ( queryCommand( Handle, aInfo ) )
335*cdf0e10cSrcweir 		return aInfo;
336*cdf0e10cSrcweir 
337*cdf0e10cSrcweir 	throw com::sun::star::ucb::UnsupportedCommandException();
338*cdf0e10cSrcweir }
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir //=========================================================================
341*cdf0e10cSrcweir // virtual
342*cdf0e10cSrcweir sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByName(
343*cdf0e10cSrcweir        const rtl::OUString& Name )
344*cdf0e10cSrcweir 	throw( uno::RuntimeException )
345*cdf0e10cSrcweir {
346*cdf0e10cSrcweir 	com::sun::star::ucb::CommandInfo aInfo;
347*cdf0e10cSrcweir 	return queryCommand( Name, aInfo );
348*cdf0e10cSrcweir }
349*cdf0e10cSrcweir 
350*cdf0e10cSrcweir //=========================================================================
351*cdf0e10cSrcweir // virtual
352*cdf0e10cSrcweir sal_Bool SAL_CALL CommandProcessorInfo::hasCommandByHandle( sal_Int32 Handle )
353*cdf0e10cSrcweir 	throw( uno::RuntimeException )
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir 	com::sun::star::ucb::CommandInfo aInfo;
356*cdf0e10cSrcweir 	return queryCommand( Handle, aInfo );
357*cdf0e10cSrcweir }
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir //=========================================================================
360*cdf0e10cSrcweir //
361*cdf0e10cSrcweir // Non-Interface methods.
362*cdf0e10cSrcweir //
363*cdf0e10cSrcweir //=========================================================================
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir void CommandProcessorInfo::reset()
366*cdf0e10cSrcweir {
367*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
368*cdf0e10cSrcweir 	delete m_pCommands;
369*cdf0e10cSrcweir 	m_pCommands = 0;
370*cdf0e10cSrcweir }
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir 
373*cdf0e10cSrcweir //=========================================================================
374*cdf0e10cSrcweir sal_Bool CommandProcessorInfo::queryCommand(
375*cdf0e10cSrcweir     const rtl::OUString& rName,
376*cdf0e10cSrcweir     com::sun::star::ucb::CommandInfo& rCommand )
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
379*cdf0e10cSrcweir 
380*cdf0e10cSrcweir 	getCommands();
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir 	const com::sun::star::ucb::CommandInfo* pCommands
383*cdf0e10cSrcweir         = m_pCommands->getConstArray();
384*cdf0e10cSrcweir 	sal_Int32 nCount = m_pCommands->getLength();
385*cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < nCount; ++n )
386*cdf0e10cSrcweir 	{
387*cdf0e10cSrcweir 		const com::sun::star::ucb::CommandInfo& rCurrCommand = pCommands[ n ];
388*cdf0e10cSrcweir 		if ( rCurrCommand.Name == rName )
389*cdf0e10cSrcweir 		{
390*cdf0e10cSrcweir 			rCommand = rCurrCommand;
391*cdf0e10cSrcweir 			return sal_True;
392*cdf0e10cSrcweir 		}
393*cdf0e10cSrcweir 	}
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir 	return sal_False;
396*cdf0e10cSrcweir }
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir //=========================================================================
399*cdf0e10cSrcweir sal_Bool CommandProcessorInfo::queryCommand(
400*cdf0e10cSrcweir     sal_Int32 nHandle,
401*cdf0e10cSrcweir     com::sun::star::ucb::CommandInfo& rCommand )
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	osl::MutexGuard aGuard( m_aMutex );
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir 	getCommands();
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir 	const com::sun::star::ucb::CommandInfo* pCommands
408*cdf0e10cSrcweir         = m_pCommands->getConstArray();
409*cdf0e10cSrcweir 	sal_Int32 nCount = m_pCommands->getLength();
410*cdf0e10cSrcweir 	for ( sal_Int32 n = 0; n < nCount; ++n )
411*cdf0e10cSrcweir 	{
412*cdf0e10cSrcweir 		const com::sun::star::ucb::CommandInfo& rCurrCommand = pCommands[ n ];
413*cdf0e10cSrcweir 		if ( rCurrCommand.Handle == nHandle )
414*cdf0e10cSrcweir 		{
415*cdf0e10cSrcweir 			rCommand = rCurrCommand;
416*cdf0e10cSrcweir 			return sal_True;
417*cdf0e10cSrcweir 		}
418*cdf0e10cSrcweir 	}
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 	return sal_False;
421*cdf0e10cSrcweir }
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir } // namespace ucbhelper
424