Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / controller / main / StatusBarCommandDispatch.cxx
blobc265adca03360033d48a208bdb266c429e6906f6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "StatusBarCommandDispatch.hxx"
21 #include <ObjectNameProvider.hxx>
22 #include <com/sun/star/util/XModifyBroadcaster.hpp>
25 using namespace ::com::sun::star;
27 using ::com::sun::star::uno::Reference;
28 using ::com::sun::star::uno::Sequence;
30 namespace chart
33 StatusBarCommandDispatch::StatusBarCommandDispatch(
34 const Reference< uno::XComponentContext > & xContext,
35 const Reference< frame::XModel > & xModel,
36 const Reference< view::XSelectionSupplier > & xSelSupp ) :
37 impl::StatusBarCommandDispatch_Base( xContext ),
38 m_xModifiable( xModel, uno::UNO_QUERY ),
39 m_xSelectionSupplier( xSelSupp ),
40 m_bIsModified( false )
43 StatusBarCommandDispatch::~StatusBarCommandDispatch()
46 void StatusBarCommandDispatch::initialize()
48 if( m_xModifiable.is())
50 Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xModifiable, uno::UNO_QUERY );
51 OSL_ASSERT( xModifyBroadcaster.is());
52 if( xModifyBroadcaster.is())
53 xModifyBroadcaster->addModifyListener( this );
56 if( m_xSelectionSupplier.is())
58 m_xSelectionSupplier->addSelectionChangeListener( this );
62 void StatusBarCommandDispatch::fireStatusEvent(
63 const OUString & rURL,
64 const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
66 bool bFireAll( rURL.isEmpty() );
67 bool bFireContext( bFireAll || rURL == ".uno:Context" );
68 bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
70 if( bFireContext )
72 uno::Any aArg;
73 Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
74 aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc );
75 fireStatusEventForURL( ".uno:Context", aArg, true, xSingleListener );
77 if( bFireModified )
79 uno::Any aArg;
80 if( m_bIsModified )
81 aArg <<= OUString("*");
82 fireStatusEventForURL( ".uno:ModifiedStatus", aArg, true, xSingleListener );
86 // ____ XDispatch ____
87 void SAL_CALL StatusBarCommandDispatch::dispatch(
88 const util::URL& /* URL */,
89 const Sequence< beans::PropertyValue >& /* Arguments */ )
91 // nothing to do here
94 // ____ WeakComponentImplHelperBase ____
95 /// is called when this is disposed
96 void SAL_CALL StatusBarCommandDispatch::disposing()
98 m_xModifiable.clear();
99 m_xSelectionSupplier.clear();
102 // ____ XEventListener (base of XModifyListener) ____
103 void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
105 m_xModifiable.clear();
106 m_xSelectionSupplier.clear();
109 // ____ XModifyListener ____
110 void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
112 if( m_xModifiable.is())
113 m_bIsModified = m_xModifiable->isModified();
115 CommandDispatch::modified( aEvent );
118 // ____ XSelectionChangeListener ____
119 void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
121 if( m_xSelectionSupplier.is())
122 m_aSelectedOID = ObjectIdentifier( m_xSelectionSupplier->getSelection() );
123 else
124 m_aSelectedOID = ObjectIdentifier();
125 fireAllStatusEvents( nullptr );
128 } // namespace chart
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */