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

Generated by: LCOV version 1.10