/src/libreoffice/chart2/source/controller/main/FeatureCommandDispatchBase.hxx
Line | Count | Source |
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 <sal/config.h> |
22 | | |
23 | | #include <CommandDispatch.hxx> |
24 | | |
25 | | #include <com/sun/star/frame/DispatchInformation.hpp> |
26 | | |
27 | | enum class ChartCommandID |
28 | | { |
29 | | NONE = 0, |
30 | | |
31 | | //Draw Command Ids: |
32 | | DrawObjectSelect = 1, |
33 | | DrawLine = 2, |
34 | | DrawLineArrowEnd = 3, |
35 | | DrawRect = 4, |
36 | | DrawEllipse = 5, |
37 | | DrawFreelineNoFill = 6, |
38 | | DrawText = 7, |
39 | | DrawTextVertical = 8, |
40 | | DrawCaption = 9, |
41 | | DrawCaptionVertical = 10, |
42 | | DrawToolboxCsBasic = 11, |
43 | | DrawToolboxCsSymbol = 12, |
44 | | DrawToolboxCsArrow = 13, |
45 | | DrawToolboxCsFlowchart = 14, |
46 | | DrawToolboxCsCallout = 15, |
47 | | DrawToolboxCsStar = 16, |
48 | | |
49 | | //Shape Controller Command Ids: |
50 | | ShapeFormatLine = 21, |
51 | | ShapeFormatArea = 22, |
52 | | ShapeTextAttributes = 23, |
53 | | ShapeTransformDialog = 24, |
54 | | ShapeObjectTitleDescription = 25, |
55 | | ShapeRenameObject = 26, |
56 | | ShapeBringToFront = 28, |
57 | | ShapeForward = 29, |
58 | | ShapeBackward = 30, |
59 | | ShapeSendToBack = 31, |
60 | | ShapeFontDialog = 35, |
61 | | ShapeParagraphDialog = 36 |
62 | | }; |
63 | | |
64 | | |
65 | | namespace chart |
66 | | { |
67 | | |
68 | | struct ControllerFeature: public css::frame::DispatchInformation |
69 | | { |
70 | | ChartCommandID nFeatureId; |
71 | 0 | ControllerFeature() = default; |
72 | | ControllerFeature(const OUString& command, sal_Int16 groupId, ChartCommandID featureId) |
73 | 0 | : css::frame::DispatchInformation(command, groupId) |
74 | 0 | , nFeatureId(featureId) |
75 | 0 | { |
76 | 0 | } |
77 | | }; |
78 | | |
79 | | typedef std::map< OUString, |
80 | | ControllerFeature > SupportedFeatures; |
81 | | |
82 | | struct FeatureState |
83 | | { |
84 | | bool bEnabled; |
85 | | css::uno::Any aState; |
86 | | |
87 | 0 | FeatureState() : bEnabled( false ) { } |
88 | | }; |
89 | | |
90 | | /** This is a base class for CommandDispatch implementations with feature support. |
91 | | */ |
92 | | class FeatureCommandDispatchBase: public CommandDispatch |
93 | | { |
94 | | public: |
95 | | explicit FeatureCommandDispatchBase( const css::uno::Reference< css::uno::XComponentContext >& rxContext ); |
96 | | virtual ~FeatureCommandDispatchBase() override; |
97 | | |
98 | | // late initialisation, especially for adding as listener |
99 | | virtual void initialize() override; |
100 | | |
101 | | virtual bool isFeatureSupported( const OUString& rCommandURL ); |
102 | | |
103 | | protected: |
104 | | // XDispatch |
105 | | virtual void SAL_CALL dispatch( const css::util::URL& URL, |
106 | | const css::uno::Sequence< css::beans::PropertyValue >& Arguments ) override; |
107 | | |
108 | | virtual void fireStatusEvent( const OUString& rURL, |
109 | | const css::uno::Reference< css::frame::XStatusListener >& xSingleListener ) override; |
110 | | |
111 | | // state of a feature |
112 | | virtual FeatureState getState( const OUString& rCommand ) = 0; |
113 | | |
114 | | // execute a feature |
115 | | virtual void execute( const OUString& rCommand, const css::uno::Sequence< css::beans::PropertyValue>& rArgs ) = 0; |
116 | | |
117 | | // all the features which should be handled by this class |
118 | | virtual void describeSupportedFeatures() = 0; |
119 | | |
120 | | /** describes a feature supported by the controller |
121 | | |
122 | | Must not be called outside <member>describeSupportedFeatures</member>. |
123 | | |
124 | | @param sCommandURL |
125 | | the URL of the feature command |
126 | | @param nId |
127 | | the id of the feature. Later references to this feature usually happen by id, not by |
128 | | URL. |
129 | | @param nGroup |
130 | | the command group of the feature. This is important for configuring the controller UI |
131 | | by the user, see also <type scope="css::frame">CommandGroup</type>. |
132 | | */ |
133 | | void implDescribeSupportedFeature( const OUString& sCommandURL, ChartCommandID nId, |
134 | | sal_Int16 nGroup ); |
135 | | |
136 | | mutable SupportedFeatures m_aSupportedFeatures; |
137 | | |
138 | | ChartCommandID m_nFeatureId; |
139 | | }; |
140 | | |
141 | | } // namespace chart |
142 | | |
143 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |