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