LibreOffice Module chart2 (master) 1
FeatureCommandDispatchBase.cxx
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
21
22using namespace ::com::sun::star;
23
24using ::com::sun::star::uno::Reference;
25using ::com::sun::star::uno::Sequence;
26
27namespace chart
28{
29
31 :CommandDispatch( rxContext )
32 ,m_nFeatureId( ChartCommandID::NONE )
33{
34}
35
37{
38}
39
41{
44}
45
46bool FeatureCommandDispatchBase::isFeatureSupported( const OUString& rCommandURL )
47{
48 SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommandURL );
49 return aIter != m_aSupportedFeatures.end();
50}
51
53 const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ )
54{
55 if ( rURL.isEmpty() )
56 {
57 for (auto const& elem : m_aSupportedFeatures)
58 {
59 FeatureState aFeatureState( getState(elem.first) );
60 fireStatusEventForURL( elem.first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
61 }
62 }
63 else
64 {
65 FeatureState aFeatureState( getState( rURL ) );
66 fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
67 }
68}
69
70// XDispatch
71void FeatureCommandDispatchBase::dispatch( const util::URL& URL,
72 const Sequence< beans::PropertyValue >& Arguments )
73{
74 OUString aCommand( URL.Complete );
75 if ( getState( aCommand ).bEnabled )
76 {
77 execute( aCommand, Arguments );
78 }
79}
80
82 ChartCommandID nId, sal_Int16 nGroup )
83{
84 ControllerFeature aFeature;
85 aFeature.Command = OUString::createFromAscii( pAsciiCommandURL );
86 aFeature.nFeatureId = nId;
87 aFeature.GroupId = nGroup;
88
89 m_aSupportedFeatures[ aFeature.Command ] = aFeature;
90}
91
92} // namespace chart
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This is the base class for an XDispatch.
void fireStatusEventForURL(const OUString &rURL, const css::uno::Any &rState, bool bEnabled, const css::uno::Reference< css::frame::XStatusListener > &xSingleListener)
sends a status event for a specific command to all registered listeners or only the one given when se...
virtual void fireStatusEvent(const OUString &rURL, const css::uno::Reference< css::frame::XStatusListener > &xSingleListener) override
sends a status event for a specific command to all registered listeners or only the one given when se...
virtual void describeSupportedFeatures()=0
void implDescribeSupportedFeature(const char *pAsciiCommandURL, ChartCommandID nId, sal_Int16 nGroup)
describes a feature supported by the controller
virtual void SAL_CALL dispatch(const css::util::URL &URL, const css::uno::Sequence< css::beans::PropertyValue > &Arguments) override
virtual FeatureState getState(const OUString &rCommand)=0
virtual void execute(const OUString &rCommand, const css::uno::Sequence< css::beans::PropertyValue > &rArgs)=0
virtual bool isFeatureSupported(const OUString &rCommandURL)
FeatureCommandDispatchBase(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
NONE
sal_Int16 nId
OUString aCommand