Bump for 3.6-28
[LibreOffice.git] / chart2 / source / controller / main / StatusBarCommandDispatch.cxx
blobbc3d6df799533639e4edf283908d98926ef73283
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "StatusBarCommandDispatch.hxx"
31 #include "ObjectNameProvider.hxx"
32 #include "macros.hxx"
33 #include <com/sun/star/util/XModifyBroadcaster.hpp>
35 #include "ResId.hxx"
37 using namespace ::com::sun::star;
39 using ::com::sun::star::uno::Reference;
40 using ::com::sun::star::uno::Sequence;
41 using ::rtl::OUString;
43 namespace chart
46 StatusBarCommandDispatch::StatusBarCommandDispatch(
47 const Reference< uno::XComponentContext > & xContext,
48 const Reference< frame::XModel > & xModel,
49 const Reference< view::XSelectionSupplier > & xSelSupp ) :
50 impl::StatusBarCommandDispatch_Base( xContext ),
51 m_xModifiable( xModel, uno::UNO_QUERY ),
52 m_xSelectionSupplier( xSelSupp ),
53 m_bIsModified( false )
56 StatusBarCommandDispatch::~StatusBarCommandDispatch()
59 void StatusBarCommandDispatch::initialize()
61 if( m_xModifiable.is())
63 Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xModifiable, uno::UNO_QUERY );
64 OSL_ASSERT( xModifyBroadcaster.is());
65 if( xModifyBroadcaster.is())
66 xModifyBroadcaster->addModifyListener( this );
69 if( m_xSelectionSupplier.is())
71 m_xSelectionSupplier->addSelectionChangeListener( this );
75 void StatusBarCommandDispatch::fireStatusEvent(
76 const OUString & rURL,
77 const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
79 bool bFireAll( rURL.isEmpty() );
80 bool bFireContext( bFireAll || rURL == ".uno:Context" );
81 bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" );
83 if( bFireContext )
85 uno::Any aArg;
86 Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
87 aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc );
88 fireStatusEventForURL( C2U(".uno:Context"), aArg, true, xSingleListener );
90 if( bFireModified )
92 uno::Any aArg;
93 if( m_bIsModified )
94 aArg <<= C2U("*");
95 fireStatusEventForURL( C2U(".uno:ModifiedStatus"), aArg, true, xSingleListener );
99 // ____ XDispatch ____
100 void SAL_CALL StatusBarCommandDispatch::dispatch(
101 const util::URL& /* URL */,
102 const Sequence< beans::PropertyValue >& /* Arguments */ )
103 throw (uno::RuntimeException)
105 // nothing to do here
108 // ____ WeakComponentImplHelperBase ____
109 /// is called when this is disposed
110 void SAL_CALL StatusBarCommandDispatch::disposing()
112 m_xModifiable.clear();
113 m_xSelectionSupplier.clear();
116 // ____ XEventListener (base of XModifyListener) ____
117 void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
118 throw (uno::RuntimeException)
120 m_xModifiable.clear();
121 m_xSelectionSupplier.clear();
124 // ____ XModifyListener ____
125 void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
126 throw (uno::RuntimeException)
128 if( m_xModifiable.is())
129 m_bIsModified = m_xModifiable->isModified();
131 CommandDispatch::modified( aEvent );
134 // ____ XSelectionChangeListener ____
135 void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
136 throw (uno::RuntimeException)
138 if( m_xSelectionSupplier.is())
139 m_aSelectedOID = ObjectIdentifier( m_xSelectionSupplier->getSelection() );
140 else
141 m_aSelectedOID = ObjectIdentifier();
142 fireAllStatusEvents( 0 );
145 } // namespace chart
147 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */