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

Generated by: LCOV version 1.10