/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
if ( m_bInitialized &&
m_xFrame.is() &&
!m_aCommandURL.isEmpty() )
{
aCommandURL = m_aCommandURL;
URLToDispatchMap::iterator pIter = m_aListenerMap.find( m_aCommandURL ); if ( pIter != m_aListenerMap.end() )
xDispatch = pIter->second;
}
}
if ( !xDispatch.is() ) return;
try
{
css::util::URL aTargetURL;
// Provide key modifier information to dispatch function
Sequence<PropertyValue> aArgs{ comphelper::makePropertyValue(u"KeyModifier"_ustr, KeyModifier) };
{
SolarMutexGuard aSolarMutexGuard;
URLToDispatchMap::iterator pIter = m_aListenerMap.find( aCommandURL );
// Already in the list of status listener. Do nothing. if ( pIter != m_aListenerMap.end() ) return;
// Check if we are already initialized. Implementation starts adding itself as status listener when // initialize is called. if ( !m_bInitialized )
{ // Put into the unordered_map of status listener. Will be activated when initialized is called
m_aListenerMap.emplace( aCommandURL, Reference< XDispatch >() ); return;
} else
{ // Add status listener directly as initialize has already been called.
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( m_xContext.is() && xDispatchProvider.is() )
{
aTargetURL.Complete = aCommandURL; if ( m_xUrlTransformer.is() )
m_xUrlTransformer->parseStrict( aTargetURL );
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
// Call without locked mutex as we are called back from dispatch implementation try
{ if ( xDispatch.is() )
xDispatch->addStatusListener( xStatusListener, aTargetURL );
} catch ( Exception& )
{
}
}
// Collect all registered command URL's and store them temporary
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( m_xContext.is() && xDispatchProvider.is() )
{
xStatusListener = this; for (auto & listener : m_aListenerMap)
{
css::util::URL aTargetURL;
aTargetURL.Complete = listener.first; if ( m_xUrlTransformer.is() )
m_xUrlTransformer->parseStrict( aTargetURL );
Reference< XDispatch > xDispatch(listener.second); if ( xDispatch.is() )
{ // We already have a dispatch object => we have to requery. // Release old dispatch object and remove it as listener try
{
xDispatch->removeStatusListener( xStatusListener, aTargetURL );
} catch ( Exception& )
{
}
}
listener.second.clear();
xDispatch.clear();
// Query for dispatch object. Old dispatch will be released with this, too. try
{
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
} catch ( Exception& )
{
}
// it may be a command alias if (!xDispatch.is())
{ try
{ auto aProperties = vcl::CommandInfoProvider::GetCommandProperties(listener.first,
vcl::CommandInfoProvider::GetModuleIdentifier(m_xFrame));
OUString sRealCommand = vcl::CommandInfoProvider::GetRealCommandForCommand(aProperties);
if (!sRealCommand.isEmpty())
{
aTargetURL.Complete = sRealCommand; if ( m_xUrlTransformer.is() )
m_xUrlTransformer->parseStrict( aTargetURL );
// Collect all registered command URL's and store them temporary
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( !(m_xContext.is() && xDispatchProvider.is()) ) return;
Reference< XDispatch > xDispatch(listener.second); if ( xDispatch.is() )
{ // We already have a dispatch object => we have to requery. // Release old dispatch object and remove it as listener try
{
xDispatch->removeStatusListener( xStatusListener, aTargetURL );
} catch ( Exception& )
{
}
}
listener.second.clear();
}
}
// Try to find a dispatch object for the requested command URL
Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY );
xStatusListener = this; if ( m_xContext.is() && xDispatchProvider.is() )
{
aTargetURL.Complete = aCommandURL; if ( m_xUrlTransformer.is() )
m_xUrlTransformer->parseStrict( aTargetURL );
xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 );
}
}
if ( !(xDispatch.is() && xStatusListener.is()) ) return;
// Catch exception as we release our mutex, it is possible that someone else // has already disposed this instance! // Add/remove status listener to get an update status information from the // requested command. try
{
xDispatch->addStatusListener( xStatusListener, aTargetURL );
xDispatch->removeStatusListener( xStatusListener, aTargetURL );
} catch ( Exception& )
{
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.