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/XSelectionSupplier.hpp>
24 #include <cppuhelper/implbase.hxx>
25 #include <rtl/ref.hxx>
32 class ChartController
;
33 class CommandDispatchContainer
;
38 struct ControllerState
;
40 // #i63017# : need to implement the XSelectionChangeListener in order
41 // to update the ControllerState when the selection changes.
42 typedef ::cppu::ImplInheritanceHelper
<
44 css::view::XSelectionChangeListener
>
45 ControllerCommandDispatch_Base
;
48 /** This class is a CommandDispatch that is responsible for all commands that
49 the ChartController supports.
51 This class determines which commands are currently available (via the model
52 state) and if an available command is called forwards it to the
55 class ControllerCommandDispatch
: public impl::ControllerCommandDispatch_Base
58 explicit ControllerCommandDispatch(
59 const css::uno::Reference
< css::uno::XComponentContext
> & xContext
,
60 ChartController
* pController
, CommandDispatchContainer
* pContainer
);
61 virtual ~ControllerCommandDispatch() override
;
63 // late initialisation, especially for adding as listener
64 virtual void initialize() override
;
67 // ____ XDispatch ____
68 virtual void SAL_CALL
dispatch(
69 const css::util::URL
& URL
,
70 const css::uno::Sequence
< css::beans::PropertyValue
>& Arguments
) override
;
72 // ____ WeakComponentImplHelperBase ____
73 /// is called when this is disposed
74 virtual void SAL_CALL
disposing() override
;
76 // ____ XEventListener (base of XModifyListener) ____
77 virtual void SAL_CALL
disposing(
78 const css::lang::EventObject
& Source
) override
;
80 virtual void fireStatusEvent(
81 const OUString
& rURL
,
82 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
) override
;
84 // ____ XModifyListener ____
85 virtual void SAL_CALL
modified(
86 const css::lang::EventObject
& aEvent
) override
;
88 // ____ XSelectionChangeListener ____
89 virtual void SAL_CALL
selectionChanged(
90 const css::lang::EventObject
& aEvent
) override
;
93 void fireStatusEventForURLImpl(
94 const OUString
& rURL
,
95 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
);
97 bool commandAvailable( const OUString
& rCommand
);
98 void updateCommandAvailability();
100 bool isShapeControllerCommandAvailable( const OUString
& rCommand
);
102 rtl::Reference
<ChartController
> m_xChartController
;
103 css::uno::Reference
< css::view::XSelectionSupplier
> m_xSelectionSupplier
;
104 css::uno::Reference
< css::frame::XDispatch
> m_xDispatch
;
106 std::unique_ptr
< impl::ModelState
> m_apModelState
;
107 std::unique_ptr
< impl::ControllerState
> m_apControllerState
;
109 mutable std::map
< OUString
, bool > m_aCommandAvailability
;
110 mutable std::map
< OUString
, css::uno::Any
> m_aCommandArguments
;
112 CommandDispatchContainer
* m_pDispatchContainer
;
117 // INCLUDED_CHART2_SOURCE_CONTROLLER_MAIN_CONTROLLERCOMMANDDISPATCH_HXX
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */