2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-06 17:28:37 +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 .
|
|
|
|
*/
|
2003-09-04 06:20:47 +00:00
|
|
|
|
2014-04-18 22:47:44 +02:00
|
|
|
#ifndef INCLUDED_SCRIPTING_SOURCE_PROVIDER_PROVIDERCACHE_HXX
|
|
|
|
#define INCLUDED_SCRIPTING_SOURCE_PROVIDER_PROVIDERCACHE_HXX
|
2003-09-04 06:20:47 +00:00
|
|
|
|
|
|
|
#include <osl/mutex.hxx>
|
2006-06-19 09:21:53 +00:00
|
|
|
#include <rtl/ustring.hxx>
|
2003-09-04 06:20:47 +00:00
|
|
|
#include <com/sun/star/uno/RuntimeException.hpp>
|
|
|
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
|
|
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
|
|
|
#include <com/sun/star/lang/XSingleComponentFactory.hpp>
|
|
|
|
#include <com/sun/star/lang/XMultiComponentFactory.hpp>
|
|
|
|
|
2004-10-22 13:07:52 +00:00
|
|
|
#include <com/sun/star/script/provider/XScriptProvider.hpp>
|
2003-09-04 06:20:47 +00:00
|
|
|
|
2015-01-04 11:10:45 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
|
2003-09-04 06:20:47 +00:00
|
|
|
namespace func_provider
|
|
|
|
{
|
|
|
|
|
|
|
|
//Typedefs
|
2014-02-25 20:05:49 +01:00
|
|
|
|
2003-09-04 06:20:47 +00:00
|
|
|
|
|
|
|
struct ProviderDetails
|
|
|
|
{
|
|
|
|
//css::uno::Reference< css::lang::XSingleServiceFactory > factory;
|
|
|
|
css::uno::Reference< css::lang::XSingleComponentFactory > factory;
|
2004-10-22 13:07:52 +00:00
|
|
|
css::uno::Reference< css::script::provider::XScriptProvider > provider;
|
2003-09-04 06:20:47 +00:00
|
|
|
};
|
2016-04-03 15:53:23 +02:00
|
|
|
typedef std::unordered_map < OUString, ProviderDetails , OUStringHash > ProviderDetails_hash;
|
2003-09-04 06:20:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ProviderCache
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
2017-01-19 17:52:02 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2017-01-26 12:28:58 +01:00
|
|
|
ProviderCache( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Sequence< css::uno::Any >& scriptContext );
|
2017-01-19 17:52:02 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2004-07-23 13:10:59 +00:00
|
|
|
ProviderCache( const css::uno::Reference< css::uno::XComponentContext >& xContext, const css::uno::Sequence< css::uno::Any >& scriptContext,
|
2017-01-26 12:28:58 +01:00
|
|
|
const css::uno::Sequence< OUString >& blackList );
|
2003-09-04 06:20:47 +00:00
|
|
|
~ProviderCache();
|
2004-10-22 13:07:52 +00:00
|
|
|
css::uno::Reference< css::script::provider::XScriptProvider >
|
2013-04-07 12:06:47 +02:00
|
|
|
getProvider( const OUString& providerName );
|
2017-01-19 17:52:02 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2004-10-22 13:07:52 +00:00
|
|
|
css::uno::Sequence < css::uno::Reference< css::script::provider::XScriptProvider > >
|
2017-01-26 12:28:58 +01:00
|
|
|
getAllProviders();
|
2003-09-04 06:20:47 +00:00
|
|
|
private:
|
2017-01-19 17:52:02 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2017-01-26 12:28:58 +01:00
|
|
|
void populateCache();
|
2003-09-04 06:20:47 +00:00
|
|
|
|
2017-01-19 17:52:02 +01:00
|
|
|
/// @throws css::uno::RuntimeException
|
2004-10-22 13:07:52 +00:00
|
|
|
css::uno::Reference< css::script::provider::XScriptProvider >
|
2017-01-26 12:28:58 +01:00
|
|
|
createProvider( ProviderDetails& details );
|
2013-04-07 12:06:47 +02:00
|
|
|
bool isInBlackList( const OUString& serviceName )
|
2004-07-23 13:10:59 +00:00
|
|
|
{
|
|
|
|
if ( m_sBlackList.getLength() > 0 )
|
|
|
|
{
|
|
|
|
for ( sal_Int32 index = 0; index < m_sBlackList.getLength(); index++ )
|
|
|
|
{
|
|
|
|
if ( m_sBlackList[ index ].equals( serviceName ) )
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-04-07 12:06:47 +02:00
|
|
|
css::uno::Sequence< OUString > m_sBlackList;
|
2003-09-04 06:20:47 +00:00
|
|
|
ProviderDetails_hash m_hProviderDetailsCache;
|
|
|
|
osl::Mutex m_mutex;
|
|
|
|
css::uno::Sequence< css::uno::Any > m_Sctx;
|
|
|
|
css::uno::Reference< css::uno::XComponentContext > m_xContext;
|
|
|
|
css::uno::Reference< css::lang::XMultiComponentFactory > m_xMgr;
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
} // func_provider
|
|
|
|
#endif
|
2010-10-27 13:11:31 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|