Branch data Line data Source code
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 : :
21 : : #include "FeatureCommandDispatchBase.hxx"
22 : :
23 : : using namespace ::com::sun::star;
24 : :
25 : : using ::com::sun::star::uno::Reference;
26 : : using ::com::sun::star::uno::Sequence;
27 : :
28 : : namespace chart
29 : : {
30 : :
31 : 68 : FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext )
32 : : :CommandDispatch( rxContext )
33 [ + - ]: 68 : ,m_nFeatureId( 0 )
34 : : {
35 : 68 : }
36 : :
37 : 68 : FeatureCommandDispatchBase::~FeatureCommandDispatchBase()
38 : : {
39 [ - + ]: 68 : }
40 : :
41 : 68 : void FeatureCommandDispatchBase::initialize()
42 : : {
43 : 68 : CommandDispatch::initialize();
44 : 68 : fillSupportedFeatures();
45 : 68 : }
46 : :
47 : 204 : bool FeatureCommandDispatchBase::isFeatureSupported( const ::rtl::OUString& rCommandURL )
48 : : {
49 [ + - ]: 204 : SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommandURL );
50 [ - + ]: 204 : if ( aIter != m_aSupportedFeatures.end() )
51 : : {
52 : 0 : return true;
53 : : }
54 : 204 : return false;
55 : : }
56 : :
57 : 476 : void FeatureCommandDispatchBase::fireStatusEvent( const ::rtl::OUString& rURL,
58 : : const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ )
59 : : {
60 [ - + ]: 476 : if ( rURL.isEmpty() )
61 : : {
62 : 0 : SupportedFeatures::const_iterator aEnd( m_aSupportedFeatures.end() );
63 [ # # ]: 0 : for ( SupportedFeatures::const_iterator aIter( m_aSupportedFeatures.begin() ); aIter != aEnd; ++aIter )
64 : : {
65 [ # # ]: 0 : FeatureState aFeatureState( getState( aIter->first ) );
66 [ # # ]: 0 : fireStatusEventForURL( aIter->first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
67 : 0 : }
68 : : }
69 : : else
70 : : {
71 [ + - ]: 476 : FeatureState aFeatureState( getState( rURL ) );
72 [ + - ]: 476 : fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
73 : : }
74 : 476 : }
75 : :
76 : : // XDispatch
77 : 0 : void FeatureCommandDispatchBase::dispatch( const util::URL& URL,
78 : : const Sequence< beans::PropertyValue >& Arguments )
79 : : throw (uno::RuntimeException)
80 : : {
81 : 0 : ::rtl::OUString aCommand( URL.Complete );
82 [ # # ][ # # ]: 0 : if ( getState( aCommand ).bEnabled )
83 : : {
84 [ # # ]: 0 : execute( aCommand, Arguments );
85 : 0 : }
86 : 0 : }
87 : :
88 : 884 : void FeatureCommandDispatchBase::implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL,
89 : : sal_uInt16 nId, sal_Int16 nGroup )
90 : : {
91 : 884 : ControllerFeature aFeature;
92 : 884 : aFeature.Command = ::rtl::OUString::createFromAscii( pAsciiCommandURL );
93 : 884 : aFeature.nFeatureId = nId;
94 : 884 : aFeature.GroupId = nGroup;
95 : :
96 [ + - ]: 884 : m_aSupportedFeatures[ aFeature.Command ] = aFeature;
97 : 884 : }
98 : :
99 : 68 : void FeatureCommandDispatchBase::fillSupportedFeatures()
100 : : {
101 : 68 : describeSupportedFeatures();
102 : 68 : }
103 : :
104 : : } // namespace chart
105 : :
106 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|