Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / chart2 / source / controller / main / StatusBarCommandDispatch.cxx
blob1a7e9a35c6b5fe59ae90abeeeb036a17cd724a6c
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>
23 #include <com/sun/star/chart2/XChartDocument.hpp>
24 #include <com/sun/star/view/XSelectionSupplier.hpp>
25 #include <com/sun/star/util/XModifiable.hpp>
27 using namespace ::com::sun::star;
29 using ::com::sun::star::uno::Reference;
30 using ::com::sun::star::uno::Sequence;
32 namespace chart
35 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 m_bIsModified( false )
45 StatusBarCommandDispatch::~StatusBarCommandDispatch()
48 void StatusBarCommandDispatch::initialize()
50 if( m_xModifiable.is())
52 m_xModifiable->addModifyListener( this );
55 if( m_xSelectionSupplier.is())
57 m_xSelectionSupplier->addSelectionChangeListener( this );
61 void StatusBarCommandDispatch::fireStatusEvent(
62 const OUString & rURL,
63 const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
65 bool bFireAll( rURL.isEmpty() );
66 bool bFireContext( bFireAll || rURL == ".uno:Context" );
67 bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
69 if( bFireContext )
71 uno::Any aArg;
72 Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
73 aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc );
74 fireStatusEventForURL( ".uno:Context", aArg, true, xSingleListener );
76 if( bFireModified )
78 uno::Any aArg;
79 if( m_bIsModified )
80 aArg <<= OUString("*");
81 fireStatusEventForURL( ".uno:ModifiedStatus", aArg, true, xSingleListener );
85 // ____ XDispatch ____
86 void SAL_CALL StatusBarCommandDispatch::dispatch(
87 const util::URL& /* URL */,
88 const Sequence< beans::PropertyValue >& /* Arguments */ )
90 // nothing to do here
93 // ____ WeakComponentImplHelperBase ____
94 /// is called when this is disposed
95 void SAL_CALL StatusBarCommandDispatch::disposing()
97 m_xModifiable.clear();
98 m_xSelectionSupplier.clear();
101 // ____ XEventListener (base of XModifyListener) ____
102 void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
104 m_xModifiable.clear();
105 m_xSelectionSupplier.clear();
108 // ____ XModifyListener ____
109 void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
111 if( m_xModifiable.is())
112 m_bIsModified = m_xModifiable->isModified();
114 CommandDispatch::modified( aEvent );
117 // ____ XSelectionChangeListener ____
118 void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
120 if( m_xSelectionSupplier.is())
121 m_aSelectedOID = ObjectIdentifier( m_xSelectionSupplier->getSelection() );
122 else
123 m_aSelectedOID = ObjectIdentifier();
124 fireAllStatusEvents( nullptr );
127 } // namespace chart
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */