LCOV - code coverage report
Current view: top level - UnoControls/source/base - basecontrol.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 292 0.0 %
Date: 2014-04-14 Functions: 0 65 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "basecontrol.hxx"
      21             : 
      22             : #include <com/sun/star/awt/XDevice.hpp>
      23             : #include <com/sun/star/awt/XDisplayBitmap.hpp>
      24             : #include <com/sun/star/awt/DeviceInfo.hpp>
      25             : #include <com/sun/star/awt/WindowAttribute.hpp>
      26             : #include <com/sun/star/awt/PosSize.hpp>
      27             : #include <com/sun/star/awt/Toolkit.hpp>
      28             : #include <comphelper/processfactory.hxx>
      29             : #include <cppuhelper/supportsservice.hxx>
      30             : #include <cppuhelper/typeprovider.hxx>
      31             : 
      32             : //  namespaces
      33             : 
      34             : using namespace ::cppu;
      35             : using namespace ::osl;
      36             : using namespace ::rtl;
      37             : using namespace ::com::sun::star::uno;
      38             : using namespace ::com::sun::star::lang;
      39             : using namespace ::com::sun::star::awt;
      40             : 
      41             : namespace unocontrols{
      42             : 
      43             : #define DEFAULT_PMULTIPLEXER                NULL
      44             : #define DEFAULT_X                           0
      45             : #define DEFAULT_Y                           0
      46             : #define DEFAULT_WIDTH                       100
      47             : #define DEFAULT_HEIGHT                      100
      48             : #define DEFAULT_VISIBLE                     false
      49             : #define DEFAULT_INDESIGNMODE                false
      50             : #define DEFAULT_ENABLE                      true
      51             : 
      52             : //  construct/destruct
      53             : 
      54           0 : BaseControl::BaseControl( const Reference< XComponentContext >& rxContext )
      55             :     : IMPL_MutexContainer       (                       )
      56             :     , OComponentHelper          ( m_aMutex              )
      57             :     , m_xComponentContext       ( rxContext              )
      58             :     , m_pMultiplexer            ( DEFAULT_PMULTIPLEXER  )
      59             :     , m_nX                      ( DEFAULT_X             )
      60             :     , m_nY                      ( DEFAULT_Y             )
      61             :     , m_nWidth                  ( DEFAULT_WIDTH         )
      62             :     , m_nHeight                 ( DEFAULT_HEIGHT        )
      63             :     , m_bVisible                ( DEFAULT_VISIBLE       )
      64             :     , m_bInDesignMode           ( DEFAULT_INDESIGNMODE  )
      65           0 :     , m_bEnable                 ( DEFAULT_ENABLE        )
      66             : {
      67           0 : }
      68             : 
      69           0 : BaseControl::~BaseControl()
      70             : {
      71           0 : }
      72             : 
      73             : //  XInterface
      74             : 
      75           0 : Any SAL_CALL BaseControl::queryInterface( const Type& rType ) throw( RuntimeException, std::exception )
      76             : {
      77           0 :     Any aReturn;
      78           0 :     if ( m_xDelegator.is() )
      79             :     {
      80             :         // If an delegator exist, forward question to his queryInterface.
      81             :         // Delegator will ask his own queryAggregation!
      82           0 :         aReturn = m_xDelegator->queryInterface( rType );
      83             :     }
      84             :     else
      85             :     {
      86             :         // If an delegator unknown, forward question to own queryAggregation.
      87           0 :         aReturn = queryAggregation( rType );
      88             :     }
      89             : 
      90           0 :     return aReturn;
      91             : }
      92             : 
      93             : //  XInterface
      94             : 
      95           0 : void SAL_CALL BaseControl::acquire() throw()
      96             : {
      97             :     // Attention:
      98             :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
      99             : 
     100             :     // Forward to baseclass
     101           0 :     OComponentHelper::acquire();
     102           0 : }
     103             : 
     104             : //  XInterface
     105             : 
     106           0 : void SAL_CALL BaseControl::release() throw()
     107             : {
     108             :     // Attention:
     109             :     //  Don't use mutex or guard in this method!!! Is a method of XInterface.
     110             : 
     111             :     // Forward to baseclass
     112           0 :     OComponentHelper::release();
     113           0 : }
     114             : 
     115             : //  XTypeProvider
     116             : 
     117           0 : Sequence< Type > SAL_CALL BaseControl::getTypes() throw( RuntimeException, std::exception )
     118             : {
     119             :     // Optimize this method !
     120             :     // We initialize a static variable only one time. And we don't must use a mutex at every call!
     121             :     // For the first call; pTypeCollection is NULL - for the second call pTypeCollection is different from NULL!
     122             :     static OTypeCollection* pTypeCollection = NULL;
     123             : 
     124           0 :     if ( pTypeCollection == NULL )
     125             :     {
     126             :         // Ready for multithreading; get global mutex for first call of this method only! see before
     127           0 :         MutexGuard aGuard( Mutex::getGlobalMutex() );
     128             : 
     129             :         // Control these pointer again ... it can be, that another instance will be faster then these!
     130           0 :         if ( pTypeCollection == NULL )
     131             :         {
     132             :             // Create a static typecollection ...
     133           0 :             static OTypeCollection aTypeCollection( ::getCppuType(( const Reference< XPaintListener >*)NULL ) ,
     134           0 :                                                     ::getCppuType(( const Reference< XWindowListener>*)NULL ) ,
     135           0 :                                                     ::getCppuType(( const Reference< XView          >*)NULL ) ,
     136           0 :                                                     ::getCppuType(( const Reference< XWindow        >*)NULL ) ,
     137           0 :                                                     ::getCppuType(( const Reference< XServiceInfo   >*)NULL ) ,
     138           0 :                                                     ::getCppuType(( const Reference< XControl       >*)NULL ) ,
     139             :                                                     OComponentHelper::getTypes()
     140           0 :                                                   );
     141             : 
     142             :             // ... and set his address to static pointer!
     143           0 :             pTypeCollection = &aTypeCollection;
     144           0 :         }
     145             :     }
     146             : 
     147           0 :     return pTypeCollection->getTypes();
     148             : }
     149             : 
     150             : //  XTypeProvider
     151             : 
     152           0 : Sequence< sal_Int8 > SAL_CALL BaseControl::getImplementationId() throw( RuntimeException, std::exception )
     153             : {
     154           0 :     return css::uno::Sequence<sal_Int8>();
     155             : }
     156             : 
     157             : //  XAggregation
     158             : 
     159           0 : void SAL_CALL BaseControl::setDelegator( const Reference< XInterface >& xDel ) throw( RuntimeException, std::exception )
     160             : {
     161             :     // Ready for multithreading
     162           0 :     MutexGuard aGuard( m_aMutex );
     163           0 :     m_xDelegator = xDel;
     164           0 : }
     165             : 
     166             : //  XAggregation
     167             : 
     168           0 : Any SAL_CALL BaseControl::queryAggregation( const Type& aType ) throw( RuntimeException, std::exception )
     169             : {
     170             :     // Ask for my own supported interfaces ...
     171             :     // Attention: XTypeProvider and XInterface are supported by OComponentHelper!
     172             :     Any aReturn ( ::cppu::queryInterface(   aType                                   ,
     173             :                                                static_cast< XPaintListener*> ( this )   ,
     174             :                                                static_cast< XWindowListener*> ( this )  ,
     175             :                                                static_cast< XView*          > ( this )  ,
     176             :                                                static_cast< XWindow*        > ( this )  ,
     177             :                                                static_cast< XServiceInfo*   > ( this )  ,
     178             :                                                static_cast< XControl*       > ( this )
     179             :                                         )
     180           0 :                 );
     181             : 
     182             :     // If searched interface supported by this class ...
     183           0 :     if ( aReturn.hasValue() )
     184             :     {
     185             :         // ... return this information.
     186           0 :         return aReturn;
     187             :     }
     188             :     else
     189             :     {
     190             :         // Else; ... ask baseclass for interfaces!
     191           0 :         return OComponentHelper::queryAggregation( aType );
     192           0 :     }
     193             : }
     194             : 
     195             : //  XServiceInfo
     196             : 
     197           0 : OUString SAL_CALL BaseControl::getImplementationName() throw( RuntimeException, std::exception )
     198             : {
     199           0 :     return impl_getStaticImplementationName();
     200             : }
     201             : 
     202             : //  XServiceInfo
     203             : 
     204           0 : sal_Bool SAL_CALL BaseControl::supportsService( const OUString& sServiceName ) throw( RuntimeException, std::exception )
     205             : {
     206           0 :     return cppu::supportsService(this, sServiceName);
     207             : }
     208             : 
     209             : //  XServiceInfo
     210             : 
     211           0 : Sequence< OUString > SAL_CALL BaseControl::getSupportedServiceNames() throw( RuntimeException, std::exception )
     212             : {
     213           0 :     return impl_getStaticSupportedServiceNames();
     214             : }
     215             : 
     216             : //  XComponent
     217             : 
     218           0 : void SAL_CALL BaseControl::dispose() throw( RuntimeException, std::exception )
     219             : {
     220             :     // Ready for multithreading
     221           0 :     MutexGuard aGuard( m_aMutex );
     222             : 
     223           0 :     if ( m_pMultiplexer != NULL )
     224             :     {
     225             :         // to all other paint, focus, etc.
     226           0 :         m_pMultiplexer->disposeAndClear();
     227             :     }
     228             : 
     229             :     // set the service manager to disposed
     230           0 :     OComponentHelper::dispose();
     231             : 
     232             :     // release context and peer
     233           0 :     m_xContext.clear();
     234           0 :     impl_releasePeer();
     235             : 
     236             :     // release view
     237           0 :     if ( m_xGraphicsView.is() )
     238             :     {
     239           0 :         m_xGraphicsView.clear();
     240           0 :     }
     241           0 : }
     242             : 
     243             : //  XComponent
     244             : 
     245           0 : void SAL_CALL BaseControl::addEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException, std::exception )
     246             : {
     247             :     // Ready for multithreading
     248           0 :     MutexGuard aGuard( m_aMutex );
     249           0 :     OComponentHelper::addEventListener( xListener );
     250           0 : }
     251             : 
     252             : //  XComponent
     253             : 
     254           0 : void SAL_CALL BaseControl::removeEventListener( const Reference< XEventListener >& xListener ) throw( RuntimeException, std::exception )
     255             : {
     256             :     // Ready for multithreading
     257           0 :     MutexGuard aGuard( m_aMutex );
     258           0 :     OComponentHelper::removeEventListener( xListener );
     259           0 : }
     260             : 
     261             : //  XControl
     262             : 
     263           0 : void SAL_CALL BaseControl::createPeer(  const   Reference< XToolkit >&      xToolkit    ,
     264             :                                         const   Reference< XWindowPeer >&   xParentPeer ) throw( RuntimeException, std::exception )
     265             : {
     266             :     // Ready for multithreading
     267           0 :     MutexGuard aGuard( m_aMutex );
     268             : 
     269           0 :     if ( !m_xPeer.is() )
     270             :     {
     271             :         // use method "BaseControl::getWindowDescriptor()" fot change window attributes !!!
     272           0 :         WindowDescriptor* pDescriptor = impl_getWindowDescriptor( xParentPeer );
     273             : 
     274           0 :         if ( m_bVisible )
     275             :         {
     276           0 :             pDescriptor->WindowAttributes |= WindowAttribute::SHOW;
     277             :         }
     278             : 
     279             :         // very slow under remote conditions!
     280             :         // create the window on the server
     281           0 :         Reference< XToolkit > xLocalToolkit = xToolkit;
     282           0 :         if ( !xLocalToolkit.is() )
     283             :         {
     284             :             // but first create well known toolkit, if it not exist
     285           0 :             xLocalToolkit = Reference< XToolkit > ( Toolkit::create(m_xComponentContext), UNO_QUERY_THROW );
     286             :         }
     287           0 :         m_xPeer         = xLocalToolkit->createWindow( *pDescriptor );
     288           0 :         m_xPeerWindow   = Reference< XWindow >( m_xPeer, UNO_QUERY );
     289             : 
     290             :         // don't forget to release the memory!
     291           0 :         delete pDescriptor;
     292             : 
     293           0 :         if ( m_xPeerWindow.is() )
     294             :         {
     295           0 :             if ( m_pMultiplexer != NULL )
     296             :             {
     297           0 :                 m_pMultiplexer->setPeer( m_xPeerWindow );
     298             :             }
     299             : 
     300             :             // create new referenz to xgraphics for painting on a peer
     301             :             // and add a paint listener
     302           0 :             Reference< XDevice > xDevice( m_xPeerWindow, UNO_QUERY );
     303             : 
     304           0 :             if ( xDevice.is() )
     305             :             {
     306           0 :                 m_xGraphicsPeer = xDevice->createGraphics();
     307             :             }
     308             : 
     309           0 :             if ( m_xGraphicsPeer.is() )
     310             :             {
     311           0 :                 addPaintListener( this );
     312           0 :                 addWindowListener( this );
     313             :             }
     314             : 
     315           0 :             m_xPeerWindow->setPosSize(  m_nX, m_nY, m_nWidth, m_nHeight, PosSize::POSSIZE   );
     316           0 :             m_xPeerWindow->setEnable(   m_bEnable                                           );
     317           0 :             m_xPeerWindow->setVisible(  m_bVisible && !m_bInDesignMode                      );
     318           0 :         }
     319           0 :     }
     320           0 : }
     321             : 
     322             : //  XControl
     323             : 
     324           0 : void SAL_CALL BaseControl::setContext( const Reference< XInterface >& xContext ) throw( RuntimeException, std::exception )
     325             : {
     326             :     // Ready for multithreading
     327           0 :     MutexGuard aGuard( m_aMutex );
     328           0 :     m_xContext = xContext;
     329           0 : }
     330             : 
     331             : //  XControl
     332             : 
     333           0 : void SAL_CALL BaseControl::setDesignMode( sal_Bool bOn ) throw( RuntimeException, std::exception )
     334             : {
     335             :     // Ready for multithreading
     336           0 :     MutexGuard aGuard( m_aMutex );
     337           0 :     m_bInDesignMode = bOn;
     338           0 : }
     339             : 
     340             : //  XControl
     341             : 
     342           0 : Reference< XInterface > SAL_CALL BaseControl::getContext() throw( RuntimeException, std::exception )
     343             : {
     344             :     // Ready for multithreading
     345           0 :     MutexGuard aGuard( m_aMutex );
     346           0 :     return m_xContext;
     347             : }
     348             : 
     349             : //  XControl
     350             : 
     351           0 : Reference< XWindowPeer > SAL_CALL BaseControl::getPeer() throw( RuntimeException, std::exception )
     352             : {
     353             :     // Ready for multithreading
     354           0 :     MutexGuard aGuard( m_aMutex );
     355           0 :     return m_xPeer;
     356             : }
     357             : 
     358             : //  XControl
     359             : 
     360           0 : Reference< XView > SAL_CALL BaseControl::getView() throw( RuntimeException, std::exception )
     361             : {
     362             :     // Ready for multithreading
     363           0 :     MutexGuard aGuard( m_aMutex );
     364           0 :     return Reference< XView >( (OWeakObject*)this, UNO_QUERY );
     365             : }
     366             : 
     367             : //  XControl
     368             : 
     369           0 : sal_Bool SAL_CALL BaseControl::isDesignMode() throw( RuntimeException, std::exception )
     370             : {
     371             :     // Ready for multithreading
     372           0 :     MutexGuard aGuard( m_aMutex );
     373           0 :     return m_bInDesignMode;
     374             : }
     375             : 
     376             : //  XControl
     377             : 
     378           0 : sal_Bool SAL_CALL BaseControl::isTransparent() throw( RuntimeException, std::exception )
     379             : {
     380           0 :     return sal_False;
     381             : }
     382             : 
     383             : //  XWindow
     384             : 
     385           0 : void SAL_CALL BaseControl::setPosSize(  sal_Int32   nX      ,
     386             :                                         sal_Int32   nY      ,
     387             :                                         sal_Int32   nWidth  ,
     388             :                                         sal_Int32   nHeight ,
     389             :                                         sal_Int16   nFlags  ) throw( RuntimeException, std::exception )
     390             : {
     391             :     // - change size and position of window and save the values
     392             : 
     393             :     // Ready for multithreading
     394           0 :     MutexGuard aGuard( m_aMutex );
     395             : 
     396           0 :     bool bChanged = false;
     397             : 
     398           0 :     if ( nFlags & PosSize::X )
     399             :     {
     400           0 :         bChanged |= m_nX != nX, m_nX = nX;
     401             :     }
     402             : 
     403           0 :     if ( nFlags & PosSize::Y )
     404             :     {
     405           0 :         bChanged |= m_nY != nY, m_nY = nY;
     406             :     }
     407             : 
     408           0 :     if ( nFlags & PosSize::WIDTH )
     409             :     {
     410           0 :         bChanged |= m_nWidth != nWidth, m_nWidth  = nWidth;
     411             :     }
     412             : 
     413           0 :     if ( nFlags & PosSize::HEIGHT )
     414             :     {
     415           0 :         bChanged |= m_nHeight != nHeight, m_nHeight = nHeight;
     416             :     }
     417             : 
     418           0 :     if ( bChanged && m_xPeerWindow.is() )
     419             :     {
     420           0 :         m_xPeerWindow->setPosSize( m_nX, m_nY, m_nWidth, m_nHeight, nFlags );
     421           0 :     }
     422           0 : }
     423             : 
     424             : //  XWindow
     425             : 
     426           0 : void SAL_CALL BaseControl::setVisible( sal_Bool bVisible ) throw( RuntimeException, std::exception )
     427             : {
     428             :     // Ready for multithreading
     429           0 :     MutexGuard aGuard( m_aMutex );
     430             : 
     431             :     // Set new state of flag
     432           0 :     m_bVisible = bVisible;
     433             : 
     434           0 :     if ( m_xPeerWindow.is() )
     435             :     {
     436             :         // Set it also on peerwindow
     437           0 :         m_xPeerWindow->setVisible( m_bVisible );
     438           0 :     }
     439           0 : }
     440             : 
     441             : //  XWindow
     442             : 
     443           0 : void SAL_CALL BaseControl::setEnable( sal_Bool bEnable ) throw( RuntimeException, std::exception )
     444             : {
     445             :     // Ready for multithreading
     446           0 :     MutexGuard aGuard( m_aMutex );
     447             : 
     448             :     // Set new state of flag
     449           0 :     m_bEnable = bEnable;
     450             : 
     451           0 :     if ( m_xPeerWindow.is() )
     452             :     {
     453             :         // Set it also on peerwindow
     454           0 :         m_xPeerWindow->setEnable( m_bEnable );
     455           0 :     }
     456           0 : }
     457             : 
     458             : //  XWindow
     459             : 
     460           0 : void SAL_CALL BaseControl::setFocus() throw( RuntimeException, std::exception )
     461             : {
     462             :     // Ready for multithreading
     463           0 :     MutexGuard aGuard( m_aMutex );
     464             : 
     465           0 :     if ( m_xPeerWindow.is() )
     466             :     {
     467           0 :         m_xPeerWindow->setFocus();
     468           0 :     }
     469           0 : }
     470             : 
     471             : //  XWindow
     472             : 
     473           0 : Rectangle SAL_CALL BaseControl::getPosSize() throw( RuntimeException, std::exception )
     474             : {
     475             :     // Ready for multithreading
     476           0 :     MutexGuard aGuard( m_aMutex );
     477           0 :     return Rectangle( m_nX, m_nY , m_nWidth, m_nHeight );
     478             : }
     479             : 
     480             : //  XWindow
     481             : 
     482           0 : void SAL_CALL BaseControl::addWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException, std::exception )
     483             : {
     484           0 :     impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener );
     485           0 : }
     486             : 
     487             : //  XWindow
     488             : 
     489           0 : void SAL_CALL BaseControl::addFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException, std::exception )
     490             : {
     491           0 :     impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener );
     492           0 : }
     493             : 
     494             : //  XWindow
     495             : 
     496           0 : void SAL_CALL BaseControl::addKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException, std::exception )
     497             : {
     498           0 :     impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener );
     499           0 : }
     500             : 
     501             : //  XWindow
     502             : 
     503           0 : void SAL_CALL BaseControl::addMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException, std::exception )
     504             : {
     505           0 :     impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener );
     506           0 : }
     507             : 
     508             : //  XWindow
     509             : 
     510           0 : void SAL_CALL BaseControl::addMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException, std::exception )
     511             : {
     512           0 :     impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener );
     513           0 : }
     514             : 
     515             : //  XWindow
     516             : 
     517           0 : void SAL_CALL BaseControl::addPaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException, std::exception )
     518             : {
     519           0 :     impl_getMultiplexer()->advise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener );
     520           0 : }
     521             : 
     522             : //  XWindow
     523             : 
     524           0 : void SAL_CALL BaseControl::removeWindowListener( const Reference< XWindowListener >& xListener ) throw( RuntimeException, std::exception )
     525             : {
     526           0 :     impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XWindowListener >*)0), xListener );
     527           0 : }
     528             : 
     529             : //  XWindow
     530             : 
     531           0 : void SAL_CALL BaseControl::removeFocusListener( const Reference< XFocusListener >& xListener ) throw( RuntimeException, std::exception )
     532             : {
     533           0 :     impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XFocusListener >*)0), xListener );
     534           0 : }
     535             : 
     536             : //  XWindow
     537             : 
     538           0 : void SAL_CALL BaseControl::removeKeyListener( const Reference< XKeyListener >& xListener ) throw( RuntimeException, std::exception )
     539             : {
     540           0 :     impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XKeyListener >*)0), xListener );
     541           0 : }
     542             : 
     543             : //  XWindow
     544             : 
     545           0 : void SAL_CALL BaseControl::removeMouseListener( const Reference< XMouseListener >& xListener ) throw( RuntimeException, std::exception )
     546             : {
     547           0 :     impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseListener >*)0), xListener );
     548           0 : }
     549             : 
     550             : //  XWindow
     551             : 
     552           0 : void  SAL_CALL BaseControl::removeMouseMotionListener( const Reference< XMouseMotionListener >& xListener ) throw( RuntimeException, std::exception )
     553             : {
     554           0 :     impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XMouseMotionListener >*)0), xListener );
     555           0 : }
     556             : 
     557             : //  XWindow
     558             : 
     559           0 : void SAL_CALL BaseControl::removePaintListener( const Reference< XPaintListener >& xListener ) throw( RuntimeException, std::exception )
     560             : {
     561           0 :     impl_getMultiplexer()->unadvise( ::getCppuType(( const Reference< XPaintListener >*)0), xListener );
     562           0 : }
     563             : 
     564             : //  XView
     565             : 
     566           0 : void SAL_CALL BaseControl::draw(    sal_Int32   nX  ,
     567             :                                     sal_Int32   nY  ) throw( RuntimeException, std::exception )
     568             : {
     569             :     // Ready for multithreading
     570           0 :     MutexGuard aGuard( m_aMutex );
     571             : 
     572             :     // - paint to an view
     573             :     // - use the method "paint()"
     574             :     // - see also "windowPaint()"
     575           0 :     impl_paint( nX, nY, m_xGraphicsView );
     576           0 : }
     577             : 
     578             : //  XView
     579             : 
     580           0 : sal_Bool SAL_CALL BaseControl::setGraphics( const Reference< XGraphics >& xDevice ) throw( RuntimeException, std::exception )
     581             : {
     582             :     // - set the graphics for an view
     583             :     // - in this class exist 2 graphics-member ... one for peer[_xGraphicsPeer] and one for view[_xGraphicsView]
     584             :     // - they are used by "windowPaint() and draw()", forwarded to "paint ()"
     585           0 :     bool bReturn = false;
     586           0 :     if ( xDevice.is() )
     587             :     {
     588             :         // Ready for multithreading
     589           0 :         MutexGuard aGuard( m_aMutex );
     590             : 
     591           0 :         m_xGraphicsView = xDevice;
     592           0 :         bReturn         = true;
     593             :     }
     594             : 
     595           0 :     return bReturn;
     596             : }
     597             : 
     598             : //  XView
     599             : 
     600           0 : void SAL_CALL BaseControl::setZoom( float   /*fZoomX*/  ,
     601             :                                     float   /*fZoomY*/  ) throw( RuntimeException, std::exception )
     602             : {
     603             :     // Not implemented yet
     604           0 : }
     605             : 
     606             : //  XView
     607             : 
     608           0 : Reference< XGraphics > SAL_CALL BaseControl::getGraphics() throw( RuntimeException, std::exception )
     609             : {
     610             :     // Ready for multithreading
     611           0 :     MutexGuard aGuard( m_aMutex );
     612           0 :     return m_xGraphicsView;
     613             : }
     614             : 
     615             : //  XView
     616             : 
     617           0 : Size SAL_CALL BaseControl::getSize() throw( RuntimeException, std::exception )
     618             : {
     619             :     // Ready for multithreading
     620           0 :     MutexGuard aGuard( m_aMutex );
     621           0 :     return Size( m_nWidth, m_nHeight );
     622             : }
     623             : 
     624             : //  XEventListener
     625             : 
     626           0 : void SAL_CALL BaseControl::disposing( const EventObject& /*aSource*/ ) throw( RuntimeException, std::exception )
     627             : {
     628             :     // Ready for multithreading
     629           0 :     MutexGuard aGuard( m_aMutex );
     630             : 
     631             :     // - release ALL references
     632             :     // - it must be !!!
     633           0 :     if ( m_xGraphicsPeer.is() )
     634             :     {
     635           0 :         removePaintListener( this );
     636           0 :         removeWindowListener( this );
     637           0 :         m_xGraphicsPeer.clear();
     638             :     }
     639             : 
     640           0 :     if ( m_xGraphicsView.is() )
     641             :     {
     642           0 :         m_xGraphicsView.clear();
     643           0 :     }
     644           0 : }
     645             : 
     646             : //  XPaintListener
     647             : 
     648           0 : void SAL_CALL BaseControl::windowPaint( const PaintEvent& /*aEvent*/ ) throw( RuntimeException, std::exception )
     649             : {
     650             :     // Ready for multithreading
     651           0 :     MutexGuard aGuard( m_aMutex );
     652             : 
     653             :     // - repaint the peer
     654             :     // - use the method "paint ()" for painting on a peer and a print device !!!
     655             :     // - see also "draw ()"
     656           0 :     impl_paint( 0, 0, m_xGraphicsPeer );
     657           0 : }
     658             : 
     659             : //  XWindowListener
     660             : 
     661           0 : void SAL_CALL BaseControl::windowResized( const WindowEvent& aEvent ) throw( RuntimeException, std::exception )
     662             : {
     663             :     // Ready for multithreading
     664           0 :     MutexGuard aGuard( m_aMutex );
     665             : 
     666           0 :     m_nWidth    =   aEvent.Width;
     667           0 :     m_nHeight   =   aEvent.Height;
     668           0 :     WindowEvent aMappedEvent = aEvent;
     669           0 :     aMappedEvent.X = 0;
     670           0 :     aMappedEvent.Y = 0;
     671           0 :     impl_recalcLayout( aMappedEvent );
     672           0 : }
     673             : 
     674             : //  XWindowListener
     675             : 
     676           0 : void SAL_CALL BaseControl::windowMoved( const WindowEvent& aEvent ) throw( RuntimeException, std::exception )
     677             : {
     678             :     // Ready for multithreading
     679           0 :     MutexGuard aGuard( m_aMutex );
     680             : 
     681           0 :     m_nWidth    =   aEvent.Width;
     682           0 :     m_nHeight   =   aEvent.Height;
     683           0 :     WindowEvent aMappedEvent = aEvent;
     684           0 :     aMappedEvent.X = 0;
     685           0 :     aMappedEvent.Y = 0;
     686           0 :     impl_recalcLayout( aMappedEvent );
     687           0 : }
     688             : 
     689             : //  XWindowListener
     690             : 
     691           0 : void SAL_CALL BaseControl::windowShown( const EventObject& /*aEvent*/ ) throw( RuntimeException, std::exception )
     692             : {
     693           0 : }
     694             : 
     695             : //  XWindowListener
     696             : 
     697           0 : void SAL_CALL BaseControl::windowHidden( const EventObject& /*aEvent*/ ) throw( RuntimeException, std::exception )
     698             : {
     699           0 : }
     700             : 
     701             : //  impl but public method to register service in DLL
     702             : //  (In this BASE-implementation not implemented! Overwrite it in derived classes.)
     703             : 
     704           0 : const Sequence< OUString > BaseControl::impl_getStaticSupportedServiceNames()
     705             : {
     706           0 :     return Sequence< OUString >();
     707             : }
     708             : 
     709             : //  impl but public method to register service in DLL
     710             : //  (In this BASE-implementation not implemented! Overwrite it in derived classes.)
     711             : 
     712           0 : const OUString BaseControl::impl_getStaticImplementationName()
     713             : {
     714           0 :     return OUString();
     715             : }
     716             : 
     717             : //  protected method
     718             : 
     719           0 : const Reference< XComponentContext > BaseControl::impl_getComponentContext()
     720             : {
     721           0 :     return m_xComponentContext;
     722             : }
     723             : 
     724             : //  protected method
     725             : 
     726           0 : const Reference< XWindow > BaseControl::impl_getPeerWindow()
     727             : {
     728           0 :     return m_xPeerWindow;
     729             : }
     730             : 
     731             : //  protected method
     732             : 
     733           0 : const Reference< XGraphics > BaseControl::impl_getGraphicsPeer()
     734             : {
     735           0 :     return m_xGraphicsPeer;
     736             : }
     737             : 
     738             : //  protected method
     739             : 
     740           0 : const sal_Int32& BaseControl::impl_getWidth()
     741             : {
     742           0 :     return m_nWidth;
     743             : }
     744             : 
     745             : //  protected method
     746             : 
     747           0 : const sal_Int32& BaseControl::impl_getHeight()
     748             : {
     749           0 :     return m_nHeight;
     750             : }
     751             : 
     752             : //  protected method
     753             : 
     754           0 : WindowDescriptor* BaseControl::impl_getWindowDescriptor( const Reference< XWindowPeer >& xParentPeer )
     755             : {
     756             :     // - used from "createPeer()" to set the values of an ::com::sun::star::awt::WindowDescriptor !!!
     757             :     // - if you will change the descriptor-values, you must override this virtuell function
     758             :     // - the caller must release the memory for this dynamical descriptor !!!
     759             : 
     760           0 :     WindowDescriptor* pDescriptor = new WindowDescriptor;
     761             : 
     762           0 :     pDescriptor->Type               = WindowClass_SIMPLE;
     763           0 :     pDescriptor->WindowServiceName  = "window";
     764           0 :     pDescriptor->ParentIndex        = -1;
     765           0 :     pDescriptor->Parent             = xParentPeer;
     766           0 :     pDescriptor->Bounds             = getPosSize ();
     767           0 :     pDescriptor->WindowAttributes   = 0;
     768             : 
     769           0 :     return pDescriptor;
     770             : }
     771             : 
     772             : //  protected method
     773             : 
     774           0 : void BaseControl::impl_paint(           sal_Int32               /*nX*/          ,
     775             :                                         sal_Int32               /*nY*/          ,
     776             :                                 const   Reference< XGraphics >& /*xGraphics*/   )
     777             : {
     778             :     // - one paint method for peer AND view !!!
     779             :     //   (see also => "windowPaint()" and "draw()")
     780             :     // - not used in this implementation, but its not necessary to make it pure virtual !!!
     781           0 : }
     782             : 
     783             : //  protected method
     784             : 
     785           0 : void BaseControl::impl_recalcLayout( const WindowEvent& /*aEvent*/ )
     786             : {
     787             :     // We need as virtual function to support automaticly resizing of derived controls!
     788             :     // But we make it not pure virtual because it's not necessary for all derived classes!
     789           0 : }
     790             : 
     791             : //  protected method
     792             : 
     793           0 : Reference< XInterface > BaseControl::impl_getDelegator()
     794             : {
     795           0 :     return m_xDelegator;
     796             : }
     797             : 
     798             : //  private method
     799             : 
     800           0 : void BaseControl::impl_releasePeer()
     801             : {
     802           0 :     if ( m_xPeer.is() )
     803             :     {
     804           0 :         if ( m_xGraphicsPeer.is() )
     805             :         {
     806           0 :             removePaintListener( this );
     807           0 :             removeWindowListener( this );
     808           0 :             m_xGraphicsPeer.clear();
     809             :         }
     810             : 
     811           0 :         m_xPeer->dispose();
     812           0 :         m_xPeerWindow.clear();
     813           0 :         m_xPeer.clear();
     814             : 
     815           0 :         if ( m_pMultiplexer != NULL )
     816             :         {
     817             :             // take changes on multiplexer
     818           0 :             m_pMultiplexer->setPeer( Reference< XWindow >() );
     819             :         }
     820             :     }
     821           0 : }
     822             : 
     823             : //  private method
     824             : 
     825           0 : OMRCListenerMultiplexerHelper* BaseControl::impl_getMultiplexer()
     826             : {
     827           0 :     if ( m_pMultiplexer == NULL )
     828             :     {
     829           0 :         m_pMultiplexer = new OMRCListenerMultiplexerHelper( (XWindow*)this, m_xPeerWindow );
     830           0 :         m_xMultiplexer = Reference< XInterface >( (OWeakObject*)m_pMultiplexer, UNO_QUERY );
     831             :     }
     832             : 
     833           0 :     return m_pMultiplexer;
     834             : }
     835             : 
     836             : } // namespace unocontrols
     837             : 
     838             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10