2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-17 12:30:48 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2009-05-29 09:10:08 +00:00
|
|
|
|
|
|
|
#include "FeatureCommandDispatchBase.hxx"
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::uno::Sequence;
|
|
|
|
|
|
|
|
namespace chart
|
|
|
|
{
|
|
|
|
|
|
|
|
FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext )
|
|
|
|
:CommandDispatch( rxContext )
|
2009-10-02 16:06:50 +00:00
|
|
|
,m_nFeatureId( 0 )
|
2009-05-29 09:10:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FeatureCommandDispatchBase::~FeatureCommandDispatchBase()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void FeatureCommandDispatchBase::initialize()
|
|
|
|
{
|
|
|
|
CommandDispatch::initialize();
|
2016-10-18 11:55:32 +02:00
|
|
|
describeSupportedFeatures();
|
2009-05-29 09:10:08 +00:00
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
bool FeatureCommandDispatchBase::isFeatureSupported( const OUString& rCommandURL )
|
2009-05-29 09:10:08 +00:00
|
|
|
{
|
2009-10-21 12:52:00 +00:00
|
|
|
SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommandURL );
|
2009-05-29 09:10:08 +00:00
|
|
|
if ( aIter != m_aSupportedFeatures.end() )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
void FeatureCommandDispatchBase::fireStatusEvent( const OUString& rURL,
|
2009-05-29 09:10:08 +00:00
|
|
|
const Reference< frame::XStatusListener >& xSingleListener /* = 0 */ )
|
|
|
|
{
|
2011-12-10 22:03:11 -02:00
|
|
|
if ( rURL.isEmpty() )
|
2009-05-29 09:10:08 +00:00
|
|
|
{
|
|
|
|
SupportedFeatures::const_iterator aEnd( m_aSupportedFeatures.end() );
|
|
|
|
for ( SupportedFeatures::const_iterator aIter( m_aSupportedFeatures.begin() ); aIter != aEnd; ++aIter )
|
|
|
|
{
|
|
|
|
FeatureState aFeatureState( getState( aIter->first ) );
|
|
|
|
fireStatusEventForURL( aIter->first, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FeatureState aFeatureState( getState( rURL ) );
|
|
|
|
fireStatusEventForURL( rURL, aFeatureState.aState, aFeatureState.bEnabled, xSingleListener );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// XDispatch
|
|
|
|
void FeatureCommandDispatchBase::dispatch( const util::URL& URL,
|
|
|
|
const Sequence< beans::PropertyValue >& Arguments )
|
2014-02-25 21:31:58 +01:00
|
|
|
throw (uno::RuntimeException, std::exception)
|
2009-05-29 09:10:08 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aCommand( URL.Complete );
|
2009-05-29 09:10:08 +00:00
|
|
|
if ( getState( aCommand ).bEnabled )
|
|
|
|
{
|
|
|
|
execute( aCommand, Arguments );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FeatureCommandDispatchBase::implDescribeSupportedFeature( const sal_Char* pAsciiCommandURL,
|
|
|
|
sal_uInt16 nId, sal_Int16 nGroup )
|
|
|
|
{
|
|
|
|
ControllerFeature aFeature;
|
2013-04-07 12:06:47 +02:00
|
|
|
aFeature.Command = OUString::createFromAscii( pAsciiCommandURL );
|
2009-05-29 09:10:08 +00:00
|
|
|
aFeature.nFeatureId = nId;
|
|
|
|
aFeature.GroupId = nGroup;
|
|
|
|
|
|
|
|
m_aSupportedFeatures[ aFeature.Command ] = aFeature;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace chart
|
2010-10-12 15:59:00 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|