merged tag ooo/OOO330_m14
[LibreOffice.git] / chart2 / source / controller / main / FeatureCommandDispatchBase.cxx
blob39b4e1d4a171b9594e618ab1d5b77db9e8f9d467
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "FeatureCommandDispatchBase.hxx"
33 using namespace ::com::sun::star;
35 using ::com::sun::star::uno::Reference;
36 using ::com::sun::star::uno::Sequence;
38 namespace chart
41 FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext )
42 :CommandDispatch( rxContext )
43 ,m_nFeatureId( 0 )
47 FeatureCommandDispatchBase::~FeatureCommandDispatchBase()
51 void FeatureCommandDispatchBase::initialize()
53 CommandDispatch::initialize();
54 fillSupportedFeatures();
57 bool FeatureCommandDispatchBase::isFeatureSupported( const ::rtl::OUString& rCommandURL )
59 SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommandURL );
60 if ( aIter != m_aSupportedFeatures.end() )
62 return true;
64 return false;
67 void FeatureCommandDispatchBase::fireStatusEvent( const ::rtl::OUString& rURL,
68 const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ )
70 if ( rURL.getLength() == 0 )
72 SupportedFeatures::const_iterator aEnd( m_aSupportedFeatures.end() );
73 for ( SupportedFeatures::const_iterator aIter( m_aSupportedFeatures.begin() ); aIter != aEnd; ++aIter )
75 FeatureState aFeatureState( getState( aIter->first ) );
76 fireStatusEventForURL( aIter->first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
79 else
81 FeatureState aFeatureState( getState( rURL ) );
82 fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
86 // XDispatch
87 void FeatureCommandDispatchBase::dispatch( const util::URL& URL,
88 const Sequence< beans::PropertyValue >& Arguments )
89 throw (uno::RuntimeException)
91 ::rtl::OUString aCommand( URL.Complete );
92 if ( getState( aCommand ).bEnabled )
94 execute( aCommand, Arguments );
98 void FeatureCommandDispatchBase::implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL,
99 sal_uInt16 nId, sal_Int16 nGroup )
101 ControllerFeature aFeature;
102 aFeature.Command = ::rtl::OUString::createFromAscii( pAsciiCommandURL );
103 aFeature.nFeatureId = nId;
104 aFeature.GroupId = nGroup;
106 m_aSupportedFeatures[ aFeature.Command ] = aFeature;
109 void FeatureCommandDispatchBase::fillSupportedFeatures()
111 describeSupportedFeatures();
114 } // namespace chart