LCOV - code coverage report
Current view: top level - chart2/source/controller/main - StatusBarCommandDispatch.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 42 50 84.0 %
Date: 2014-11-03 Functions: 10 12 83.3 %
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 "StatusBarCommandDispatch.hxx"
      21             : #include "ObjectNameProvider.hxx"
      22             : #include "macros.hxx"
      23             : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      24             : 
      25             : #include "ResId.hxx"
      26             : 
      27             : using namespace ::com::sun::star;
      28             : 
      29             : using ::com::sun::star::uno::Reference;
      30             : using ::com::sun::star::uno::Sequence;
      31             : 
      32             : namespace chart
      33             : {
      34             : 
      35          34 : StatusBarCommandDispatch::StatusBarCommandDispatch(
      36             :     const Reference< uno::XComponentContext > & xContext,
      37             :     const Reference< frame::XModel > & xModel,
      38             :     const Reference< view::XSelectionSupplier > & xSelSupp ) :
      39             :         impl::StatusBarCommandDispatch_Base( xContext ),
      40             :         m_xModifiable( xModel, uno::UNO_QUERY  ),
      41             :         m_xSelectionSupplier( xSelSupp ),
      42          34 :         m_bIsModified( false )
      43          34 : {}
      44             : 
      45           4 : StatusBarCommandDispatch::~StatusBarCommandDispatch()
      46           4 : {}
      47             : 
      48          34 : void StatusBarCommandDispatch::initialize()
      49             : {
      50          34 :     if( m_xModifiable.is())
      51             :     {
      52          34 :         Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xModifiable, uno::UNO_QUERY );
      53             :         OSL_ASSERT( xModifyBroadcaster.is());
      54          34 :         if( xModifyBroadcaster.is())
      55          34 :             xModifyBroadcaster->addModifyListener( this );
      56             :     }
      57             : 
      58          34 :     if( m_xSelectionSupplier.is())
      59             :     {
      60          34 :         m_xSelectionSupplier->addSelectionChangeListener( this );
      61             :     }
      62          34 : }
      63             : 
      64        1671 : void StatusBarCommandDispatch::fireStatusEvent(
      65             :     const OUString & rURL,
      66             :     const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
      67             : {
      68        1671 :     bool bFireAll( rURL.isEmpty() );
      69        1671 :     bool bFireContext(  bFireAll || rURL == ".uno:Context" );
      70        1671 :     bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
      71             : 
      72        1671 :     if( bFireContext )
      73             :     {
      74        1637 :         uno::Any aArg;
      75        3274 :         Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
      76        1637 :         aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc );
      77        3274 :         fireStatusEventForURL( ".uno:Context", aArg, true, xSingleListener );
      78             :     }
      79        1671 :     if( bFireModified )
      80             :     {
      81        1637 :         uno::Any aArg;
      82        1637 :         if( m_bIsModified )
      83        1577 :             aArg <<= OUString("*");
      84        1637 :         fireStatusEventForURL( ".uno:ModifiedStatus", aArg, true, xSingleListener );
      85             :     }
      86        1671 : }
      87             : 
      88             : // ____ XDispatch ____
      89           0 : void SAL_CALL StatusBarCommandDispatch::dispatch(
      90             :     const util::URL& /* URL */,
      91             :     const Sequence< beans::PropertyValue >& /* Arguments */ )
      92             :     throw (uno::RuntimeException, std::exception)
      93             : {
      94             :     // nothing to do here
      95           0 : }
      96             : 
      97             : // ____ WeakComponentImplHelperBase ____
      98             : /// is called when this is disposed
      99          34 : void SAL_CALL StatusBarCommandDispatch::disposing()
     100             : {
     101          34 :     m_xModifiable.clear();
     102          34 :     m_xSelectionSupplier.clear();
     103          34 : }
     104             : 
     105             : // ____ XEventListener (base of XModifyListener) ____
     106          34 : void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
     107             :     throw (uno::RuntimeException, std::exception)
     108             : {
     109          34 :     m_xModifiable.clear();
     110          34 :     m_xSelectionSupplier.clear();
     111          34 : }
     112             : 
     113             : // ____ XModifyListener ____
     114        1603 : void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
     115             :     throw (uno::RuntimeException, std::exception)
     116             : {
     117        1603 :     if( m_xModifiable.is())
     118        1603 :         m_bIsModified = m_xModifiable->isModified();
     119             : 
     120        1603 :     CommandDispatch::modified( aEvent );
     121        1603 : }
     122             : 
     123             : // ____ XSelectionChangeListener ____
     124           0 : void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
     125             :     throw (uno::RuntimeException, std::exception)
     126             : {
     127           0 :     if( m_xSelectionSupplier.is())
     128           0 :         m_aSelectedOID = ObjectIdentifier( m_xSelectionSupplier->getSelection() );
     129             :     else
     130           0 :         m_aSelectedOID = ObjectIdentifier();
     131           0 :     fireAllStatusEvents( 0 );
     132           0 : }
     133             : 
     134         102 : } //  namespace chart
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10