/src/libreoffice/chart2/source/controller/main/FeatureCommandDispatchBase.cxx
Line | Count | Source (jump to first uncovered line) |
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 | | |
20 | | #include "FeatureCommandDispatchBase.hxx" |
21 | | |
22 | | using namespace ::com::sun::star; |
23 | | |
24 | | using ::com::sun::star::uno::Reference; |
25 | | using ::com::sun::star::uno::Sequence; |
26 | | |
27 | | namespace chart |
28 | | { |
29 | | |
30 | | FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext ) |
31 | 0 | :CommandDispatch( rxContext ) |
32 | 0 | ,m_nFeatureId( ChartCommandID::NONE ) |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | FeatureCommandDispatchBase::~FeatureCommandDispatchBase() |
37 | 0 | { |
38 | 0 | } |
39 | | |
40 | | void FeatureCommandDispatchBase::initialize() |
41 | 0 | { |
42 | 0 | CommandDispatch::initialize(); |
43 | 0 | describeSupportedFeatures(); |
44 | 0 | } |
45 | | |
46 | | bool FeatureCommandDispatchBase::isFeatureSupported( const OUString& rCommandURL ) |
47 | 0 | { |
48 | 0 | return m_aSupportedFeatures.contains(rCommandURL); |
49 | 0 | } |
50 | | |
51 | | void FeatureCommandDispatchBase::fireStatusEvent( const OUString& rURL, |
52 | | const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ ) |
53 | 0 | { |
54 | 0 | if ( rURL.isEmpty() ) |
55 | 0 | { |
56 | 0 | for (auto const& elem : m_aSupportedFeatures) |
57 | 0 | { |
58 | 0 | FeatureState aFeatureState( getState(elem.first) ); |
59 | 0 | fireStatusEventForURL( elem.first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); |
60 | 0 | } |
61 | 0 | } |
62 | 0 | else |
63 | 0 | { |
64 | 0 | FeatureState aFeatureState( getState( rURL ) ); |
65 | 0 | fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); |
66 | 0 | } |
67 | 0 | } |
68 | | |
69 | | // XDispatch |
70 | | void FeatureCommandDispatchBase::dispatch( const util::URL& URL, |
71 | | const Sequence< beans::PropertyValue >& Arguments ) |
72 | 0 | { |
73 | 0 | OUString aCommand( URL.Complete ); |
74 | 0 | if ( getState( aCommand ).bEnabled ) |
75 | 0 | { |
76 | 0 | execute( aCommand, Arguments ); |
77 | 0 | } |
78 | 0 | } |
79 | | |
80 | | void FeatureCommandDispatchBase::implDescribeSupportedFeature( const OUString& sCommandURL, |
81 | | ChartCommandID nId, sal_Int16 nGroup ) |
82 | 0 | { |
83 | 0 | m_aSupportedFeatures[sCommandURL] = { sCommandURL, nGroup, nId }; |
84 | 0 | } |
85 | | |
86 | | } // namespace chart |
87 | | |
88 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |