tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / chart2 / source / controller / main / FeatureCommandDispatchBase.cxx
blobb1c5f72d1d5b25c40777b35a107694185704fa23
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include "FeatureCommandDispatchBase.hxx"
22 using namespace ::com::sun::star;
24 using ::com::sun::star::uno::Reference;
25 using ::com::sun::star::uno::Sequence;
27 namespace chart
30 FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext )
31 :CommandDispatch( rxContext )
32 ,m_nFeatureId( ChartCommandID::NONE )
36 FeatureCommandDispatchBase::~FeatureCommandDispatchBase()
40 void FeatureCommandDispatchBase::initialize()
42 CommandDispatch::initialize();
43 describeSupportedFeatures();
46 bool FeatureCommandDispatchBase::isFeatureSupported( const OUString& rCommandURL )
48 SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommandURL );
49 return aIter != m_aSupportedFeatures.end();
52 void FeatureCommandDispatchBase::fireStatusEvent( const OUString& rURL,
53 const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ )
55 if ( rURL.isEmpty() )
57 for (auto const& elem : m_aSupportedFeatures)
59 FeatureState aFeatureState( getState(elem.first) );
60 fireStatusEventForURL( elem.first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
63 else
65 FeatureState aFeatureState( getState( rURL ) );
66 fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
70 // XDispatch
71 void FeatureCommandDispatchBase::dispatch( const util::URL& URL,
72 const Sequence< beans::PropertyValue >& Arguments )
74 OUString aCommand( URL.Complete );
75 if ( getState( aCommand ).bEnabled )
77 execute( aCommand, Arguments );
81 void FeatureCommandDispatchBase::implDescribeSupportedFeature( const char* pAsciiCommandURL,
82 ChartCommandID nId, sal_Int16 nGroup )
84 ControllerFeature aFeature;
85 aFeature.Command = OUString::createFromAscii( pAsciiCommandURL );
86 aFeature.nFeatureId = nId;
87 aFeature.GroupId = nGroup;
89 m_aSupportedFeatures[ aFeature.Command ] = aFeature;
92 } // namespace chart
94 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */