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