LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/plugin/base - plctrl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 126 0.0 %
Date: 2012-12-27 Functions: 0 32 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             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      12             :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13             :  * it under the terms of the GNU Lesser General Public License version 3
      14             :  * only, as published by the Free Software Foundation.
      15             :  *
      16             :  * OpenOffice.org is distributed in the hope that it will be useful,
      17             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :  * GNU Lesser General Public License version 3 for more details
      20             :  * (a copy is included in the LICENSE file that accompanied this code).
      21             :  *
      22             :  * You should have received a copy of the GNU Lesser General Public License
      23             :  * version 3 along with OpenOffice.org.  If not, see
      24             :  * <http://www.openoffice.org/license.html>
      25             :  * for a copy of the LGPLv3 License.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #include <com/sun/star/awt/XAdjustmentListener.hpp>
      30             : #include <com/sun/star/awt/XActionListener.hpp>
      31             : #include <com/sun/star/awt/XTextListener.hpp>
      32             : #include <com/sun/star/awt/XSpinListener.hpp>
      33             : #include <com/sun/star/awt/XItemListener.hpp>
      34             : #include <com/sun/star/awt/XVclContainerListener.hpp>
      35             : 
      36             : #include <plugin/plctrl.hxx>
      37             : #include <vcl/syschild.hxx>
      38             : #include <toolkit/helper/vclunohelper.hxx>
      39             : 
      40             : 
      41             : //--------------------------------------------------------------------------------------------------
      42           0 : PluginControl_Impl::PluginControl_Impl() :
      43             :     _pMultiplexer( NULL )
      44             :     , _nX( 0 )
      45             :     , _nY( 0 )
      46             :     , _nWidth( 100 )
      47             :     , _nHeight( 100 )
      48             :     , _nFlags( WINDOW_POSSIZE_ALL )
      49             :     , _bVisible( sal_False )
      50             :     , _bInDesignMode( sal_False )
      51           0 :     , _bEnable( sal_True )
      52             : {
      53           0 : }
      54             : 
      55             : //--------------------------------------------------------------------------------------------------
      56           0 : PluginControl_Impl::~PluginControl_Impl()
      57             : {
      58           0 : }
      59             : 
      60           0 : MRCListenerMultiplexerHelper* PluginControl_Impl::getMultiplexer()
      61             : {
      62           0 :     if( ! _pMultiplexer )
      63           0 :         _pMultiplexer = new MRCListenerMultiplexerHelper( this, _xPeerWindow );
      64           0 :     return _pMultiplexer;
      65             : }
      66             : //==================================================================================================
      67             : 
      68           0 : void PluginControl_Impl::addEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l )
      69             :     throw( RuntimeException )
      70             : {
      71           0 :     _aDisposeListeners.push_back( l );
      72           0 : }
      73             : 
      74             : //---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
      75           0 : void PluginControl_Impl::removeEventListener( const Reference< ::com::sun::star::lang::XEventListener > & l )
      76             :     throw( RuntimeException )
      77             : {
      78           0 :     _aDisposeListeners.remove( l );
      79           0 : }
      80             : 
      81             : //---- ::com::sun::star::lang::XComponent ----------------------------------------------------------------------------------
      82           0 : void PluginControl_Impl::dispose(void)
      83             :     throw( RuntimeException )
      84             : {
      85             :     // send disposing events
      86           0 :     ::com::sun::star::lang::EventObject aEvt;
      87           0 :     if( getMultiplexer() )
      88           0 :         getMultiplexer()->disposeAndClear();
      89             : 
      90             :     // release context
      91           0 :     _xContext = Reference< XInterface > ();
      92           0 :     releasePeer();
      93           0 : }
      94             : 
      95             : 
      96             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
      97           0 : void PluginControl_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags )
      98             :     throw( RuntimeException )
      99             : {
     100           0 :     _nX         = nX_ >=0 ? nX_ : 0;
     101           0 :     _nY         = nY_ >=0 ? nY_ : 0;
     102           0 :     _nWidth     = nWidth_ >=0 ? nWidth_ : 0;
     103           0 :     _nHeight    = nHeight_ >=0 ? nHeight_ : 0;
     104           0 :     _nFlags     = nFlags;
     105             : 
     106           0 :     if (_xPeerWindow.is())
     107           0 :         _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, nFlags );
     108           0 : }
     109             : 
     110             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     111           0 : ::com::sun::star::awt::Rectangle PluginControl_Impl::getPosSize(void)
     112             :     throw( RuntimeException )
     113             : {
     114           0 :     return _xPeerWindow->getPosSize();
     115             : }
     116             : 
     117             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     118           0 : void PluginControl_Impl::setVisible( sal_Bool bVisible )
     119             :     throw( RuntimeException )
     120             : {
     121           0 :     _bVisible = bVisible;
     122           0 :     if (_xPeerWindow.is())
     123           0 :         _xPeerWindow->setVisible( _bVisible && !_bInDesignMode );
     124           0 : }
     125             : 
     126             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     127           0 : void PluginControl_Impl::setEnable( sal_Bool bEnable )
     128             :     throw( RuntimeException )
     129             : {
     130           0 :     _bEnable = bEnable;
     131           0 :     if (_xPeerWindow.is())
     132           0 :         _xPeerWindow->setEnable( _bEnable );
     133           0 : }
     134             : 
     135             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     136           0 : void PluginControl_Impl::setFocus(void) throw( RuntimeException )
     137             : {
     138           0 :     if (_xPeerWindow.is())
     139           0 :         _xPeerWindow->setFocus();
     140           0 : }
     141             : 
     142             : 
     143             : //--------------------------------------------------------------------------------------------------
     144           0 : void PluginControl_Impl::releasePeer()
     145             : {
     146           0 :     if (_xPeer.is())
     147             :     {
     148           0 :         _xParentWindow->removeFocusListener( this );
     149           0 :         _xPeerWindow->dispose();
     150           0 :         _pSysChild      = NULL;
     151           0 :         _xPeerWindow    = Reference< ::com::sun::star::awt::XWindow > ();
     152           0 :         _xPeer          = Reference< ::com::sun::star::awt::XWindowPeer > ();
     153           0 :         getMultiplexer()->setPeer( Reference< ::com::sun::star::awt::XWindow > () );
     154             :     }
     155           0 : }
     156             : 
     157             : //---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------
     158           0 : void PluginControl_Impl::createPeer( const Reference< ::com::sun::star::awt::XToolkit > & /*xToolkit*/, const Reference< ::com::sun::star::awt::XWindowPeer >  & xParentPeer )
     159             :     throw( RuntimeException )
     160             : {
     161           0 :     if (_xPeer.is())
     162             :     {
     163             :         OSL_FAIL( "### Peer is already set!" );
     164           0 :         return;
     165             :     }
     166             : 
     167           0 :     _xParentPeer = xParentPeer;
     168           0 :     _xParentWindow = Reference< ::com::sun::star::awt::XWindow > ( xParentPeer, UNO_QUERY );
     169             :     DBG_ASSERT( _xParentWindow.is(), "### no parent peer window!" );
     170             : 
     171           0 :     Window* pImpl = VCLUnoHelper::GetWindow( xParentPeer );
     172           0 :     if (pImpl)
     173             :     {
     174           0 :         _pSysChild = new SystemChildWindow( pImpl, WB_CLIPCHILDREN );
     175           0 :         if (pImpl->HasFocus())
     176           0 :             _pSysChild->GrabFocus();
     177             : 
     178             :         // get peer
     179           0 :         _xPeer          = Reference< ::com::sun::star::awt::XWindowPeer > ( _pSysChild->GetComponentInterface() );
     180           0 :         _xPeerWindow    = Reference< ::com::sun::star::awt::XWindow > ( _xPeer, UNO_QUERY );
     181             :         // !_BOTH_ MUST BE VALID!
     182             :         DBG_ASSERT( (_xPeer.is() && _xPeerWindow.is()), "### no peer!" );
     183             : 
     184           0 :         _xParentWindow->addFocusListener( this );
     185           0 :         _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, _nFlags );
     186           0 :         _xPeerWindow->setEnable( _bEnable );
     187           0 :         _xPeerWindow->setVisible( _bVisible && !_bInDesignMode );
     188             :     }
     189             :     else
     190             :     {
     191             :         OSL_FAIL( "### cannot get implementation of parent peer!" );
     192             :     }
     193             : 
     194           0 :     getMultiplexer()->setPeer( _xPeerWindow );
     195             : }
     196             : 
     197             : //---- ::com::sun::star::awt::XControl ------------------------------------------------------------------------------------
     198           0 : void PluginControl_Impl::setDesignMode( sal_Bool bOn )
     199             :     throw( RuntimeException )
     200             : {
     201           0 :     _bInDesignMode = bOn;
     202           0 :     if (_xPeerWindow.is())
     203           0 :         _xPeerWindow->setVisible( _bVisible && !_bInDesignMode );
     204           0 : }
     205             : 
     206             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     207           0 : void PluginControl_Impl::addPaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l )
     208             :     throw( RuntimeException )
     209             : {
     210           0 :     getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l );
     211           0 : }
     212             : 
     213             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     214           0 : void PluginControl_Impl::removePaintListener( const Reference< ::com::sun::star::awt::XPaintListener > & l )
     215             :     throw( RuntimeException )
     216             : {
     217           0 :     getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XPaintListener >*)0), l );
     218           0 : }
     219             : 
     220             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     221           0 : void PluginControl_Impl::addWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l )
     222             :     throw( RuntimeException )
     223             : {
     224           0 :     getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l );
     225           0 : }
     226             : 
     227             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     228           0 : void PluginControl_Impl::removeWindowListener( const Reference< ::com::sun::star::awt::XWindowListener > & l )
     229             :     throw( RuntimeException )
     230             : {
     231           0 :     getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XWindowListener >*)0), l );
     232           0 : }
     233             : 
     234             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     235           0 : void PluginControl_Impl::addFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l )
     236             :     throw( RuntimeException )
     237             : {
     238           0 :     getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l );
     239           0 : }
     240             : 
     241             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     242           0 : void PluginControl_Impl::removeFocusListener( const Reference< ::com::sun::star::awt::XFocusListener > & l )
     243             :     throw( RuntimeException )
     244             : {
     245           0 :     getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XFocusListener >*)0), l );
     246           0 : }
     247             : 
     248             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     249           0 : void PluginControl_Impl::addKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l )
     250             :     throw( RuntimeException )
     251             : {
     252           0 :     getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l );
     253           0 : }
     254             : 
     255             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     256           0 : void PluginControl_Impl::removeKeyListener( const Reference< ::com::sun::star::awt::XKeyListener > & l )
     257             :     throw( RuntimeException )
     258             : {
     259           0 :     getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XKeyListener >*)0), l );
     260           0 : }
     261             : 
     262             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     263           0 : void PluginControl_Impl::addMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l )
     264             :     throw( RuntimeException )
     265             : {
     266           0 :     getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l );
     267           0 : }
     268             : 
     269             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     270           0 : void PluginControl_Impl::removeMouseListener( const Reference< ::com::sun::star::awt::XMouseListener > & l )
     271             :     throw( RuntimeException )
     272             : {
     273           0 :     getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseListener >*)0), l );
     274           0 : }
     275             : 
     276             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     277           0 : void PluginControl_Impl::addMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l )
     278             :     throw( RuntimeException )
     279             : {
     280           0 :     getMultiplexer()->advise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l );
     281           0 : }
     282             : 
     283             : //---- ::com::sun::star::awt::XWindow -------------------------------------------------------------------------------------
     284           0 : void PluginControl_Impl::removeMouseMotionListener( const Reference< ::com::sun::star::awt::XMouseMotionListener > & l )
     285             :     throw( RuntimeException )
     286             : {
     287           0 :     getMultiplexer()->unadvise( ::getCppuType((const Reference< ::com::sun::star::awt::XMouseMotionListener >*)0), l );
     288           0 : }
     289             : 
     290             : 
     291             : //---- ::com::sun::star::awt::XView ---------------------------------------------------------------------------------------
     292           0 : void PluginControl_Impl::draw( sal_Int32 /*x*/, sal_Int32 /*y*/ )
     293             :     throw( RuntimeException )
     294             : {
     295             :     // has to be done by further implementation of control
     296           0 : }
     297             : 
     298             : //---- ::com::sun::star::awt::XView ---------------------------------------------------------------------------------------
     299           0 : void PluginControl_Impl::setZoom( float /*ZoomX*/, float /*ZoomY*/ )
     300             :     throw( RuntimeException )
     301             : {
     302             :     // has to be done by further implementation of control
     303           0 : }
     304             : 
     305             : //---- ::com::sun::star::lang::XEventListener ------------------------------------------------------------------------------
     306           0 : void PluginControl_Impl::disposing( const ::com::sun::star::lang::EventObject & /*rSource*/ )
     307             :     throw( RuntimeException )
     308             : {
     309           0 : }
     310             : //---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------
     311           0 : void PluginControl_Impl::focusGained( const ::com::sun::star::awt::FocusEvent & /*rEvt*/ )
     312             :     throw( RuntimeException )
     313             : {
     314           0 :     if (_xPeerWindow.is())
     315           0 :         _xPeerWindow->setFocus();
     316           0 : }
     317             : //---- ::com::sun::star::awt::XFocusListener ------------------------------------------------------------------------------
     318           0 : void PluginControl_Impl::focusLost( const ::com::sun::star::awt::FocusEvent & /*rEvt*/ )
     319             :     throw( RuntimeException )
     320             : {
     321           0 : }
     322             : 
     323             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10