LibreOffice Module chart2 (master) 1
ControllerCommandDispatch.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19#pragma once
20
21#include "CommandDispatch.hxx"
22#include <com/sun/star/view/XSelectionChangeListener.hpp>
24#include <rtl/ref.hxx>
25
26#include <memory>
27
28namespace com::sun::star::view { class XSelectionSupplier; }
29
30namespace chart
31{
32
33class ChartController;
34class CommandDispatchContainer;
35
36namespace impl
37{
38struct ModelState;
39struct ControllerState;
40
41// #i63017# : need to implement the XSelectionChangeListener in order
42// to update the ControllerState when the selection changes.
43typedef ::cppu::ImplInheritanceHelper<
44 CommandDispatch,
45 css::view::XSelectionChangeListener >
47}
48
57{
58public:
60 const css::uno::Reference< css::uno::XComponentContext > & xContext,
61 ChartController* pController, CommandDispatchContainer* pContainer );
62 virtual ~ControllerCommandDispatch() override;
63
64 // late initialisation, especially for adding as listener
65 virtual void initialize() override;
66
67 bool commandAvailable( const OUString & rCommand );
68
69protected:
70 // ____ XDispatch ____
71 virtual void SAL_CALL dispatch(
72 const css::util::URL& URL,
73 const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) override;
74
75 // ____ WeakComponentImplHelperBase ____
77 virtual void disposing(std::unique_lock<std::mutex>& rGuard) override;
78
79 // ____ XEventListener (base of XModifyListener) ____
80 virtual void SAL_CALL disposing(
81 const css::lang::EventObject& Source ) override;
82
83 virtual void fireStatusEvent(
84 const OUString & rURL,
85 const css::uno::Reference< css::frame::XStatusListener > & xSingleListener ) override;
86
87 // ____ XModifyListener ____
88 virtual void SAL_CALL modified(
89 const css::lang::EventObject& aEvent ) override;
90
91 // ____ XSelectionChangeListener ____
92 virtual void SAL_CALL selectionChanged(
93 const css::lang::EventObject& aEvent ) override;
94
95private:
97 const OUString & rURL,
98 const css::uno::Reference< css::frame::XStatusListener > & xSingleListener );
99
101
102 bool isShapeControllerCommandAvailable( const OUString& rCommand );
103
105 css::uno::Reference< css::view::XSelectionSupplier > m_xSelectionSupplier;
106 css::uno::Reference< css::frame::XDispatch > m_xDispatch;
107
108 std::unique_ptr< impl::ModelState > m_apModelState;
109 std::unique_ptr< impl::ControllerState > m_apControllerState;
110
111 mutable std::map< OUString, bool > m_aCommandAvailability;
112 mutable std::map< OUString, css::uno::Any > m_aCommandArguments;
113
115};
116
117} // namespace chart
118
119/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This class is a CommandDispatch that is responsible for all commands that the ChartController support...
bool commandAvailable(const OUString &rCommand)
bool isShapeControllerCommandAvailable(const OUString &rCommand)
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
virtual void fireStatusEvent(const OUString &rURL, const css::uno::Reference< css::frame::XStatusListener > &xSingleListener) override
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &aEvent) override
ControllerCommandDispatch(const css::uno::Reference< css::uno::XComponentContext > &xContext, ChartController *pController, CommandDispatchContainer *pContainer)
std::map< OUString, bool > m_aCommandAvailability
CommandDispatchContainer * m_pDispatchContainer
std::unique_ptr< impl::ControllerState > m_apControllerState
css::uno::Reference< css::view::XSelectionSupplier > m_xSelectionSupplier
std::unique_ptr< impl::ModelState > m_apModelState
rtl::Reference< ChartController > m_xChartController
virtual void SAL_CALL dispatch(const css::util::URL &URL, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
css::uno::Reference< css::frame::XDispatch > m_xDispatch
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void disposing(std::unique_lock< std::mutex > &rGuard) override
is called when this is disposed
void fireStatusEventForURLImpl(const OUString &rURL, const css::uno::Reference< css::frame::XStatusListener > &xSingleListener)
std::map< OUString, css::uno::Any > m_aCommandArguments
::cppu::ImplInheritanceHelper< CommandDispatch, css::view::XSelectionChangeListener > ControllerCommandDispatch_Base