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 // my own include 30*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 31*cdf0e10cSrcweir 32*cdf0e10cSrcweir #include "basecontrol.hxx" 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 35*cdf0e10cSrcweir // includes of other projects 36*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 37*cdf0e10cSrcweir #include <com/sun/star/awt/XDevice.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/awt/XDisplayBitmap.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/awt/DeviceInfo.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/awt/WindowAttribute.hpp> 41*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 42*cdf0e10cSrcweir #include <cppuhelper/typeprovider.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 45*cdf0e10cSrcweir // includes of my own project 46*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 49*cdf0e10cSrcweir // namespaces 50*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir using namespace ::cppu ; 53*cdf0e10cSrcweir using namespace ::osl ; 54*cdf0e10cSrcweir using namespace ::rtl ; 55*cdf0e10cSrcweir using namespace ::com::sun::star::uno ; 56*cdf0e10cSrcweir using namespace ::com::sun::star::lang ; 57*cdf0e10cSrcweir using namespace ::com::sun::star::awt ; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweir namespace unocontrols{ 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 62*cdf0e10cSrcweir // defines 63*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 64*cdf0e10cSrcweir 65*cdf0e10cSrcweir #define DEFAULT_PMULTIPLEXER NULL 66*cdf0e10cSrcweir #define DEFAULT_X 0 67*cdf0e10cSrcweir #define DEFAULT_Y 0 68*cdf0e10cSrcweir #define DEFAULT_WIDTH 100 69*cdf0e10cSrcweir #define DEFAULT_HEIGHT 100 70*cdf0e10cSrcweir #define DEFAULT_VISIBLE sal_False 71*cdf0e10cSrcweir #define DEFAULT_INDESIGNMODE sal_False 72*cdf0e10cSrcweir #define DEFAULT_ENABLE sal_True 73*cdf0e10cSrcweir #define SERVICE_VCLTOOLKIT "com.sun.star.awt.Toolkit" 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 76*cdf0e10cSrcweir // construct/destruct 77*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir BaseControl::BaseControl( const Reference< XMultiServiceFactory >& xFactory ) 80*cdf0e10cSrcweir : IMPL_MutexContainer ( ) 81*cdf0e10cSrcweir , OComponentHelper ( m_aMutex ) 82*cdf0e10cSrcweir , m_xFactory ( xFactory ) 83*cdf0e10cSrcweir , m_pMultiplexer ( DEFAULT_PMULTIPLEXER ) 84*cdf0e10cSrcweir , m_nX ( DEFAULT_X ) 85*cdf0e10cSrcweir , m_nY ( DEFAULT_Y ) 86*cdf0e10cSrcweir , m_nWidth ( DEFAULT_WIDTH ) 87*cdf0e10cSrcweir , m_nHeight ( DEFAULT_HEIGHT ) 88*cdf0e10cSrcweir , m_bVisible ( DEFAULT_VISIBLE ) 89*cdf0e10cSrcweir , m_bInDesignMode ( DEFAULT_INDESIGNMODE ) 90*cdf0e10cSrcweir , m_bEnable ( DEFAULT_ENABLE ) 91*cdf0e10cSrcweir { 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir BaseControl::~BaseControl() 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir } 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 99*cdf0e10cSrcweir // XInterface 100*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir Any SAL_CALL BaseControl::queryInterface( const Type& rType ) throw( RuntimeException ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir Any aReturn ; 105*cdf0e10cSrcweir if ( m_xDelegator.is() == sal_True ) 106*cdf0e10cSrcweir { 107*cdf0e10cSrcweir // If an delegator exist, forward question to his queryInterface. 108*cdf0e10cSrcweir // Delegator will ask his own queryAggregation! 109*cdf0e10cSrcweir aReturn = m_xDelegator->queryInterface( rType ); 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir else 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir // If an delegator unknown, forward question to own queryAggregation. 114*cdf0e10cSrcweir aReturn = queryAggregation( rType ); 115*cdf0e10cSrcweir } 116*cdf0e10cSrcweir 117*cdf0e10cSrcweir return aReturn ; 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 121*cdf0e10cSrcweir // XInterface 122*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir void SAL_CALL BaseControl::acquire() throw() 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir // Attention: 127*cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface. 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir // Forward to baseclass 130*cdf0e10cSrcweir OComponentHelper::acquire(); 131*cdf0e10cSrcweir } 132*cdf0e10cSrcweir 133*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 134*cdf0e10cSrcweir // XInterface 135*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir void SAL_CALL BaseControl::release() throw() 138*cdf0e10cSrcweir { 139*cdf0e10cSrcweir // Attention: 140*cdf0e10cSrcweir // Don't use mutex or guard in this method!!! Is a method of XInterface. 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir // Forward to baseclass 143*cdf0e10cSrcweir OComponentHelper::release(); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 147*cdf0e10cSrcweir // XTypeProvider 148*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 149*cdf0e10cSrcweir 150*cdf0e10cSrcweir Sequence< Type > SAL_CALL BaseControl::getTypes() throw( RuntimeException ) 151*cdf0e10cSrcweir { 152*cdf0e10cSrcweir // Optimize this method ! 153*cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 154*cdf0e10cSrcweir // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL! 155*cdf0e10cSrcweir static OTypeCollection* pTypeCollection = NULL ; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir if ( pTypeCollection == NULL ) 158*cdf0e10cSrcweir { 159*cdf0e10cSrcweir // Ready for multithreading; get global mutex for first call of this method only! see before 160*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 161*cdf0e10cSrcweir 162*cdf0e10cSrcweir // Control these pointer again ... it can be, that another instance will be faster then these! 163*cdf0e10cSrcweir if ( pTypeCollection == NULL ) 164*cdf0e10cSrcweir { 165*cdf0e10cSrcweir // Create a static typecollection ... 166*cdf0e10cSrcweir static OTypeCollection aTypeCollection ( ::getCppuType(( const Reference< XPaintListener >*)NULL ) , 167*cdf0e10cSrcweir ::getCppuType(( const Reference< XWindowListener>*)NULL ) , 168*cdf0e10cSrcweir ::getCppuType(( const Reference< XView >*)NULL ) , 169*cdf0e10cSrcweir ::getCppuType(( const Reference< XWindow >*)NULL ) , 170*cdf0e10cSrcweir ::getCppuType(( const Reference< XServiceInfo >*)NULL ) , 171*cdf0e10cSrcweir ::getCppuType(( const Reference< XControl >*)NULL ) , 172*cdf0e10cSrcweir OComponentHelper::getTypes() 173*cdf0e10cSrcweir ); 174*cdf0e10cSrcweir 175*cdf0e10cSrcweir // ... and set his address to static pointer! 176*cdf0e10cSrcweir pTypeCollection = &aTypeCollection ; 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir return pTypeCollection->getTypes(); 181*cdf0e10cSrcweir } 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 184*cdf0e10cSrcweir // XTypeProvider 185*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 186*cdf0e10cSrcweir 187*cdf0e10cSrcweir Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId() throw( RuntimeException ) 188*cdf0e10cSrcweir { 189*cdf0e10cSrcweir // Create one Id for all instances of this class. 190*cdf0e10cSrcweir // Use ethernet address to do this! (sal_True) 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir // Optimize this method 193*cdf0e10cSrcweir // We initialize a static variable only one time. And we don't must use a mutex at every call! 194*cdf0e10cSrcweir // For the first call; pID is NULL - for the second call pID is different from NULL! 195*cdf0e10cSrcweir static OImplementationId* pID = NULL ; 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir if ( pID == NULL ) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir // Ready for multithreading; get global mutex for first call of this method only! see before 200*cdf0e10cSrcweir MutexGuard aGuard( Mutex::getGlobalMutex() ); 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir // Control these pointer again ... it can be, that another instance will be faster then these! 203*cdf0e10cSrcweir if ( pID == NULL ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir // Create a new static ID ... 206*cdf0e10cSrcweir static OImplementationId aID( sal_False ); 207*cdf0e10cSrcweir // ... and set his address to static pointer! 208*cdf0e10cSrcweir pID = &aID ; 209*cdf0e10cSrcweir } 210*cdf0e10cSrcweir } 211*cdf0e10cSrcweir 212*cdf0e10cSrcweir return pID->getImplementationId(); 213*cdf0e10cSrcweir } 214*cdf0e10cSrcweir 215*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 216*cdf0e10cSrcweir // XAggregation 217*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir void SAL_CALL BaseControl::setDelegator( const Reference< XInterface >& xDel ) throw( RuntimeException ) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir // Ready for multithreading 222*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 223*cdf0e10cSrcweir m_xDelegator = xDel; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 227*cdf0e10cSrcweir // XAggregation 228*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 229*cdf0e10cSrcweir 230*cdf0e10cSrcweir Any SAL_CALL BaseControl::queryAggregation( const Type& aType ) throw( RuntimeException ) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir // Ask for my own supported interfaces ... 233*cdf0e10cSrcweir // Attention: XTypeProvider and XInterface are supported by OComponentHelper! 234*cdf0e10cSrcweir Any aReturn ( ::cppu::queryInterface( aType , 235*cdf0e10cSrcweir static_cast< XPaintListener*> ( this ) , 236*cdf0e10cSrcweir static_cast< XWindowListener*> ( this ) , 237*cdf0e10cSrcweir static_cast< XView* > ( this ) , 238*cdf0e10cSrcweir static_cast< XWindow* > ( this ) , 239*cdf0e10cSrcweir static_cast< XServiceInfo* > ( this ) , 240*cdf0e10cSrcweir static_cast< XControl* > ( this ) 241*cdf0e10cSrcweir ) 242*cdf0e10cSrcweir ); 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir // If searched interface supported by this class ... 245*cdf0e10cSrcweir if ( aReturn.hasValue() == sal_True ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir // ... return this information. 248*cdf0e10cSrcweir return aReturn ; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir else 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir // Else; ... ask baseclass for interfaces! 253*cdf0e10cSrcweir return OComponentHelper::queryAggregation( aType ); 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 258*cdf0e10cSrcweir // XServiceInfo 259*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir OUString SAL_CALL BaseControl::getImplementationName() throw( RuntimeException ) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir return impl_getStaticImplementationName(); 264*cdf0e10cSrcweir } 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 267*cdf0e10cSrcweir // XServiceInfo 268*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::supportsService( const OUString& sServiceName ) throw( RuntimeException ) 271*cdf0e10cSrcweir { 272*cdf0e10cSrcweir Sequence< OUString > seqServiceNames = getSupportedServiceNames(); 273*cdf0e10cSrcweir const OUString* pArray = seqServiceNames.getConstArray(); 274*cdf0e10cSrcweir for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ ) 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir if ( pArray[nCounter] == sServiceName ) 277*cdf0e10cSrcweir { 278*cdf0e10cSrcweir return sal_True ; 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir return sal_False ; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 285*cdf0e10cSrcweir // XServiceInfo 286*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir Sequence< OUString > SAL_CALL BaseControl::getSupportedServiceNames() throw( RuntimeException ) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir return impl_getStaticSupportedServiceNames(); 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir 293*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 294*cdf0e10cSrcweir // XComponent 295*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 296*cdf0e10cSrcweir 297*cdf0e10cSrcweir void SAL_CALL BaseControl::dispose() throw( RuntimeException ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir // Ready for multithreading 300*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir if ( m_pMultiplexer != NULL ) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir // to all other paint, focus, etc. 305*cdf0e10cSrcweir m_pMultiplexer->disposeAndClear(); 306*cdf0e10cSrcweir } 307*cdf0e10cSrcweir 308*cdf0e10cSrcweir // set the service manager to disposed 309*cdf0e10cSrcweir OComponentHelper::dispose(); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir // release context and peer 312*cdf0e10cSrcweir m_xContext = Reference< XInterface >(); 313*cdf0e10cSrcweir impl_releasePeer(); 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir // release view 316*cdf0e10cSrcweir if ( m_xGraphicsView.is() == sal_True ) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir m_xGraphicsView = Reference< XGraphics >(); 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 323*cdf0e10cSrcweir // XComponent 324*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir void SAL_CALL BaseControl::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir // Ready for multithreading 329*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 330*cdf0e10cSrcweir OComponentHelper::addEventListener( xListener ); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir 333*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 334*cdf0e10cSrcweir // XComponent 335*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir void SAL_CALL BaseControl::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException ) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir // Ready for multithreading 340*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 341*cdf0e10cSrcweir OComponentHelper::removeEventListener( xListener ); 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 345*cdf0e10cSrcweir // XControl 346*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir void SAL_CALL BaseControl::createPeer( const Reference< XToolkit >& xToolkit , 349*cdf0e10cSrcweir const Reference< XWindowPeer >& xParentPeer ) throw( RuntimeException ) 350*cdf0e10cSrcweir { 351*cdf0e10cSrcweir // Ready for multithreading 352*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir if ( m_xPeer.is() == sal_False ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir // use method "BaseControl::getWindowDescriptor()" fot change window attributes !!! 357*cdf0e10cSrcweir WindowDescriptor* pDescriptor = impl_getWindowDescriptor( xParentPeer ); 358*cdf0e10cSrcweir 359*cdf0e10cSrcweir if ( m_bVisible == sal_True ) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir pDescriptor->WindowAttributes |= WindowAttribute::SHOW ; 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir // very slow under remote conditions! 365*cdf0e10cSrcweir // create the window on the server 366*cdf0e10cSrcweir Reference< XToolkit > xLocalToolkit = xToolkit ; 367*cdf0e10cSrcweir if ( xLocalToolkit.is() == sal_False ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir // but first create wellknown toolkit, if it not exist 370*cdf0e10cSrcweir xLocalToolkit = Reference< XToolkit > ( m_xFactory->createInstance( OUString::createFromAscii( SERVICE_VCLTOOLKIT ) ), UNO_QUERY ); 371*cdf0e10cSrcweir } 372*cdf0e10cSrcweir m_xPeer = xLocalToolkit->createWindow( *pDescriptor ); 373*cdf0e10cSrcweir m_xPeerWindow = Reference< XWindow >( m_xPeer, UNO_QUERY ); 374*cdf0e10cSrcweir 375*cdf0e10cSrcweir // don't forget to release the memory! 376*cdf0e10cSrcweir delete pDescriptor ; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True ) 379*cdf0e10cSrcweir { 380*cdf0e10cSrcweir if ( m_pMultiplexer != NULL ) 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir m_pMultiplexer->setPeer( m_xPeerWindow ); 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir // create new referenz to xgraphics for painting on a peer 386*cdf0e10cSrcweir // and add a paint listener 387*cdf0e10cSrcweir Reference< XDevice > xDevice( m_xPeerWindow, UNO_QUERY ); 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir if ( xDevice.is() == sal_True ) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir m_xGraphicsPeer = xDevice->createGraphics(); 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir if ( m_xGraphicsPeer.is() == sal_True ) 395*cdf0e10cSrcweir { 396*cdf0e10cSrcweir addPaintListener( this ); 397*cdf0e10cSrcweir addWindowListener( this ); 398*cdf0e10cSrcweir } 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir // PosSize_POSSIZE defined in <stardiv/uno/awt/window.hxx> 401*cdf0e10cSrcweir m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, PosSize::POSSIZE ); 402*cdf0e10cSrcweir m_xPeerWindow->setEnable( m_bEnable ); 403*cdf0e10cSrcweir m_xPeerWindow->setVisible( m_bVisible && !m_bInDesignMode ); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir } 406*cdf0e10cSrcweir } 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 409*cdf0e10cSrcweir // XControl 410*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir void SAL_CALL BaseControl::setContext( const Reference< XInterface >& xContext ) throw( RuntimeException ) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir // Ready for multithreading 415*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 416*cdf0e10cSrcweir m_xContext = xContext ; 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir 419*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 420*cdf0e10cSrcweir // XControl 421*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 422*cdf0e10cSrcweir 423*cdf0e10cSrcweir void SAL_CALL BaseControl::setDesignMode( sal_Bool bOn ) throw( RuntimeException ) 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir // Ready for multithreading 426*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 427*cdf0e10cSrcweir m_bInDesignMode = bOn ; 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 431*cdf0e10cSrcweir // XControl 432*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir Reference< XInterface > SAL_CALL BaseControl::getContext() throw( RuntimeException ) 435*cdf0e10cSrcweir { 436*cdf0e10cSrcweir // Ready for multithreading 437*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 438*cdf0e10cSrcweir return m_xContext ; 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir 441*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 442*cdf0e10cSrcweir // XControl 443*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 444*cdf0e10cSrcweir 445*cdf0e10cSrcweir Reference< XWindowPeer > SAL_CALL BaseControl::getPeer() throw( RuntimeException ) 446*cdf0e10cSrcweir { 447*cdf0e10cSrcweir // Ready for multithreading 448*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 449*cdf0e10cSrcweir return m_xPeer ; 450*cdf0e10cSrcweir } 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 453*cdf0e10cSrcweir // XControl 454*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir Reference< XView > SAL_CALL BaseControl::getView() throw( RuntimeException ) 457*cdf0e10cSrcweir { 458*cdf0e10cSrcweir // Ready for multithreading 459*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 460*cdf0e10cSrcweir return Reference< XView >( (OWeakObject*)this, UNO_QUERY ); 461*cdf0e10cSrcweir } 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 464*cdf0e10cSrcweir // XControl 465*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 466*cdf0e10cSrcweir 467*cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::isDesignMode() throw( RuntimeException ) 468*cdf0e10cSrcweir { 469*cdf0e10cSrcweir // Ready for multithreading 470*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 471*cdf0e10cSrcweir return m_bInDesignMode ; 472*cdf0e10cSrcweir } 473*cdf0e10cSrcweir 474*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 475*cdf0e10cSrcweir // XControl 476*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::isTransparent() throw( RuntimeException ) 479*cdf0e10cSrcweir { 480*cdf0e10cSrcweir return sal_False ; 481*cdf0e10cSrcweir } 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 484*cdf0e10cSrcweir // XWindow 485*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 486*cdf0e10cSrcweir 487*cdf0e10cSrcweir void SAL_CALL BaseControl::setPosSize( sal_Int32 nX , 488*cdf0e10cSrcweir sal_Int32 nY , 489*cdf0e10cSrcweir sal_Int32 nWidth , 490*cdf0e10cSrcweir sal_Int32 nHeight , 491*cdf0e10cSrcweir sal_Int16 nFlags ) throw( RuntimeException ) 492*cdf0e10cSrcweir { 493*cdf0e10cSrcweir // - change size and position of window and save the values 494*cdf0e10cSrcweir // - "nFlags" declared in <stardiv/uno/awt/window.hxx> ("#define PosSize_X .....") 495*cdf0e10cSrcweir 496*cdf0e10cSrcweir // Ready for multithreading 497*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir sal_Bool bChanged = sal_False ; 500*cdf0e10cSrcweir 501*cdf0e10cSrcweir if ( nFlags & PosSize::X ) 502*cdf0e10cSrcweir { 503*cdf0e10cSrcweir bChanged |= m_nX != nX, m_nX = nX ; 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir 506*cdf0e10cSrcweir if ( nFlags & PosSize::Y ) 507*cdf0e10cSrcweir { 508*cdf0e10cSrcweir bChanged |= m_nY != nY, m_nY = nY ; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir if ( nFlags & PosSize::WIDTH ) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir bChanged |= m_nWidth != nWidth, m_nWidth = nWidth ; 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir if ( nFlags & PosSize::HEIGHT ) 517*cdf0e10cSrcweir { 518*cdf0e10cSrcweir bChanged |= m_nHeight != nHeight, m_nHeight = nHeight ; 519*cdf0e10cSrcweir } 520*cdf0e10cSrcweir 521*cdf0e10cSrcweir if ( bChanged && m_xPeerWindow.is() ) 522*cdf0e10cSrcweir { 523*cdf0e10cSrcweir m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, nFlags ); 524*cdf0e10cSrcweir } 525*cdf0e10cSrcweir } 526*cdf0e10cSrcweir 527*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 528*cdf0e10cSrcweir // XWindow 529*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir void SAL_CALL BaseControl::setVisible( sal_Bool bVisible ) throw( RuntimeException ) 532*cdf0e10cSrcweir { 533*cdf0e10cSrcweir // Ready for multithreading 534*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 535*cdf0e10cSrcweir 536*cdf0e10cSrcweir // Set new state of flag 537*cdf0e10cSrcweir m_bVisible = bVisible ; 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True ) 540*cdf0e10cSrcweir { 541*cdf0e10cSrcweir // Set it also on peerwindow 542*cdf0e10cSrcweir m_xPeerWindow->setVisible( m_bVisible ); 543*cdf0e10cSrcweir } 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 547*cdf0e10cSrcweir // XWindow 548*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 549*cdf0e10cSrcweir 550*cdf0e10cSrcweir void SAL_CALL BaseControl::setEnable( sal_Bool bEnable ) throw( RuntimeException ) 551*cdf0e10cSrcweir { 552*cdf0e10cSrcweir // Ready for multithreading 553*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir // Set new state of flag 556*cdf0e10cSrcweir m_bEnable = bEnable ; 557*cdf0e10cSrcweir 558*cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True ) 559*cdf0e10cSrcweir { 560*cdf0e10cSrcweir // Set it also on peerwindow 561*cdf0e10cSrcweir m_xPeerWindow->setEnable( m_bEnable ); 562*cdf0e10cSrcweir } 563*cdf0e10cSrcweir } 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 566*cdf0e10cSrcweir // XWindow 567*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir void SAL_CALL BaseControl::setFocus() throw( RuntimeException ) 570*cdf0e10cSrcweir { 571*cdf0e10cSrcweir // Ready for multithreading 572*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 573*cdf0e10cSrcweir 574*cdf0e10cSrcweir if ( m_xPeerWindow.is() == sal_True ) 575*cdf0e10cSrcweir { 576*cdf0e10cSrcweir m_xPeerWindow->setFocus(); 577*cdf0e10cSrcweir } 578*cdf0e10cSrcweir } 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 581*cdf0e10cSrcweir // XWindow 582*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 583*cdf0e10cSrcweir 584*cdf0e10cSrcweir Rectangle SAL_CALL BaseControl::getPosSize() throw( RuntimeException ) 585*cdf0e10cSrcweir { 586*cdf0e10cSrcweir // Ready for multithreading 587*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 588*cdf0e10cSrcweir return Rectangle( m_nX, m_nY , m_nWidth, m_nHeight ); 589*cdf0e10cSrcweir } 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 592*cdf0e10cSrcweir // XWindow 593*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir void SAL_CALL BaseControl::addWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException ) 596*cdf0e10cSrcweir { 597*cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener ); 598*cdf0e10cSrcweir } 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 601*cdf0e10cSrcweir // XWindow 602*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 603*cdf0e10cSrcweir 604*cdf0e10cSrcweir void SAL_CALL BaseControl::addFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException ) 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener ); 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir 609*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 610*cdf0e10cSrcweir // XWindow 611*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir void SAL_CALL BaseControl::addKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener ); 616*cdf0e10cSrcweir } 617*cdf0e10cSrcweir 618*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 619*cdf0e10cSrcweir // XWindow 620*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 621*cdf0e10cSrcweir 622*cdf0e10cSrcweir void SAL_CALL BaseControl::addMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException ) 623*cdf0e10cSrcweir { 624*cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener ); 625*cdf0e10cSrcweir } 626*cdf0e10cSrcweir 627*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 628*cdf0e10cSrcweir // XWindow 629*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 630*cdf0e10cSrcweir 631*cdf0e10cSrcweir void SAL_CALL BaseControl::addMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException ) 632*cdf0e10cSrcweir { 633*cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener ); 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir 636*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 637*cdf0e10cSrcweir // XWindow 638*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir void SAL_CALL BaseControl::addPaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException ) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener ); 643*cdf0e10cSrcweir } 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 646*cdf0e10cSrcweir // XWindow 647*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir void SAL_CALL BaseControl::removeWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException ) 650*cdf0e10cSrcweir { 651*cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener ); 652*cdf0e10cSrcweir } 653*cdf0e10cSrcweir 654*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 655*cdf0e10cSrcweir // XWindow 656*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir void SAL_CALL BaseControl::removeFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException ) 659*cdf0e10cSrcweir { 660*cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener ); 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 664*cdf0e10cSrcweir // XWindow 665*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 666*cdf0e10cSrcweir 667*cdf0e10cSrcweir void SAL_CALL BaseControl::removeKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException ) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener ); 670*cdf0e10cSrcweir } 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 673*cdf0e10cSrcweir // XWindow 674*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 675*cdf0e10cSrcweir 676*cdf0e10cSrcweir void SAL_CALL BaseControl::removeMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException ) 677*cdf0e10cSrcweir { 678*cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener ); 679*cdf0e10cSrcweir } 680*cdf0e10cSrcweir 681*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 682*cdf0e10cSrcweir // XWindow 683*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 684*cdf0e10cSrcweir 685*cdf0e10cSrcweir void SAL_CALL BaseControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException ) 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener ); 688*cdf0e10cSrcweir } 689*cdf0e10cSrcweir 690*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 691*cdf0e10cSrcweir // XWindow 692*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir void SAL_CALL BaseControl::removePaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException ) 695*cdf0e10cSrcweir { 696*cdf0e10cSrcweir impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener ); 697*cdf0e10cSrcweir } 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 700*cdf0e10cSrcweir // XView 701*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 702*cdf0e10cSrcweir 703*cdf0e10cSrcweir void SAL_CALL BaseControl::draw( sal_Int32 nX , 704*cdf0e10cSrcweir sal_Int32 nY ) throw( RuntimeException ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir // Ready for multithreading 707*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 708*cdf0e10cSrcweir 709*cdf0e10cSrcweir // - paint to an view 710*cdf0e10cSrcweir // - use the method "paint()" 711*cdf0e10cSrcweir // - see also "windowPaint()" 712*cdf0e10cSrcweir impl_paint( nX, nY, m_xGraphicsView ); 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 716*cdf0e10cSrcweir // XView 717*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 718*cdf0e10cSrcweir 719*cdf0e10cSrcweir sal_Bool SAL_CALL BaseControl::setGraphics( const Reference< XGraphics >& xDevice ) throw( RuntimeException ) 720*cdf0e10cSrcweir { 721*cdf0e10cSrcweir // - set the graphics for an view 722*cdf0e10cSrcweir // - in this class exist 2 graphics-member ... one for peer[_xGraphicsPeer] and one for view[_xGraphicsView] 723*cdf0e10cSrcweir // - they are used by "windowPaint() and draw()", forwarded to "paint ()" 724*cdf0e10cSrcweir sal_Bool bReturn = sal_False ; 725*cdf0e10cSrcweir if ( xDevice.is() == sal_True ) 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir // Ready for multithreading 728*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 729*cdf0e10cSrcweir 730*cdf0e10cSrcweir m_xGraphicsView = xDevice ; 731*cdf0e10cSrcweir bReturn = sal_True ; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir return bReturn ; 735*cdf0e10cSrcweir } 736*cdf0e10cSrcweir 737*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 738*cdf0e10cSrcweir // XView 739*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 740*cdf0e10cSrcweir 741*cdf0e10cSrcweir void SAL_CALL BaseControl::setZoom( float /*fZoomX*/ , 742*cdf0e10cSrcweir float /*fZoomY*/ ) throw( RuntimeException ) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir // Not implemented yet 745*cdf0e10cSrcweir } 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 748*cdf0e10cSrcweir // XView 749*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir Reference< XGraphics > SAL_CALL BaseControl::getGraphics() throw( RuntimeException ) 752*cdf0e10cSrcweir { 753*cdf0e10cSrcweir // Ready for multithreading 754*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 755*cdf0e10cSrcweir return m_xGraphicsView ; 756*cdf0e10cSrcweir } 757*cdf0e10cSrcweir 758*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 759*cdf0e10cSrcweir // XView 760*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 761*cdf0e10cSrcweir 762*cdf0e10cSrcweir Size SAL_CALL BaseControl::getSize() throw( RuntimeException ) 763*cdf0e10cSrcweir { 764*cdf0e10cSrcweir // Ready for multithreading 765*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 766*cdf0e10cSrcweir return Size( m_nWidth, m_nHeight ); 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir 769*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 770*cdf0e10cSrcweir // XEventListener 771*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir void SAL_CALL BaseControl::disposing( const EventObject& /*aSource*/ ) throw( RuntimeException ) 774*cdf0e10cSrcweir { 775*cdf0e10cSrcweir // Ready for multithreading 776*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir // - release ALL references 779*cdf0e10cSrcweir // - it must be !!! 780*cdf0e10cSrcweir if ( m_xGraphicsPeer.is() == sal_True ) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir removePaintListener( this ); 783*cdf0e10cSrcweir removeWindowListener( this ); 784*cdf0e10cSrcweir m_xGraphicsPeer = Reference< XGraphics >(); 785*cdf0e10cSrcweir } 786*cdf0e10cSrcweir 787*cdf0e10cSrcweir if ( m_xGraphicsView.is() == sal_True ) 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir m_xGraphicsView = Reference< XGraphics >(); 790*cdf0e10cSrcweir } 791*cdf0e10cSrcweir } 792*cdf0e10cSrcweir 793*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 794*cdf0e10cSrcweir // XPaintListener 795*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir void SAL_CALL BaseControl::windowPaint( const PaintEvent& /*aEvent*/ ) throw( RuntimeException ) 798*cdf0e10cSrcweir { 799*cdf0e10cSrcweir // Ready for multithreading 800*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 801*cdf0e10cSrcweir 802*cdf0e10cSrcweir // - repaint the peer 803*cdf0e10cSrcweir // - use the method "paint ()" for painting on a peer and a print device !!! 804*cdf0e10cSrcweir // - see also "draw ()" 805*cdf0e10cSrcweir impl_paint( 0, 0, m_xGraphicsPeer ); 806*cdf0e10cSrcweir } 807*cdf0e10cSrcweir 808*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 809*cdf0e10cSrcweir // XWindowListener 810*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 811*cdf0e10cSrcweir 812*cdf0e10cSrcweir void SAL_CALL BaseControl::windowResized( const WindowEvent& aEvent ) throw( RuntimeException ) 813*cdf0e10cSrcweir { 814*cdf0e10cSrcweir // Ready for multithreading 815*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir m_nWidth = aEvent.Width ; 818*cdf0e10cSrcweir m_nHeight = aEvent.Height ; 819*cdf0e10cSrcweir WindowEvent aMappedEvent = aEvent; 820*cdf0e10cSrcweir aMappedEvent.X = 0; 821*cdf0e10cSrcweir aMappedEvent.Y = 0; 822*cdf0e10cSrcweir impl_recalcLayout( aMappedEvent ); 823*cdf0e10cSrcweir } 824*cdf0e10cSrcweir 825*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 826*cdf0e10cSrcweir // XWindowListener 827*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 828*cdf0e10cSrcweir 829*cdf0e10cSrcweir void SAL_CALL BaseControl::windowMoved( const WindowEvent& aEvent ) throw( RuntimeException ) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir // Ready for multithreading 832*cdf0e10cSrcweir MutexGuard aGuard( m_aMutex ); 833*cdf0e10cSrcweir 834*cdf0e10cSrcweir m_nWidth = aEvent.Width ; 835*cdf0e10cSrcweir m_nHeight = aEvent.Height ; 836*cdf0e10cSrcweir WindowEvent aMappedEvent = aEvent; 837*cdf0e10cSrcweir aMappedEvent.X = 0; 838*cdf0e10cSrcweir aMappedEvent.Y = 0; 839*cdf0e10cSrcweir impl_recalcLayout( aMappedEvent ); 840*cdf0e10cSrcweir } 841*cdf0e10cSrcweir 842*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 843*cdf0e10cSrcweir // XWindowListener 844*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 845*cdf0e10cSrcweir 846*cdf0e10cSrcweir void SAL_CALL BaseControl::windowShown( const EventObject& /*aEvent*/ ) throw( RuntimeException ) 847*cdf0e10cSrcweir { 848*cdf0e10cSrcweir } 849*cdf0e10cSrcweir 850*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 851*cdf0e10cSrcweir // XWindowListener 852*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 853*cdf0e10cSrcweir 854*cdf0e10cSrcweir void SAL_CALL BaseControl::windowHidden( const EventObject& /*aEvent*/ ) throw( RuntimeException ) 855*cdf0e10cSrcweir { 856*cdf0e10cSrcweir } 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 859*cdf0e10cSrcweir // impl but public method to register service in DLL 860*cdf0e10cSrcweir // (In this BASE-implementation not implemented! Overwrite it in derived classes.) 861*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir const Sequence< OUString > BaseControl::impl_getStaticSupportedServiceNames() 864*cdf0e10cSrcweir { 865*cdf0e10cSrcweir return Sequence< OUString >(); 866*cdf0e10cSrcweir } 867*cdf0e10cSrcweir 868*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 869*cdf0e10cSrcweir // impl but public method to register service in DLL 870*cdf0e10cSrcweir // (In this BASE-implementation not implemented! Overwrite it in derived classes.) 871*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 872*cdf0e10cSrcweir 873*cdf0e10cSrcweir const OUString BaseControl::impl_getStaticImplementationName() 874*cdf0e10cSrcweir { 875*cdf0e10cSrcweir return OUString(); 876*cdf0e10cSrcweir } 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 879*cdf0e10cSrcweir // protected method 880*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir const Reference< XMultiServiceFactory > BaseControl::impl_getMultiServiceFactory() 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir return m_xFactory ; 885*cdf0e10cSrcweir } 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 888*cdf0e10cSrcweir // protected method 889*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 890*cdf0e10cSrcweir 891*cdf0e10cSrcweir const Reference< XWindow > BaseControl::impl_getPeerWindow() 892*cdf0e10cSrcweir { 893*cdf0e10cSrcweir return m_xPeerWindow ; 894*cdf0e10cSrcweir } 895*cdf0e10cSrcweir 896*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 897*cdf0e10cSrcweir // protected method 898*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 899*cdf0e10cSrcweir 900*cdf0e10cSrcweir const Reference< XGraphics > BaseControl::impl_getGraphicsPeer() 901*cdf0e10cSrcweir { 902*cdf0e10cSrcweir return m_xGraphicsPeer ; 903*cdf0e10cSrcweir } 904*cdf0e10cSrcweir 905*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 906*cdf0e10cSrcweir // protected method 907*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 908*cdf0e10cSrcweir 909*cdf0e10cSrcweir const sal_Int32& BaseControl::impl_getWidth() 910*cdf0e10cSrcweir { 911*cdf0e10cSrcweir return m_nWidth ; 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir 914*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 915*cdf0e10cSrcweir // protected method 916*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 917*cdf0e10cSrcweir 918*cdf0e10cSrcweir const sal_Int32& BaseControl::impl_getHeight() 919*cdf0e10cSrcweir { 920*cdf0e10cSrcweir return m_nHeight ; 921*cdf0e10cSrcweir } 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 924*cdf0e10cSrcweir // protected method 925*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 926*cdf0e10cSrcweir 927*cdf0e10cSrcweir WindowDescriptor* BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer ) 928*cdf0e10cSrcweir { 929*cdf0e10cSrcweir // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!! 930*cdf0e10cSrcweir // - if you will change the descriptor-values, you must override this virtuell function 931*cdf0e10cSrcweir // - the caller must release the memory for this dynamical descriptor !!! 932*cdf0e10cSrcweir 933*cdf0e10cSrcweir WindowDescriptor* pDescriptor = new WindowDescriptor ; 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir pDescriptor->Type = WindowClass_SIMPLE ; 936*cdf0e10cSrcweir pDescriptor->WindowServiceName = OUString::createFromAscii( "window" ) ; 937*cdf0e10cSrcweir pDescriptor->ParentIndex = -1 ; 938*cdf0e10cSrcweir pDescriptor->Parent = xParentPeer ; 939*cdf0e10cSrcweir pDescriptor->Bounds = getPosSize () ; 940*cdf0e10cSrcweir pDescriptor->WindowAttributes = 0 ; 941*cdf0e10cSrcweir 942*cdf0e10cSrcweir return pDescriptor ; 943*cdf0e10cSrcweir } 944*cdf0e10cSrcweir 945*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 946*cdf0e10cSrcweir // protected method 947*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 948*cdf0e10cSrcweir 949*cdf0e10cSrcweir void BaseControl::impl_paint( sal_Int32 /*nX*/ , 950*cdf0e10cSrcweir sal_Int32 /*nY*/ , 951*cdf0e10cSrcweir const Reference< XGraphics >& /*xGraphics*/ ) 952*cdf0e10cSrcweir { 953*cdf0e10cSrcweir // - one paint method for peer AND view !!! 954*cdf0e10cSrcweir // (see also => "windowPaint()" and "draw()") 955*cdf0e10cSrcweir // - not used in this implementation, but its not necessary to make it pure virtual !!! 956*cdf0e10cSrcweir } 957*cdf0e10cSrcweir 958*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 959*cdf0e10cSrcweir // protected method 960*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 961*cdf0e10cSrcweir 962*cdf0e10cSrcweir void BaseControl::impl_recalcLayout( const WindowEvent& /*aEvent*/ ) 963*cdf0e10cSrcweir { 964*cdf0e10cSrcweir // We need as virtual function to support automaticly resizing of derived controls! 965*cdf0e10cSrcweir // But we make it not pure virtual because it's not neccessary for all derived classes! 966*cdf0e10cSrcweir } 967*cdf0e10cSrcweir 968*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 969*cdf0e10cSrcweir // protected method 970*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 971*cdf0e10cSrcweir 972*cdf0e10cSrcweir Reference< XInterface > BaseControl::impl_getDelegator() 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir return m_xDelegator ; 975*cdf0e10cSrcweir } 976*cdf0e10cSrcweir 977*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 978*cdf0e10cSrcweir // private method 979*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 980*cdf0e10cSrcweir 981*cdf0e10cSrcweir void BaseControl::impl_releasePeer() 982*cdf0e10cSrcweir { 983*cdf0e10cSrcweir if ( m_xPeer.is() == sal_True ) 984*cdf0e10cSrcweir { 985*cdf0e10cSrcweir if ( m_xGraphicsPeer.is() == sal_True ) 986*cdf0e10cSrcweir { 987*cdf0e10cSrcweir removePaintListener( this ); 988*cdf0e10cSrcweir removeWindowListener( this ); 989*cdf0e10cSrcweir m_xGraphicsPeer = Reference< XGraphics >(); 990*cdf0e10cSrcweir } 991*cdf0e10cSrcweir 992*cdf0e10cSrcweir m_xPeer->dispose(); 993*cdf0e10cSrcweir m_xPeerWindow = Reference< XWindow >(); 994*cdf0e10cSrcweir m_xPeer = Reference< XWindowPeer >(); 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir if ( m_pMultiplexer != NULL ) 997*cdf0e10cSrcweir { 998*cdf0e10cSrcweir // take changes on multiplexer 999*cdf0e10cSrcweir m_pMultiplexer->setPeer( Reference< XWindow >() ); 1000*cdf0e10cSrcweir } 1001*cdf0e10cSrcweir } 1002*cdf0e10cSrcweir } 1003*cdf0e10cSrcweir 1004*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 1005*cdf0e10cSrcweir // private method 1006*cdf0e10cSrcweir //____________________________________________________________________________________________________________ 1007*cdf0e10cSrcweir 1008*cdf0e10cSrcweir OMRCListenerMultiplexerHelper* BaseControl::impl_getMultiplexer() 1009*cdf0e10cSrcweir { 1010*cdf0e10cSrcweir if ( m_pMultiplexer == NULL ) 1011*cdf0e10cSrcweir { 1012*cdf0e10cSrcweir m_pMultiplexer = new OMRCListenerMultiplexerHelper( (XWindow*)this, m_xPeerWindow ); 1013*cdf0e10cSrcweir m_xMultiplexer = Reference< XInterface >( (OWeakObject*)m_pMultiplexer, UNO_QUERY ); 1014*cdf0e10cSrcweir } 1015*cdf0e10cSrcweir 1016*cdf0e10cSrcweir return m_pMultiplexer ; 1017*cdf0e10cSrcweir } 1018*cdf0e10cSrcweir 1019*cdf0e10cSrcweir } // namespace unocontrols 1020