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 .
21 #include "CommandDispatch.hxx"
22 #include <com/sun/star/view/XSelectionChangeListener.hpp>
23 #include <cppuhelper/implbase.hxx>
24 #include <rtl/ref.hxx>
28 namespace com::sun::star::view
{ class XSelectionSupplier
; }
33 class ChartController
;
34 class CommandDispatchContainer
;
39 struct ControllerState
;
41 // #i63017# : need to implement the XSelectionChangeListener in order
42 // to update the ControllerState when the selection changes.
43 typedef ::cppu::ImplInheritanceHelper
<
45 css::view::XSelectionChangeListener
>
46 ControllerCommandDispatch_Base
;
49 /** This class is a CommandDispatch that is responsible for all commands that
50 the ChartController supports.
52 This class determines which commands are currently available (via the model
53 state) and if an available command is called forwards it to the
56 class ControllerCommandDispatch
: public impl::ControllerCommandDispatch_Base
59 explicit ControllerCommandDispatch(
60 const css::uno::Reference
< css::uno::XComponentContext
> & xContext
,
61 ChartController
* pController
, CommandDispatchContainer
* pContainer
);
62 virtual ~ControllerCommandDispatch() override
;
64 // late initialisation, especially for adding as listener
65 virtual void initialize() override
;
67 bool commandAvailable( const OUString
& rCommand
);
70 // ____ XDispatch ____
71 virtual void SAL_CALL
dispatch(
72 const css::util::URL
& URL
,
73 const css::uno::Sequence
< css::beans::PropertyValue
>& Arguments
) override
;
75 // ____ WeakComponentImplHelperBase ____
76 /// is called when this is disposed
77 virtual void disposing(std::unique_lock
<std::mutex
>& rGuard
) override
;
79 // ____ XEventListener (base of XModifyListener) ____
80 virtual void SAL_CALL
disposing(
81 const css::lang::EventObject
& Source
) override
;
83 virtual void fireStatusEvent(
84 const OUString
& rURL
,
85 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
) override
;
87 // ____ XModifyListener ____
88 virtual void SAL_CALL
modified(
89 const css::lang::EventObject
& aEvent
) override
;
91 // ____ XSelectionChangeListener ____
92 virtual void SAL_CALL
selectionChanged(
93 const css::lang::EventObject
& aEvent
) override
;
96 void fireStatusEventForURLImpl(
97 const OUString
& rURL
,
98 const css::uno::Reference
< css::frame::XStatusListener
> & xSingleListener
);
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 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */