1*0b4ced1dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0b4ced1dSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0b4ced1dSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0b4ced1dSAndrew Rist  * distributed with this work for additional information
6*0b4ced1dSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0b4ced1dSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0b4ced1dSAndrew Rist  * "License"); you may not use this file except in compliance
9*0b4ced1dSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*0b4ced1dSAndrew Rist  *
11*0b4ced1dSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*0b4ced1dSAndrew Rist  *
13*0b4ced1dSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0b4ced1dSAndrew Rist  * software distributed under the License is distributed on an
15*0b4ced1dSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0b4ced1dSAndrew Rist  * KIND, either express or implied.  See the License for the
17*0b4ced1dSAndrew Rist  * specific language governing permissions and limitations
18*0b4ced1dSAndrew Rist  * under the License.
19*0b4ced1dSAndrew Rist  *
20*0b4ced1dSAndrew Rist  *************************************************************/
21*0b4ced1dSAndrew Rist 
22*0b4ced1dSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir 
25cdf0e10cSrcweir //______________________________________________________________________________________________________________
26cdf0e10cSrcweir //	my own include
27cdf0e10cSrcweir //______________________________________________________________________________________________________________
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #include "framecontrol.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir //______________________________________________________________________________________________________________
32cdf0e10cSrcweir //	includes of other projects
33cdf0e10cSrcweir //______________________________________________________________________________________________________________
34cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp>
35cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp>
36cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp>
37cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
38cdf0e10cSrcweir #include <com/sun/star/frame/FrameSearchFlag.hpp>
39cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
40cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx>
41cdf0e10cSrcweir #include <vos/diagnose.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir //______________________________________________________________________________________________________________
44cdf0e10cSrcweir //	include of my own project
45cdf0e10cSrcweir //______________________________________________________________________________________________________________
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //______________________________________________________________________________________________________________
48cdf0e10cSrcweir //	namespaces
49cdf0e10cSrcweir //______________________________________________________________________________________________________________
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace	::rtl					;
52cdf0e10cSrcweir using namespace	::osl					;
53cdf0e10cSrcweir using namespace	::cppu					;
54cdf0e10cSrcweir using namespace	::com::sun::star::uno	;
55cdf0e10cSrcweir using namespace	::com::sun::star::lang	;
56cdf0e10cSrcweir using namespace	::com::sun::star::beans	;
57cdf0e10cSrcweir using namespace	::com::sun::star::awt	;
58cdf0e10cSrcweir using namespace	::com::sun::star::frame	;
59cdf0e10cSrcweir using namespace	::com::sun::star::util	;
60cdf0e10cSrcweir 
61cdf0e10cSrcweir namespace unocontrols{
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //______________________________________________________________________________________________________________
64cdf0e10cSrcweir //	construct/destruct
65cdf0e10cSrcweir //______________________________________________________________________________________________________________
66cdf0e10cSrcweir 
FrameControl(const Reference<XMultiServiceFactory> & xFactory)67cdf0e10cSrcweir FrameControl::FrameControl( const Reference< XMultiServiceFactory >& xFactory )
68cdf0e10cSrcweir 	: BaseControl					( xFactory																				)
69cdf0e10cSrcweir 	, OBroadcastHelper				( m_aMutex																				)
70cdf0e10cSrcweir 	, OPropertySetHelper			( *SAL_STATIC_CAST( OBroadcastHelper *, this )	)
71cdf0e10cSrcweir 	, m_aInterfaceContainer			( m_aMutex																				)
72cdf0e10cSrcweir 	, m_aConnectionPointContainer	( m_aMutex																				)
73cdf0e10cSrcweir {
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
~FrameControl()76cdf0e10cSrcweir FrameControl::~FrameControl()
77cdf0e10cSrcweir {
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir //____________________________________________________________________________________________________________
81cdf0e10cSrcweir //	XInterface
82cdf0e10cSrcweir //____________________________________________________________________________________________________________
83cdf0e10cSrcweir 
queryInterface(const Type & rType)84cdf0e10cSrcweir Any SAL_CALL FrameControl::queryInterface( const Type& rType ) throw( RuntimeException )
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	// Attention:
87cdf0e10cSrcweir 	//	Don't use mutex or guard in this method!!! Is a method of XInterface.
88cdf0e10cSrcweir 	Any aReturn ;
89cdf0e10cSrcweir 	Reference< XInterface > xDel = BaseControl::impl_getDelegator();
90cdf0e10cSrcweir 	if ( xDel.is() )
91cdf0e10cSrcweir 	{
92cdf0e10cSrcweir 		// If an delegator exist, forward question to his queryInterface.
93cdf0e10cSrcweir 		// Delegator will ask his own queryAggregation!
94cdf0e10cSrcweir 		aReturn = xDel->queryInterface( rType );
95cdf0e10cSrcweir 	}
96cdf0e10cSrcweir 	else
97cdf0e10cSrcweir 	{
98cdf0e10cSrcweir 		// If an delegator unknown, forward question to own queryAggregation.
99cdf0e10cSrcweir 		aReturn = queryAggregation( rType );
100cdf0e10cSrcweir 	}
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 	return aReturn ;
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir //____________________________________________________________________________________________________________
106cdf0e10cSrcweir //	XInterface
107cdf0e10cSrcweir //____________________________________________________________________________________________________________
108cdf0e10cSrcweir 
acquire()109cdf0e10cSrcweir void SAL_CALL FrameControl::acquire() throw()
110cdf0e10cSrcweir {
111cdf0e10cSrcweir 	// Attention:
112cdf0e10cSrcweir 	//	Don't use mutex or guard in this method!!! Is a method of XInterface.
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 	// Forward to baseclass
115cdf0e10cSrcweir 	BaseControl::acquire();
116cdf0e10cSrcweir }
117cdf0e10cSrcweir 
118cdf0e10cSrcweir //____________________________________________________________________________________________________________
119cdf0e10cSrcweir //	XInterface
120cdf0e10cSrcweir //____________________________________________________________________________________________________________
121cdf0e10cSrcweir 
release()122cdf0e10cSrcweir void SAL_CALL FrameControl::release() throw()
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	// Attention:
125cdf0e10cSrcweir 	//	Don't use mutex or guard in this method!!! Is a method of XInterface.
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	// Forward to baseclass
128cdf0e10cSrcweir 	BaseControl::release();
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
131cdf0e10cSrcweir //____________________________________________________________________________________________________________
132cdf0e10cSrcweir //	XTypeProvider
133cdf0e10cSrcweir //____________________________________________________________________________________________________________
134cdf0e10cSrcweir 
getTypes()135cdf0e10cSrcweir Sequence< Type > SAL_CALL FrameControl::getTypes() throw( RuntimeException )
136cdf0e10cSrcweir {
137cdf0e10cSrcweir 	// Optimize this method !
138cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
139cdf0e10cSrcweir 	// For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
140cdf0e10cSrcweir 	static OTypeCollection* pTypeCollection = NULL ;
141cdf0e10cSrcweir 
142cdf0e10cSrcweir 	if ( pTypeCollection == NULL )
143cdf0e10cSrcweir 	{
144cdf0e10cSrcweir 		// Ready for multithreading; get global mutex for first call of this method only! see before
145cdf0e10cSrcweir 		MutexGuard aGuard( Mutex::getGlobalMutex() );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 		// Control these pointer again ... it can be, that another instance will be faster then these!
148cdf0e10cSrcweir 		if ( pTypeCollection == NULL )
149cdf0e10cSrcweir 		{
150cdf0e10cSrcweir 			// Create a static typecollection ...
151cdf0e10cSrcweir 			static OTypeCollection aTypeCollection	(	::getCppuType(( const Reference< XControlModel				>*)NULL )	,
152cdf0e10cSrcweir 												  		::getCppuType(( const Reference< XControlContainer			>*)NULL )	,
153cdf0e10cSrcweir 												  		::getCppuType(( const Reference< XConnectionPointContainer	>*)NULL )	,
154cdf0e10cSrcweir 														BaseControl::getTypes()
155cdf0e10cSrcweir 													);
156cdf0e10cSrcweir 			// ... and set his address to static pointer!
157cdf0e10cSrcweir 			pTypeCollection = &aTypeCollection ;
158cdf0e10cSrcweir 		}
159cdf0e10cSrcweir 	}
160cdf0e10cSrcweir 
161cdf0e10cSrcweir 	return pTypeCollection->getTypes();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir //____________________________________________________________________________________________________________
165cdf0e10cSrcweir //	XAggregation
166cdf0e10cSrcweir //____________________________________________________________________________________________________________
167cdf0e10cSrcweir 
queryAggregation(const Type & aType)168cdf0e10cSrcweir Any SAL_CALL FrameControl::queryAggregation( const Type& aType ) throw( RuntimeException )
169cdf0e10cSrcweir {
170cdf0e10cSrcweir 	// Ask for my own supported interfaces ...
171cdf0e10cSrcweir 	// Attention: XTypeProvider and XInterface are supported by OComponentHelper!
172cdf0e10cSrcweir 	Any aReturn	( ::cppu::queryInterface(	aType												,
173cdf0e10cSrcweir 									   		static_cast< XControlModel*				> ( this )	,
174cdf0e10cSrcweir 									   		static_cast< XConnectionPointContainer*	> ( this )
175cdf0e10cSrcweir 										)
176cdf0e10cSrcweir 				);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	// If searched interface not supported by this class ...
179cdf0e10cSrcweir 	if ( aReturn.hasValue() == sal_False )
180cdf0e10cSrcweir 	{
181cdf0e10cSrcweir 		// ... ask baseclasses.
182cdf0e10cSrcweir 		aReturn = OPropertySetHelper::queryInterface( aType );
183cdf0e10cSrcweir 		if ( aReturn.hasValue() == sal_False )
184cdf0e10cSrcweir 		{
185cdf0e10cSrcweir 			aReturn = BaseControl::queryAggregation( aType );
186cdf0e10cSrcweir 		}
187cdf0e10cSrcweir 	}
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 	return aReturn ;
190cdf0e10cSrcweir }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir //____________________________________________________________________________________________________________
193cdf0e10cSrcweir //	XControl
194cdf0e10cSrcweir //____________________________________________________________________________________________________________
195cdf0e10cSrcweir 
createPeer(const Reference<XToolkit> & xToolkit,const Reference<XWindowPeer> & xParentPeer)196cdf0e10cSrcweir void SAL_CALL FrameControl::createPeer(	const	Reference< XToolkit >&		xToolkit	,
197cdf0e10cSrcweir 										const	Reference< XWindowPeer >&	xParentPeer	) throw( RuntimeException )
198cdf0e10cSrcweir {
199cdf0e10cSrcweir 	BaseControl::createPeer( xToolkit, xParentPeer );
200cdf0e10cSrcweir 	if ( impl_getPeerWindow().is() )
201cdf0e10cSrcweir 	{
202cdf0e10cSrcweir 		if( m_sComponentURL.getLength() > 0 )
203cdf0e10cSrcweir 		{
204cdf0e10cSrcweir 			impl_createFrame( getPeer(), m_sComponentURL, m_seqLoaderArguments );
205cdf0e10cSrcweir 		}
206cdf0e10cSrcweir 	}
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
209cdf0e10cSrcweir //____________________________________________________________________________________________________________
210cdf0e10cSrcweir //	XControl
211cdf0e10cSrcweir //____________________________________________________________________________________________________________
212cdf0e10cSrcweir 
setModel(const Reference<XControlModel> &)213cdf0e10cSrcweir sal_Bool SAL_CALL FrameControl::setModel( const Reference< XControlModel >& /*xModel*/ ) throw( RuntimeException )
214cdf0e10cSrcweir {
215cdf0e10cSrcweir 	// We have no model.
216cdf0e10cSrcweir 	return sal_False ;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir 
219cdf0e10cSrcweir //____________________________________________________________________________________________________________
220cdf0e10cSrcweir //	XControl
221cdf0e10cSrcweir //____________________________________________________________________________________________________________
222cdf0e10cSrcweir 
getModel()223cdf0e10cSrcweir Reference< XControlModel > SAL_CALL FrameControl::getModel() throw( RuntimeException )
224cdf0e10cSrcweir {
225cdf0e10cSrcweir 	// We have no model.
226cdf0e10cSrcweir 	return Reference< XControlModel >();
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir //____________________________________________________________________________________________________________
230cdf0e10cSrcweir //	XControl
231cdf0e10cSrcweir //____________________________________________________________________________________________________________
232cdf0e10cSrcweir 
dispose()233cdf0e10cSrcweir void SAL_CALL FrameControl::dispose() throw( RuntimeException )
234cdf0e10cSrcweir {
235cdf0e10cSrcweir     impl_deleteFrame();
236cdf0e10cSrcweir     BaseControl::dispose();
237cdf0e10cSrcweir }
238cdf0e10cSrcweir 
239cdf0e10cSrcweir //____________________________________________________________________________________________________________
240cdf0e10cSrcweir //	XView
241cdf0e10cSrcweir //____________________________________________________________________________________________________________
242cdf0e10cSrcweir 
setGraphics(const Reference<XGraphics> &)243cdf0e10cSrcweir sal_Bool SAL_CALL FrameControl::setGraphics( const Reference< XGraphics >& /*xDevice*/ ) throw( RuntimeException )
244cdf0e10cSrcweir {
245cdf0e10cSrcweir 	// it is not possible to print this control
246cdf0e10cSrcweir 	return sal_False ;
247cdf0e10cSrcweir }
248cdf0e10cSrcweir 
249cdf0e10cSrcweir //____________________________________________________________________________________________________________
250cdf0e10cSrcweir //	XView
251cdf0e10cSrcweir //____________________________________________________________________________________________________________
252cdf0e10cSrcweir 
getGraphics()253cdf0e10cSrcweir Reference< XGraphics > SAL_CALL FrameControl::getGraphics() throw( RuntimeException )
254cdf0e10cSrcweir {
255cdf0e10cSrcweir 	// when its not posible to set graphics ! then its possible to return null
256cdf0e10cSrcweir 	return Reference< XGraphics >();
257cdf0e10cSrcweir }
258cdf0e10cSrcweir 
259cdf0e10cSrcweir //____________________________________________________________________________________________________________
260cdf0e10cSrcweir //	XConnectionPointContainer
261cdf0e10cSrcweir //____________________________________________________________________________________________________________
262cdf0e10cSrcweir 
getConnectionPointTypes()263cdf0e10cSrcweir Sequence< Type > SAL_CALL FrameControl::getConnectionPointTypes() throw( RuntimeException )
264cdf0e10cSrcweir {
265cdf0e10cSrcweir 	// Forwarded to helper class
266cdf0e10cSrcweir 	return m_aConnectionPointContainer.getConnectionPointTypes();
267cdf0e10cSrcweir }
268cdf0e10cSrcweir 
269cdf0e10cSrcweir //____________________________________________________________________________________________________________
270cdf0e10cSrcweir //	XConnectionPointContainer
271cdf0e10cSrcweir //____________________________________________________________________________________________________________
272cdf0e10cSrcweir 
queryConnectionPoint(const Type & aType)273cdf0e10cSrcweir Reference< XConnectionPoint > SAL_CALL FrameControl::queryConnectionPoint( const Type& aType ) throw( RuntimeException )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir 	// Forwarded to helper class
276cdf0e10cSrcweir 	return m_aConnectionPointContainer.queryConnectionPoint( aType );
277cdf0e10cSrcweir }
278cdf0e10cSrcweir 
279cdf0e10cSrcweir //____________________________________________________________________________________________________________
280cdf0e10cSrcweir //	XConnectionPointContainer
281cdf0e10cSrcweir //____________________________________________________________________________________________________________
282cdf0e10cSrcweir 
advise(const Type & aType,const Reference<XInterface> & xListener)283cdf0e10cSrcweir void SAL_CALL FrameControl::advise(	const	Type&						aType		,
284cdf0e10cSrcweir 									const	Reference< XInterface >&	xListener	) throw( RuntimeException )
285cdf0e10cSrcweir {
286cdf0e10cSrcweir 	// Forwarded to helper class
287cdf0e10cSrcweir 	m_aConnectionPointContainer.advise( aType, xListener );
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir //____________________________________________________________________________________________________________
291cdf0e10cSrcweir //	XConnectionPointContainer
292cdf0e10cSrcweir //____________________________________________________________________________________________________________
293cdf0e10cSrcweir 
unadvise(const Type & aType,const Reference<XInterface> & xListener)294cdf0e10cSrcweir void SAL_CALL FrameControl::unadvise(	const	Type&						aType		,
295cdf0e10cSrcweir 										const	Reference< XInterface >&	xListener	) throw( RuntimeException )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir 	// Forwarded to helper class
298cdf0e10cSrcweir 	m_aConnectionPointContainer.unadvise( aType, xListener );
299cdf0e10cSrcweir }
300cdf0e10cSrcweir 
301cdf0e10cSrcweir //____________________________________________________________________________________________________________
302cdf0e10cSrcweir //	impl but public method to register service
303cdf0e10cSrcweir //____________________________________________________________________________________________________________
304cdf0e10cSrcweir 
impl_getStaticSupportedServiceNames()305cdf0e10cSrcweir const Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames()
306cdf0e10cSrcweir {
307cdf0e10cSrcweir 	MutexGuard aGuard( Mutex::getGlobalMutex() );
308cdf0e10cSrcweir     Sequence< OUString > seqServiceNames( 1 );
309cdf0e10cSrcweir     seqServiceNames.getArray() [0] = OUString::createFromAscii( SERVICENAME_FRAMECONTROL );
310cdf0e10cSrcweir     return seqServiceNames ;
311cdf0e10cSrcweir }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir //____________________________________________________________________________________________________________
314cdf0e10cSrcweir //	impl but public method to register service
315cdf0e10cSrcweir //____________________________________________________________________________________________________________
316cdf0e10cSrcweir 
impl_getStaticImplementationName()317cdf0e10cSrcweir const OUString FrameControl::impl_getStaticImplementationName()
318cdf0e10cSrcweir {
319cdf0e10cSrcweir 	return OUString::createFromAscii( IMPLEMENTATIONNAME_FRAMECONTROL );
320cdf0e10cSrcweir }
321cdf0e10cSrcweir 
322cdf0e10cSrcweir //____________________________________________________________________________________________________________
323cdf0e10cSrcweir //	OPropertySetHelper
324cdf0e10cSrcweir //____________________________________________________________________________________________________________
325cdf0e10cSrcweir 
convertFastPropertyValue(Any & rConvertedValue,Any & rOldValue,sal_Int32 nHandle,const Any & rValue)326cdf0e10cSrcweir sal_Bool FrameControl::convertFastPropertyValue(		Any&		rConvertedValue	,
327cdf0e10cSrcweir 														Any&		rOldValue		,
328cdf0e10cSrcweir 														sal_Int32	nHandle			,
329cdf0e10cSrcweir 												const	Any&		rValue			) throw( IllegalArgumentException )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir 	sal_Bool bReturn = sal_False ;
332cdf0e10cSrcweir 	switch (nHandle)
333cdf0e10cSrcweir 	{
334cdf0e10cSrcweir 		case PROPERTYHANDLE_COMPONENTURL		:		rConvertedValue	  = rValue					;
335cdf0e10cSrcweir 														rOldValue		<<= m_sComponentURL			;
336cdf0e10cSrcweir 														bReturn			  = sal_True				;
337cdf0e10cSrcweir 														break ;
338cdf0e10cSrcweir 
339cdf0e10cSrcweir 		case PROPERTYHANDLE_LOADERARGUMENTS		:		rConvertedValue	  = rValue					;
340cdf0e10cSrcweir 														rOldValue		<<= m_seqLoaderArguments	;
341cdf0e10cSrcweir 														bReturn			  = sal_True				;
342cdf0e10cSrcweir 														break ;
343cdf0e10cSrcweir 	}
344cdf0e10cSrcweir 
345cdf0e10cSrcweir 	if ( bReturn == sal_False )
346cdf0e10cSrcweir 	{
347cdf0e10cSrcweir 		throw IllegalArgumentException();
348cdf0e10cSrcweir 	}
349cdf0e10cSrcweir 
350cdf0e10cSrcweir 	return bReturn ;
351cdf0e10cSrcweir }
352cdf0e10cSrcweir 
353cdf0e10cSrcweir //____________________________________________________________________________________________________________
354cdf0e10cSrcweir //	OPropertySetHelper
355cdf0e10cSrcweir //____________________________________________________________________________________________________________
356cdf0e10cSrcweir 
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any & rValue)357cdf0e10cSrcweir void FrameControl::setFastPropertyValue_NoBroadcast(			sal_Int32	nHandle	,
358cdf0e10cSrcweir 														const	Any&		rValue	)
359cdf0e10cSrcweir                                                         throw ( ::com::sun::star::uno::Exception )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir 	// this method only set the value
362cdf0e10cSrcweir 	MutexGuard	aGuard (m_aMutex) ;
363cdf0e10cSrcweir 	switch (nHandle)
364cdf0e10cSrcweir 	{
365cdf0e10cSrcweir 		case PROPERTYHANDLE_COMPONENTURL		:		rValue >>= m_sComponentURL ;
366cdf0e10cSrcweir 														if (getPeer().is())
367cdf0e10cSrcweir 														{
368cdf0e10cSrcweir 															impl_createFrame ( getPeer(), m_sComponentURL, m_seqLoaderArguments ) ;
369cdf0e10cSrcweir 														}
370cdf0e10cSrcweir 														break ;
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 		case PROPERTYHANDLE_LOADERARGUMENTS		:		rValue >>= m_seqLoaderArguments ;
373cdf0e10cSrcweir 														break ;
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 		default	:										VOS_ENSHURE ( nHandle == -1, ERRORTEXT_VOSENSHURE ) ;
376cdf0e10cSrcweir 	}
377cdf0e10cSrcweir }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir //____________________________________________________________________________________________________________
380cdf0e10cSrcweir //	OPropertySetHelper
381cdf0e10cSrcweir //____________________________________________________________________________________________________________
382cdf0e10cSrcweir 
getFastPropertyValue(Any & rRet,sal_Int32 nHandle) const383cdf0e10cSrcweir void FrameControl::getFastPropertyValue(	Any&		rRet	,
384cdf0e10cSrcweir 											sal_Int32	nHandle	) const
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	MutexGuard	aGuard ( Mutex::getGlobalMutex() ) ;
387cdf0e10cSrcweir 
388cdf0e10cSrcweir 	switch (nHandle)
389cdf0e10cSrcweir 	{
390cdf0e10cSrcweir 		case PROPERTYHANDLE_COMPONENTURL	:		rRet <<= m_sComponentURL ;
391cdf0e10cSrcweir 													break ;
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 		case PROPERTYHANDLE_LOADERARGUMENTS	:		rRet <<= m_seqLoaderArguments ;
394cdf0e10cSrcweir 													break ;
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 		case PROPERTYHANDLE_FRAME			:		rRet <<= m_xFrame ;
397cdf0e10cSrcweir 							   						break ;
398cdf0e10cSrcweir 
399cdf0e10cSrcweir 		default	:			                        VOS_ENSHURE ( nHandle == -1, ERRORTEXT_VOSENSHURE ) ;
400cdf0e10cSrcweir 	}
401cdf0e10cSrcweir }
402cdf0e10cSrcweir 
403cdf0e10cSrcweir //____________________________________________________________________________________________________________
404cdf0e10cSrcweir //	OPropertySetHelper
405cdf0e10cSrcweir //____________________________________________________________________________________________________________
406cdf0e10cSrcweir 
getInfoHelper()407cdf0e10cSrcweir IPropertyArrayHelper& FrameControl::getInfoHelper()
408cdf0e10cSrcweir {
409cdf0e10cSrcweir 	// Create a table that map names to index values.
410cdf0e10cSrcweir 	static OPropertyArrayHelper* pInfo ;
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 	if (!pInfo)
413cdf0e10cSrcweir 	{
414cdf0e10cSrcweir 		// global method must be guarded
415cdf0e10cSrcweir 		MutexGuard	aGuard ( Mutex::getGlobalMutex() ) ;
416cdf0e10cSrcweir 
417cdf0e10cSrcweir 		if (!pInfo)
418cdf0e10cSrcweir 		{
419cdf0e10cSrcweir 			pInfo = new OPropertyArrayHelper( impl_getStaticPropertyDescriptor(), sal_True );
420cdf0e10cSrcweir 		}
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 	return *pInfo ;
424cdf0e10cSrcweir }
425cdf0e10cSrcweir /*
426cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
427cdf0e10cSrcweir // start OConnectionPointContainerHelper
428cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
429cdf0e10cSrcweir Uik* FrameControl::getConnectionPointUiks ( sal_Int32* pCount ) const
430cdf0e10cSrcweir {
431cdf0e10cSrcweir 	static Uik szUiks[] =
432cdf0e10cSrcweir 	{
433cdf0e10cSrcweir 		((XEventListener*)NULL)->getSmartUik  (),
434cdf0e10cSrcweir 		::getCppuType((const Reference< XPropertyChangeListener >*)0),
435cdf0e10cSrcweir 		::getCppuType((const Reference< XVetoableChangeListener >*)0),
436cdf0e10cSrcweir 		::getCppuType((const Reference< XPropertiesChangeListener >*)0)
437cdf0e10cSrcweir 	} ;
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	*pCount = 4 ;
440cdf0e10cSrcweir 
441cdf0e10cSrcweir 	return szUiks ;
442cdf0e10cSrcweir }
443cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
444cdf0e10cSrcweir // end OConnectionPointContainerHelper
445cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------
446cdf0e10cSrcweir */
447cdf0e10cSrcweir 
448cdf0e10cSrcweir //____________________________________________________________________________________________________________
449cdf0e10cSrcweir //	OPropertySetHelper
450cdf0e10cSrcweir //____________________________________________________________________________________________________________
451cdf0e10cSrcweir 
getPropertySetInfo()452cdf0e10cSrcweir Reference< XPropertySetInfo > SAL_CALL FrameControl::getPropertySetInfo() throw( RuntimeException )
453cdf0e10cSrcweir {
454cdf0e10cSrcweir 	// Optimize this method !
455cdf0e10cSrcweir 	// We initialize a static variable only one time. And we don't must use a mutex at every call!
456cdf0e10cSrcweir 	// For the first call; pInfo is NULL - for the second call pInfo is different from NULL!
457cdf0e10cSrcweir 	static Reference< XPropertySetInfo >* pInfo = (Reference< XPropertySetInfo >*)0 ;
458cdf0e10cSrcweir 	if ( pInfo == (Reference< XPropertySetInfo >*)0 )
459cdf0e10cSrcweir 	{
460cdf0e10cSrcweir 		// Ready for multithreading
461cdf0e10cSrcweir 		MutexGuard aGuard ( Mutex::getGlobalMutex () ) ;
462cdf0e10cSrcweir 		// Control this pointer again, another instance can be faster then these!
463cdf0e10cSrcweir 		if ( pInfo == (Reference< XPropertySetInfo >*)0 )
464cdf0e10cSrcweir 		{
465cdf0e10cSrcweir 			// Create structure of propertysetinfo for baseclass "OPropertySetHelper".
466cdf0e10cSrcweir 			// (Use method "getInfoHelper()".)
467cdf0e10cSrcweir 			static Reference< XPropertySetInfo > xInfo ( createPropertySetInfo ( getInfoHelper () ) ) ;
468cdf0e10cSrcweir 			pInfo = &xInfo ;
469cdf0e10cSrcweir 		}
470cdf0e10cSrcweir 	}
471cdf0e10cSrcweir 	return ( *pInfo ) ;
472cdf0e10cSrcweir }
473cdf0e10cSrcweir 
474cdf0e10cSrcweir //____________________________________________________________________________________________________________
475cdf0e10cSrcweir //	BaseControl
476cdf0e10cSrcweir //____________________________________________________________________________________________________________
477cdf0e10cSrcweir 
impl_getWindowDescriptor(const Reference<XWindowPeer> & xParentPeer)478cdf0e10cSrcweir WindowDescriptor* FrameControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
479cdf0e10cSrcweir {
480cdf0e10cSrcweir 	WindowDescriptor* pDescriptor	= new WindowDescriptor	;
481cdf0e10cSrcweir 
482cdf0e10cSrcweir 	pDescriptor->Type				= WindowClass_CONTAINER	;
483cdf0e10cSrcweir 	pDescriptor->ParentIndex		= -1					;
484cdf0e10cSrcweir 	pDescriptor->Parent				= xParentPeer			;
485cdf0e10cSrcweir 	pDescriptor->Bounds				= getPosSize ()			;
486cdf0e10cSrcweir 	pDescriptor->WindowAttributes	= 0						;
487cdf0e10cSrcweir 
488cdf0e10cSrcweir 	return pDescriptor ;
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir //____________________________________________________________________________________________________________
492cdf0e10cSrcweir //	private method
493cdf0e10cSrcweir //____________________________________________________________________________________________________________
494cdf0e10cSrcweir 
impl_createFrame(const Reference<XWindowPeer> & xPeer,const OUString & rURL,const Sequence<PropertyValue> & rArguments)495cdf0e10cSrcweir void FrameControl::impl_createFrame(	const	Reference< XWindowPeer >&	xPeer		,
496cdf0e10cSrcweir 										const	OUString&					rURL		,
497cdf0e10cSrcweir 										const	Sequence< PropertyValue >&	rArguments	)
498cdf0e10cSrcweir {
499cdf0e10cSrcweir 	Reference< XFrame > 	xOldFrame	;
500cdf0e10cSrcweir 	Reference< XFrame > 	xNewFrame	;
501cdf0e10cSrcweir 
502cdf0e10cSrcweir 	{
503cdf0e10cSrcweir 		MutexGuard	aGuard ( m_aMutex ) ;
504cdf0e10cSrcweir 		xOldFrame = m_xFrame ;
505cdf0e10cSrcweir 	}
506cdf0e10cSrcweir 
507cdf0e10cSrcweir 	xNewFrame = Reference< XFrame >  ( impl_getMultiServiceFactory()->createInstance ( OUString::createFromAscii( "com.sun.star.frame.Frame" ) ), UNO_QUERY ) ;
508cdf0e10cSrcweir 	Reference< XDispatchProvider >  xDSP ( xNewFrame, UNO_QUERY ) ;
509cdf0e10cSrcweir 
510cdf0e10cSrcweir 	if (xDSP.is())
511cdf0e10cSrcweir 	{
512cdf0e10cSrcweir 		Reference< XWindow >  xWP ( xPeer, UNO_QUERY ) ;
513cdf0e10cSrcweir 		xNewFrame->initialize ( xWP ) ;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir 		//	option
516cdf0e10cSrcweir 		//xFrame->setName( "WhatYouWant" );
517cdf0e10cSrcweir 
518cdf0e10cSrcweir 		Reference< XURLTransformer >  xTrans ( impl_getMultiServiceFactory()->createInstance ( OUString::createFromAscii( "com.sun.star.util.URLTransformer" ) ), UNO_QUERY ) ;
519cdf0e10cSrcweir 		if(xTrans.is())
520cdf0e10cSrcweir 		{
521cdf0e10cSrcweir 			// load file
522cdf0e10cSrcweir 			URL	aURL ;
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 			aURL.Complete = rURL ;
525cdf0e10cSrcweir 			xTrans->parseStrict( aURL ) ;
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 			Reference< XDispatch >  xDisp = xDSP->queryDispatch ( aURL, OUString (), FrameSearchFlag::SELF ) ;
528cdf0e10cSrcweir 			if (xDisp.is())
529cdf0e10cSrcweir 			{
530cdf0e10cSrcweir 				xDisp->dispatch ( aURL, rArguments ) ;
531cdf0e10cSrcweir 			}
532cdf0e10cSrcweir 		}
533cdf0e10cSrcweir 	}
534cdf0e10cSrcweir 
535cdf0e10cSrcweir 	// set the frame
536cdf0e10cSrcweir 	{
537cdf0e10cSrcweir 		MutexGuard aGuard ( m_aMutex ) ;
538cdf0e10cSrcweir 		m_xFrame = xNewFrame ;
539cdf0e10cSrcweir 	}
540cdf0e10cSrcweir 
541cdf0e10cSrcweir 	// notify the listeners
542cdf0e10cSrcweir 	sal_Int32	nFrameId = PROPERTYHANDLE_FRAME ;
543cdf0e10cSrcweir 	Any	aNewFrame ( &xNewFrame, ::getCppuType((const Reference< XFrame >*)0) ) ;
544cdf0e10cSrcweir 	Any	aOldFrame ( &xOldFrame, ::getCppuType((const Reference< XFrame >*)0) ) ;
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 	fire ( &nFrameId, &aNewFrame, &aOldFrame, 1, sal_False ) ;
547cdf0e10cSrcweir 
548cdf0e10cSrcweir 	if (xOldFrame.is())
549cdf0e10cSrcweir 	{
550cdf0e10cSrcweir 		xOldFrame->dispose () ;
551cdf0e10cSrcweir 	}
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir //____________________________________________________________________________________________________________
555cdf0e10cSrcweir //	private method
556cdf0e10cSrcweir //____________________________________________________________________________________________________________
557cdf0e10cSrcweir 
impl_deleteFrame()558cdf0e10cSrcweir void FrameControl::impl_deleteFrame()
559cdf0e10cSrcweir {
560cdf0e10cSrcweir 	Reference< XFrame >  xOldFrame;
561cdf0e10cSrcweir 	Reference< XFrame >  xNullFrame;
562cdf0e10cSrcweir 
563cdf0e10cSrcweir 	{
564cdf0e10cSrcweir         // do not dispose the frame in this guarded section (deadlock?)
565cdf0e10cSrcweir         MutexGuard aGuard( m_aMutex );
566cdf0e10cSrcweir         xOldFrame = m_xFrame;
567cdf0e10cSrcweir         m_xFrame = Reference< XFrame > ();
568cdf0e10cSrcweir 	}
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 	// notify the listeners
571cdf0e10cSrcweir     sal_Int32 nFrameId = PROPERTYHANDLE_FRAME;
572cdf0e10cSrcweir 	Any aNewFrame( &xNullFrame, ::getCppuType((const Reference< XFrame >*)0) );
573cdf0e10cSrcweir 	Any aOldFrame( &xOldFrame, ::getCppuType((const Reference< XFrame >*)0) );
574cdf0e10cSrcweir 	fire( &nFrameId, &aNewFrame, &aOldFrame, 1, sal_False );
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 	// dispose the frame
577cdf0e10cSrcweir 	if( xOldFrame.is() )
578cdf0e10cSrcweir 		xOldFrame->dispose();
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir //____________________________________________________________________________________________________________
582cdf0e10cSrcweir //	private method
583cdf0e10cSrcweir //____________________________________________________________________________________________________________
584cdf0e10cSrcweir 
impl_getStaticPropertyDescriptor()585cdf0e10cSrcweir const Sequence< Property > FrameControl::impl_getStaticPropertyDescriptor()
586cdf0e10cSrcweir {
587cdf0e10cSrcweir 	// All Properties of this implementation. The array must be sorted!
588cdf0e10cSrcweir 	static const Property pPropertys[PROPERTY_COUNT] =
589cdf0e10cSrcweir 	{
590cdf0e10cSrcweir 		Property( OUString::createFromAscii( PROPERTYNAME_COMPONENTURL		), PROPERTYHANDLE_COMPONENTURL		, ::getCppuType((const OUString*)0)					, PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED	),
591cdf0e10cSrcweir 		Property( OUString::createFromAscii( PROPERTYNAME_FRAME				), PROPERTYHANDLE_FRAME				, ::getCppuType((const Reference< XFrame >*)0)		, PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT	),
592cdf0e10cSrcweir 		Property( OUString::createFromAscii( PROPERTYNAME_LOADERARGUMENTS	), PROPERTYHANDLE_LOADERARGUMENTS	, ::getCppuType((const Sequence< PropertyValue >*)0), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED	)
593cdf0e10cSrcweir 	};
594cdf0e10cSrcweir 
595cdf0e10cSrcweir 	static const Sequence< Property > seqPropertys( pPropertys, PROPERTY_COUNT );
596cdf0e10cSrcweir 
597cdf0e10cSrcweir 	return seqPropertys ;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir 
600cdf0e10cSrcweir }	// namespace unocontrols
601