Update ooo320-m1
[ooovba.git] / chart2 / source / controller / main / ControllerCommandDispatch.hxx
blob6976960a0aae14a30a20585407fabb1feddd0aee
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: ControllerCommandDispatch.hxx,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 ************************************************************************/
30 #ifndef CHART2_CONTROLLERCOMMANDDISPATCH_HXX
31 #define CHART2_CONTROLLERCOMMANDDISPATCH_HXX
33 #include "CommandDispatch.hxx"
34 #include <com/sun/star/frame/XModel.hpp>
35 #include <com/sun/star/frame/XController.hpp>
36 #include <com/sun/star/view/XSelectionSupplier.hpp>
37 #include <cppuhelper/implbase1.hxx>
39 #include <memory>
41 namespace chart
44 namespace impl
46 struct ModelState;
47 struct ControllerState;
49 // #i63017# : need to implement the XSelectionChangeListener in order
50 // to update the ControllerState when the selection changes.
51 typedef ::cppu::ImplInheritanceHelper1<
52 CommandDispatch,
53 ::com::sun::star::view::XSelectionChangeListener >
54 ControllerCommandDispatch_Base;
57 /** This class is a CommandDispatch that is responsible for all commands that
58 the ChartController supports.
60 This class determines which commands are currently available (via the model
61 state) and if an available command is called forwards it to the
62 ChartController.
64 class ControllerCommandDispatch : public impl::ControllerCommandDispatch_Base
66 public:
67 explicit ControllerCommandDispatch(
68 const ::com::sun::star::uno::Reference<
69 ::com::sun::star::uno::XComponentContext > & xContext,
70 const ::com::sun::star::uno::Reference<
71 ::com::sun::star::frame::XController > & xController );
72 virtual ~ControllerCommandDispatch();
74 // late initialisation, especially for adding as listener
75 virtual void initialize();
77 protected:
78 // ____ XDispatch ____
79 virtual void SAL_CALL dispatch(
80 const ::com::sun::star::util::URL& URL,
81 const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments )
82 throw (::com::sun::star::uno::RuntimeException);
84 // ____ WeakComponentImplHelperBase ____
85 /// is called when this is disposed
86 virtual void SAL_CALL disposing();
88 // ____ XEventListener (base of XModifyListener) ____
89 virtual void SAL_CALL disposing(
90 const ::com::sun::star::lang::EventObject& Source )
91 throw (::com::sun::star::uno::RuntimeException);
93 virtual void fireStatusEvent(
94 const ::rtl::OUString & rURL,
95 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener );
97 // ____ XModifyListener ____
98 virtual void SAL_CALL modified(
99 const ::com::sun::star::lang::EventObject& aEvent )
100 throw (::com::sun::star::uno::RuntimeException);
102 // ____ XSelectionChangeListener ____
103 virtual void SAL_CALL selectionChanged(
104 const ::com::sun::star::lang::EventObject& aEvent )
105 throw (::com::sun::star::uno::RuntimeException);
107 private:
108 void fireStatusEventForURLImpl(
109 const ::rtl::OUString & rURL,
110 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener );
112 bool commandAvailable( const ::rtl::OUString & rCommand );
113 void updateCommandAvailability();
115 ::com::sun::star::uno::Reference<
116 ::com::sun::star::frame::XController > m_xController;
117 ::com::sun::star::uno::Reference<
118 ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier;
119 ::com::sun::star::uno::Reference<
120 ::com::sun::star::frame::XDispatch > m_xDispatch;
122 ::std::auto_ptr< impl::ModelState > m_apModelState;
123 ::std::auto_ptr< impl::ControllerState > m_apControllerState;
125 mutable ::std::map< ::rtl::OUString, bool > m_aCommandAvailability;
126 mutable ::std::map< ::rtl::OUString, ::com::sun::star::uno::Any > m_aCommandArguments;
129 } // namespace chart
131 // CHART2_CONTROLLERCOMMANDDISPATCH_HXX
132 #endif