Update ooo320-m1
[ooovba.git] / chart2 / source / controller / main / StatusBarCommandDispatch.cxx
blob4d4a90d6883530972f197f3e5155183b428d5600
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: StatusBarCommandDispatch.cxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_chart2.hxx"
34 #include "StatusBarCommandDispatch.hxx"
35 #include "ObjectNameProvider.hxx"
36 #include "macros.hxx"
37 #include <com/sun/star/util/XModifyBroadcaster.hpp>
39 // #ifndef _VOS_MUTEX_HXX_
40 // #include <vos/mutex.hxx>
41 // #endif
42 // #ifndef _SV_SVAPP_HXX
43 // #include <vcl/svapp.hxx>
44 // #endif
46 // for ressource strings STR_UNDO and STR_REDO
47 #include <sfx2/sfx.hrc>
49 #include "ResId.hxx"
51 using namespace ::com::sun::star;
53 using ::com::sun::star::uno::Reference;
54 using ::com::sun::star::uno::Sequence;
55 using ::rtl::OUString;
57 namespace chart
60 StatusBarCommandDispatch::StatusBarCommandDispatch(
61 const Reference< uno::XComponentContext > & xContext,
62 const Reference< frame::XModel > & xModel,
63 const Reference< view::XSelectionSupplier > & xSelSupp ) :
64 impl::StatusBarCommandDispatch_Base( xContext ),
65 m_xModifiable( xModel, uno::UNO_QUERY ),
66 m_xSelectionSupplier( xSelSupp ),
67 m_bIsModified( false )
70 StatusBarCommandDispatch::~StatusBarCommandDispatch()
73 void StatusBarCommandDispatch::initialize()
75 if( m_xModifiable.is())
77 Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xModifiable, uno::UNO_QUERY );
78 OSL_ASSERT( xModifyBroadcaster.is());
79 if( xModifyBroadcaster.is())
80 xModifyBroadcaster->addModifyListener( this );
83 if( m_xSelectionSupplier.is())
85 m_xSelectionSupplier->addSelectionChangeListener( this );
89 void StatusBarCommandDispatch::fireStatusEvent(
90 const OUString & rURL,
91 const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ )
93 bool bFireAll(rURL.getLength() == 0);
94 bool bFireContext( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Context")));
95 bool bFireModified( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:ModifiedStatus")));
97 if( bFireContext )
99 uno::Any aArg;
100 Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY );
101 aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedCID, xDoc );
102 fireStatusEventForURL( C2U(".uno:Context"), aArg, true, xSingleListener );
104 if( bFireModified )
106 uno::Any aArg;
107 if( m_bIsModified )
108 aArg <<= C2U("*");
109 fireStatusEventForURL( C2U(".uno:ModifiedStatus"), aArg, true, xSingleListener );
113 // ____ XDispatch ____
114 void SAL_CALL StatusBarCommandDispatch::dispatch(
115 const util::URL& /* URL */,
116 const Sequence< beans::PropertyValue >& /* Arguments */ )
117 throw (uno::RuntimeException)
119 // nothing to do here
122 // ____ WeakComponentImplHelperBase ____
123 /// is called when this is disposed
124 void SAL_CALL StatusBarCommandDispatch::disposing()
126 m_xModifiable.clear();
127 m_xSelectionSupplier.clear();
130 // ____ XEventListener (base of XModifyListener) ____
131 void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ )
132 throw (uno::RuntimeException)
134 m_xModifiable.clear();
135 m_xSelectionSupplier.clear();
138 // ____ XModifyListener ____
139 void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent )
140 throw (uno::RuntimeException)
142 if( m_xModifiable.is())
143 m_bIsModified = m_xModifiable->isModified();
145 CommandDispatch::modified( aEvent );
148 // ____ XSelectionChangeListener ____
149 void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ )
150 throw (uno::RuntimeException)
152 if( m_xSelectionSupplier.is())
153 m_xSelectionSupplier->getSelection() >>= m_aSelectedCID;
154 else
155 m_aSelectedCID = OUString();
156 fireAllStatusEvents( 0 );
159 } // namespace chart