1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
19 #ifndef INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_CONTROLLERCOMMANDDISPATCH_HXX
20 #define INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_CONTROLLERCOMMANDDISPATCH_HXX
22 #include "CommandDispatch.hxx"
23 #include <com/sun/star/view/XSelectionChangeListener.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <rtl/ref.hxx>
29 namespace com
{ namespace sun
{ namespace star
{ namespace view
{ class XSelectionSupplier
; } } } }
34 class ChartController
;
35 class CommandDispatchContainer
;
40 struct ControllerState
;
42 // #i63017# : need to implement the XSelectionChangeListener in order
43 // to update the ControllerState when the selection changes.
44 typedef ::cppu::ImplInheritanceHelper
<
46 css::view::XSelectionChangeListener
>
47 ControllerCommandDispatch_Base
;
50 /** This class is a CommandDispatch that is responsible for all commands that
51 the ChartController supports.
53 This class determines which commands are currently available (via the model
54 state) and if an available command is called forwards it to the
57 class ControllerCommandDispatch
: public impl::ControllerCommandDispatch_Base
60 explicit ControllerCommandDispatch(
61 const css::uno::Reference
< css::uno::XComponentContext
> & xContext
,
62 ChartController
* pController
, CommandDispatchContainer
* pContainer
);
63 virtual ~ControllerCommandDispatch() override
;
65 // late initialisation, especially for adding as listener
66 virtual void initialize() override
;
69 // ____ XDispatch ____
70 virtual void SAL_CALL
dispatch(
71 const css::util::URL
& URL
,
72 const css::uno::Sequence
< css::beans::PropertyValue
>& Arguments
) override
;
74 // ____ WeakComponentImplHelperBase ____
75 /// is called when this is disposed
76 virtual void SAL_CALL
disposing() override
;
78 // ____ XEventListener (base of XModifyListener) ____
79 virtual void SAL_CALL
disposing(
80 const css::lang::EventObject
& Source
) override
;
82 virtual void fireStatusEvent(
83 const OUString
& rURL
,
84 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
) override
;
86 // ____ XModifyListener ____
87 virtual void SAL_CALL
modified(
88 const css::lang::EventObject
& aEvent
) override
;
90 // ____ XSelectionChangeListener ____
91 virtual void SAL_CALL
selectionChanged(
92 const css::lang::EventObject
& aEvent
) override
;
95 void fireStatusEventForURLImpl(
96 const OUString
& rURL
,
97 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
);
99 bool commandAvailable( const OUString
& rCommand
);
100 void updateCommandAvailability();
102 bool isShapeControllerCommandAvailable( const OUString
& rCommand
);
104 rtl::Reference
<ChartController
> m_xChartController
;
105 css::uno::Reference
< css::view::XSelectionSupplier
> m_xSelectionSupplier
;
106 css::uno::Reference
< css::frame::XDispatch
> m_xDispatch
;
108 std::unique_ptr
< impl::ModelState
> m_apModelState
;
109 std::unique_ptr
< impl::ControllerState
> m_apControllerState
;
111 mutable std::map
< OUString
, bool > m_aCommandAvailability
;
112 mutable std::map
< OUString
, css::uno::Any
> m_aCommandArguments
;
114 CommandDispatchContainer
* m_pDispatchContainer
;
119 // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_CONTROLLERCOMMANDDISPATCH_HXX
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */