Kaydet (Commit) b6cebf4a authored tarafından Matúš Kukan's avatar Matúš Kukan

Allow UNO component libraries to have each implementation in its own function.

Demonstrating on expwrap library.

There is hope, this will bring code size savings for mobile
platforms, where we don't need every implementation.

Change-Id: I3519fb6148fd7a47ed9df092c73779ea6add552f
üst 4c539fac
...@@ -21,7 +21,6 @@ extern "C" ...@@ -21,7 +21,6 @@ extern "C"
extern void * embobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * embobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * emboleobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * emboleobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * evtatt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * evtatt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * expwrap_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * filterconfig1_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * filterconfig1_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * frm_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * frm_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * fsstorage_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * fsstorage_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
...@@ -85,7 +84,6 @@ lo_get_libmap(void) ...@@ -85,7 +84,6 @@ lo_get_libmap(void)
{ "libembobj.a", embobj_component_getFactory }, { "libembobj.a", embobj_component_getFactory },
{ "libemboleobj.a", emboleobj_component_getFactory }, { "libemboleobj.a", emboleobj_component_getFactory },
{ "libevtattlo.a", evtatt_component_getFactory }, { "libevtattlo.a", evtatt_component_getFactory },
{ "libexpwrap.uno.a", expwrap_component_getFactory },
{ "libfilterconfiglo.a", filterconfig1_component_getFactory }, { "libfilterconfiglo.a", filterconfig1_component_getFactory },
{ "libfrmlo.a", frm_component_getFactory }, { "libfrmlo.a", frm_component_getFactory },
{ "libfsstoragelo.a", fsstorage_component_getFactory }, { "libfsstoragelo.a", fsstorage_component_getFactory },
......
...@@ -22,7 +22,6 @@ extern "C" ...@@ -22,7 +22,6 @@ extern "C"
extern void * embobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * embobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * emboleobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * emboleobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * evtatt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * evtatt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * expwrap_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * filterconfig1_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * filterconfig1_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * frm_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * frm_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * fsstorage_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * fsstorage_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
...@@ -90,7 +89,6 @@ lo_get_libmap(void) ...@@ -90,7 +89,6 @@ lo_get_libmap(void)
{ "libembobj.a", embobj_component_getFactory }, { "libembobj.a", embobj_component_getFactory },
{ "libemboleobj.a", emboleobj_component_getFactory }, { "libemboleobj.a", emboleobj_component_getFactory },
{ "libevtattlo.a", evtatt_component_getFactory }, { "libevtattlo.a", evtatt_component_getFactory },
{ "libexpwraplo.a", expwrap_component_getFactory },
{ "libfilterconfiglo.a", filterconfig1_component_getFactory }, { "libfilterconfiglo.a", filterconfig1_component_getFactory },
{ "libfrmlo.a", frm_component_getFactory }, { "libfrmlo.a", frm_component_getFactory },
{ "libfsstoragelo.a", fsstorage_component_getFactory }, { "libfsstoragelo.a", fsstorage_component_getFactory },
......
...@@ -245,7 +245,6 @@ extern "C" ...@@ -245,7 +245,6 @@ extern "C"
extern void * configmgr_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * configmgr_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * comphelp_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * comphelp_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * deployment_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * deployment_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * expwrap_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * filterconfig1_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * filterconfig1_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * fwk_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * fwk_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * introspection_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * introspection_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
...@@ -263,6 +262,10 @@ extern "C" ...@@ -263,6 +262,10 @@ extern "C"
extern void * utl_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * utl_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * vcl_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * vcl_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * xstor_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * xstor_component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory( const char * , void * , void * );
extern void * com_sun_star_extensions_xml_sax_Writer_component_getFactory( const char * , void * , void * );
extern void * com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory( const char * , void * , void * );
} }
#endif #endif
...@@ -310,13 +313,15 @@ css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory( ...@@ -310,13 +313,15 @@ css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory(
aFullPrefix += "_"; aFullPrefix += "_";
} }
OUString aGetFactoryName = aFullPrefix + COMPONENT_GETFACTORY; OUString aGetFactoryName = aFullPrefix + COMPONENT_GETFACTORY;
if (rPrefix == "direct")
aGetFactoryName = rImplName.replace('.', '_') + "_" + COMPONENT_GETFACTORY;
oslGenericFunction pSym = NULL; oslGenericFunction pSym = NULL;
#ifdef DISABLE_DYNLOADING #ifdef DISABLE_DYNLOADING
// First test library names that aren't app-specific. // First test library names that aren't app-specific.
static lib_to_component_mapping non_app_specific_map[] = { static lib_to_component_mapping components_mapping[] = {
// Sigh, the name under which the bootstrap component is looked for // Sigh, the name under which the bootstrap component is looked for
// varies a lot? Or then I just have been confused by some mixed-up // varies a lot? Or then I just have been confused by some mixed-up
// incremental build. // incremental build.
...@@ -330,7 +335,6 @@ css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory( ...@@ -330,7 +335,6 @@ css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory(
{ "libcomphelper.a", comphelp_component_getFactory }, { "libcomphelper.a", comphelp_component_getFactory },
{ "libconfigmgrlo.a", configmgr_component_getFactory }, { "libconfigmgrlo.a", configmgr_component_getFactory },
{ "libdeployment.a", deployment_component_getFactory }, { "libdeployment.a", deployment_component_getFactory },
{ "libexpwraplo.a", expwrap_component_getFactory },
{ "libfilterconfiglo.a", filterconfig1_component_getFactory }, { "libfilterconfiglo.a", filterconfig1_component_getFactory },
{ "libfwklo.a", fwk_component_getFactory }, { "libfwklo.a", fwk_component_getFactory },
{ "libi18npoollo.a", i18npool_component_getFactory }, { "libi18npoollo.a", i18npool_component_getFactory },
...@@ -347,9 +351,26 @@ css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory( ...@@ -347,9 +351,26 @@ css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory(
{ "libxstor.a", xstor_component_getFactory }, { "libxstor.a", xstor_component_getFactory },
{ NULL, NULL } { NULL, NULL }
}; };
static lib_to_component_mapping direct_components_mapping[] = {
{ "com.sun.star.comp.extensions.xml.sax.ParserExpat", com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory },
{ "com.sun.star.extensions.xml.sax.Writer", com_sun_star_extensions_xml_sax_Writer_component_getFactory },
{ "com.sun.star.comp.extensions.xml.sax.FastParser", com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory },
{ NULL, NULL }
};
lib_to_component_mapping *non_app_specific_map = components_mapping;
OString sName;
if (rPrefix == "direct")
{
sName = OUStringToOString(rImplName, RTL_TEXTENCODING_ASCII_US);
non_app_specific_map = direct_components_mapping;
}
else
{
sName = OUStringToOString(uri, RTL_TEXTENCODING_ASCII_US);
}
for (int i = 0; pSym == NULL && non_app_specific_map[i].lib != NULL; ++i) for (int i = 0; pSym == NULL && non_app_specific_map[i].lib != NULL; ++i)
{ {
if ( uri.equalsAscii( non_app_specific_map[i].lib ) ) if ( sName == non_app_specific_map[i].lib )
pSym = (oslGenericFunction) non_app_specific_map[i].component_getFactory_function; pSym = (oslGenericFunction) non_app_specific_map[i].component_getFactory_function;
} }
......
...@@ -28,7 +28,6 @@ extern "C" { ...@@ -28,7 +28,6 @@ extern "C" {
extern void * embobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * embobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * emboleobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * emboleobj_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * evtatt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * evtatt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * expwrap_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * filterconfig1_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * filterconfig1_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * frm_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * frm_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * fsstorage_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * fsstorage_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
...@@ -90,7 +89,6 @@ lo_get_libmap(void) ...@@ -90,7 +89,6 @@ lo_get_libmap(void)
{ "libembobj.a", embobj_component_getFactory }, { "libembobj.a", embobj_component_getFactory },
{ "libemboleobj.a", emboleobj_component_getFactory }, { "libemboleobj.a", emboleobj_component_getFactory },
{ "libevtattlo.a", evtatt_component_getFactory }, { "libevtattlo.a", evtatt_component_getFactory },
{ "libexpwraplo.a", expwrap_component_getFactory },
{ "libfilterconfiglo.a", filterconfig1_component_getFactory }, { "libfilterconfiglo.a", filterconfig1_component_getFactory },
{ "libfrmlo.a", frm_component_getFactory }, { "libfrmlo.a", frm_component_getFactory },
{ "libfsstoragelo.a", fsstorage_component_getFactory }, { "libfsstoragelo.a", fsstorage_component_getFactory },
......
...@@ -155,7 +155,7 @@ lo_get_libmap(void) ...@@ -155,7 +155,7 @@ lo_get_libmap(void)
//MAP_LIB(ucppkg1), //MAP_LIB_LO(vbaswobj), //MAP_LIB_LO(wpftwriter), //MAP_LIB(ucppkg1), //MAP_LIB_LO(vbaswobj), //MAP_LIB_LO(wpftwriter),
//MAP_LIB_LO(wpftdraw), //MAP_LIB_LO(svxcore), //MAP_LIB_LO(protocolhandler), //MAP_LIB_LO(wpftdraw), //MAP_LIB_LO(svxcore), //MAP_LIB_LO(protocolhandler),
//MAP_LIB_LO_1(filterconfig), //MAP_LIB_LO(canvasfactory), //MAP_LIB_LO(mtfrenderer), //MAP_LIB_LO_1(filterconfig), //MAP_LIB_LO(canvasfactory), //MAP_LIB_LO(mtfrenderer),
MAP_LIB_LO(expwrap), MAP_LIB_LO(writerfilter), MAP_LIB_LO(writerfilter),
MAP_LIB(embobj), MAP_LIB(emboleobj), MAP_LIB_LO(sot), MAP_LIB(embobj), MAP_LIB(emboleobj), MAP_LIB_LO(sot),
// ADDED for search // ADDED for search
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
--> -->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="expwrap" xmlns="http://openoffice.org/2010/uno-components"> prefix="direct" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.extensions.xml.sax.ParserExpat"> <implementation name="com.sun.star.comp.extensions.xml.sax.ParserExpat">
<service name="com.sun.star.xml.sax.Parser"/> <service name="com.sun.star.xml.sax.Parser"/>
</implementation> </implementation>
......
...@@ -51,8 +51,6 @@ using namespace ::com::sun::star::io; ...@@ -51,8 +51,6 @@ using namespace ::com::sun::star::io;
#include "xml2utf.hxx" #include "xml2utf.hxx"
#include <sax/fastparser.hxx> #include <sax/fastparser.hxx>
#define PARSER_IMPLEMENTATION_NAME "com.sun.star.comp.extensions.xml.sax.FastParser"
namespace sax_expatwrap { namespace sax_expatwrap {
// Useful macros for correct String conversion depending on the choosen expat-mode // Useful macros for correct String conversion depending on the choosen expat-mode
...@@ -1061,55 +1059,55 @@ void SaxExpatParser_Impl::callbackEndCDATA( void *pvThis ) ...@@ -1061,55 +1059,55 @@ void SaxExpatParser_Impl::callbackEndCDATA( void *pvThis )
} }
} }
static void * getSingleFactory(
void *pServiceManager,
const OUString& sImplementation,
ComponentInstantiation pCreateFunction,
const Sequence< OUString > & rServiceNames)
{
Reference< XSingleServiceFactory > xFactory;
Reference< XMultiServiceFactory > xSMgr =
reinterpret_cast< XMultiServiceFactory * >( pServiceManager );
xFactory = createSingleFactory( xSMgr,
sImplementation, pCreateFunction, rServiceNames );
xFactory->acquire();
return xFactory.get();
}
using namespace sax_expatwrap; using namespace sax_expatwrap;
extern "C" extern "C"
{ {
SAL_DLLPUBLIC_EXPORT void * SAL_CALL expwrap_component_getFactory( SAL_DLLPUBLIC_EXPORT void * SAL_CALL com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory(
const sal_Char * pImplName, void * pServiceManager, const char * , void *pServiceManager, void * )
SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
{ {
void * pRet = 0; return getSingleFactory( pServiceManager,
"com.sun.star.comp.extensions.xml.sax.ParserExpat",
if (pServiceManager )
{
Reference< XSingleServiceFactory > xRet;
Reference< XMultiServiceFactory > xSMgr =
reinterpret_cast< XMultiServiceFactory * > ( pServiceManager );
OUString aImplementationName = OUString::createFromAscii( pImplName );
if ( aImplementationName == IMPLEMENTATION_NAME )
{
xRet = createSingleFactory( xSMgr, aImplementationName,
SaxExpatParser_CreateInstance, SaxExpatParser_CreateInstance,
SaxExpatParser::getSupportedServiceNames_Static() ); SaxExpatParser::getSupportedServiceNames_Static() );
} }
else if ( aImplementationName == SaxWriter_getImplementationName() )
{
xRet = createSingleFactory( xSMgr, aImplementationName, SAL_DLLPUBLIC_EXPORT void * SAL_CALL com_sun_star_extensions_xml_sax_Writer_component_getFactory(
const char * , void *pServiceManager, void * )
{
return getSingleFactory( pServiceManager,
"com.sun.star.extensions.xml.sax.Writer",
SaxWriter_CreateInstance, SaxWriter_CreateInstance,
SaxWriter_getSupportedServiceNames() ); SaxWriter_getSupportedServiceNames() );
} }
else if ( aImplementationName == PARSER_IMPLEMENTATION_NAME)
{ SAL_DLLPUBLIC_EXPORT void * SAL_CALL com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory(
xRet = createSingleFactory( xSMgr, aImplementationName, const char * , void *pServiceManager, void * )
{
return getSingleFactory( pServiceManager,
"com.sun.star.comp.extensions.xml.sax.FastParser",
FastSaxParser_CreateInstance, FastSaxParser_CreateInstance,
sax_fastparser::FastSaxParser::getSupportedServiceNames_Static() ); sax_fastparser::FastSaxParser::getSupportedServiceNames_Static() );
}
if (xRet.is())
{
xRet->acquire();
pRet = xRet.get();
}
}
return pRet;
} }
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment