1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
;
30 FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference
< uno::XComponentContext
>& rxContext
)
31 :CommandDispatch( rxContext
)
36 FeatureCommandDispatchBase::~FeatureCommandDispatchBase()
40 void FeatureCommandDispatchBase::initialize()
42 CommandDispatch::initialize();
43 fillSupportedFeatures();
46 bool FeatureCommandDispatchBase::isFeatureSupported( const OUString
& rCommandURL
)
48 SupportedFeatures::const_iterator aIter
= m_aSupportedFeatures
.find( rCommandURL
);
49 if ( aIter
!= m_aSupportedFeatures
.end() )
56 void FeatureCommandDispatchBase::fireStatusEvent( const OUString
& rURL
,
57 const Reference
< frame::XStatusListener
>& xSingleListener
/* = 0 */ )
61 SupportedFeatures::const_iterator
aEnd( m_aSupportedFeatures
.end() );
62 for ( SupportedFeatures::const_iterator
aIter( m_aSupportedFeatures
.begin() ); aIter
!= aEnd
; ++aIter
)
64 FeatureState
aFeatureState( getState( aIter
->first
) );
65 fireStatusEventForURL( aIter
->first
, aFeatureState
.aState
, aFeatureState
.bEnabled
, xSingleListener
);
70 FeatureState
aFeatureState( getState( rURL
) );
71 fireStatusEventForURL( rURL
, aFeatureState
.aState
, aFeatureState
.bEnabled
, xSingleListener
);
76 void FeatureCommandDispatchBase::dispatch( const util::URL
& URL
,
77 const Sequence
< beans::PropertyValue
>& Arguments
)
78 throw (uno::RuntimeException
, std::exception
)
80 OUString
aCommand( URL
.Complete
);
81 if ( getState( aCommand
).bEnabled
)
83 execute( aCommand
, Arguments
);
87 void FeatureCommandDispatchBase::implDescribeSupportedFeature( const sal_Char
* pAsciiCommandURL
,
88 sal_uInt16 nId
, sal_Int16 nGroup
)
90 ControllerFeature aFeature
;
91 aFeature
.Command
= OUString::createFromAscii( pAsciiCommandURL
);
92 aFeature
.nFeatureId
= nId
;
93 aFeature
.GroupId
= nGroup
;
95 m_aSupportedFeatures
[ aFeature
.Command
] = aFeature
;
98 void FeatureCommandDispatchBase::fillSupportedFeatures()
100 describeSupportedFeatures();
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */