| 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 |
:CommandDispatch( rxContext ) |
| 32 |
,m_nFeatureId( ChartCommandID::NONE ) |
| 33 |
{ |
| 34 |
} |
| 35 |
|
| 36 |
FeatureCommandDispatchBase::~FeatureCommandDispatchBase() |
| 37 |
{ |
| 38 |
} |
| 39 |
|
| 40 |
void FeatureCommandDispatchBase::initialize() |
| 41 |
{ |
| 42 |
CommandDispatch::initialize(); |
| 43 |
describeSupportedFeatures(); |
| 44 |
} |
| 45 |
|
| 46 |
bool FeatureCommandDispatchBase::isFeatureSupported( const OUString& rCommandURL ) |
| 47 |
{ |
| 48 |
return m_aSupportedFeatures.contains(rCommandURL); |
| 49 |
} |
| 50 |
|
| 51 |
void FeatureCommandDispatchBase::fireStatusEvent( const OUString& rURL, |
| 52 |
const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ ) |
| 53 |
{ |
| 54 |
if ( rURL.isEmpty() ) |
| 55 |
{ |
| 56 |
for (auto const& elem : m_aSupportedFeatures) |
| 57 |
{ |
| 58 |
FeatureState aFeatureState( getState(elem.first) ); |
| 59 |
fireStatusEventForURL( elem.first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); |
| 60 |
} |
| 61 |
} |
| 62 |
else |
| 63 |
{ |
| 64 |
FeatureState aFeatureState( getState( rURL ) ); |
| 65 |
fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener ); |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
// XDispatch |
| 70 |
void FeatureCommandDispatchBase::dispatch( const util::URL& URL, |
| 71 |
const Sequence< beans::PropertyValue >& Arguments ) |
| 72 |
{ |
| 73 |
OUString aCommand( URL.Complete ); |
| 74 |
if ( getState( aCommand ).bEnabled ) |
| 75 |
{ |
| 76 |
execute( aCommand, Arguments ); |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
void FeatureCommandDispatchBase::implDescribeSupportedFeature( const OUString& sCommandURL, |
| 81 |
ChartCommandID nId, sal_Int16 nGroup ) |
| 82 |
{ |
| 83 |
m_aSupportedFeatures[sCommandURL] = { sCommandURL, nGroup, nId }; |
| 84 |
} |
| 85 |
|
| 86 |
} // namespace chart |
| 87 |
|
| 88 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |