2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-12-05 11:46:50 +00: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 .
|
|
|
|
*/
|
2000-12-19 14:01:16 +00:00
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
#include <sal/config.h>
|
2006-09-16 11:42:31 +00:00
|
|
|
|
2013-12-16 21:39:14 +01:00
|
|
|
#include <cassert>
|
2013-12-19 08:48:56 +01:00
|
|
|
#include <cstdlib>
|
2013-12-16 21:39:14 +01:00
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
#include <com/sun/star/loader/CannotActivateFactoryException.hpp>
|
2014-11-18 00:06:30 +01:00
|
|
|
#include <com/sun/star/registry/CannotRegisterImplementationException.hpp>
|
2013-12-19 08:48:56 +01:00
|
|
|
#include <cppuhelper/factory.hxx>
|
|
|
|
#include <cppuhelper/shlib.hxx>
|
|
|
|
#include <osl/module.hxx>
|
2015-04-22 09:42:28 +02:00
|
|
|
#include <sal/log.hxx>
|
2013-12-19 08:48:56 +01:00
|
|
|
#include <uno/environment.hxx>
|
|
|
|
#include <uno/mapping.hxx>
|
2003-09-04 09:54:36 +00:00
|
|
|
|
2014-06-04 16:23:19 +02:00
|
|
|
#include "loadsharedlibcomponentfactory.hxx"
|
2013-12-13 15:10:18 +01:00
|
|
|
|
2014-01-01 18:54:50 +01:00
|
|
|
#if defined DISABLE_DYNLOADING
|
2013-10-13 20:45:16 +03:00
|
|
|
#include <osl/detail/component-mapping.h>
|
2012-04-09 22:40:17 +03:00
|
|
|
#endif
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
css::uno::Environment cppuhelper::detail::getEnvironment(
|
|
|
|
rtl::OUString const & name, rtl::OUString const & implementation)
|
2013-12-16 21:39:14 +01:00
|
|
|
{
|
2013-12-19 08:48:56 +01:00
|
|
|
assert(!implementation.isEmpty());
|
|
|
|
rtl::OUString n(name);
|
|
|
|
static char const * log = std::getenv("UNO_ENV_LOG");
|
2015-11-10 10:13:11 +01:00
|
|
|
if (log != nullptr && *log != 0) {
|
2013-12-19 08:48:56 +01:00
|
|
|
rtl::OString imps(log);
|
|
|
|
for (sal_Int32 i = 0; i != -1;) {
|
|
|
|
rtl::OString imp(imps.getToken(0, ';', i));
|
|
|
|
//TODO: this assumes UNO_ENV_LOG only contains ASCII characters:
|
|
|
|
if (implementation.equalsAsciiL(imp.getStr(), imp.getLength())) {
|
|
|
|
n += ":log";
|
2013-12-16 21:39:14 +01:00
|
|
|
break;
|
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
}
|
2013-12-16 21:39:14 +01:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
return css::uno::Environment(n);
|
2013-12-16 21:39:14 +01:00
|
|
|
}
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
namespace {
|
2007-05-09 12:26:03 +00:00
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
#if !defined DISABLE_DYNLOADING
|
2007-05-09 12:26:03 +00:00
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
css::uno::Environment getEnvironmentFromModule(
|
|
|
|
osl::Module const & module, css::uno::Environment const & target,
|
|
|
|
rtl::OUString const & implementation, rtl::OUString const & prefix)
|
|
|
|
{
|
2015-11-10 10:13:11 +01:00
|
|
|
char const * name = nullptr;
|
2013-12-19 08:48:56 +01:00
|
|
|
css::uno::Environment env;
|
|
|
|
rtl::OUString fullPrefix(prefix);
|
|
|
|
if (!fullPrefix.isEmpty()) {
|
|
|
|
fullPrefix += "_";
|
2007-05-09 12:26:03 +00:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
component_getImplementationEnvironmentExtFunc fp1
|
|
|
|
= reinterpret_cast<component_getImplementationEnvironmentExtFunc>(
|
|
|
|
module.getFunctionSymbol(fullPrefix + COMPONENT_GETENVEXT));
|
2015-11-10 10:13:11 +01:00
|
|
|
if (fp1 != nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
(*fp1)(
|
|
|
|
&name, reinterpret_cast<uno_Environment **>(&env),
|
|
|
|
(rtl::OUStringToOString(implementation, RTL_TEXTENCODING_ASCII_US)
|
|
|
|
.getStr()),
|
|
|
|
target.get());
|
|
|
|
} else {
|
|
|
|
component_getImplementationEnvironmentFunc fp2
|
|
|
|
= reinterpret_cast<component_getImplementationEnvironmentFunc>(
|
|
|
|
module.getFunctionSymbol(fullPrefix + COMPONENT_GETENV));
|
2015-11-10 10:13:11 +01:00
|
|
|
if (fp2 != nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
(*fp2)(&name, reinterpret_cast<uno_Environment **>(&env));
|
|
|
|
} else {
|
|
|
|
name = CPPU_CURRENT_LANGUAGE_BINDING_NAME; //TODO: fail
|
|
|
|
}
|
2007-05-09 12:26:03 +00:00
|
|
|
}
|
2015-11-10 10:13:11 +01:00
|
|
|
if (!env.is() && name != nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
env = cppuhelper::detail::getEnvironment(
|
|
|
|
rtl::OUString::createFromAscii(name), implementation);
|
CWS-TOOLING: integrate CWS dba32e
2009-08-10 13:16:25 +0200 fs r274805 : #i84390# typo corrected
2009-08-10 13:04:28 +0200 fs r274804 : #i103741# properly terminate the last token in a string with a 0 byte
2009-07-24 08:54:05 +0200 msc r274286 : #103219# changed long name
2009-07-24 08:42:28 +0200 msc r274285 : #i79649# changed behaviour of the wizard
2009-07-22 14:17:49 +0200 oj r274238 : GrabFocus
2009-07-22 13:38:01 +0200 oj r274232 : #i102934# mixed up
2009-07-22 13:37:16 +0200 oj r274231 : #i102934# mixed up
2009-07-21 12:30:36 +0200 oj r274176 : crash when using distinct
2009-07-21 10:03:44 +0200 oj r274163 : set last char to 0
2009-07-21 09:31:22 +0200 oj r274161 : mediatype corrected
2009-07-20 11:45:33 +0200 fs r274118 : typo in formatting string
2009-07-20 11:40:39 +0200 fs r274117 : removed unused include
2009-07-20 11:40:01 +0200 fs r274116 : class name corrected
2009-07-16 13:41:45 +0200 oj r274046 : i101587 wrong check for embeddeddatabase url in confguration, have to check path
2009-07-16 13:12:05 +0200 tbo r274044 : #i103219# adjust declarion to new hid.lst
2009-07-16 12:43:48 +0200 oj r274041 : #i102497# check also fot longvarchar
2009-07-16 12:15:41 +0200 oj r274039 : #i103030# handle type description and exceptions as well
2009-07-16 11:14:26 +0200 fs r274035 : let SVN ignore output paths
2009-07-16 09:23:43 +0200 fs r274030 : TransforFormComponentProperties: no need to check for attribute equality
2009-07-10 14:16:23 +0200 oj r273892 : CWS-TOOLING: rebase CWS dba32e to trunk@273858 (milestone: DEV300:m52)
2009-07-01 21:41:50 +0200 fs r273614 : #i10000#
2009-07-01 15:01:10 +0200 fs r273589 : Input required doesn't make sense at all in XML form documents
2009-07-01 12:10:31 +0200 fs r273562 : updated
2009-07-01 11:46:12 +0200 fs r273560 : #i103219# add about 100 missing long names
2009-07-01 10:11:41 +0200 fs r273551 : moved from socket/port usage to pipe/name usage, which is more common nowadays
2009-07-01 09:50:03 +0200 fs r273549 : removed obsolete (empty) folder
2009-07-01 09:47:35 +0200 fs r273548 : copied the code for the Accessibility Workbench herein, formerly located in the old CVS repository, at gsl/awb
2009-06-30 10:07:47 +0200 fs r273493 : merging latest changes from CWS dba32d
2009-06-29 20:46:31 +0200 fs r273482 : #i103138# Rectangle conversions
2009-06-29 10:01:13 +0200 fs r273453 : #i103138#
refactored the code for positioning/zooming the control
Basically, we now allow adjustControlGeometry_throw (formerly known as positionControl_throw and setControlZoom) to
take an additional ViewTransformation parameter, describing the transformation to obtain the actual
control position/size. Consequently, positionControl itself also allows for a ViewTransformation parameter.
This has become necessary since during painting, the device which we created our control for might not necessarily
have a proper MapMode set. In this case, if we would use this map mode for calculating the control's position/size,
this would lead to wrong results.
Note that this problem was introduced by the fix for #i101398#: During the fix, we postponed the control creation
to a later time (when it is really needed). At this later time, the MapMode at the device is broken, at the earlier
time where we formerly crearted the control (createPrimitive2DSequence), it is not yet broken.
Whether or not the MapMode is defined as "broken" might depend on one's point of view, however ...
I consider it broken, since:
- we need the map mode to obtain the proper zoom level, which is to be forwarded to the control
- there are scenarios where the MapMode is *not* set to MAP_PIXEL (in those scenarios, everything works
fine), and there are scenarios where it *is* set to MAP_PIXEL (in those the bug 103138 appears).
It somehow feels wrong that one cannot rely on the device's map mode this way, but on the other hand
one has no possibility to obtain the current zoom by other means.
Note that one issue (still to be submitted) is left: In the page pane of a Draw/Impress document, controls
have a wrong text size. This is because in this pane, the above-mentioned "broken" map mode is used,
which means the controls have a zoom of "1:1" set, which is wrong here.
2009-06-29 09:52:13 +0200 fs r273452 : during #i103138#: belongsToDevice is unused nowadays
2009-06-24 12:40:06 +0200 fs r273329 : #i102888# #i102899#
2009-06-24 12:10:29 +0200 oj r273327 : #i103030# some code changes
2009-06-24 09:44:14 +0200 oj r273311 : #i103030# some code changes
2009-06-24 09:24:42 +0200 oj r273309 : #i103030# add log
2009-06-24 09:03:29 +0200 fs r273308 : if a col's table name is schema.table, properly quote all parts
2009-06-24 08:56:06 +0200 oj r273307 : #i102691# changed string
2009-06-23 13:31:43 +0200 oj r273280 : #i102479# fix date, time and datetime
2009-06-23 12:51:28 +0200 oj r273277 : #i103020# clear old expression when updating to avoid dead pointers in treelist userdata
2009-06-23 12:17:16 +0200 oj r273275 : #i103030# add LogBridge
2009-06-23 11:53:10 +0200 oj r273272 : shawdowed var resolved
2009-06-23 11:48:49 +0200 oj r273270 : #i103030# add :log to uno env if var UNO_ENV_LOG is set
2009-06-23 11:47:47 +0200 oj r273269 : #i103030# add LogBridge
2009-06-23 11:47:11 +0200 oj r273268 : #i103030# add LogBridge
2009-06-23 08:05:08 +0200 oj r273253 : #i102934# add key for collapsing
2009-06-22 13:21:33 +0200 fs r273225 : merging latest changes from CWS dba32d
2009-06-22 13:15:22 +0200 fs r273221 : why restrict to 12 entries?
2009-06-22 08:12:21 +0200 oj r273196 : #i102655# choosen > chosen typo fixed
2009-06-22 08:08:04 +0200 oj r273195 : #i102657# typo fix
2009-06-22 08:06:28 +0200 oj r273194 : #i102934# expanding and collasping of section
2009-06-22 08:05:52 +0200 oj r273193 : #i102930# set focus in treelistbox
2009-06-22 08:04:56 +0200 oj r273192 : #i102929# enable tabstop
2009-06-19 13:18:26 +0200 oj r273157 : remove unused param
2009-06-19 10:07:05 +0200 oj r273149 : CWS-TOOLING: rebase CWS dba32e to trunk@272827 (milestone: DEV300:m50)
2009-06-19 07:32:40 +0200 oj r273146 : merge from dba32d to dba32e
2009-06-19 07:22:56 +0200 oj r273145 : merge from dba32d to dba32e
2009-06-19 07:22:33 +0200 oj r273144 : merge from dba32d to dba32e
2009-06-18 14:09:34 +0200 fs r273116 : merging the latest changes from CWS dba32d (up to revision 273108) herein, which effectively is a rebase to DEV300.m50
2009-06-18 08:50:35 +0200 oj r273098 : #i102894# fix for new line in text
2009-06-18 08:28:48 +0200 oj r273097 : #i102892# check any
2009-06-18 08:21:34 +0200 oj r273096 : check if error is valid
2009-06-16 13:49:28 +0200 fs r273019 : why make a drop down control by default? The form control factory in SVX does this better those days ...
2009-06-10 09:53:20 +0200 oj r272797 : add lic text
2009-06-10 09:48:55 +0200 oj r272796 : test added for i101618
2009-06-09 14:57:39 +0200 oj r272771 : #i101618# access database document only when script container is needed
2009-06-09 12:42:25 +0200 oj r272765 : #i102497# check type property
2009-06-09 12:32:49 +0200 oj r272764 : adjust test cases
2009-06-09 12:31:58 +0200 oj r272763 : adjust test cases
2009-06-09 12:31:22 +0200 oj r272762 : adjust test cases
2009-06-09 11:35:42 +0200 oj r272761 : check if error is valid
2009-06-09 11:29:42 +0200 oj r272760 : #i102497# longvarchar was missing
2009-06-08 14:52:49 +0200 fs r272733 : #i102564# when setting a new field, also set m_nFieldType
2009-06-08 13:51:20 +0200 oj r272730 : add tests
2009-06-05 14:38:01 +0200 oj r272686 : add dep
2009-06-05 14:35:00 +0200 oj r272684 : add new tests
2009-06-05 13:41:18 +0200 oj r272681 : code clean ups
2009-06-05 12:40:51 +0200 oj r272678 : code cleanup
2009-06-05 12:02:57 +0200 oj r272677 : code cleanup
2009-06-05 10:42:38 +0200 oj r272670 : #i49320# impl export of single rows and as RTF and HTML
2009-06-03 14:30:37 +0200 oj r272576 : #i79649# check if file matches filter wildcard
2009-06-03 13:41:57 +0200 oj r272560 : #i102470# impl not b like 'c'
2009-08-26 10:09:17 +00:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
return env;
|
2007-05-09 12:26:03 +00:00
|
|
|
}
|
|
|
|
|
2012-03-19 18:43:59 +02:00
|
|
|
#endif
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
extern "C" void getFactory(va_list * args) {
|
|
|
|
component_getFactoryFunc fn = va_arg(*args, component_getFactoryFunc);
|
|
|
|
rtl::OString const * implementation = va_arg(*args, rtl::OString const *);
|
|
|
|
void * smgr = va_arg(*args, void *);
|
|
|
|
void * key = va_arg(*args, void *);
|
|
|
|
void ** factory = va_arg(*args, void **);
|
|
|
|
*factory = (*fn)(implementation->getStr(), smgr, key);
|
2013-12-13 15:10:18 +01:00
|
|
|
}
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
css::uno::Reference<css::uno::XInterface> invokeComponentFactory(
|
|
|
|
css::uno::Environment const & source, css::uno::Environment const & target,
|
|
|
|
component_getFactoryFunc function, rtl::OUString const & uri,
|
|
|
|
rtl::OUString const & implementation,
|
|
|
|
css::uno::Reference<css::lang::XMultiServiceFactory> const & serviceManager)
|
2011-06-24 12:24:49 +01:00
|
|
|
{
|
2013-12-19 08:48:56 +01:00
|
|
|
if (!(source.is() && target.is())) {
|
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
"cannot get environments",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
|
|
|
}
|
|
|
|
rtl::OString impl(
|
|
|
|
rtl::OUStringToOString(implementation, RTL_TEXTENCODING_ASCII_US));
|
|
|
|
if (source.get() == target.get()) {
|
|
|
|
return css::uno::Reference<css::uno::XInterface>(
|
|
|
|
static_cast<css::uno::XInterface *>(
|
2015-11-10 10:13:11 +01:00
|
|
|
(*function)(impl.getStr(), serviceManager.get(), nullptr)),
|
2013-12-19 08:48:56 +01:00
|
|
|
SAL_NO_ACQUIRE);
|
|
|
|
} else {
|
|
|
|
css::uno::Mapping mapTo(source, target);
|
|
|
|
css::uno::Mapping mapFrom(target, source);
|
|
|
|
if (!(mapTo.is() && mapFrom.is())) {
|
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
"cannot get mappings",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
|
|
|
}
|
|
|
|
void * smgr = mapTo.mapInterface(
|
|
|
|
serviceManager.get(),
|
|
|
|
cppu::UnoType<css::lang::XMultiServiceFactory>::get());
|
2015-11-10 10:13:11 +01:00
|
|
|
void * factory = nullptr;
|
2013-12-19 08:48:56 +01:00
|
|
|
target.invoke(getFactory, function, &impl, smgr, 0, &factory);
|
2015-11-10 10:13:11 +01:00
|
|
|
if (smgr != nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
(*target.get()->pExtEnv->releaseInterface)(
|
|
|
|
target.get()->pExtEnv, smgr);
|
|
|
|
}
|
2015-11-10 10:13:11 +01:00
|
|
|
if (factory == nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
("calling factory function for \"" + implementation + "\" in <"
|
|
|
|
+ uri + "> returned null"),
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
|
|
|
}
|
|
|
|
css::uno::Reference<css::uno::XInterface> res;
|
|
|
|
mapFrom.mapInterface(
|
|
|
|
reinterpret_cast<void **>(&res), factory,
|
|
|
|
cppu::UnoType<css::uno::XInterface>::get());
|
|
|
|
(*target.get()->pExtEnv->releaseInterface)(
|
|
|
|
target.get()->pExtEnv, factory);
|
|
|
|
return res;
|
|
|
|
}
|
2013-12-13 15:10:18 +01:00
|
|
|
}
|
|
|
|
|
2011-06-24 12:24:49 +01:00
|
|
|
}
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
void cppuhelper::detail::loadSharedLibComponentFactory(
|
|
|
|
rtl::OUString const & uri, rtl::OUString const & environment,
|
|
|
|
rtl::OUString const & prefix, rtl::OUString const & implementation,
|
|
|
|
rtl::OUString const & constructor,
|
|
|
|
css::uno::Reference<css::lang::XMultiServiceFactory> const & serviceManager,
|
|
|
|
ImplementationConstructorFn ** constructorFunction,
|
|
|
|
css::uno::Reference<css::uno::XInterface> * factory)
|
2011-08-08 17:34:53 +03:00
|
|
|
{
|
2013-12-19 08:48:56 +01:00
|
|
|
assert(constructor.isEmpty() || !environment.isEmpty());
|
|
|
|
assert(
|
2015-11-10 10:13:11 +01:00
|
|
|
(constructorFunction == nullptr && constructor.isEmpty())
|
|
|
|
|| *constructorFunction == nullptr);
|
|
|
|
assert(factory != nullptr && !factory->is());
|
2013-12-19 08:48:56 +01:00
|
|
|
#if defined DISABLE_DYNLOADING
|
|
|
|
assert(!environment.isEmpty());
|
|
|
|
if (constructor.isEmpty()) {
|
|
|
|
css::uno::Environment curEnv(css::uno::Environment::getCurrent());
|
|
|
|
css::uno::Environment env(getEnvironment(environment, implementation));
|
|
|
|
if (!(curEnv.is() && env.is())) {
|
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
"cannot get environments",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
2011-08-08 17:34:53 +03:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
if (curEnv.get() != env.get()) {
|
|
|
|
std::abort();//TODO
|
2013-12-13 16:18:52 +01:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
rtl::OUString name(prefix == "direct" ? implementation : uri);
|
2014-01-24 16:40:53 +02:00
|
|
|
SAL_INFO("cppuhelper.shlib", "prefix=" << prefix << " implementation=" << implementation << " uri=" << uri);
|
2013-12-19 08:48:56 +01:00
|
|
|
lib_to_factory_mapping const * map = lo_get_factory_map();
|
2013-12-19 11:00:13 +01:00
|
|
|
component_getFactoryFunc fp = 0;
|
2013-12-19 08:48:56 +01:00
|
|
|
for (int i = 0; map[i].name != 0; ++i) {
|
|
|
|
if (name.equalsAscii(map[i].name)) {
|
|
|
|
fp = map[i].component_getFactory_function;
|
|
|
|
break;
|
2011-08-08 17:34:53 +03:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
}
|
|
|
|
if (fp == 0) {
|
2014-01-14 18:55:20 +02:00
|
|
|
SAL_WARN("cppuhelper", "unknown factory name \"" << name << "\"");
|
2014-04-25 12:12:22 +03:00
|
|
|
#if defined IOS && !defined SAL_LOG_WARN
|
|
|
|
// If the above SAL_WARN expanded to nothing, print to stderr...
|
|
|
|
fprintf(stderr, "Unknown factory name %s\n", OUStringToOString(name, RTL_TEXTENCODING_UTF8).getStr());
|
|
|
|
#endif
|
2013-12-19 08:48:56 +01:00
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
"unknown factory name \"" + name + "\"",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
|
|
|
}
|
|
|
|
*factory = invokeComponentFactory(
|
|
|
|
css::uno::Environment::getCurrent(),
|
|
|
|
getEnvironment(environment, implementation), fp, uri,
|
|
|
|
implementation, serviceManager);
|
|
|
|
} else {
|
2014-01-24 16:40:53 +02:00
|
|
|
SAL_INFO("cppuhelper.shlib", "constructor=" << constructor);
|
2013-12-19 08:48:56 +01:00
|
|
|
lib_to_constructor_mapping const * map = lo_get_constructor_map();
|
|
|
|
for (int i = 0; map[i].name != 0; ++i) {
|
|
|
|
if (constructor.equalsAscii(map[i].name)) {
|
|
|
|
*constructorFunction
|
|
|
|
= reinterpret_cast<ImplementationConstructorFn *>(
|
|
|
|
map[i].constructor_function);
|
|
|
|
return;
|
2011-08-08 17:34:53 +03:00
|
|
|
}
|
|
|
|
}
|
2014-01-14 18:55:20 +02:00
|
|
|
SAL_WARN("cppuhelper", "unknown constructor name \"" << constructor << "\"");
|
2014-04-25 12:12:22 +03:00
|
|
|
#if defined IOS && !defined SAL_LOG_WARN
|
|
|
|
// If the above SAL_WARN expanded to nothing, print to stderr...
|
|
|
|
fprintf(stderr, "Unknown constructor name %s\n", OUStringToOString(constructor, RTL_TEXTENCODING_UTF8).getStr());
|
|
|
|
#endif
|
2013-12-19 08:48:56 +01:00
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
"unknown constructor name \"" + constructor + "\"",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
2000-12-19 14:01:16 +00:00
|
|
|
}
|
2011-08-01 21:10:14 +03:00
|
|
|
#else
|
2013-12-19 08:48:56 +01:00
|
|
|
osl::Module mod(uri, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
|
|
|
|
if (!mod.is()) {
|
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
"loading component library <" + uri + "> failed",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
2012-03-19 18:43:59 +02:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
if (constructor.isEmpty()) {
|
|
|
|
rtl::OUString sym;
|
2015-05-02 12:25:43 +02:00
|
|
|
SAL_INFO("cppuhelper.shlib", "prefix=" << prefix << " implementation=" << implementation << " uri=" << uri);
|
2013-12-19 08:48:56 +01:00
|
|
|
if (prefix == "direct") {
|
2014-07-01 15:45:52 +02:00
|
|
|
sym = implementation.replace('.', '_') + "_" COMPONENT_GETFACTORY;
|
2013-12-19 08:48:56 +01:00
|
|
|
} else if (!prefix.isEmpty()) {
|
2014-07-01 15:45:52 +02:00
|
|
|
sym = prefix + "_" COMPONENT_GETFACTORY;
|
2013-12-16 21:39:14 +01:00
|
|
|
} else {
|
2013-12-19 08:48:56 +01:00
|
|
|
sym = COMPONENT_GETFACTORY;
|
2013-12-16 21:39:14 +01:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
oslGenericFunction fp = mod.getFunctionSymbol(sym);
|
2015-11-10 10:13:11 +01:00
|
|
|
if (fp == nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
("no factory symbol \"" + sym + "\" in component library <"
|
|
|
|
+ uri + ">"),
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
|
|
|
}
|
|
|
|
css::uno::Environment curEnv(css::uno::Environment::getCurrent());
|
|
|
|
*factory = invokeComponentFactory(
|
|
|
|
curEnv,
|
|
|
|
(environment.isEmpty()
|
|
|
|
? getEnvironmentFromModule(mod, curEnv, implementation, prefix)
|
|
|
|
: getEnvironment(environment, implementation)),
|
|
|
|
reinterpret_cast<component_getFactoryFunc>(fp), uri, implementation,
|
|
|
|
serviceManager);
|
|
|
|
} else {
|
2015-05-02 12:25:43 +02:00
|
|
|
SAL_INFO("cppuhelper.shlib", "constructor=" << constructor);
|
2013-12-19 08:48:56 +01:00
|
|
|
oslGenericFunction fp = mod.getFunctionSymbol(constructor);
|
2015-11-10 10:13:11 +01:00
|
|
|
if (fp == nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
throw css::loader::CannotActivateFactoryException(
|
|
|
|
("no constructor symbol \"" + constructor
|
|
|
|
+ "\" in component library <" + uri + ">"),
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
|
|
|
}
|
|
|
|
*constructorFunction = reinterpret_cast<ImplementationConstructorFn *>(
|
|
|
|
fp);
|
2011-08-07 19:40:44 +03:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
mod.release();
|
2012-10-07 07:52:26 +03:00
|
|
|
#endif
|
2000-12-19 14:01:16 +00:00
|
|
|
}
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
css::uno::Reference<css::uno::XInterface> cppu::loadSharedLibComponentFactory(
|
|
|
|
rtl::OUString const & uri, rtl::OUString const & rPath,
|
|
|
|
rtl::OUString const & rImplName,
|
|
|
|
css::uno::Reference<css::lang::XMultiServiceFactory> const & xMgr,
|
|
|
|
css::uno::Reference<css::registry::XRegistryKey> const & xKey)
|
2007-05-09 12:26:03 +00:00
|
|
|
{
|
2013-12-19 08:48:56 +01:00
|
|
|
assert(rPath.isEmpty()); (void) rPath;
|
|
|
|
assert(!xKey.is()); (void) xKey;
|
|
|
|
css::uno::Reference<css::uno::XInterface> fac;
|
|
|
|
cppuhelper::detail::loadSharedLibComponentFactory(
|
2015-11-10 10:13:11 +01:00
|
|
|
uri, "", "", rImplName, "", xMgr, nullptr, &fac);
|
2013-12-19 08:48:56 +01:00
|
|
|
return fac;
|
|
|
|
}
|
2007-05-09 12:26:03 +00:00
|
|
|
|
2013-12-19 10:56:58 +01:00
|
|
|
#if !defined DISABLE_DYNLOADING
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
namespace {
|
2007-05-09 12:26:03 +00:00
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
extern "C" void writeInfo(va_list * args) {
|
|
|
|
component_writeInfoFunc fn = va_arg(*args, component_writeInfoFunc);
|
|
|
|
void * smgr = va_arg(*args, void *);
|
|
|
|
void * key = va_arg(*args, void *);
|
|
|
|
sal_Bool * ok = va_arg(*args, sal_Bool *);
|
|
|
|
*ok = (*fn)(smgr, key);
|
|
|
|
}
|
2007-05-09 12:26:03 +00:00
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
}
|
2013-12-13 15:10:18 +01:00
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
void cppu::writeSharedLibComponentInfo(
|
|
|
|
rtl::OUString const & uri, rtl::OUString const & rPath,
|
|
|
|
css::uno::Reference<css::lang::XMultiServiceFactory> const & xMgr,
|
|
|
|
css::uno::Reference<css::registry::XRegistryKey> const & xKey)
|
2000-12-19 14:01:16 +00:00
|
|
|
{
|
2013-12-19 08:48:56 +01:00
|
|
|
assert(rPath.isEmpty()); (void) rPath;
|
|
|
|
osl::Module mod(uri, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
|
|
|
|
if (!mod.is()) {
|
|
|
|
throw css::registry::CannotRegisterImplementationException(
|
|
|
|
"loading component library <" + uri + "> failed",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
2000-12-19 14:01:16 +00:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
oslGenericFunction fp = mod.getFunctionSymbol(COMPONENT_WRITEINFO);
|
2015-11-10 10:13:11 +01:00
|
|
|
if (fp == nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
throw css::registry::CannotRegisterImplementationException(
|
|
|
|
("no symbol \"" COMPONENT_WRITEINFO "\" in component library <"
|
|
|
|
+ uri + ">"),
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
2000-12-19 14:01:16 +00:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
css::uno::Environment curEnv(css::uno::Environment::getCurrent());
|
|
|
|
css::uno::Environment env(getEnvironmentFromModule(mod, curEnv, "", ""));
|
|
|
|
if (!(curEnv.is() && env.is())) {
|
|
|
|
throw css::registry::CannotRegisterImplementationException(
|
|
|
|
"cannot get environments",
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
2011-08-07 19:40:44 +03:00
|
|
|
}
|
2013-12-19 08:48:56 +01:00
|
|
|
css::uno::Mapping map(curEnv, env);
|
|
|
|
if (!map.is()) {
|
|
|
|
throw css::registry::CannotRegisterImplementationException(
|
|
|
|
"cannot get mapping", css::uno::Reference<css::uno::XInterface>());
|
|
|
|
}
|
|
|
|
void * smgr = map.mapInterface(
|
|
|
|
xMgr.get(), cppu::UnoType<css::lang::XMultiServiceFactory>::get());
|
|
|
|
void * key = map.mapInterface(
|
|
|
|
xKey.get(), cppu::UnoType<css::registry::XRegistryKey>::get());
|
|
|
|
sal_Bool ok;
|
|
|
|
env.invoke(writeInfo, fp, smgr, key, &ok);
|
|
|
|
(*env.get()->pExtEnv->releaseInterface)(env.get()->pExtEnv, key);
|
2015-11-10 10:13:11 +01:00
|
|
|
if (smgr != nullptr) {
|
2013-12-19 08:48:56 +01:00
|
|
|
(*env.get()->pExtEnv->releaseInterface)(env.get()->pExtEnv, smgr);
|
|
|
|
}
|
|
|
|
if (!ok) {
|
|
|
|
throw css::registry::CannotRegisterImplementationException(
|
|
|
|
("calling \"" COMPONENT_WRITEINFO "\" in component library <" + uri
|
|
|
|
+ "> returned false"),
|
|
|
|
css::uno::Reference<css::uno::XInterface>());
|
2000-12-19 14:01:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-19 08:48:56 +01:00
|
|
|
#endif
|
2013-12-13 15:10:18 +01:00
|
|
|
|
2010-10-14 08:30:07 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|