diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2013-12-19 08:48:56 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2013-12-19 08:48:56 +0100 |
commit | ae3a0c8da50b36db395984637f5ad74d3b4887bc (patch) | |
tree | c4936b9fba1f24d412d41474ebef44a5f094dbc8 /sax | |
parent | 80d977b896904a0261d32857469c1b3e7516ca1e (diff) |
Add .component <implementation constructor="..." feature
...to directly call constructor functions of ComponentContext-based C++
implementations of (non-single-instance) UNO services. The case where these
calls would need to be bridged across different environments (e.g., from gcc3
to gcc3:affine) is not yet implemented.
bootstrap.component and expwrap.component are adapted accordingly as a proof-of-
concept (which had previously been adapted to use the prefix="direct" feature,
which may become unnecessary again in the end, depending on how to handle
single-instance services/singletons). More to follow.
Change-Id: I18682d75bcd29d3d427e31331b4ce8161dbb846d
Diffstat (limited to 'sax')
-rw-r--r-- | sax/source/expatwrap/expwrap.component | 11 | ||||
-rw-r--r-- | sax/source/expatwrap/sax_expat.cxx | 51 | ||||
-rw-r--r-- | sax/source/expatwrap/saxwriter.cxx | 52 | ||||
-rw-r--r-- | sax/source/fastparser/fastparser.cxx | 50 |
4 files changed, 62 insertions, 102 deletions
diff --git a/sax/source/expatwrap/expwrap.component b/sax/source/expatwrap/expwrap.component index 9365a6d7d4da..306e517ef2ea 100644 --- a/sax/source/expatwrap/expwrap.component +++ b/sax/source/expatwrap/expwrap.component @@ -18,14 +18,17 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="direct" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.extensions.xml.sax.ParserExpat"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.extensions.xml.sax.ParserExpat" + constructor="com_sun_star_comp_extensions_xml_sax_ParserExpat"> <service name="com.sun.star.xml.sax.Parser"/> </implementation> - <implementation name="com.sun.star.extensions.xml.sax.Writer"> + <implementation name="com.sun.star.extensions.xml.sax.Writer" + constructor="com_sun_star_extensions_xml_sax_Writer"> <service name="com.sun.star.xml.sax.Writer"/> </implementation> - <implementation name="com.sun.star.comp.extensions.xml.sax.FastParser"> + <implementation name="com.sun.star.comp.extensions.xml.sax.FastParser" + constructor="com_sun_star_comp_extensions_xml_sax_FastParser"> <service name="com.sun.star.xml.sax.FastParser"/> </implementation> </component> diff --git a/sax/source/expatwrap/sax_expat.cxx b/sax/source/expatwrap/sax_expat.cxx index 4f00ad9f378e..981d68e2cd4f 100644 --- a/sax/source/expatwrap/sax_expat.cxx +++ b/sax/source/expatwrap/sax_expat.cxx @@ -19,6 +19,7 @@ #include <stdlib.h> #include <string.h> #include <sal/alloca.h> +#include <cassert> #include <vector> #include <osl/diagnose.h> @@ -30,7 +31,6 @@ #include <com/sun/star/xml/sax/SAXParseException.hpp> #include <com/sun/star/io/XSeekable.hpp> -#include <cppuhelper/factory.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/implbase3.hxx> #include <cppuhelper/supportsservice.hxx> @@ -42,13 +42,16 @@ using namespace ::osl; using namespace ::cppu; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::io; #include "attrlistimpl.hxx" #include "xml2utf.hxx" +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + namespace { // Useful macros for correct String conversion depending on the choosen expat-mode @@ -129,17 +132,6 @@ OUString XmlChar2OUString( const XML_Char *p ) class SaxExpatParser_Impl; -OUString SaxExpatParser_getImplementationName() { - return OUString("com.sun.star.comp.extensions.xml.sax.ParserExpat"); -} - -Sequence< OUString > SaxExpatParser_getSupportedServiceNames(void) -{ - Sequence<OUString> seq(1); - seq[0] = OUString("com.sun.star.xml.sax.Parser"); - return seq; -} - // This class implements the external Parser interface class SaxExpatParser : public WeakImplHelper3< XInitialization @@ -598,7 +590,7 @@ void SaxExpatParser::setLocale( const Locale & locale ) throw (RuntimeException) // XServiceInfo OUString SaxExpatParser::getImplementationName() throw () { - return SaxExpatParser_getImplementationName(); + return OUString("com.sun.star.comp.extensions.xml.sax.ParserExpat"); } // XServiceInfo @@ -610,7 +602,9 @@ sal_Bool SaxExpatParser::supportsService(const OUString& ServiceName) throw () // XServiceInfo Sequence< OUString > SaxExpatParser::getSupportedServiceNames(void) throw () { - return SaxExpatParser_getSupportedServiceNames(); + Sequence<OUString> seq(1); + seq[0] = "com.sun.star.xml.sax.Parser"; + return seq; } @@ -1023,27 +1017,18 @@ void SaxExpatParser_Impl::callbackEndCDATA( void *pvThis ) CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(pImpl,rExtendedDocumentHandler->endCDATA() ); } -Reference< XInterface > SAL_CALL SaxExpatParser_CreateInstance( - SAL_UNUSED_PARAMETER const Reference<css::uno::XComponentContext> & ) - SAL_THROW((css::uno::Exception)) -{ - SaxExpatParser *p = new SaxExpatParser; - return Reference< XInterface > ( (OWeakObject * ) p ); -} - } // namespace -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL -com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory( - const char *, void *, void * ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_extensions_xml_sax_ParserExpat( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) { - Reference<css::lang::XSingleComponentFactory> xFactory( - cppu::createSingleComponentFactory( - &SaxExpatParser_CreateInstance, - SaxExpatParser_getImplementationName(), - SaxExpatParser_getSupportedServiceNames())); - xFactory->acquire(); - return xFactory.get(); + assert(arguments != 0 && arguments->nElements == 0); (void) arguments; + css::uno::Reference<css::uno::XInterface> x( + static_cast<cppu::OWeakObject *>(new SaxExpatParser)); + x->acquire(); + return x.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/expatwrap/saxwriter.cxx b/sax/source/expatwrap/saxwriter.cxx index b17f3787ac10..6279640e971c 100644 --- a/sax/source/expatwrap/saxwriter.cxx +++ b/sax/source/expatwrap/saxwriter.cxx @@ -19,8 +19,9 @@ #include <string.h> -#include <stack> +#include <cassert> #include <set> +#include <stack> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XCloneable.hpp> @@ -31,7 +32,6 @@ #include <com/sun/star/io/XActiveDataSource.hpp> -#include <cppuhelper/factory.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/implbase2.hxx> #include <cppuhelper/supportsservice.hxx> @@ -46,13 +46,16 @@ using namespace ::osl; using namespace ::cppu; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::util; using namespace ::com::sun::star::io; #include "xml2utf.hxx" +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + #define LINEFEED 10 #define SEQUENCESIZE 1024 #define MAXCOLUMNCOUNT 72 @@ -867,17 +870,6 @@ static inline sal_Int32 getFirstLineBreak( const OUString & str ) throw () return -1; } -OUString SAXWriter_getImplementationName() { - return OUString("com.sun.star.extensions.xml.sax.Writer"); -} - -Sequence< OUString > SAXWriter_getSupportedServiceNames(void) throw () -{ - Sequence<OUString> seq(1); - seq.getArray()[0] = OUString("com.sun.star.xml.sax.Writer"); - return seq; -} - class SAXWriter : public WeakImplHelper2< XWriter, @@ -998,7 +990,7 @@ static inline sal_Bool isFirstCharWhitespace( const sal_Unicode *p ) throw() // XServiceInfo OUString SAXWriter::getImplementationName() throw() { - return SAXWriter_getImplementationName(); + return OUString("com.sun.star.extensions.xml.sax.Writer"); } // XServiceInfo @@ -1010,7 +1002,9 @@ sal_Bool SAXWriter::supportsService(const OUString& ServiceName) throw() // XServiceInfo Sequence< OUString > SAXWriter::getSupportedServiceNames(void) throw () { - return SAXWriter_getSupportedServiceNames(); + Sequence<OUString> seq(1); + seq[0] = "com.sun.star.xml.sax.Writer"; + return seq; } void SAXWriter::startDocument() throw(SAXException, RuntimeException ) @@ -1376,26 +1370,18 @@ void SAXWriter::unknown(const OUString& sString) throw (SAXException, RuntimeExc } } -Reference < XInterface > SAL_CALL SAXWriter_CreateInstance( - SAL_UNUSED_PARAMETER const Reference<css::uno::XComponentContext> & ) - SAL_THROW((css::uno::Exception)) -{ - SAXWriter *p = new SAXWriter; - return Reference< XInterface > ( (static_cast< OWeakObject * >(p)) ); -} - } // namespace -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL -com_sun_star_extensions_xml_sax_Writer_component_getFactory( - const char *, void *, void * ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_extensions_xml_sax_Writer( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) { - Reference<css::lang::XSingleComponentFactory > xFactory( - cppu::createSingleComponentFactory( - &SAXWriter_CreateInstance, SAXWriter_getImplementationName(), - SAXWriter_getSupportedServiceNames())); - xFactory->acquire(); - return xFactory.get(); + assert(arguments != 0 && arguments->nElements == 0); (void) arguments; + css::uno::Reference<css::uno::XInterface> x( + static_cast<cppu::OWeakObject *>(new SAXWriter)); + x->acquire(); + return x.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sax/source/fastparser/fastparser.cxx b/sax/source/fastparser/fastparser.cxx index 8d17b650cf0d..04cfbee960a9 100644 --- a/sax/source/fastparser/fastparser.cxx +++ b/sax/source/fastparser/fastparser.cxx @@ -27,7 +27,6 @@ #include <com/sun/star/xml/sax/XFastContextHandler.hpp> #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp> #include <com/sun/star/xml/sax/XFastTokenHandler.hpp> -#include <cppuhelper/factory.hxx> #include <cppuhelper/supportsservice.hxx> #include <osl/conditn.hxx> #include <osl/diagnose.h> @@ -42,9 +41,14 @@ #include <stack> #include <vector> #include <queue> +#include <cassert> #include <cstring> #include <expat.h> +namespace com { namespace sun { namespace star { namespace uno { + class XComponentContext; +} } } } + using namespace ::std; using namespace ::osl; using namespace ::cppu; @@ -57,17 +61,6 @@ using namespace sax_fastparser; namespace { -OUString FastSaxParser_getImplementationName() { - return OUString("com.sun.star.comp.extensions.xml.sax.FastParser"); -} - -uno::Sequence<OUString> FastSaxParser_getSupportedServiceNames() -{ - Sequence<OUString> seq(1); - seq.getArray()[0] = OUString("com.sun.star.xml.sax.FastParser"); - return seq; -} - struct Event; class FastLocatorImpl; struct NamespaceDefine; @@ -1404,7 +1397,7 @@ void FastSaxParser::setLocale( const lang::Locale& rLocale ) OUString FastSaxParser::getImplementationName() throw (uno::RuntimeException) { - return FastSaxParser_getImplementationName(); + return OUString("com.sun.star.comp.extensions.xml.sax.FastParser"); } sal_Bool FastSaxParser::supportsService( const OUString& ServiceName ) @@ -1416,7 +1409,9 @@ sal_Bool FastSaxParser::supportsService( const OUString& ServiceName ) uno::Sequence<OUString> FastSaxParser::getSupportedServiceNames() throw (uno::RuntimeException) { - return FastSaxParser_getSupportedServiceNames(); + Sequence<OUString> seq(1); + seq[0] = OUString("com.sun.star.xml.sax.FastParser"); + return seq; } bool FastSaxParser::hasNamespaceURL( const OUString& rPrefix ) const @@ -1426,25 +1421,16 @@ bool FastSaxParser::hasNamespaceURL( const OUString& rPrefix ) const } // namespace sax_fastparser -static Reference< XInterface > SAL_CALL FastSaxParser_CreateInstance( - SAL_UNUSED_PARAMETER const Reference<css::uno::XComponentContext> & ) - SAL_THROW((css::uno::Exception)) -{ - FastSaxParser *p = new FastSaxParser; - return Reference< XInterface > ( (OWeakObject * ) p ); -} - -extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL -com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory( - const char *, void *, void * ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL +com_sun_star_comp_extensions_xml_sax_FastParser( + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + uno_Sequence * arguments) { - Reference<css::lang::XSingleComponentFactory> xFactory( - cppu::createSingleComponentFactory( - &FastSaxParser_CreateInstance, - FastSaxParser_getImplementationName(), - FastSaxParser_getSupportedServiceNames())); - xFactory->acquire(); - return xFactory.get(); + assert(arguments != 0 && arguments->nElements == 0); (void) arguments; + css::uno::Reference<css::uno::XInterface> x( + static_cast<cppu::OWeakObject *>(new FastSaxParser)); + x->acquire(); + return x.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |