LCOV - code coverage report
Current view: top level - framework/source/uielement - buttontoolbarcontroller.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 120 0.0 %
Date: 2012-08-25 Functions: 0 18 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 172 0.0 %

           Branch data     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                 :            : 
      30                 :            : #include "uielement/buttontoolbarcontroller.hxx"
      31                 :            : 
      32                 :            : #include "uielement/toolbar.hxx"
      33                 :            : 
      34                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      35                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      36                 :            : #include <com/sun/star/frame/XDispatchProvider.hpp>
      37                 :            : #include <com/sun/star/beans/PropertyValue.hpp>
      38                 :            : #include <com/sun/star/lang/DisposedException.hpp>
      39                 :            : #include "com/sun/star/util/XMacroExpander.hpp"
      40                 :            : #include "com/sun/star/uno/XComponentContext.hpp"
      41                 :            : #include "com/sun/star/beans/XPropertySet.hpp"
      42                 :            : 
      43                 :            : #include <rtl/uri.hxx>
      44                 :            : #include <osl/mutex.hxx>
      45                 :            : #include <comphelper/componentcontext.hxx>
      46                 :            : #include <comphelper/processfactory.hxx>
      47                 :            : #include <unotools/ucbstreamhelper.hxx>
      48                 :            : #include <vcl/svapp.hxx>
      49                 :            : #include <vcl/mnemonic.hxx>
      50                 :            : #include <vcl/window.hxx>
      51                 :            : #include <vcl/graph.hxx>
      52                 :            : #include <vcl/bitmap.hxx>
      53                 :            : #include <svtools/filter.hxx>
      54                 :            : #include <svtools/miscopt.hxx>
      55                 :            : 
      56                 :            : using namespace ::com::sun::star;
      57                 :            : using namespace ::com::sun::star::awt;
      58                 :            : using namespace ::com::sun::star::uno;
      59                 :            : using namespace ::com::sun::star::beans;
      60                 :            : using namespace ::com::sun::star::lang;
      61                 :            : using namespace ::com::sun::star::frame;
      62                 :            : using namespace ::com::sun::star::util;
      63                 :            : 
      64                 :            : namespace framework
      65                 :            : {
      66                 :            : 
      67                 :          0 : ButtonToolbarController::ButtonToolbarController(
      68                 :            :     const uno::Reference< lang::XMultiServiceFactory >& rServiceManager,
      69                 :            :     ToolBox*                                            pToolBar,
      70                 :            :     const rtl::OUString&                                aCommand ) :
      71                 :            :     cppu::OWeakObject(),
      72                 :            :     m_bInitialized( sal_False ),
      73                 :            :     m_bDisposed( sal_False ),
      74                 :            :     m_aCommandURL( aCommand ),
      75                 :            :     m_xServiceManager( rServiceManager ),
      76         [ #  # ]:          0 :     m_pToolbar( pToolBar )
      77                 :            : {
      78                 :          0 : }
      79                 :            : 
      80 [ #  # ][ #  # ]:          0 : ButtonToolbarController::~ButtonToolbarController()
      81                 :            : {
      82         [ #  # ]:          0 : }
      83                 :            : 
      84                 :            :         // XInterface
      85                 :          0 : uno::Any SAL_CALL ButtonToolbarController::queryInterface( const uno::Type& rType )
      86                 :            : throw (::com::sun::star::uno::RuntimeException)
      87                 :            : {
      88                 :            :     Any a = ::cppu::queryInterface(
      89                 :            :                 rType ,
      90                 :            :                 static_cast< frame::XStatusListener* >( this ),
      91                 :            :                 static_cast< frame::XToolbarController* >( this ),
      92                 :            :                 static_cast< lang::XInitialization* >( this ),
      93                 :            :                 static_cast< lang::XComponent* >( this ),
      94         [ #  # ]:          0 :                 static_cast< util::XUpdatable* >( this ));
      95                 :            : 
      96         [ #  # ]:          0 :     if ( a.hasValue() )
      97                 :          0 :         return a;
      98                 :            : 
      99         [ #  # ]:          0 :     return cppu::OWeakObject::queryInterface( rType );
     100                 :            : }
     101                 :            : 
     102                 :          0 : void SAL_CALL ButtonToolbarController::acquire() throw ()
     103                 :            : {
     104                 :          0 :     cppu::OWeakObject::acquire();
     105                 :          0 : }
     106                 :            : 
     107                 :          0 : void SAL_CALL ButtonToolbarController::release() throw ()
     108                 :            : {
     109                 :          0 :     cppu::OWeakObject::release();
     110                 :          0 : }
     111                 :            : 
     112                 :            : // XInitialization
     113                 :          0 : void SAL_CALL ButtonToolbarController::initialize(
     114                 :            :     const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
     115                 :            : throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
     116                 :            : {
     117                 :          0 :     bool bInitialized( true );
     118                 :            : 
     119                 :            :     {
     120         [ #  # ]:          0 :         SolarMutexGuard aSolarMutexGuard;
     121                 :            : 
     122         [ #  # ]:          0 :         if ( m_bDisposed )
     123         [ #  # ]:          0 :             throw DisposedException();
     124                 :            : 
     125         [ #  # ]:          0 :         bInitialized = m_bInitialized;
     126                 :            :     }
     127                 :            : 
     128         [ #  # ]:          0 :     if ( !bInitialized )
     129                 :            :     {
     130         [ #  # ]:          0 :         SolarMutexGuard aSolarMutexGuard;
     131                 :          0 :         m_bInitialized = sal_True;
     132                 :            : 
     133                 :          0 :         PropertyValue aPropValue;
     134         [ #  # ]:          0 :         for ( int i = 0; i < aArguments.getLength(); i++ )
     135                 :            :         {
     136 [ #  # ][ #  # ]:          0 :             if ( aArguments[i] >>= aPropValue )
     137                 :            :             {
     138         [ #  # ]:          0 :                 if ( aPropValue.Name == "Frame" )
     139         [ #  # ]:          0 :                     m_xFrame.set(aPropValue.Value,UNO_QUERY);
     140         [ #  # ]:          0 :                 else if ( aPropValue.Name == "CommandURL" )
     141                 :          0 :                     aPropValue.Value >>= m_aCommandURL;
     142         [ #  # ]:          0 :                 else if ( aPropValue.Name == "ServiceManager" )
     143         [ #  # ]:          0 :                     m_xServiceManager.set(aPropValue.Value,UNO_QUERY);
     144                 :            :             }
     145         [ #  # ]:          0 :         }
     146                 :            :     }
     147                 :          0 : }
     148                 :            : 
     149                 :            : // XComponent
     150                 :          0 : void SAL_CALL ButtonToolbarController::dispose() throw (::com::sun::star::uno::RuntimeException)
     151                 :            : {
     152         [ #  # ]:          0 :     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
     153                 :            : 
     154                 :            :     {
     155         [ #  # ]:          0 :         SolarMutexGuard aSolarMutexGuard;
     156         [ #  # ]:          0 :         if ( m_bDisposed )
     157         [ #  # ]:          0 :             throw DisposedException();
     158                 :            : 
     159                 :          0 :         m_xServiceManager.clear();
     160                 :          0 :         m_xURLTransformer.clear();
     161                 :          0 :         m_xFrame.clear();
     162                 :          0 :         m_pToolbar = 0;
     163         [ #  # ]:          0 :         m_bDisposed = sal_True;
     164                 :          0 :     }
     165                 :          0 : }
     166                 :            : 
     167                 :          0 : void SAL_CALL ButtonToolbarController::addEventListener(
     168                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& )
     169                 :            : throw (::com::sun::star::uno::RuntimeException)
     170                 :            : {
     171                 :            :     // do nothing
     172                 :          0 : }
     173                 :            : 
     174                 :          0 : void SAL_CALL ButtonToolbarController::removeEventListener(
     175                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& )
     176                 :            : throw (::com::sun::star::uno::RuntimeException)
     177                 :            : {
     178                 :            :     // do nothing
     179                 :          0 : }
     180                 :            : 
     181                 :            : // XUpdatable
     182                 :          0 : void SAL_CALL ButtonToolbarController::update()
     183                 :            : throw (::com::sun::star::uno::RuntimeException)
     184                 :            : {
     185         [ #  # ]:          0 :     SolarMutexGuard aSolarMutexGuard;
     186         [ #  # ]:          0 :     if ( m_bDisposed )
     187 [ #  # ][ #  # ]:          0 :         throw DisposedException();
     188                 :          0 : }
     189                 :            : 
     190                 :            : // XEventListener
     191                 :          0 : void SAL_CALL ButtonToolbarController::disposing(
     192                 :            :     const com::sun::star::lang::EventObject& Source )
     193                 :            : throw ( ::com::sun::star::uno::RuntimeException )
     194                 :            : {
     195                 :          0 :     uno::Reference< uno::XInterface > xSource( Source.Source );
     196                 :            : 
     197         [ #  # ]:          0 :     SolarMutexGuard aSolarMutexGuard;
     198                 :            : 
     199         [ #  # ]:          0 :     if ( m_bDisposed )
     200                 :          0 :         return;
     201                 :            : 
     202         [ #  # ]:          0 :     uno::Reference< uno::XInterface > xIfac( m_xFrame, uno::UNO_QUERY );
     203 [ #  # ][ #  # ]:          0 :     if ( xIfac == xSource )
     204 [ #  # ][ #  # ]:          0 :         m_xFrame.clear();
                 [ #  # ]
     205                 :            : }
     206                 :            : 
     207                 :          0 : void SAL_CALL ButtonToolbarController::statusChanged( const ::com::sun::star::frame::FeatureStateEvent& )
     208                 :            : throw ( ::com::sun::star::uno::RuntimeException )
     209                 :            : {
     210                 :            :     // do nothing
     211         [ #  # ]:          0 :     if ( m_bDisposed )
     212         [ #  # ]:          0 :         throw DisposedException();
     213                 :          0 : }
     214                 :            : 
     215                 :            : // XToolbarController
     216                 :          0 : void SAL_CALL ButtonToolbarController::execute( sal_Int16 KeyModifier )
     217                 :            : throw (::com::sun::star::uno::RuntimeException)
     218                 :            : {
     219                 :          0 :     uno::Reference< frame::XDispatch >      xDispatch;
     220                 :          0 :     uno::Reference< frame::XFrame >         xFrame;
     221                 :          0 :     uno::Reference< util::XURLTransformer > xURLTransformer;
     222                 :          0 :     rtl::OUString                           aCommandURL;
     223                 :          0 :     ::com::sun::star::util::URL             aTargetURL;
     224                 :            : 
     225                 :            :     {
     226         [ #  # ]:          0 :         SolarMutexGuard aSolarMutexGuard;
     227                 :            : 
     228         [ #  # ]:          0 :         if ( m_bDisposed )
     229         [ #  # ]:          0 :             throw DisposedException();
     230                 :            : 
     231   [ #  #  #  #  :          0 :         if ( m_bInitialized &&
             #  #  #  # ]
                 [ #  # ]
     232                 :          0 :              m_xFrame.is() &&
     233                 :          0 :              m_xServiceManager.is() &&
     234                 :          0 :              !m_aCommandURL.isEmpty() )
     235                 :            :         {
     236         [ #  # ]:          0 :             if ( !m_xURLTransformer.is() )
     237                 :            :             {
     238 [ #  # ][ #  # ]:          0 :                 m_xURLTransformer = util::URLTransformer::create( ::comphelper::ComponentContext(m_xServiceManager).getUNOContext() );
         [ #  # ][ #  # ]
                 [ #  # ]
     239                 :            :             }
     240                 :            : 
     241         [ #  # ]:          0 :             xFrame          = m_xFrame;
     242                 :          0 :             aCommandURL     = m_aCommandURL;
     243         [ #  # ]:          0 :             xURLTransformer = m_xURLTransformer;
     244         [ #  # ]:          0 :         }
     245                 :            :     }
     246                 :            : 
     247         [ #  # ]:          0 :     uno::Reference< frame::XDispatchProvider > xDispatchProvider( xFrame, uno::UNO_QUERY );
     248         [ #  # ]:          0 :     if ( xDispatchProvider.is() )
     249                 :            :     {
     250                 :          0 :         aTargetURL.Complete = aCommandURL;
     251 [ #  # ][ #  # ]:          0 :         xURLTransformer->parseStrict( aTargetURL );
     252 [ #  # ][ #  # ]:          0 :         xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 );
                 [ #  # ]
     253                 :            :     }
     254                 :            : 
     255         [ #  # ]:          0 :     if ( xDispatch.is() )
     256                 :            :     {
     257                 :            :         try
     258                 :            :         {
     259         [ #  # ]:          0 :             Sequence<PropertyValue>   aArgs( 1 );
     260                 :            : 
     261                 :            :             // Provide key modifier information to dispatch function
     262         [ #  # ]:          0 :             aArgs[0].Name   = rtl::OUString( "KeyModifier" );
     263 [ #  # ][ #  # ]:          0 :             aArgs[0].Value  <<= KeyModifier;
     264                 :            : 
     265 [ #  # ][ #  # ]:          0 :             xDispatch->dispatch( aTargetURL, aArgs );
         [ #  # ][ #  # ]
     266                 :            :         }
     267         [ #  # ]:          0 :         catch ( const DisposedException& )
     268                 :            :         {
     269                 :            :         }
     270                 :          0 :     }
     271                 :          0 : }
     272                 :            : 
     273                 :          0 : void SAL_CALL ButtonToolbarController::click()
     274                 :            : throw (::com::sun::star::uno::RuntimeException)
     275                 :            : {
     276         [ #  # ]:          0 :     SolarMutexGuard aSolarMutexGuard;
     277                 :            : 
     278         [ #  # ]:          0 :     if ( m_bDisposed )
     279         [ #  # ]:          0 :         throw DisposedException();
     280                 :            : 
     281                 :          0 :     sal_Int16   nKeyModifier( (sal_Int16)m_pToolbar->GetModifier() );
     282 [ #  # ][ #  # ]:          0 :     execute( nKeyModifier );
     283                 :          0 : }
     284                 :            : 
     285                 :          0 : void SAL_CALL ButtonToolbarController::doubleClick()
     286                 :            : throw (::com::sun::star::uno::RuntimeException)
     287                 :            : {
     288                 :            :     // do nothing
     289         [ #  # ]:          0 :     if ( m_bDisposed )
     290         [ #  # ]:          0 :         throw DisposedException();
     291                 :          0 : }
     292                 :            : 
     293                 :          0 : uno::Reference< awt::XWindow > SAL_CALL ButtonToolbarController::createPopupWindow()
     294                 :            : throw (::com::sun::star::uno::RuntimeException)
     295                 :            : {
     296         [ #  # ]:          0 :     if ( m_bDisposed )
     297         [ #  # ]:          0 :         throw DisposedException();
     298                 :            : 
     299                 :          0 :     return uno::Reference< awt::XWindow >();
     300                 :            : }
     301                 :            : 
     302                 :          0 : uno::Reference< awt::XWindow > SAL_CALL ButtonToolbarController::createItemWindow(
     303                 :            :     const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& )
     304                 :            : throw (::com::sun::star::uno::RuntimeException)
     305                 :            : {
     306         [ #  # ]:          0 :     if ( m_bDisposed )
     307         [ #  # ]:          0 :         throw DisposedException();
     308                 :            : 
     309                 :          0 :     return uno::Reference< awt::XWindow >();
     310                 :            : }
     311                 :            : 
     312                 :            : } // namespace
     313                 :            : 
     314                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10