New cppu::defaultBootstrap_InitialComponentContext implementation
...that no longer uses XSimpleRegistry structures for the service data and thus is potentially more performant. * Registry-based functions from cppuhelper/bootstrap are deprecated now, client code should always use defaultBootstrap_InitialComponentContext. * References to the obsolete UNO_WRITERDB have been removed. * Some of the functions in cppuhelper/source that are used from multiple .cxx but had not been properly placed into .hxx have been cleaned up. * css.lang.ServiceManager XSet insert/remove now support special sequence<NamedValue> to improve live deployment/removal of XML-based extension components data. * 09524d410bbaad2a0b9b39811cb5cc16621b1396 "stoc: accelerate opening of multiple XML .rdb files in a directory" and its follow-up cb5c881a7f179391ee853f76e159254c97d776a3 "avoid using the new rdb reading logic for empty/non-existent directories" have been obsoleted by this change and have been reverted again.
This commit is contained in:
parent
b2fdaed465
commit
c2fd9b533c
@ -44,8 +44,10 @@ $(eval $(call gb_Library_add_defs,cppuhelper,\
|
|||||||
|
|
||||||
$(eval $(call gb_Library_use_libraries,cppuhelper,\
|
$(eval $(call gb_Library_use_libraries,cppuhelper,\
|
||||||
cppu \
|
cppu \
|
||||||
|
reg \
|
||||||
sal \
|
sal \
|
||||||
salhelper \
|
salhelper \
|
||||||
|
xmlreader \
|
||||||
$(gb_STDLIBS) \
|
$(gb_STDLIBS) \
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -58,6 +60,7 @@ $(eval $(call gb_Library_add_exception_objects,cppuhelper,\
|
|||||||
cppuhelper/source/bootstrap \
|
cppuhelper/source/bootstrap \
|
||||||
cppuhelper/source/component_context \
|
cppuhelper/source/component_context \
|
||||||
cppuhelper/source/component \
|
cppuhelper/source/component \
|
||||||
|
cppuhelper/source/defaultbootstrap \
|
||||||
cppuhelper/source/exc_thrower \
|
cppuhelper/source/exc_thrower \
|
||||||
cppuhelper/source/factory \
|
cppuhelper/source/factory \
|
||||||
cppuhelper/source/implbase \
|
cppuhelper/source/implbase \
|
||||||
@ -65,6 +68,7 @@ $(eval $(call gb_Library_add_exception_objects,cppuhelper,\
|
|||||||
cppuhelper/source/implementationentry \
|
cppuhelper/source/implementationentry \
|
||||||
cppuhelper/source/interfacecontainer \
|
cppuhelper/source/interfacecontainer \
|
||||||
cppuhelper/source/macro_expander \
|
cppuhelper/source/macro_expander \
|
||||||
|
cppuhelper/source/paths \
|
||||||
cppuhelper/source/propertysetmixin \
|
cppuhelper/source/propertysetmixin \
|
||||||
cppuhelper/source/propshlp \
|
cppuhelper/source/propshlp \
|
||||||
cppuhelper/source/servicefactory \
|
cppuhelper/source/servicefactory \
|
||||||
|
@ -48,6 +48,10 @@ namespace cppu
|
|||||||
|
|
||||||
@rBootstrapPath optional bootstrap path for initial components
|
@rBootstrapPath optional bootstrap path for initial components
|
||||||
@return simple registry service instance
|
@return simple registry service instance
|
||||||
|
|
||||||
|
@deprecated Registry-based type/service information is successively
|
||||||
|
replaced with more modern formats; client code should exclusively use
|
||||||
|
::cppu::defaultBootstrap_InitialComponentContext (or ::cppu::bootstrap).
|
||||||
*/
|
*/
|
||||||
CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry >
|
CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry >
|
||||||
SAL_CALL createSimpleRegistry(
|
SAL_CALL createSimpleRegistry(
|
||||||
@ -58,6 +62,10 @@ SAL_CALL createSimpleRegistry(
|
|||||||
|
|
||||||
@rBootstrapPath optional bootstrap path for initial components
|
@rBootstrapPath optional bootstrap path for initial components
|
||||||
@return nested registry service instance
|
@return nested registry service instance
|
||||||
|
|
||||||
|
@deprecated Registry-based type/service information is successively
|
||||||
|
replaced with more modern formats; client code should exclusively use
|
||||||
|
::cppu::defaultBootstrap_InitialComponentContext (or ::cppu::bootstrap).
|
||||||
*/
|
*/
|
||||||
CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry >
|
CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry >
|
||||||
SAL_CALL createNestedRegistry(
|
SAL_CALL createNestedRegistry(
|
||||||
@ -83,6 +91,10 @@ CPPUHELPER_DLLPUBLIC sal_Bool SAL_CALL installTypeDescriptionManager(
|
|||||||
@param xRegistry registry for service manager and singleton objects of context (may be null)
|
@param xRegistry registry for service manager and singleton objects of context (may be null)
|
||||||
@param rBootstrapPath optional bootstrap path for initial components
|
@param rBootstrapPath optional bootstrap path for initial components
|
||||||
@return component context
|
@return component context
|
||||||
|
|
||||||
|
@deprecated Registry-based type/service information is successively
|
||||||
|
replaced with more modern formats; client code should exclusively use
|
||||||
|
::cppu::defaultBootstrap_InitialComponentContext (or ::cppu::bootstrap).
|
||||||
*/
|
*/
|
||||||
CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
|
CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL
|
||||||
bootstrap_InitialComponentContext(
|
bootstrap_InitialComponentContext(
|
||||||
@ -91,19 +103,13 @@ bootstrap_InitialComponentContext(
|
|||||||
SAL_THROW( (::com::sun::star::uno::Exception) );
|
SAL_THROW( (::com::sun::star::uno::Exception) );
|
||||||
|
|
||||||
|
|
||||||
/** Bootstraps an initial component context with service manager upon default types and
|
/** Bootstraps an initial component context with service manager upon
|
||||||
services registry.
|
information from bootstrap variables.
|
||||||
This includes insertion of initial services:
|
|
||||||
- (registry) service manager, shared lib loader,
|
|
||||||
- simple registry, nested registry,
|
|
||||||
- implementation registration
|
|
||||||
- registry typedescription provider, typedescription manager (also installs it into cppu core)
|
|
||||||
|
|
||||||
This function tries to find its parameters via these bootstrap variables:
|
This function tries to find its parameters via these bootstrap variables:
|
||||||
|
|
||||||
- UNO_TYPES -- a space separated list of file urls of type rdbs
|
- UNO_TYPES -- a space separated list of file urls of type rdbs
|
||||||
- UNO_SERVICES -- a space separated list of file urls of service rdbs
|
- UNO_SERVICES -- a space separated list of file urls of service rdbs
|
||||||
- UNO_WRITERDB -- a file url of a write rdb (e.g. user.rdb)
|
|
||||||
|
|
||||||
Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
|
Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
|
||||||
for further info.
|
for further info.
|
||||||
@ -114,19 +120,13 @@ CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XC
|
|||||||
defaultBootstrap_InitialComponentContext() SAL_THROW( (::com::sun::star::uno::Exception) );
|
defaultBootstrap_InitialComponentContext() SAL_THROW( (::com::sun::star::uno::Exception) );
|
||||||
|
|
||||||
|
|
||||||
/** Bootstraps an initial component context with service manager upon default types and
|
/** Bootstraps an initial component context with service manager upon
|
||||||
services registry.
|
information from an ini file.
|
||||||
This includes insertion of initial services:
|
|
||||||
- (registry) service manager, shared lib loader,
|
|
||||||
- simple registry, nested registry,
|
|
||||||
- implementation registration
|
|
||||||
- registry typedescription provider, typedescription manager (also installs it into cppu core)
|
|
||||||
|
|
||||||
This function tries to find its parameters via these bootstrap variables:
|
This function tries to find its parameters via these bootstrap variables:
|
||||||
|
|
||||||
- UNO_TYPES -- a space separated list of file urls of type rdbs
|
- UNO_TYPES -- a space separated list of file urls of type rdbs
|
||||||
- UNO_SERVICES -- a space separated list of file urls of service rdbs
|
- UNO_SERVICES -- a space separated list of file urls of service rdbs
|
||||||
- UNO_WRITERDB -- a file url of a write rdb (e.g. user.rdb)
|
|
||||||
|
|
||||||
Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
|
Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html
|
||||||
for further info.
|
for further info.
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
ch cppuhelper : BOOST:boost LIBXSLT:libxslt DESKTOP:codemaker cppu offapi NULL
|
ch cppuhelper : BOOST:boost LIBXSLT:libxslt DESKTOP:codemaker cppu offapi registry salhelper xmlreader NULL
|
||||||
ch cppuhelper\prj nmake - all ch_prj NULL
|
ch cppuhelper\prj nmake - all ch_prj NULL
|
||||||
ch cppuhelper\qa\propertysetmixin nmake - all ch_qa_propertysetmixin ch_prj NULL
|
ch cppuhelper\qa\propertysetmixin nmake - all ch_qa_propertysetmixin ch_prj NULL
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
#include "sal/config.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include "rtl/process.h"
|
#include "rtl/process.h"
|
||||||
#include "rtl/bootstrap.hxx"
|
#include "rtl/bootstrap.hxx"
|
||||||
@ -38,27 +38,14 @@
|
|||||||
#include "rtl/uri.hxx"
|
#include "rtl/uri.hxx"
|
||||||
#include "osl/diagnose.h"
|
#include "osl/diagnose.h"
|
||||||
#include "osl/file.hxx"
|
#include "osl/file.hxx"
|
||||||
#include "osl/module.hxx"
|
|
||||||
#include "osl/security.hxx"
|
#include "osl/security.hxx"
|
||||||
#include "osl/thread.hxx"
|
#include "osl/thread.hxx"
|
||||||
|
|
||||||
#include "cppuhelper/shlib.hxx"
|
|
||||||
#include "cppuhelper/bootstrap.hxx"
|
#include "cppuhelper/bootstrap.hxx"
|
||||||
#include "cppuhelper/component_context.hxx"
|
|
||||||
#include "cppuhelper/access_control.hxx"
|
|
||||||
#include "cppuhelper/findsofficepath.h"
|
#include "cppuhelper/findsofficepath.h"
|
||||||
|
|
||||||
#include "com/sun/star/uno/XComponentContext.hpp"
|
#include "com/sun/star/uno/XComponentContext.hpp"
|
||||||
#include "com/sun/star/uno/XCurrentContext.hpp"
|
|
||||||
|
|
||||||
#include "com/sun/star/lang/XSingleServiceFactory.hpp"
|
|
||||||
#include "com/sun/star/lang/XSingleComponentFactory.hpp"
|
|
||||||
#include "com/sun/star/lang/XInitialization.hpp"
|
|
||||||
#include "com/sun/star/lang/XServiceInfo.hpp"
|
|
||||||
#include "com/sun/star/registry/XSimpleRegistry.hpp"
|
|
||||||
#include "com/sun/star/container/XSet.hpp"
|
|
||||||
#include "com/sun/star/beans/PropertyValue.hpp"
|
|
||||||
#include "com/sun/star/io/IOException.hpp"
|
|
||||||
#include "com/sun/star/bridge/UnoUrlResolver.hpp"
|
#include "com/sun/star/bridge/UnoUrlResolver.hpp"
|
||||||
#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
|
#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
|
||||||
|
|
||||||
@ -73,458 +60,9 @@ using namespace ::osl;
|
|||||||
using namespace ::com::sun::star;
|
using namespace ::com::sun::star;
|
||||||
using namespace ::com::sun::star::uno;
|
using namespace ::com::sun::star::uno;
|
||||||
|
|
||||||
namespace css = com::sun::star;
|
|
||||||
|
|
||||||
namespace cppu
|
namespace cppu
|
||||||
{
|
{
|
||||||
|
|
||||||
OUString const & get_this_libpath()
|
|
||||||
{
|
|
||||||
static OUString s_path;
|
|
||||||
if (s_path.isEmpty())
|
|
||||||
{
|
|
||||||
OUString path;
|
|
||||||
Module::getUrlFromAddress( reinterpret_cast<oslGenericFunction>(get_this_libpath), path );
|
|
||||||
path = path.copy( 0, path.lastIndexOf( '/' ) );
|
|
||||||
MutexGuard guard( Mutex::getGlobalMutex() );
|
|
||||||
if (s_path.isEmpty())
|
|
||||||
s_path = path;
|
|
||||||
}
|
|
||||||
return s_path;
|
|
||||||
}
|
|
||||||
|
|
||||||
Bootstrap const & get_unorc() SAL_THROW(())
|
|
||||||
{
|
|
||||||
static rtlBootstrapHandle s_bstrap = 0;
|
|
||||||
if (! s_bstrap)
|
|
||||||
{
|
|
||||||
#ifdef ANDROID
|
|
||||||
// Wouldn't it be lovely to avoid this fugly hard-coding.
|
|
||||||
// The problem is that the 'create_bootstrap_macro_expander_factory()'
|
|
||||||
// required for bootstrapping services, calls cppu::get_unorc directly
|
|
||||||
// instead of re-using the BoostrapHandle from:
|
|
||||||
// defaultBootstrap_InitialComponentContext
|
|
||||||
// and since rtlBootstrapHandle is not ref-counted doing anything
|
|
||||||
// clean here is hardish.
|
|
||||||
OUString iniName( RTL_CONSTASCII_USTRINGPARAM( "file:///assets/program/unorc" ) );
|
|
||||||
#else
|
|
||||||
OUString iniName(
|
|
||||||
get_this_libpath() + OUSTR("/" SAL_CONFIGFILE("uno")) );
|
|
||||||
#endif
|
|
||||||
rtlBootstrapHandle bstrap = rtl_bootstrap_args_open( iniName.pData );
|
|
||||||
|
|
||||||
ClearableMutexGuard guard( Mutex::getGlobalMutex() );
|
|
||||||
if (s_bstrap)
|
|
||||||
{
|
|
||||||
guard.clear();
|
|
||||||
rtl_bootstrap_args_close( bstrap );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
s_bstrap = bstrap;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return *(Bootstrap const *)&s_bstrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// private forward decl
|
|
||||||
Reference< lang::XMultiComponentFactory > bootstrapInitialSF(
|
|
||||||
OUString const & rBootstrapPath )
|
|
||||||
SAL_THROW( (Exception) );
|
|
||||||
|
|
||||||
Reference< XComponentContext > bootstrapInitialContext(
|
|
||||||
Reference< lang::XMultiComponentFactory > const & xSF,
|
|
||||||
Reference< registry::XSimpleRegistry > const & types_xRegistry,
|
|
||||||
Reference< registry::XSimpleRegistry > const & services_xRegistry,
|
|
||||||
OUString const & rBootstrapPath, Bootstrap const & bootstrap )
|
|
||||||
SAL_THROW( (Exception) );
|
|
||||||
|
|
||||||
Reference< XComponentContext > SAL_CALL createInitialCfgComponentContext(
|
|
||||||
ContextEntry_Init const * pEntries, sal_Int32 nEntries,
|
|
||||||
Reference< XComponentContext > const & xDelegate )
|
|
||||||
SAL_THROW(());
|
|
||||||
|
|
||||||
Reference< registry::XSimpleRegistry > SAL_CALL createRegistryWrapper(
|
|
||||||
const Reference< XComponentContext >& xContext );
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
template< class T >
|
|
||||||
inline beans::PropertyValue createPropertyValue(
|
|
||||||
OUString const & name, T const & value )
|
|
||||||
SAL_THROW(())
|
|
||||||
{
|
|
||||||
return beans::PropertyValue(
|
|
||||||
name, -1, makeAny( value ), beans::PropertyState_DIRECT_VALUE );
|
|
||||||
}
|
|
||||||
|
|
||||||
OUString findBootstrapArgument(
|
|
||||||
const Bootstrap & bootstrap,
|
|
||||||
const OUString & arg_name,
|
|
||||||
sal_Bool * pFallenBack )
|
|
||||||
SAL_THROW(())
|
|
||||||
{
|
|
||||||
OUString result;
|
|
||||||
|
|
||||||
OUString prefixed_arg_name = OUSTR("UNO_");
|
|
||||||
prefixed_arg_name += arg_name.toAsciiUpperCase();
|
|
||||||
|
|
||||||
// environment not set -> try relative to executable
|
|
||||||
if(!bootstrap.getFrom(prefixed_arg_name, result))
|
|
||||||
{
|
|
||||||
if(pFallenBack)
|
|
||||||
*pFallenBack = sal_True;
|
|
||||||
|
|
||||||
OUString fileName;
|
|
||||||
bootstrap.getIniName(fileName);
|
|
||||||
|
|
||||||
// cut the rc extension
|
|
||||||
OUStringBuffer result_buf( 64 );
|
|
||||||
result_buf.append(
|
|
||||||
fileName.copy(
|
|
||||||
0, fileName.getLength() - strlen(SAL_CONFIGFILE(""))) );
|
|
||||||
result_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_") );
|
|
||||||
result_buf.append( arg_name.toAsciiLowerCase() );
|
|
||||||
result_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(".rdb") );
|
|
||||||
result = result_buf.makeStringAndClear();
|
|
||||||
|
|
||||||
OSL_TRACE(
|
|
||||||
(OSL_LOG_PREFIX "findBootstrapArgument, setting \"%s\" relative to"
|
|
||||||
" executable \"%s\""),
|
|
||||||
OUStringToOString(arg_name, RTL_TEXTENCODING_UTF8).getStr(),
|
|
||||||
OUStringToOString(result, RTL_TEXTENCODING_UTF8).getStr());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(pFallenBack)
|
|
||||||
*pFallenBack = sal_False;
|
|
||||||
|
|
||||||
OSL_TRACE(
|
|
||||||
OSL_LOG_PREFIX "findBootstrapArgument, found \"%s\" in env \"%s\"",
|
|
||||||
(OUStringToOString(prefixed_arg_name, RTL_TEXTENCODING_UTF8).
|
|
||||||
getStr()),
|
|
||||||
OUStringToOString(result, RTL_TEXTENCODING_UTF8).getStr());
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
css::uno::Reference< css::registry::XSimpleRegistry > readRdbFile(
|
|
||||||
rtl::OUString const & url, bool fatalErrors,
|
|
||||||
css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry,
|
|
||||||
css::uno::Reference< css::lang::XSingleServiceFactory > const &
|
|
||||||
simpleRegistryFactory,
|
|
||||||
css::uno::Reference< css::lang::XSingleServiceFactory > const &
|
|
||||||
nestedRegistryFactory)
|
|
||||||
{
|
|
||||||
OSL_ASSERT(simpleRegistryFactory.is() && nestedRegistryFactory.is());
|
|
||||||
try {
|
|
||||||
css::uno::Reference< css::registry::XSimpleRegistry > simple(
|
|
||||||
simpleRegistryFactory->createInstance(), css::uno::UNO_QUERY_THROW);
|
|
||||||
simple->open(url, true, false);
|
|
||||||
if (lastRegistry.is()) {
|
|
||||||
css::uno::Reference< css::registry::XSimpleRegistry > nested(
|
|
||||||
nestedRegistryFactory->createInstance(),
|
|
||||||
css::uno::UNO_QUERY_THROW);
|
|
||||||
css::uno::Sequence< css::uno::Any > args(2);
|
|
||||||
args[0] <<= lastRegistry;
|
|
||||||
args[1] <<= simple;
|
|
||||||
css::uno::Reference< css::lang::XInitialization >(
|
|
||||||
nested, css::uno::UNO_QUERY_THROW)->
|
|
||||||
initialize(args);
|
|
||||||
return nested;
|
|
||||||
} else {
|
|
||||||
return simple;
|
|
||||||
}
|
|
||||||
} catch (css::registry::InvalidRegistryException & e) {
|
|
||||||
(void) e; // avoid warnings
|
|
||||||
OSL_TRACE(
|
|
||||||
OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"",
|
|
||||||
rtl::OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr(),
|
|
||||||
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
|
|
||||||
if (fatalErrors) {
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
return lastRegistry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference< registry::XSimpleRegistry > readRdbDirectory(
|
|
||||||
rtl::OUString const & url, bool fatalErrors,
|
|
||||||
css::uno::Reference< css::registry::XSimpleRegistry > const & lastRegistry,
|
|
||||||
css::uno::Reference< css::lang::XSingleServiceFactory > const &
|
|
||||||
simpleRegistryFactory,
|
|
||||||
css::uno::Reference< css::lang::XSingleServiceFactory > const &
|
|
||||||
nestedRegistryFactory)
|
|
||||||
{
|
|
||||||
OSL_ASSERT(simpleRegistryFactory.is() && nestedRegistryFactory.is());
|
|
||||||
osl::Directory dir(url);
|
|
||||||
switch (dir.open()) {
|
|
||||||
case osl::FileBase::E_None:
|
|
||||||
break;
|
|
||||||
case osl::FileBase::E_NOENT:
|
|
||||||
if (!fatalErrors) {
|
|
||||||
return lastRegistry;
|
|
||||||
}
|
|
||||||
// fall through
|
|
||||||
default:
|
|
||||||
throw css::uno::RuntimeException(
|
|
||||||
(rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM("cannot open directory ")) +
|
|
||||||
url),
|
|
||||||
css::uno::Reference< css::uno::XInterface >());
|
|
||||||
}
|
|
||||||
std::vector<rtl::OUString> aURLs;
|
|
||||||
css::uno::Reference< css::registry::XSimpleRegistry > last(lastRegistry);
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
osl::DirectoryItem i;
|
|
||||||
osl::FileBase::RC eResult;
|
|
||||||
eResult = dir.getNextItem(i, SAL_MAX_UINT32);
|
|
||||||
if (eResult == osl::FileBase::E_NOENT)
|
|
||||||
break;
|
|
||||||
if (eResult != osl::FileBase::E_None)
|
|
||||||
{
|
|
||||||
throw css::uno::RuntimeException(
|
|
||||||
(rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM("cannot iterate directory ")) +
|
|
||||||
url),
|
|
||||||
css::uno::Reference< css::uno::XInterface >());
|
|
||||||
}
|
|
||||||
osl::FileStatus stat(
|
|
||||||
osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
|
|
||||||
osl_FileStatus_Mask_FileURL);
|
|
||||||
if (i.getFileStatus(stat) != osl::FileBase::E_None) {
|
|
||||||
throw css::uno::RuntimeException(
|
|
||||||
(rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM("cannot stat in directory ")) +
|
|
||||||
url),
|
|
||||||
css::uno::Reference< css::uno::XInterface >());
|
|
||||||
}
|
|
||||||
rtl::OUString aName = stat.getFileName();
|
|
||||||
|
|
||||||
// Ignore backup files - to allow people to edit their
|
|
||||||
// services/ without extremely confusing behaviour
|
|
||||||
if (aName.toChar() == '.' || aName.endsWithAsciiL("~", 1))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (stat.getFileType() != osl::FileStatus::Directory) //TODO: symlinks
|
|
||||||
aURLs.push_back(stat.getFileURL());
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t nXML = 0;
|
|
||||||
for (std::vector<rtl::OUString>::iterator it = aURLs.begin(); it != aURLs.end(); it++)
|
|
||||||
{
|
|
||||||
// Read / sniff the nasty files ...
|
|
||||||
osl::File aIn( *it );
|
|
||||||
if (aIn.open(osl_File_OpenFlag_Read) != osl::FileBase::E_None)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sal_uInt64 nRead = 0;
|
|
||||||
char buffer[6];
|
|
||||||
bool bIsXML = aIn.read(buffer, 6, nRead) == osl::FileBase::E_None &&
|
|
||||||
nRead == 6 && !strncmp(buffer, "<?xml ", 6);
|
|
||||||
aIn.close();
|
|
||||||
if (!bIsXML)
|
|
||||||
{
|
|
||||||
OSL_TRACE (OSL_LOG_PREFIX "rdb '%s' is a legacy format\n",
|
|
||||||
rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nXML++;
|
|
||||||
}
|
|
||||||
if (nXML > 0 && nXML == aURLs.size())
|
|
||||||
{
|
|
||||||
OSL_TRACE (OSL_LOG_PREFIX "no legacy rdbs in directory '%s'\n",
|
|
||||||
rtl::OUStringToOString( url, RTL_TEXTENCODING_UTF8 ).getStr());
|
|
||||||
// read whole directory...
|
|
||||||
last = readRdbFile( url, fatalErrors, last,
|
|
||||||
simpleRegistryFactory, nestedRegistryFactory);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (std::vector<rtl::OUString>::iterator it = aURLs.begin(); it != aURLs.end(); it++)
|
|
||||||
{
|
|
||||||
// Read / sniff the nasty files ...
|
|
||||||
last = readRdbFile(*it, fatalErrors, last,
|
|
||||||
simpleRegistryFactory, nestedRegistryFactory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference< registry::XSimpleRegistry > nestRegistries(
|
|
||||||
const OUString &baseDir,
|
|
||||||
const Reference< lang::XSingleServiceFactory > & xSimRegFac,
|
|
||||||
const Reference< lang::XSingleServiceFactory > & xNesRegFac,
|
|
||||||
OUString csl_rdbs,
|
|
||||||
const OUString & write_rdb,
|
|
||||||
sal_Bool forceWrite_rdb,
|
|
||||||
sal_Bool bFallenBack )
|
|
||||||
SAL_THROW((Exception))
|
|
||||||
{
|
|
||||||
sal_Int32 index;
|
|
||||||
Reference< registry::XSimpleRegistry > lastRegistry;
|
|
||||||
|
|
||||||
if(!write_rdb.isEmpty()) // is there a write registry given?
|
|
||||||
{
|
|
||||||
lastRegistry.set(xSimRegFac->createInstance(), UNO_QUERY);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
lastRegistry->open(write_rdb, sal_False, forceWrite_rdb);
|
|
||||||
}
|
|
||||||
catch (registry::InvalidRegistryException & e)
|
|
||||||
{
|
|
||||||
(void) e; // avoid warnings
|
|
||||||
OSL_TRACE(
|
|
||||||
OSL_LOG_PREFIX "warning, could not open \"%s\": \"%s\"",
|
|
||||||
OUStringToOString(write_rdb, RTL_TEXTENCODING_UTF8).getStr(),
|
|
||||||
OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!lastRegistry->isValid())
|
|
||||||
lastRegistry.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
index = csl_rdbs.indexOf((sal_Unicode)' ');
|
|
||||||
OUString rdb_name = (index == -1) ? csl_rdbs : csl_rdbs.copy(0, index);
|
|
||||||
csl_rdbs = (index == -1) ? OUString() : csl_rdbs.copy(index + 1);
|
|
||||||
|
|
||||||
if (rdb_name.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool fatalErrors = !bFallenBack;
|
|
||||||
if (rdb_name[0] == '?') {
|
|
||||||
rdb_name = rdb_name.copy(1);
|
|
||||||
fatalErrors = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool directory = rdb_name.getLength() >= 3 && rdb_name[0] == '<' &&
|
|
||||||
rdb_name[rdb_name.getLength() - 2] == '>' &&
|
|
||||||
rdb_name[rdb_name.getLength() -1] == '*';
|
|
||||||
if (directory) {
|
|
||||||
rdb_name = rdb_name.copy(1, rdb_name.getLength() - 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
osl::FileBase::getAbsoluteFileURL(baseDir, rdb_name, rdb_name);
|
|
||||||
|
|
||||||
lastRegistry = directory
|
|
||||||
? readRdbDirectory(
|
|
||||||
rdb_name, fatalErrors, lastRegistry, xSimRegFac, xNesRegFac)
|
|
||||||
: readRdbFile(
|
|
||||||
rdb_name, fatalErrors, lastRegistry, xSimRegFac, xNesRegFac);
|
|
||||||
}
|
|
||||||
while(index != -1 && csl_rdbs.getLength()); // are there more rdbs in list?
|
|
||||||
|
|
||||||
return lastRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference< XComponentContext >
|
|
||||||
SAL_CALL defaultBootstrap_InitialComponentContext(
|
|
||||||
Bootstrap const & bootstrap )
|
|
||||||
SAL_THROW( (Exception) )
|
|
||||||
{
|
|
||||||
OUString bootstrapPath;
|
|
||||||
if (!bootstrap.getFrom(
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URE_INTERNAL_LIB_DIR")),
|
|
||||||
bootstrapPath))
|
|
||||||
{
|
|
||||||
bootstrapPath = get_this_libpath();
|
|
||||||
}
|
|
||||||
|
|
||||||
OUString iniDir;
|
|
||||||
osl_getProcessWorkingDir(&iniDir.pData);
|
|
||||||
|
|
||||||
Reference<lang::XMultiComponentFactory> smgr_XMultiComponentFactory(
|
|
||||||
bootstrapInitialSF(bootstrapPath) );
|
|
||||||
Reference<lang::XMultiServiceFactory> smgr_XMultiServiceFactory(
|
|
||||||
smgr_XMultiComponentFactory, UNO_QUERY );
|
|
||||||
|
|
||||||
Reference<registry::XRegistryKey> xEmptyKey;
|
|
||||||
Reference<lang::XSingleServiceFactory> xSimRegFac(
|
|
||||||
loadSharedLibComponentFactory(
|
|
||||||
OUSTR("bootstrap.uno" SAL_DLLEXTENSION), bootstrapPath,
|
|
||||||
OUSTR("com.sun.star.comp.stoc.SimpleRegistry"),
|
|
||||||
smgr_XMultiServiceFactory,
|
|
||||||
xEmptyKey),
|
|
||||||
UNO_QUERY);
|
|
||||||
|
|
||||||
Reference<lang::XSingleServiceFactory> xNesRegFac(
|
|
||||||
loadSharedLibComponentFactory(
|
|
||||||
OUSTR("bootstrap.uno" SAL_DLLEXTENSION), bootstrapPath,
|
|
||||||
OUSTR("com.sun.star.comp.stoc.NestedRegistry"),
|
|
||||||
smgr_XMultiServiceFactory,
|
|
||||||
xEmptyKey),
|
|
||||||
UNO_QUERY);
|
|
||||||
|
|
||||||
sal_Bool bFallenback_types;
|
|
||||||
OUString cls_uno_types =
|
|
||||||
findBootstrapArgument( bootstrap, OUSTR("TYPES"), &bFallenback_types );
|
|
||||||
|
|
||||||
Reference<registry::XSimpleRegistry> types_xRegistry =
|
|
||||||
nestRegistries(
|
|
||||||
iniDir, xSimRegFac, xNesRegFac, cls_uno_types,
|
|
||||||
OUString(), sal_False, bFallenback_types );
|
|
||||||
|
|
||||||
// ==== bootstrap from services registry ====
|
|
||||||
|
|
||||||
sal_Bool bFallenback_services;
|
|
||||||
OUString cls_uno_services = findBootstrapArgument(
|
|
||||||
bootstrap, OUSTR("SERVICES"), &bFallenback_services );
|
|
||||||
|
|
||||||
sal_Bool fallenBackWriteRegistry;
|
|
||||||
OUString write_rdb = findBootstrapArgument(
|
|
||||||
bootstrap, OUSTR("WRITERDB"), &fallenBackWriteRegistry );
|
|
||||||
if (fallenBackWriteRegistry)
|
|
||||||
{
|
|
||||||
// no standard write rdb anymore
|
|
||||||
write_rdb = OUString();
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference<registry::XSimpleRegistry> services_xRegistry = nestRegistries(
|
|
||||||
iniDir, xSimRegFac, xNesRegFac, cls_uno_services, write_rdb,
|
|
||||||
!fallenBackWriteRegistry, bFallenback_services );
|
|
||||||
|
|
||||||
Reference< XComponentContext > xContext(
|
|
||||||
bootstrapInitialContext(
|
|
||||||
smgr_XMultiComponentFactory, types_xRegistry, services_xRegistry,
|
|
||||||
bootstrapPath, bootstrap ) );
|
|
||||||
|
|
||||||
// initialize sf
|
|
||||||
Reference< lang::XInitialization > xInit(
|
|
||||||
smgr_XMultiComponentFactory, UNO_QUERY );
|
|
||||||
OSL_ASSERT( xInit.is() );
|
|
||||||
Sequence< Any > aSFInit( 1 );
|
|
||||||
aSFInit[ 0 ] <<= services_xRegistry;
|
|
||||||
xInit->initialize( aSFInit );
|
|
||||||
|
|
||||||
return xContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference< XComponentContext >
|
|
||||||
SAL_CALL defaultBootstrap_InitialComponentContext(
|
|
||||||
OUString const & iniFile )
|
|
||||||
SAL_THROW( (Exception) )
|
|
||||||
{
|
|
||||||
Bootstrap bootstrap( iniFile );
|
|
||||||
if (bootstrap.getHandle() == 0)
|
|
||||||
throw io::IOException(OUSTR("Cannot open for reading: ") + iniFile, 0);
|
|
||||||
return defaultBootstrap_InitialComponentContext( bootstrap );
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference< XComponentContext >
|
|
||||||
SAL_CALL defaultBootstrap_InitialComponentContext()
|
|
||||||
SAL_THROW( (Exception) )
|
|
||||||
{
|
|
||||||
return defaultBootstrap_InitialComponentContext( get_unorc() );
|
|
||||||
}
|
|
||||||
|
|
||||||
BootstrapException::BootstrapException()
|
BootstrapException::BootstrapException()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -567,7 +105,7 @@ Reference< XComponentContext > SAL_CALL bootstrap()
|
|||||||
}
|
}
|
||||||
rtl::OUString p2;
|
rtl::OUString p2;
|
||||||
if (!rtl_convertStringToUString(
|
if (!rtl_convertStringToUString(
|
||||||
&p2.pData, p1, strlen(p1), osl_getThreadTextEncoding(),
|
&p2.pData, p1, std::strlen(p1), osl_getThreadTextEncoding(),
|
||||||
(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
|
(RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
|
||||||
RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
|
RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
|
||||||
RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
|
RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR)))
|
||||||
|
1980
cppuhelper/source/defaultbootstrap.cxx
Normal file
1980
cppuhelper/source/defaultbootstrap.cxx
Normal file
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@
|
|||||||
#include "com/sun/star/uno/RuntimeException.hpp"
|
#include "com/sun/star/uno/RuntimeException.hpp"
|
||||||
|
|
||||||
#include "macro_expander.hxx"
|
#include "macro_expander.hxx"
|
||||||
|
#include "paths.hxx"
|
||||||
|
|
||||||
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
|
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
|
||||||
#define SERVICE_NAME_A "com.sun.star.lang.MacroExpander"
|
#define SERVICE_NAME_A "com.sun.star.lang.MacroExpander"
|
||||||
@ -54,8 +55,29 @@ using namespace ::com::sun::star::uno;
|
|||||||
|
|
||||||
namespace cppu
|
namespace cppu
|
||||||
{
|
{
|
||||||
//---- private forward -----------------------------------------------------------------------------
|
|
||||||
Bootstrap const & get_unorc() SAL_THROW(());
|
Bootstrap const & get_unorc() SAL_THROW(())
|
||||||
|
{
|
||||||
|
static rtlBootstrapHandle s_bstrap = 0;
|
||||||
|
if (! s_bstrap)
|
||||||
|
{
|
||||||
|
OUString iniName(getUnoIniUri());
|
||||||
|
rtlBootstrapHandle bstrap = rtl_bootstrap_args_open( iniName.pData );
|
||||||
|
|
||||||
|
ClearableMutexGuard guard( Mutex::getGlobalMutex() );
|
||||||
|
if (s_bstrap)
|
||||||
|
{
|
||||||
|
guard.clear();
|
||||||
|
rtl_bootstrap_args_close( bstrap );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s_bstrap = bstrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *(Bootstrap const *)&s_bstrap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace cppuhelper { namespace detail {
|
namespace cppuhelper { namespace detail {
|
||||||
|
84
cppuhelper/source/paths.cxx
Normal file
84
cppuhelper/source/paths.cxx
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#include "sal/config.h"
|
||||||
|
|
||||||
|
#include "com/sun/star/uno/DeploymentException.hpp"
|
||||||
|
#include "com/sun/star/uno/Reference.hxx"
|
||||||
|
#include "com/sun/star/uno/XInterface.hpp"
|
||||||
|
#include "osl/module.hxx"
|
||||||
|
#include "osl/mutex.hxx"
|
||||||
|
#include "rtl/ustring.hxx"
|
||||||
|
#include "sal/types.h"
|
||||||
|
|
||||||
|
#include "paths.hxx"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
namespace css = com::sun::star;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
rtl::OUString cppu::get_this_libpath() {
|
||||||
|
static rtl::OUString s_uri;
|
||||||
|
if (s_uri.isEmpty()) {
|
||||||
|
rtl::OUString uri;
|
||||||
|
osl::Module::getUrlFromAddress(
|
||||||
|
reinterpret_cast< oslGenericFunction >(get_this_libpath), uri);
|
||||||
|
sal_Int32 i = uri.lastIndexOf('/');
|
||||||
|
if (i == -1) {
|
||||||
|
throw css::uno::DeploymentException(
|
||||||
|
"URI " + uri + " is expected to contain a slash",
|
||||||
|
css::uno::Reference< css::uno::XInterface >());
|
||||||
|
}
|
||||||
|
uri = uri.copy(0, i);
|
||||||
|
osl::MutexGuard guard(osl::Mutex::getGlobalMutex());
|
||||||
|
if (s_uri.isEmpty()) {
|
||||||
|
s_uri = uri;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
rtl::OUString cppu::getUnoIniUri() {
|
||||||
|
#if defined ANDROID
|
||||||
|
// Wouldn't it be lovely to avoid this fugly hard-coding.
|
||||||
|
// The problem is that the 'create_bootstrap_macro_expander_factory()'
|
||||||
|
// required for bootstrapping services, calls cppu::get_unorc directly
|
||||||
|
// instead of re-using the BoostrapHandle from:
|
||||||
|
// defaultBootstrap_InitialComponentContext
|
||||||
|
// and since rtlBootstrapHandle is not ref-counted doing anything
|
||||||
|
// clean here is hardish.
|
||||||
|
rtl::OUString uri("file:///assets/program");
|
||||||
|
#else
|
||||||
|
rtl::OUString uri(get_this_libpath());
|
||||||
|
#endif
|
||||||
|
return uri + "/" SAL_CONFIGFILE("uno");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
46
cppuhelper/source/paths.hxx
Normal file
46
cppuhelper/source/paths.hxx
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CPPUHELPER_SOURCE_PATHS_HXX
|
||||||
|
#define CPPUHELPER_SOURCE_PATHS_HXX
|
||||||
|
|
||||||
|
#include "sal/config.h"
|
||||||
|
|
||||||
|
namespace rtl { class OUString; }
|
||||||
|
|
||||||
|
namespace cppu {
|
||||||
|
|
||||||
|
rtl::OUString get_this_libpath();
|
||||||
|
|
||||||
|
rtl::OUString getUnoIniUri();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@ -59,6 +59,8 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "macro_expander.hxx"
|
#include "macro_expander.hxx"
|
||||||
|
#include "paths.hxx"
|
||||||
|
#include "servicefactory_detail.hxx"
|
||||||
|
|
||||||
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
|
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
|
||||||
|
|
||||||
@ -75,9 +77,6 @@ namespace cppu
|
|||||||
Reference< security::XAccessController >
|
Reference< security::XAccessController >
|
||||||
createDefaultAccessController() SAL_THROW(());
|
createDefaultAccessController() SAL_THROW(());
|
||||||
|
|
||||||
OUString const & get_this_libpath();
|
|
||||||
|
|
||||||
|
|
||||||
static Reference< XInterface > SAL_CALL createInstance(
|
static Reference< XInterface > SAL_CALL createInstance(
|
||||||
Reference< XInterface > const & xFactory,
|
Reference< XInterface > const & xFactory,
|
||||||
Reference< XComponentContext > const & xContext =
|
Reference< XComponentContext > const & xContext =
|
||||||
@ -182,7 +181,7 @@ Reference< registry::XSimpleRegistry > SAL_CALL createNestedRegistry(
|
|||||||
UNO_AC_POLICYFILE=<file_url> [optional]
|
UNO_AC_POLICYFILE=<file_url> [optional]
|
||||||
-- read policy out of simple text file
|
-- read policy out of simple text file
|
||||||
*/
|
*/
|
||||||
static void add_access_control_entries(
|
void add_access_control_entries(
|
||||||
::std::vector< ContextEntry_Init > * values,
|
::std::vector< ContextEntry_Init > * values,
|
||||||
Bootstrap const & bootstrap )
|
Bootstrap const & bootstrap )
|
||||||
SAL_THROW( (Exception) )
|
SAL_THROW( (Exception) )
|
||||||
|
64
cppuhelper/source/servicefactory_detail.hxx
Normal file
64
cppuhelper/source/servicefactory_detail.hxx
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_CPPUHELPER_SOURCE_SERVICEFACTORY_DETAIL_HXX
|
||||||
|
#define INCLUDED_CPPUHELPER_SOURCE_SERVICEFACTORY_DETAIL_HXX
|
||||||
|
|
||||||
|
#include "sal/config.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "com/sun/star/uno/Exception.hpp"
|
||||||
|
#include "com/sun/star/uno/Reference.hxx"
|
||||||
|
#include "sal/types.h"
|
||||||
|
|
||||||
|
namespace com { namespace sun { namespace star { namespace lang {
|
||||||
|
class XMultiComponentFactory;
|
||||||
|
} } } }
|
||||||
|
namespace cppu { struct ContextEntry_Init; }
|
||||||
|
namespace rtl {
|
||||||
|
class Bootstrap;
|
||||||
|
class OUString;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace cppu {
|
||||||
|
|
||||||
|
void add_access_control_entries(
|
||||||
|
std::vector< cppu::ContextEntry_Init > * values,
|
||||||
|
rtl::Bootstrap const & bootstrap)
|
||||||
|
SAL_THROW((com::sun::star::uno::Exception));
|
||||||
|
|
||||||
|
com::sun::star::uno::Reference< com::sun::star::lang::XMultiComponentFactory >
|
||||||
|
bootstrapInitialSF(rtl::OUString const & rBootstrapPath)
|
||||||
|
SAL_THROW((com::sun::star::uno::Exception));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@ -132,6 +132,13 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
|
|||||||
factories,
|
factories,
|
||||||
Reference<XComponentContext> const & xContext );
|
Reference<XComponentContext> const & xContext );
|
||||||
|
|
||||||
|
void componentLiveInsertion(
|
||||||
|
ComponentBackendDb::Data const & data,
|
||||||
|
std::vector< css::uno::Reference< css::uno::XInterface > > const &
|
||||||
|
factories);
|
||||||
|
|
||||||
|
void componentLiveRemoval(ComponentBackendDb::Data const & data);
|
||||||
|
|
||||||
virtual void SAL_CALL disposing();
|
virtual void SAL_CALL disposing();
|
||||||
|
|
||||||
// Package
|
// Package
|
||||||
@ -338,22 +345,6 @@ class BackendImpl : public ::dp_registry::backend::PackageRegistryBackend
|
|||||||
css::uno::Reference< css::registry::XRegistryKey > const & base,
|
css::uno::Reference< css::registry::XRegistryKey > const & base,
|
||||||
rtl::OUString const & path);
|
rtl::OUString const & path);
|
||||||
|
|
||||||
void extractComponentData(
|
|
||||||
css::uno::Reference< css::uno::XComponentContext > const & context,
|
|
||||||
css::uno::Reference< css::registry::XRegistryKey > const & registry,
|
|
||||||
ComponentBackendDb::Data * data,
|
|
||||||
std::vector< css::uno::Reference< css::uno::XInterface > > * factories,
|
|
||||||
css::uno::Reference< css::loader::XImplementationLoader > const *
|
|
||||||
componentLoader,
|
|
||||||
rtl::OUString const * componentUrl);
|
|
||||||
|
|
||||||
void componentLiveInsertion(
|
|
||||||
ComponentBackendDb::Data const & data,
|
|
||||||
std::vector< css::uno::Reference< css::uno::XInterface > > const &
|
|
||||||
factories);
|
|
||||||
|
|
||||||
void componentLiveRemoval(ComponentBackendDb::Data const & data);
|
|
||||||
|
|
||||||
css::uno::Reference< css::uno::XComponentContext > getRootContext() const;
|
css::uno::Reference< css::uno::XComponentContext > getRootContext() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -1173,184 +1164,6 @@ css::uno::Reference< css::registry::XRegistryKey > BackendImpl::openRegistryKey(
|
|||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackendImpl::extractComponentData(
|
|
||||||
css::uno::Reference< css::uno::XComponentContext > const & context,
|
|
||||||
css::uno::Reference< css::registry::XRegistryKey > const & registry,
|
|
||||||
ComponentBackendDb::Data * data,
|
|
||||||
std::vector< css::uno::Reference< css::uno::XInterface > > * factories,
|
|
||||||
css::uno::Reference< css::loader::XImplementationLoader > const *
|
|
||||||
componentLoader,
|
|
||||||
rtl::OUString const * componentUrl)
|
|
||||||
{
|
|
||||||
OSL_ASSERT(context.is() && registry.is() && data != 0);
|
|
||||||
rtl::OUString registryName(registry->getKeyName());
|
|
||||||
sal_Int32 prefix = registryName.getLength();
|
|
||||||
if (!registryName.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM("/"))) {
|
|
||||||
prefix += RTL_CONSTASCII_LENGTH("/");
|
|
||||||
}
|
|
||||||
css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
|
|
||||||
keys(registry->openKeys());
|
|
||||||
css::uno::Reference< css::lang::XMultiComponentFactory > smgr(
|
|
||||||
context->getServiceManager(), css::uno::UNO_QUERY_THROW);
|
|
||||||
for (sal_Int32 i = 0; i < keys.getLength(); ++i) {
|
|
||||||
rtl::OUString name(keys[i]->getKeyName().copy(prefix));
|
|
||||||
data->implementationNames.push_back(name);
|
|
||||||
css::uno::Reference< css::registry::XRegistryKey > singletons(
|
|
||||||
keys[i]->openKey(
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNO/SINGLETONS"))));
|
|
||||||
if (singletons.is()) {
|
|
||||||
sal_Int32 prefix2 = keys[i]->getKeyName().getLength() +
|
|
||||||
RTL_CONSTASCII_LENGTH("/UNO/SINGLETONS/");
|
|
||||||
css::uno::Sequence<
|
|
||||||
css::uno::Reference< css::registry::XRegistryKey > >
|
|
||||||
singletonKeys(singletons->openKeys());
|
|
||||||
for (sal_Int32 j = 0; j < singletonKeys.getLength(); ++j) {
|
|
||||||
data->singletons.push_back(
|
|
||||||
std::pair< rtl::OUString, rtl::OUString >(
|
|
||||||
singletonKeys[j]->getKeyName().copy(prefix2), name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (factories != 0) {
|
|
||||||
css::uno::Reference< css::loader::XImplementationLoader > loader;
|
|
||||||
if (componentLoader == 0) {
|
|
||||||
rtl::OUString activator(
|
|
||||||
openRegistryKey(
|
|
||||||
keys[i],
|
|
||||||
rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM("UNO/ACTIVATOR")))->
|
|
||||||
getAsciiValue());
|
|
||||||
loader.set(
|
|
||||||
smgr->createInstanceWithContext(activator, context),
|
|
||||||
css::uno::UNO_QUERY);
|
|
||||||
if (!loader.is()) {
|
|
||||||
throw css::deployment::DeploymentException(
|
|
||||||
(rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM(
|
|
||||||
"cannot instantiate loader ")) +
|
|
||||||
activator),
|
|
||||||
static_cast< OWeakObject * >(this), Any());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
OSL_ASSERT(componentLoader->is());
|
|
||||||
loader = *componentLoader;
|
|
||||||
}
|
|
||||||
factories->push_back(
|
|
||||||
loader->activate(
|
|
||||||
name, rtl::OUString(),
|
|
||||||
(componentUrl == 0
|
|
||||||
? (openRegistryKey(
|
|
||||||
keys[i],
|
|
||||||
rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM("UNO/LOCATION")))->
|
|
||||||
getAsciiValue())
|
|
||||||
: *componentUrl),
|
|
||||||
keys[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BackendImpl::componentLiveInsertion(
|
|
||||||
ComponentBackendDb::Data const & data,
|
|
||||||
std::vector< css::uno::Reference< css::uno::XInterface > > const &
|
|
||||||
factories)
|
|
||||||
{
|
|
||||||
css::uno::Reference< css::uno::XComponentContext > rootContext(
|
|
||||||
getRootContext());
|
|
||||||
css::uno::Reference< css::container::XSet > set(
|
|
||||||
rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
|
|
||||||
std::vector< css::uno::Reference< css::uno::XInterface > >::const_iterator
|
|
||||||
factory(factories.begin());
|
|
||||||
for (t_stringlist::const_iterator i(data.implementationNames.begin());
|
|
||||||
i != data.implementationNames.end(); ++i)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
set->insert(css::uno::Any(*factory++));
|
|
||||||
} catch (const container::ElementExistException &) {
|
|
||||||
OSL_TRACE(
|
|
||||||
"implementation %s already registered",
|
|
||||||
rtl::OUStringToOString(*i, RTL_TEXTENCODING_UTF8).getStr());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!data.singletons.empty()) {
|
|
||||||
css::uno::Reference< css::container::XNameContainer > cont(
|
|
||||||
rootContext, css::uno::UNO_QUERY_THROW);
|
|
||||||
for (t_stringpairvec::const_iterator i(data.singletons.begin());
|
|
||||||
i != data.singletons.end(); ++i)
|
|
||||||
{
|
|
||||||
rtl::OUString name(
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
|
|
||||||
i->first);
|
|
||||||
//TODO: Update should be atomic:
|
|
||||||
try {
|
|
||||||
cont->removeByName(
|
|
||||||
name +
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/arguments")));
|
|
||||||
} catch (const container::NoSuchElementException &) {}
|
|
||||||
try {
|
|
||||||
cont->insertByName(
|
|
||||||
(name +
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service"))),
|
|
||||||
css::uno::Any(i->second));
|
|
||||||
} catch (const container::ElementExistException &) {
|
|
||||||
cont->replaceByName(
|
|
||||||
(name +
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service"))),
|
|
||||||
css::uno::Any(i->second));
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
cont->insertByName(name, css::uno::Any());
|
|
||||||
} catch (const container::ElementExistException &) {
|
|
||||||
OSL_TRACE(
|
|
||||||
"singleton %s already registered",
|
|
||||||
rtl::OUStringToOString(
|
|
||||||
i->first, RTL_TEXTENCODING_UTF8).getStr());
|
|
||||||
cont->replaceByName(name, css::uno::Any());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void BackendImpl::componentLiveRemoval(ComponentBackendDb::Data const & data) {
|
|
||||||
css::uno::Reference< css::uno::XComponentContext > rootContext(
|
|
||||||
getRootContext());
|
|
||||||
css::uno::Reference< css::container::XSet > set(
|
|
||||||
rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
|
|
||||||
for (t_stringlist::const_iterator i(data.implementationNames.begin());
|
|
||||||
i != data.implementationNames.end(); ++i)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
set->remove(css::uno::Any(*i));
|
|
||||||
} catch (const css::container::NoSuchElementException &) {
|
|
||||||
// ignore if factory has not been live deployed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!data.singletons.empty()) {
|
|
||||||
css::uno::Reference< css::container::XNameContainer > cont(
|
|
||||||
rootContext, css::uno::UNO_QUERY_THROW);
|
|
||||||
for (t_stringpairvec::const_iterator i(data.singletons.begin());
|
|
||||||
i != data.singletons.end(); ++i)
|
|
||||||
{
|
|
||||||
rtl::OUString name(
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
|
|
||||||
i->first);
|
|
||||||
//TODO: Removal should be atomic:
|
|
||||||
try {
|
|
||||||
cont->removeByName(name);
|
|
||||||
} catch (const container::NoSuchElementException &) {}
|
|
||||||
try {
|
|
||||||
cont->removeByName(
|
|
||||||
name +
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service")));
|
|
||||||
} catch (const container::NoSuchElementException &) {}
|
|
||||||
try {
|
|
||||||
cont->removeByName(
|
|
||||||
name +
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/arguments")));
|
|
||||||
} catch (const container::NoSuchElementException &) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
css::uno::Reference< css::uno::XComponentContext > BackendImpl::getRootContext()
|
css::uno::Reference< css::uno::XComponentContext > BackendImpl::getRootContext()
|
||||||
const
|
const
|
||||||
{
|
{
|
||||||
@ -1448,6 +1261,56 @@ Reference<XComponentContext> raise_uno_process(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void extractComponentData(
|
||||||
|
css::uno::Reference< css::uno::XComponentContext > const & context,
|
||||||
|
css::uno::Reference< css::registry::XRegistryKey > const & registry,
|
||||||
|
ComponentBackendDb::Data * data,
|
||||||
|
std::vector< css::uno::Reference< css::uno::XInterface > > * factories,
|
||||||
|
css::uno::Reference< css::loader::XImplementationLoader > const &
|
||||||
|
componentLoader,
|
||||||
|
rtl::OUString const & componentUrl)
|
||||||
|
{
|
||||||
|
OSL_ASSERT(
|
||||||
|
context.is() && registry.is() && data != 0 && componentLoader.is());
|
||||||
|
rtl::OUString registryName(registry->getKeyName());
|
||||||
|
sal_Int32 prefix = registryName.getLength();
|
||||||
|
if (!registryName.endsWithAsciiL(RTL_CONSTASCII_STRINGPARAM("/"))) {
|
||||||
|
prefix += RTL_CONSTASCII_LENGTH("/");
|
||||||
|
}
|
||||||
|
css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > >
|
||||||
|
keys(registry->openKeys());
|
||||||
|
css::uno::Reference< css::lang::XMultiComponentFactory > smgr(
|
||||||
|
context->getServiceManager(), css::uno::UNO_QUERY_THROW);
|
||||||
|
for (sal_Int32 i = 0; i < keys.getLength(); ++i) {
|
||||||
|
rtl::OUString name(keys[i]->getKeyName().copy(prefix));
|
||||||
|
data->implementationNames.push_back(name);
|
||||||
|
css::uno::Reference< css::registry::XRegistryKey > singletons(
|
||||||
|
keys[i]->openKey(
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNO/SINGLETONS"))));
|
||||||
|
if (singletons.is()) {
|
||||||
|
sal_Int32 prefix2 = keys[i]->getKeyName().getLength() +
|
||||||
|
RTL_CONSTASCII_LENGTH("/UNO/SINGLETONS/");
|
||||||
|
css::uno::Sequence<
|
||||||
|
css::uno::Reference< css::registry::XRegistryKey > >
|
||||||
|
singletonKeys(singletons->openKeys());
|
||||||
|
for (sal_Int32 j = 0; j < singletonKeys.getLength(); ++j) {
|
||||||
|
data->singletons.push_back(
|
||||||
|
std::pair< rtl::OUString, rtl::OUString >(
|
||||||
|
singletonKeys[j]->getKeyName().copy(prefix2), name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (factories != 0) {
|
||||||
|
factories->push_back(
|
||||||
|
componentLoader->activate(
|
||||||
|
name, rtl::OUString(), componentUrl, keys[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void BackendImpl::ComponentPackageImpl::getComponentInfo(
|
void BackendImpl::ComponentPackageImpl::getComponentInfo(
|
||||||
ComponentBackendDb::Data * data,
|
ComponentBackendDb::Data * data,
|
||||||
std::vector< css::uno::Reference< css::uno::XInterface > > * factories,
|
std::vector< css::uno::Reference< css::uno::XInterface > > * factories,
|
||||||
@ -1478,8 +1341,112 @@ void BackendImpl::ComponentPackageImpl::getComponentInfo(
|
|||||||
UNO_QUERY_THROW );
|
UNO_QUERY_THROW );
|
||||||
xMemReg->open( OUString() /* in mem */, false, true );
|
xMemReg->open( OUString() /* in mem */, false, true );
|
||||||
xLoader->writeRegistryInfo( xMemReg->getRootKey(), OUString(), url );
|
xLoader->writeRegistryInfo( xMemReg->getRootKey(), OUString(), url );
|
||||||
getMyBackend()->extractComponentData(
|
extractComponentData(
|
||||||
xContext, xMemReg->getRootKey(), data, factories, &xLoader, &url);
|
xContext, xMemReg->getRootKey(), data, factories, xLoader, url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BackendImpl::ComponentPackageImpl::componentLiveInsertion(
|
||||||
|
ComponentBackendDb::Data const & data,
|
||||||
|
std::vector< css::uno::Reference< css::uno::XInterface > > const &
|
||||||
|
factories)
|
||||||
|
{
|
||||||
|
css::uno::Reference< css::uno::XComponentContext > rootContext(
|
||||||
|
getMyBackend()->getRootContext());
|
||||||
|
css::uno::Reference< css::container::XSet > set(
|
||||||
|
rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
|
||||||
|
std::vector< css::uno::Reference< css::uno::XInterface > >::const_iterator
|
||||||
|
factory(factories.begin());
|
||||||
|
for (t_stringlist::const_iterator i(data.implementationNames.begin());
|
||||||
|
i != data.implementationNames.end(); ++i)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
set->insert(css::uno::Any(*factory++));
|
||||||
|
} catch (const container::ElementExistException &) {
|
||||||
|
OSL_TRACE(
|
||||||
|
"implementation %s already registered",
|
||||||
|
rtl::OUStringToOString(*i, RTL_TEXTENCODING_UTF8).getStr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!data.singletons.empty()) {
|
||||||
|
css::uno::Reference< css::container::XNameContainer > cont(
|
||||||
|
rootContext, css::uno::UNO_QUERY_THROW);
|
||||||
|
for (t_stringpairvec::const_iterator i(data.singletons.begin());
|
||||||
|
i != data.singletons.end(); ++i)
|
||||||
|
{
|
||||||
|
rtl::OUString name(
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
|
||||||
|
i->first);
|
||||||
|
//TODO: Update should be atomic:
|
||||||
|
try {
|
||||||
|
cont->removeByName(
|
||||||
|
name +
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/arguments")));
|
||||||
|
} catch (const container::NoSuchElementException &) {}
|
||||||
|
try {
|
||||||
|
cont->insertByName(
|
||||||
|
(name +
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service"))),
|
||||||
|
css::uno::Any(i->second));
|
||||||
|
} catch (const container::ElementExistException &) {
|
||||||
|
cont->replaceByName(
|
||||||
|
(name +
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service"))),
|
||||||
|
css::uno::Any(i->second));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
cont->insertByName(name, css::uno::Any());
|
||||||
|
} catch (const container::ElementExistException &) {
|
||||||
|
OSL_TRACE(
|
||||||
|
"singleton %s already registered",
|
||||||
|
rtl::OUStringToOString(
|
||||||
|
i->first, RTL_TEXTENCODING_UTF8).getStr());
|
||||||
|
cont->replaceByName(name, css::uno::Any());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void BackendImpl::ComponentPackageImpl::componentLiveRemoval(
|
||||||
|
ComponentBackendDb::Data const & data)
|
||||||
|
{
|
||||||
|
css::uno::Reference< css::uno::XComponentContext > rootContext(
|
||||||
|
getMyBackend()->getRootContext());
|
||||||
|
css::uno::Reference< css::container::XSet > set(
|
||||||
|
rootContext->getServiceManager(), css::uno::UNO_QUERY_THROW);
|
||||||
|
for (t_stringlist::const_iterator i(data.implementationNames.begin());
|
||||||
|
i != data.implementationNames.end(); ++i)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
set->remove(css::uno::Any(*i));
|
||||||
|
} catch (const css::container::NoSuchElementException &) {
|
||||||
|
// ignore if factory has not been live deployed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!data.singletons.empty()) {
|
||||||
|
css::uno::Reference< css::container::XNameContainer > cont(
|
||||||
|
rootContext, css::uno::UNO_QUERY_THROW);
|
||||||
|
for (t_stringpairvec::const_iterator i(data.singletons.begin());
|
||||||
|
i != data.singletons.end(); ++i)
|
||||||
|
{
|
||||||
|
rtl::OUString name(
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/singletons/")) +
|
||||||
|
i->first);
|
||||||
|
//TODO: Removal should be atomic:
|
||||||
|
try {
|
||||||
|
cont->removeByName(name);
|
||||||
|
} catch (const container::NoSuchElementException &) {}
|
||||||
|
try {
|
||||||
|
cont->removeByName(
|
||||||
|
name +
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/service")));
|
||||||
|
} catch (const container::NoSuchElementException &) {}
|
||||||
|
try {
|
||||||
|
cont->removeByName(
|
||||||
|
name +
|
||||||
|
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/arguments")));
|
||||||
|
} catch (const container::NoSuchElementException &) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Package
|
// Package
|
||||||
@ -1608,7 +1575,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_(
|
|||||||
std::vector< css::uno::Reference< css::uno::XInterface > > factories;
|
std::vector< css::uno::Reference< css::uno::XInterface > > factories;
|
||||||
getComponentInfo(&data, startup ? 0 : &factories, context);
|
getComponentInfo(&data, startup ? 0 : &factories, context);
|
||||||
if (!startup) {
|
if (!startup) {
|
||||||
that->componentLiveInsertion(data, factories);
|
componentLiveInsertion(data, factories);
|
||||||
}
|
}
|
||||||
m_registered = REG_REGISTERED;
|
m_registered = REG_REGISTERED;
|
||||||
that->addDataToDb(url, data);
|
that->addDataToDb(url, data);
|
||||||
@ -1622,7 +1589,7 @@ void BackendImpl::ComponentPackageImpl::processPackage_(
|
|||||||
context = that->getComponentContext();
|
context = that->getComponentContext();
|
||||||
}
|
}
|
||||||
if (!startup) {
|
if (!startup) {
|
||||||
that->componentLiveRemoval(data);
|
componentLiveRemoval(data);
|
||||||
}
|
}
|
||||||
css::uno::Reference< css::registry::XImplementationRegistration >(
|
css::uno::Reference< css::registry::XImplementationRegistration >(
|
||||||
context->getServiceManager()->createInstanceWithContext(
|
context->getServiceManager()->createInstanceWithContext(
|
||||||
@ -1913,13 +1880,9 @@ void BackendImpl::ComponentsPackageImpl::processPackage_(
|
|||||||
BackendImpl * that = getMyBackend();
|
BackendImpl * that = getMyBackend();
|
||||||
rtl::OUString url(getURL());
|
rtl::OUString url(getURL());
|
||||||
if (doRegisterPackage) {
|
if (doRegisterPackage) {
|
||||||
ComponentBackendDb::Data data;
|
if (!startup) {
|
||||||
data.javaTypeLibrary = false;
|
css::uno::Reference< css::uno::XComponentContext > context(
|
||||||
css::uno::Reference< css::uno::XComponentContext > context;
|
that->getObject(url), css::uno::UNO_QUERY);
|
||||||
if (startup) {
|
|
||||||
context = that->getComponentContext();
|
|
||||||
} else {
|
|
||||||
context.set(that->getObject(url), css::uno::UNO_QUERY);
|
|
||||||
if (!context.is()) {
|
if (!context.is()) {
|
||||||
context.set(
|
context.set(
|
||||||
that->insertObject(
|
that->insertObject(
|
||||||
@ -1928,39 +1891,35 @@ void BackendImpl::ComponentsPackageImpl::processPackage_(
|
|||||||
that->getComponentContext(), abortChannel)),
|
that->getComponentContext(), abortChannel)),
|
||||||
css::uno::UNO_QUERY_THROW);
|
css::uno::UNO_QUERY_THROW);
|
||||||
}
|
}
|
||||||
|
// This relies on the root component context's service manager
|
||||||
|
// supporting the extended XSet semantics:
|
||||||
|
css::uno::Sequence< css::beans::NamedValue > args(2);
|
||||||
|
args[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uri"));
|
||||||
|
args[0].Value <<= expandUnoRcUrl(url);
|
||||||
|
args[1].Name = rtl::OUString(
|
||||||
|
RTL_CONSTASCII_USTRINGPARAM("component-context"));
|
||||||
|
args[1].Value <<= context;
|
||||||
|
css::uno::Reference< css::container::XSet > smgr(
|
||||||
|
that->getRootContext()->getServiceManager(),
|
||||||
|
css::uno::UNO_QUERY_THROW);
|
||||||
|
smgr->insert(css::uno::makeAny(args));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< css::uno::Reference< css::uno::XInterface > > factories;
|
|
||||||
|
|
||||||
css::uno::Reference< css::registry::XSimpleRegistry > registry(
|
|
||||||
css::uno::Reference< css::lang::XMultiComponentFactory >(
|
|
||||||
that->getComponentContext()->getServiceManager(),
|
|
||||||
css::uno::UNO_SET_THROW)->createInstanceWithContext(
|
|
||||||
rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM(
|
|
||||||
"com.sun.star.registry.SimpleRegistry")),
|
|
||||||
that->getComponentContext()),
|
|
||||||
css::uno::UNO_QUERY_THROW);
|
|
||||||
registry->open(expandUnoRcUrl(url), true, false);
|
|
||||||
getMyBackend()->extractComponentData(
|
|
||||||
context,
|
|
||||||
that->openRegistryKey(
|
|
||||||
registry->getRootKey(),
|
|
||||||
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IMPLEMENTATIONS"))),
|
|
||||||
&data, startup ? 0 : &factories, 0, 0);
|
|
||||||
registry->close();
|
|
||||||
if (!startup) {
|
|
||||||
that->componentLiveInsertion(data, factories);
|
|
||||||
}
|
|
||||||
that->addDataToDb(url, data);
|
|
||||||
that->addToUnoRc(RCITEM_COMPONENTS, url, xCmdEnv);
|
that->addToUnoRc(RCITEM_COMPONENTS, url, xCmdEnv);
|
||||||
} else { // revoke
|
} else { // revoke
|
||||||
that->removeFromUnoRc(RCITEM_COMPONENTS, url, xCmdEnv);
|
that->removeFromUnoRc(RCITEM_COMPONENTS, url, xCmdEnv);
|
||||||
if (!startup) {
|
if (!startup) {
|
||||||
that->componentLiveRemoval(that->readDataFromDb(url));
|
// This relies on the root component context's service manager
|
||||||
|
// supporting the extended XSet semantics:
|
||||||
|
css::uno::Sequence< css::beans::NamedValue > args(1);
|
||||||
|
args[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uri"));
|
||||||
|
args[0].Value <<= expandUnoRcUrl(url);
|
||||||
|
css::uno::Reference< css::container::XSet > smgr(
|
||||||
|
that->getRootContext()->getServiceManager(),
|
||||||
|
css::uno::UNO_QUERY_THROW);
|
||||||
|
smgr->remove(css::uno::makeAny(args));
|
||||||
}
|
}
|
||||||
that->releaseObject(url);
|
that->releaseObject(url);
|
||||||
that->revokeEntryFromDb(url);
|
that->revokeEntryFromDb(url); // in case it got added with old code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,6 @@
|
|||||||
#include "cppuhelper/implbase2.hxx"
|
#include "cppuhelper/implbase2.hxx"
|
||||||
#include "cppuhelper/weak.hxx"
|
#include "cppuhelper/weak.hxx"
|
||||||
#include "osl/mutex.hxx"
|
#include "osl/mutex.hxx"
|
||||||
#include "osl/file.hxx"
|
|
||||||
#include "registry/registry.hxx"
|
#include "registry/registry.hxx"
|
||||||
#include "registry/regtype.h"
|
#include "registry/regtype.h"
|
||||||
#include "rtl/ref.hxx"
|
#include "rtl/ref.hxx"
|
||||||
@ -85,12 +84,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException);
|
virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException);
|
||||||
|
|
||||||
virtual void SAL_CALL openRdb(
|
|
||||||
rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
|
|
||||||
throw (
|
|
||||||
css::registry::InvalidRegistryException,
|
|
||||||
css::uno::RuntimeException);
|
|
||||||
|
|
||||||
virtual void SAL_CALL open(
|
virtual void SAL_CALL open(
|
||||||
rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
|
rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
|
||||||
throw (
|
throw (
|
||||||
@ -1137,17 +1130,27 @@ rtl::OUString Key::getResolvedName(rtl::OUString const & aKeyName)
|
|||||||
return resolved;
|
return resolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtl::OUString SimpleRegistry::getURL() throw (css::uno::RuntimeException)
|
rtl::OUString SimpleRegistry::getURL() throw (css::uno::RuntimeException) {
|
||||||
{
|
|
||||||
osl::MutexGuard guard(mutex_);
|
osl::MutexGuard guard(mutex_);
|
||||||
return textual_.get() == 0 ? registry_.getName() : textual_->getUri();
|
return textual_.get() == 0 ? registry_.getName() : textual_->getUri();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRegistry::openRdb(
|
void SimpleRegistry::open(
|
||||||
rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
|
rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
|
||||||
throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
|
throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
|
||||||
{
|
{
|
||||||
osl::MutexGuard guard(mutex_);
|
osl::MutexGuard guard(mutex_);
|
||||||
|
if (textual_.get() != 0) {
|
||||||
|
throw css::registry::InvalidRegistryException(
|
||||||
|
(rtl::OUString(
|
||||||
|
RTL_CONSTASCII_USTRINGPARAM(
|
||||||
|
"com.sun.star.registry.SimpleRegistry.open(")) +
|
||||||
|
rURL +
|
||||||
|
rtl::OUString(
|
||||||
|
RTL_CONSTASCII_USTRINGPARAM(
|
||||||
|
"): instance already open"))),
|
||||||
|
static_cast< OWeakObject * >(this));
|
||||||
|
}
|
||||||
RegError err = (rURL.isEmpty() && bCreate)
|
RegError err = (rURL.isEmpty() && bCreate)
|
||||||
? REG_REGISTRY_NOT_EXISTS
|
? REG_REGISTRY_NOT_EXISTS
|
||||||
: registry_.open(rURL, bReadOnly ? REG_READONLY : REG_READWRITE);
|
: registry_.open(rURL, bReadOnly ? REG_READONLY : REG_READWRITE);
|
||||||
@ -1159,10 +1162,7 @@ void SimpleRegistry::openRdb(
|
|||||||
break;
|
break;
|
||||||
case REG_INVALID_REGISTRY:
|
case REG_INVALID_REGISTRY:
|
||||||
if (bReadOnly && !bCreate) {
|
if (bReadOnly && !bCreate) {
|
||||||
if (!textual_.get())
|
textual_.reset(new stoc::simpleregistry::TextualServices(rURL));
|
||||||
textual_.reset(new stoc::simpleregistry::TextualServices(rURL));
|
|
||||||
else
|
|
||||||
textual_->merge(rURL);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
@ -1180,72 +1180,6 @@ void SimpleRegistry::openRdb(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleRegistry::open(
|
|
||||||
rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate)
|
|
||||||
throw (css::registry::InvalidRegistryException, css::uno::RuntimeException)
|
|
||||||
{
|
|
||||||
osl::MutexGuard guard(mutex_);
|
|
||||||
|
|
||||||
osl::DirectoryItem aItem;
|
|
||||||
osl::FileBase::RC eErr;
|
|
||||||
osl::FileStatus aStatus(osl_FileStatus_Mask_Type);
|
|
||||||
|
|
||||||
// FIXME: busts the 'create' mode ...
|
|
||||||
if ((eErr = osl::DirectoryItem::get( rURL, aItem )) != osl::FileBase::E_None ||
|
|
||||||
(eErr = aItem.getFileStatus( aStatus )) != osl::FileBase::E_None ||
|
|
||||||
!aStatus.isDirectory())
|
|
||||||
{
|
|
||||||
if (textual_.get() != 0)
|
|
||||||
throw css::registry::InvalidRegistryException(
|
|
||||||
(rtl::OUString("com.sun.star.registry.SimpleRegistry.open(") +
|
|
||||||
rURL + rtl::OUString("): instance already open")),
|
|
||||||
static_cast< OWeakObject * >(this));
|
|
||||||
openRdb (rURL, bReadOnly, bCreate);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
osl::Directory dir(rURL);
|
|
||||||
eErr = dir.open();
|
|
||||||
if (eErr != osl::FileBase::E_None)
|
|
||||||
goto err_throw;
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
osl::DirectoryItem i;
|
|
||||||
if (dir.getNextItem(i, SAL_MAX_UINT32) != osl::FileBase::E_None)
|
|
||||||
break;
|
|
||||||
osl::FileStatus stat(osl_FileStatus_Mask_Type | osl_FileStatus_Mask_FileName |
|
|
||||||
osl_FileStatus_Mask_FileURL);
|
|
||||||
if (i.getFileStatus(stat) != osl::FileBase::E_None)
|
|
||||||
throw css::uno::RuntimeException(
|
|
||||||
(rtl::OUString("cannot stat in directory ") + rURL ),
|
|
||||||
css::uno::Reference< css::uno::XInterface >());
|
|
||||||
|
|
||||||
rtl::OUString aName = stat.getFileName();
|
|
||||||
|
|
||||||
// Ignore backup files - to allow people to edit their
|
|
||||||
// services/ without extremely confusing behaviour
|
|
||||||
if (aName.toChar() == '.' || aName.endsWithAsciiL("~", 1))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (stat.getFileType() != osl::FileStatus::Directory)
|
|
||||||
openRdb(stat.getFileURL(), bReadOnly, bCreate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
err_throw:
|
|
||||||
throw css::registry::InvalidRegistryException(
|
|
||||||
(rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM(
|
|
||||||
"com.sun.star.registry.SimpleRegistry.open(")) +
|
|
||||||
rURL +
|
|
||||||
rtl::OUString(
|
|
||||||
RTL_CONSTASCII_USTRINGPARAM(
|
|
||||||
"): error statting url = ")) +
|
|
||||||
rtl::OUString::valueOf(static_cast< sal_Int32 >(eErr))),
|
|
||||||
static_cast< OWeakObject * >(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
sal_Bool SimpleRegistry::isValid() throw (css::uno::RuntimeException) {
|
sal_Bool SimpleRegistry::isValid() throw (css::uno::RuntimeException) {
|
||||||
osl::MutexGuard guard(mutex_);
|
osl::MutexGuard guard(mutex_);
|
||||||
return textual_.get() != 0 || registry_.isValid();
|
return textual_.get() != 0 || registry_.isValid();
|
||||||
|
@ -1235,15 +1235,6 @@ css::uno::Sequence< rtl::OUString > Key::getChildren() {
|
|||||||
|
|
||||||
TextualServices::TextualServices(rtl::OUString const & uri):
|
TextualServices::TextualServices(rtl::OUString const & uri):
|
||||||
uri_(uri), data_(new Data)
|
uri_(uri), data_(new Data)
|
||||||
{
|
|
||||||
merge(uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextualServices::~TextualServices() {}
|
|
||||||
|
|
||||||
// load and merge registry contents from uri
|
|
||||||
void TextualServices::merge(const rtl::OUString &uri)
|
|
||||||
throw (com::sun::star::registry::InvalidRegistryException)
|
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
Parser(uri, data_);
|
Parser(uri, data_);
|
||||||
@ -1256,6 +1247,8 @@ void TextualServices::merge(const rtl::OUString &uri)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextualServices::~TextualServices() {}
|
||||||
|
|
||||||
css::uno::Reference< css::registry::XRegistryKey > TextualServices::getRootKey()
|
css::uno::Reference< css::registry::XRegistryKey > TextualServices::getRootKey()
|
||||||
{
|
{
|
||||||
return new Key(data_, std::vector< rtl::OUString >());
|
return new Key(data_, std::vector< rtl::OUString >());
|
||||||
|
@ -53,9 +53,6 @@ public:
|
|||||||
|
|
||||||
virtual ~TextualServices();
|
virtual ~TextualServices();
|
||||||
|
|
||||||
void merge(const rtl::OUString &uri)
|
|
||||||
throw (com::sun::star::registry::InvalidRegistryException);
|
|
||||||
|
|
||||||
inline rtl::OUString getUri() { return uri_; }
|
inline rtl::OUString getUri() { return uri_; }
|
||||||
|
|
||||||
com::sun::star::uno::Reference< com::sun::star::registry::XRegistryKey >
|
com::sun::star::uno::Reference< com::sun::star::registry::XRegistryKey >
|
||||||
|
@ -75,6 +75,21 @@ module com { module sun { module star { module lang {
|
|||||||
on the factory when going down (i.e. it is commonly disposed by the component context).</dd>
|
on the factory when going down (i.e. it is commonly disposed by the component context).</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
|
<p>Since LibreOffice 3.6, in addition to instances of
|
||||||
|
<type>XServiceInfo</type> et al, the
|
||||||
|
<type scope="com::sun::star::container">XSet</type> of at least the default
|
||||||
|
C++ service manager implementation now also supports sequences of
|
||||||
|
<type scope="com::sun::star::beans">NamedValue</type> in <code>insert</code>
|
||||||
|
and <code>remove</code>. The sequence elements must each have a
|
||||||
|
<code>Name</code> of <code>uri</code> and a string <code>Value</code> that
|
||||||
|
is the URI of a service rdb. It is legal for there to be no such
|
||||||
|
<code>uri</code> elements. For <code>insert</code>, there can additionally
|
||||||
|
be an optional element with a <code>Name</code> of
|
||||||
|
<code>component-context</code> and a value that is a non-null reference of
|
||||||
|
type <type scope="com::sun::star::uno">XComponentContext</type> that shall
|
||||||
|
be used instead of this service manager's default component context when
|
||||||
|
loading the corresponding implementations.
|
||||||
|
|
||||||
@see com::sun::star::uno::XComponentContext
|
@see com::sun::star::uno::XComponentContext
|
||||||
*/
|
*/
|
||||||
published service ServiceManager
|
published service ServiceManager
|
||||||
|
Loading…
x
Reference in New Issue
Block a user