LCOV - code coverage report
Current view: top level - chart2/source/controller/main - StatusBarCommandDispatch.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 41 49 83.7 %
Date: 2015-06-13 12:38:46 Functions: 8 10 80.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 "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          17 : 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          17 :         m_bIsModified( false )
      43          17 : {}
      44             : 
      45           2 : StatusBarCommandDispatch::~StatusBarCommandDispatch()
      46           2 : {}
      47             : 
      48          17 : void StatusBarCommandDispatch::initialize()
      49             : {
      50          17 :     if( m_xModifiable.is())
      51             :     {
      52          17 :         Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xModifiable, uno::UNO_QUERY );
      53             :         OSL_ASSERT( xModifyBroadcaster.is());
      54          17 :         if( xModifyBroadcaster.is())
      55          17 :             xModifyBroadcaster->addModifyListener( this );
      56             :     }
      57             : 
      58          17 :     if( m_xSelectionSupplier.is())
      59             :     {
      60          17 :         m_xSelectionSupplier->addSelectionChangeListener( this );
      61             :     }
      62          17 : }
      63             : 
      64         837 : void StatusBarCommandDispatch::fireStatusEvent(
      65             :     const OUString & rURL,
      66             :     const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
      67             : {
      68         837 :     bool bFireAll( rURL.isEmpty() );
      69         837 :     bool bFireContext(  bFireAll || rURL == ".uno:Context" );
      70         837 :     bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
      71             : 
      72         837 :     if( bFireContext )
      73             :     {
      74         820 :         uno::Any aArg;
      75        1640 :         Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
      76         820 :         aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc );
      77        1640 :         fireStatusEventForURL( ".uno:Context", aArg, true, xSingleListener );
      78             :     }
      79         837 :     if( bFireModified )
      80             :     {
      81         820 :         uno::Any aArg;
      82         820 :         if( m_bIsModified )
      83         799 :             aArg <<= OUString("*");
      84         820 :         fireStatusEventForURL( ".uno:ModifiedStatus", aArg, true, xSingleListener );
      85             :     }
      86         837 : }
      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          17 : void SAL_CALL StatusBarCommandDispatch::disposing()
     100             : {
     101          17 :     m_xModifiable.clear();
     102          17 :     m_xSelectionSupplier.clear();
     103          17 : }
     104             : 
     105             : // ____ XEventListener (base of XModifyListener) ____
     106          17 : void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
     107             :     throw (uno::RuntimeException, std::exception)
     108             : {
     109          17 :     m_xModifiable.clear();
     110          17 :     m_xSelectionSupplier.clear();
     111          17 : }
     112             : 
     113             : // ____ XModifyListener ____
     114         803 : void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
     115             :     throw (uno::RuntimeException, std::exception)
     116             : {
     117         803 :     if( m_xModifiable.is())
     118         803 :         m_bIsModified = m_xModifiable->isModified();
     119             : 
     120         803 :     CommandDispatch::modified( aEvent );
     121         803 : }
     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             : } //  namespace chart
     135             : 
     136             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11