summaryrefslogtreecommitdiff
path: root/sax
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2013-12-13 17:40:06 +0100
committerMatúš Kukan <matus.kukan@collabora.com>2013-12-18 07:15:46 +0100
commitb6cebf4a3e2997e6489bba77b358b306f8f435ce (patch)
tree1f8f2a63ce9f71c7002269fb7b879e1f3662d6ed /sax
parent4c539fac018dfd44cd8db52161a8cb930c627da7 (diff)
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
Diffstat (limited to 'sax')
-rw-r--r--sax/source/expatwrap/expwrap.component2
-rw-r--r--sax/source/expatwrap/sax_expat.cxx78
2 files changed, 39 insertions, 41 deletions
diff --git a/sax/source/expatwrap/expwrap.component b/sax/source/expatwrap/expwrap.component
index c2a6bf0f4e56..9365a6d7d4da 100644
--- a/sax/source/expatwrap/expwrap.component
+++ b/sax/source/expatwrap/expwrap.component
@@ -18,7 +18,7 @@
-->
<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">
<service name="com.sun.star.xml.sax.Parser"/>
</implementation>
diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx
index 8e066e85ee46..214d2625dbc5 100644
--- a/sax/source/expatwrap/sax_expat.cxx
+++ b/sax/source/expatwrap/sax_expat.cxx
@@ -51,8 +51,6 @@ using namespace ::com::sun::star::io;
#include "xml2utf.hxx"
#include <sax/fastparser.hxx>
-#define PARSER_IMPLEMENTATION_NAME "com.sun.star.comp.extensions.xml.sax.FastParser"
-
namespace sax_expatwrap {
// Useful macros for correct String conversion depending on the choosen expat-mode
@@ -1061,54 +1059,54 @@ 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;
extern "C"
{
-SAL_DLLPUBLIC_EXPORT void * SAL_CALL expwrap_component_getFactory(
- const sal_Char * pImplName, void * pServiceManager,
- SAL_UNUSED_PARAMETER void * /*pRegistryKey*/ )
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory(
+ const char * , void *pServiceManager, void * )
{
- void * pRet = 0;
-
- 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::getSupportedServiceNames_Static() );
- }
- else if ( aImplementationName == SaxWriter_getImplementationName() )
- {
- xRet = createSingleFactory( xSMgr, aImplementationName,
- SaxWriter_CreateInstance,
- SaxWriter_getSupportedServiceNames() );
- }
- else if ( aImplementationName == PARSER_IMPLEMENTATION_NAME)
- {
- xRet = createSingleFactory( xSMgr, aImplementationName,
- FastSaxParser_CreateInstance,
- sax_fastparser::FastSaxParser::getSupportedServiceNames_Static() );
- }
+ return getSingleFactory( pServiceManager,
+ "com.sun.star.comp.extensions.xml.sax.ParserExpat",
+ SaxExpatParser_CreateInstance,
+ SaxExpatParser::getSupportedServiceNames_Static() );
+}
- if (xRet.is())
- {
- xRet->acquire();
- pRet = xRet.get();
- }
- }
- return pRet;
+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_getSupportedServiceNames() );
}
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory(
+ const char * , void *pServiceManager, void * )
+{
+ return getSingleFactory( pServiceManager,
+ "com.sun.star.comp.extensions.xml.sax.FastParser",
+ FastSaxParser_CreateInstance,
+ sax_fastparser::FastSaxParser::getSupportedServiceNames_Static() );
+}
}