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

Generated by: LCOV version 1.10