summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--framework/inc/dispatch/dispatchprovider.hxx2
-rw-r--r--framework/source/dispatch/dispatchprovider.cxx22
2 files changed, 19 insertions, 5 deletions
diff --git a/framework/inc/dispatch/dispatchprovider.hxx b/framework/inc/dispatch/dispatchprovider.hxx
index 804df44abc0c..4552e0580d2c 100644
--- a/framework/inc/dispatch/dispatchprovider.hxx
+++ b/framework/inc/dispatch/dispatchprovider.hxx
@@ -74,6 +74,8 @@ class DispatchProvider final : public ::cppu::WeakImplHelper< css::frame::XDispa
css::uno::WeakReference< css::frame::XFrame > m_xFrame;
/// cache of some other dispatch provider which are registered inside configuration to handle special URL protocols
HandlerCache m_aProtocolHandlerCache;
+ std::unordered_map<OUString, css::uno::Reference<css::frame::XDispatchProvider>>
+ m_aProtocolHandlers;
/* interface */
public:
diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx
index 578170227578..bcfa07bb333a 100644
--- a/framework/source/dispatch/dispatchprovider.cxx
+++ b/framework/source/dispatch/dispatchprovider.cxx
@@ -440,18 +440,30 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_searchProt
SolarMutexGuard g;
// create it
+ bool bInitialize = true;
try
{
- xHandler.set(
- css::uno::Reference<css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
- ->createInstance(aHandler.m_sUNOName),
- css::uno::UNO_QUERY);
+ // Only create the protocol handler instance once, the creation is expensive.
+ auto it = m_aProtocolHandlers.find(aHandler.m_sUNOName);
+ if (it == m_aProtocolHandlers.end())
+ {
+ xHandler.set(
+ css::uno::Reference<css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
+ ->createInstance(aHandler.m_sUNOName),
+ css::uno::UNO_QUERY);
+ m_aProtocolHandlers.emplace(aHandler.m_sUNOName, xHandler);
+ }
+ else
+ {
+ xHandler = it->second;
+ bInitialize = false;
+ }
}
catch(const css::uno::Exception&) {}
// look if initialization is necessary
css::uno::Reference< css::lang::XInitialization > xInit( xHandler, css::uno::UNO_QUERY );
- if (xInit.is())
+ if (xInit.is() && bInitialize)
{
css::uno::Reference< css::frame::XFrame > xOwner( m_xFrame.get(), css::uno::UNO_QUERY );
SAL_WARN_IF(!xOwner.is(), "fwk", "DispatchProvider::implts_searchProtocolHandler(): Couldn't get reference to my owner frame. So I can't set may needed context information for this protocol handler.");