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