unoxml: create instances with uno constructors

See tdf#74608 for motivation

Change-Id: I636d92faa3b26ac06c044c0485e632967daa709c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98313
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-07-08 20:26:28 +02:00
parent d29a314300
commit f4fc5dc31e
19 changed files with 88 additions and 432 deletions
+9 -2
View File
@@ -40,8 +40,6 @@ core_factory_list = [
("libucpfile1.a", "ucpfile_component_getFactory"),
("libucphier1.a", "ucphier1_component_getFactory"),
("libucptdoc1lo.a", "ucptdoc1_component_getFactory"),
("libunordflo.a", "unordf_component_getFactory"),
("libunoxmllo.a", "unoxml_component_getFactory"),
("libutllo.a", "utl_component_getFactory"),
("libxstor.a", "xstor_component_getFactory"),
("libxmlfdlo.a", "xmlfd_component_getFactory"),
@@ -308,6 +306,15 @@ core_constructor_list = [
"stardiv_Toolkit_VCLXPointer_get_implementation",
"stardiv_Toolkit_VCLXPopupMenu_get_implementation",
"stardiv_Toolkit_VCLXToolkit_get_implementation",
# unoxml/source/rdf/unordf.component
"unoxml_rdfRepository_get_implementation",
"unoxml_CURI_get_implementation",
"unoxml_CLiteral_get_implementation",
"unoxml_CBlankNode_get_implementation",
# unoxml/source/service/unoxml.component
"unoxml_CXPathAPI_get_implementation",
"unoxml_CSAXDocumentBuilder_get_implementation",
"unoxml_CDocumentBuilder_get_implementation",
# uui/util/uui.component
"com_sun_star_comp_uui_UUIInteractionHandler_get_implementation",
"com_sun_star_comp_uui_UUIInteractionRequestStringResolver_get_implementation",
-1
View File
@@ -45,7 +45,6 @@ $(eval $(call gb_Library_add_exception_objects,unordf,\
unoxml/source/rdf/CURI \
unoxml/source/rdf/CLiteral \
unoxml/source/rdf/librdf_repository \
unoxml/source/rdf/librdf_services \
))
# vim: set noet sw=4 ts=4:
-1
View File
@@ -72,7 +72,6 @@ $(eval $(call gb_Library_add_exception_objects,unoxml,\
unoxml/source/events/mutationevent \
unoxml/source/events/uievent \
unoxml/source/events/mouseevent \
unoxml/source/service/services \
))
$(eval $(call gb_Library_set_include,unoxml,\
+9 -16
View File
@@ -96,28 +96,14 @@ namespace DOM
xmlInitParser();
}
Reference< XInterface > CDocumentBuilder::_getInstance(const Reference< XMultiServiceFactory >& )
{
return static_cast< XDocumentBuilder* >(new CDocumentBuilder);
}
OUString CDocumentBuilder::_getImplementationName()
{
return "com.sun.star.comp.xml.dom.DocumentBuilder";
}
Sequence<OUString> CDocumentBuilder::_getSupportedServiceNames()
Sequence< OUString > SAL_CALL CDocumentBuilder::getSupportedServiceNames()
{
return { "com.sun.star.xml.dom.DocumentBuilder" };
}
Sequence< OUString > SAL_CALL CDocumentBuilder::getSupportedServiceNames()
{
return CDocumentBuilder::_getSupportedServiceNames();
}
OUString SAL_CALL CDocumentBuilder::getImplementationName()
{
return CDocumentBuilder::_getImplementationName();
return "com.sun.star.comp.xml.dom.DocumentBuilder";
}
sal_Bool SAL_CALL CDocumentBuilder::supportsService(const OUString& aServiceName)
@@ -442,4 +428,11 @@ namespace DOM
}
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
unoxml_CDocumentBuilder_get_implementation(
css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new DOM::CDocumentBuilder());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-7
View File
@@ -57,13 +57,6 @@ namespace DOM
// ctor
explicit CDocumentBuilder();
// static helpers for service info and component management
static OUString _getImplementationName();
static css::uno::Sequence< OUString > _getSupportedServiceNames();
static css::uno::Reference< XInterface > _getInstance(
css::uno::Reference< css::lang::XMultiServiceFactory > const&
rSMgr);
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) override;
+12 -19
View File
@@ -33,33 +33,19 @@ using namespace css::xml::sax;
namespace DOM
{
Reference< XInterface > CSAXDocumentBuilder::_getInstance(const Reference< XMultiServiceFactory >& rSMgr)
{
return static_cast< XSAXDocumentBuilder* >(new CSAXDocumentBuilder(rSMgr));
}
CSAXDocumentBuilder::CSAXDocumentBuilder(const Reference< XMultiServiceFactory >& mgr)
: m_aServiceManager(mgr)
CSAXDocumentBuilder::CSAXDocumentBuilder(const Reference< XComponentContext >& ctx)
: m_xContext(ctx)
, m_aState( SAXDocumentBuilderState_READY)
{}
OUString CSAXDocumentBuilder::_getImplementationName()
{
return "com.sun.star.comp.xml.dom.SAXDocumentBuilder";
}
Sequence<OUString> CSAXDocumentBuilder::_getSupportedServiceNames()
Sequence< OUString > SAL_CALL CSAXDocumentBuilder::getSupportedServiceNames()
{
return { "com.sun.star.xml.dom.SAXDocumentBuilder" };
}
Sequence< OUString > SAL_CALL CSAXDocumentBuilder::getSupportedServiceNames()
{
return CSAXDocumentBuilder::_getSupportedServiceNames();
}
OUString SAL_CALL CSAXDocumentBuilder::getImplementationName()
{
return CSAXDocumentBuilder::_getImplementationName();
return "com.sun.star.comp.xml.dom.SAXDocumentBuilder";
}
sal_Bool SAL_CALL CSAXDocumentBuilder::supportsService(const OUString& aServiceName)
@@ -144,7 +130,7 @@ namespace DOM
if (m_aState != SAXDocumentBuilderState_READY)
throw SAXException();
Reference< XDocumentBuilder > aBuilder(DocumentBuilder::create(comphelper::getComponentContext(m_aServiceManager)));
Reference< XDocumentBuilder > aBuilder(DocumentBuilder::create(m_xContext));
Reference< XDocument > aDocument = aBuilder->newDocument();
m_aNodeStack.push(aDocument);
m_aDocument = aDocument;
@@ -349,4 +335,11 @@ namespace DOM
}
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
unoxml_CSAXDocumentBuilder_get_implementation(
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new DOM::CSAXDocumentBuilder(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+3 -8
View File
@@ -35,7 +35,7 @@
#include <com/sun/star/xml/dom/XDocumentFragment.hpp>
#include <com/sun/star/xml/sax/XLocator.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
namespace DOM
{
@@ -45,7 +45,7 @@ namespace DOM
private:
::osl::Mutex m_Mutex;
const css::uno::Reference< css::lang::XMultiServiceFactory > m_aServiceManager;
const css::uno::Reference< css::uno::XComponentContext> m_xContext;
css::xml::dom::SAXDocumentBuilderState m_aState;
std::stack< css::uno::Reference< css::xml::dom::XNode > > m_aNodeStack;
@@ -55,12 +55,7 @@ namespace DOM
public:
// static helpers for service info and component management
static OUString _getImplementationName();
static css::uno::Sequence< OUString > _getSupportedServiceNames();
static css::uno::Reference< XInterface > _getInstance(const css::uno::Reference< css::lang::XMultiServiceFactory >& rSMgr);
explicit CSAXDocumentBuilder(const css::uno::Reference< css::lang::XMultiServiceFactory >& mgr);
explicit CSAXDocumentBuilder(const css::uno::Reference< css::uno::XComponentContext >& );
static void setElementFastAttributes(const css::uno::Reference< css::xml::dom::XElement >& aElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttribs);
+7 -22
View File
@@ -17,13 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "CNodes.hxx"
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/rdf/XBlankNode.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -65,7 +64,7 @@ CBlankNode::CBlankNode() :
// com.sun.star.uno.XServiceInfo:
OUString SAL_CALL CBlankNode::getImplementationName()
{
return comp_CBlankNode::_getImplementationName();
return "CBlankNode";
}
sal_Bool SAL_CALL CBlankNode::supportsService(OUString const & serviceName)
@@ -75,7 +74,7 @@ sal_Bool SAL_CALL CBlankNode::supportsService(OUString const & serviceName)
css::uno::Sequence< OUString > SAL_CALL CBlankNode::getSupportedServiceNames()
{
return comp_CBlankNode::_getSupportedServiceNames();
return { "com.sun.star.rdf.BlankNode" };
}
// css::lang::XInitialization:
@@ -109,25 +108,11 @@ OUString SAL_CALL CBlankNode::getStringValue()
} // closing anonymous implementation namespace
// component helper namespace
namespace comp_CBlankNode {
OUString _getImplementationName() {
return "CBlankNode";
}
css::uno::Sequence< OUString > _getSupportedServiceNames()
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
unoxml_CBlankNode_get_implementation(
css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
{
css::uno::Sequence< OUString > s { "com.sun.star.rdf.BlankNode" };
return s;
return cppu::acquire(new CBlankNode());
}
css::uno::Reference< css::uno::XInterface > _create(
const css::uno::Reference< css::uno::XComponentContext > & )
{
return static_cast< ::cppu::OWeakObject * >(new CBlankNode);
}
} // closing component helper namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+7 -22
View File
@@ -17,13 +17,12 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "CNodes.hxx"
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/rdf/XLiteral.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -72,7 +71,7 @@ CLiteral::CLiteral() :
// com.sun.star.uno.XServiceInfo:
OUString SAL_CALL CLiteral::getImplementationName()
{
return comp_CLiteral::_getImplementationName();
return "CLiteral";
}
sal_Bool SAL_CALL CLiteral::supportsService(OUString const & serviceName)
@@ -82,7 +81,7 @@ sal_Bool SAL_CALL CLiteral::supportsService(OUString const & serviceName)
css::uno::Sequence< OUString > SAL_CALL CLiteral::getSupportedServiceNames()
{
return comp_CLiteral::_getSupportedServiceNames();
return { "com.sun.star.rdf.Literal" };
}
// css::lang::XInitialization:
@@ -158,25 +157,11 @@ css::uno::Reference< css::rdf::XURI > SAL_CALL CLiteral::getDatatype()
} // closing anonymous implementation namespace
// component helper namespace
namespace comp_CLiteral {
OUString _getImplementationName() {
return "CLiteral";
}
css::uno::Sequence< OUString > _getSupportedServiceNames()
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
unoxml_CLiteral_get_implementation(
css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
{
return { "com.sun.star.rdf.Literal" };
return cppu::acquire(new CLiteral());
}
css::uno::Reference< css::uno::XInterface > _create(
const css::uno::Reference< css::uno::XComponentContext > & )
{
return static_cast< ::cppu::OWeakObject * >(new CLiteral);
}
} // closing component helper namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-61
View File
@@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#ifndef INCLUDED_UNOXML_SOURCE_RDF_CNODES_HXX
#define INCLUDED_UNOXML_SOURCE_RDF_CNODES_HXX
#include <sal/config.h>
#include <cppuhelper/factory.hxx>
// component helper namespace
namespace comp_CBlankNode {
// component and service helper functions:
OUString _getImplementationName();
css::uno::Sequence< OUString > _getSupportedServiceNames();
css::uno::Reference< css::uno::XInterface > _create( css::uno::Reference< css::uno::XComponentContext > const & context );
} // closing component helper namespace
// component helper namespace
namespace comp_CURI {
// component and service helper functions:
OUString _getImplementationName();
css::uno::Sequence< OUString > _getSupportedServiceNames();
css::uno::Reference< css::uno::XInterface > _create( css::uno::Reference< css::uno::XComponentContext > const & context );
} // closing component helper namespace
// component helper namespace
namespace comp_CLiteral {
// component and service helper functions:
OUString _getImplementationName();
css::uno::Sequence< OUString > _getSupportedServiceNames();
css::uno::Reference< css::uno::XInterface > _create( css::uno::Reference< css::uno::XComponentContext > const & context );
} // closing component helper namespace
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+7 -23
View File
@@ -17,14 +17,13 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "CNodes.hxx"
#include <cppuhelper/implbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/rdf/XURI.hpp>
#include <com/sun/star/rdf/URIs.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
@@ -74,7 +73,7 @@ CURI::CURI() :
// com.sun.star.uno.XServiceInfo:
OUString SAL_CALL CURI::getImplementationName()
{
return comp_CURI::_getImplementationName();
return "CURI";
}
sal_Bool SAL_CALL CURI::supportsService(OUString const & serviceName)
@@ -84,7 +83,7 @@ sal_Bool SAL_CALL CURI::supportsService(OUString const & serviceName)
css::uno::Sequence< OUString > SAL_CALL CURI::getSupportedServiceNames()
{
return comp_CURI::_getSupportedServiceNames();
return { "com.sun.star.rdf.URI" };
}
const char s_nsXSD [] = "http://www.w3.org/2001/XMLSchema-datatypes#";
@@ -792,26 +791,11 @@ OUString SAL_CALL CURI::getLocalName()
} // closing anonymous implementation namespace
// component helper namespace
namespace comp_CURI {
OUString _getImplementationName() {
return
"CURI";
}
css::uno::Sequence< OUString > _getSupportedServiceNames()
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
unoxml_CURI_get_implementation(
css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
{
css::uno::Sequence< OUString > s { "com.sun.star.rdf.URI" };
return s;
return cppu::acquire(new CURI());
}
css::uno::Reference< css::uno::XInterface > _create(
const css::uno::Reference< css::uno::XComponentContext > & )
{
return static_cast< ::cppu::OWeakObject * >(new CURI);
}
} // closing component helper namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+6 -21
View File
@@ -17,8 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "librdf_repository.hxx"
#include <string.h>
#include <map>
@@ -911,7 +909,7 @@ librdf_Repository::~librdf_Repository()
// com.sun.star.uno.XServiceInfo:
OUString SAL_CALL librdf_Repository::getImplementationName()
{
return comp_librdf_Repository::_getImplementationName();
return "librdf_Repository";
}
sal_Bool SAL_CALL librdf_Repository::supportsService(
@@ -923,7 +921,7 @@ sal_Bool SAL_CALL librdf_Repository::supportsService(
uno::Sequence< OUString > SAL_CALL
librdf_Repository::getSupportedServiceNames()
{
return comp_librdf_Repository::_getSupportedServiceNames();
return { "com.sun.star.rdf.Repository" };
}
// css::rdf::XRepository:
@@ -2455,24 +2453,11 @@ librdf_TypeConverter::convertToStatement(librdf_statement* i_pStmt,
} // closing anonymous implementation namespace
// component helper namespace
namespace comp_librdf_Repository {
OUString _getImplementationName() {
return "librdf_Repository";
}
uno::Sequence< OUString > _getSupportedServiceNames()
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
unoxml_rdfRepository_get_implementation(
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
{
return { "com.sun.star.rdf.Repository" };
return cppu::acquire(new librdf_Repository(context));
}
uno::Reference< uno::XInterface > _create(
const uno::Reference< uno::XComponentContext > & context)
{
return static_cast< ::cppu::OWeakObject * >(new librdf_Repository(context));
}
} // closing component helper namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-39
View File
@@ -1,39 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#ifndef INCLUDED_UNOXML_SOURCE_RDF_LIBRDF_REPOSITORY_HXX
#define INCLUDED_UNOXML_SOURCE_RDF_LIBRDF_REPOSITORY_HXX
#include <sal/config.h>
#include <cppuhelper/factory.hxx>
// component helper namespace
namespace comp_librdf_Repository {
// component and service helper functions:
OUString _getImplementationName();
css::uno::Sequence< OUString > _getSupportedServiceNames();
css::uno::Reference< css::uno::XInterface > _create( css::uno::Reference< css::uno::XComponentContext > const & context );
} // closing component helper namespace
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-62
View File
@@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#include "CNodes.hxx"
#include "librdf_repository.hxx"
using namespace ::com::sun::star;
extern "C"
{
::cppu::ImplementationEntry const entries[] = {
{ &comp_CBlankNode::_create,
&comp_CBlankNode::_getImplementationName,
&comp_CBlankNode::_getSupportedServiceNames,
&::cppu::createSingleComponentFactory, nullptr, 0 },
{ &comp_CURI::_create,
&comp_CURI::_getImplementationName,
&comp_CURI::_getSupportedServiceNames,
&::cppu::createSingleComponentFactory, nullptr, 0 },
{ &comp_CLiteral::_create,
&comp_CLiteral::_getImplementationName,
&comp_CLiteral::_getSupportedServiceNames,
&::cppu::createSingleComponentFactory, nullptr, 0 },
{ &comp_librdf_Repository::_create,
&comp_librdf_Repository::_getImplementationName,
&comp_librdf_Repository::_getSupportedServiceNames,
&::cppu::createSingleComponentFactory, nullptr, 0 },
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
SAL_DLLPUBLIC_EXPORT void * unordf_component_getFactory(
const char * implName, void * serviceManager, void * registryKey)
{
return ::cppu::component_getFactoryHelper(
implName, serviceManager, registryKey, entries);
}
} // extern "C"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+6 -5
View File
@@ -18,17 +18,18 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="unordf" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="CBlankNode">
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="CBlankNode" constructor="unoxml_CBlankNode_get_implementation">
<service name="com.sun.star.rdf.BlankNode"/>
</implementation>
<implementation name="CLiteral">
<implementation name="CLiteral" constructor="unoxml_CLiteral_get_implementation">
<service name="com.sun.star.rdf.Literal"/>
</implementation>
<implementation name="CURI">
<implementation name="CURI" constructor="unoxml_CURI_get_implementation">
<service name="com.sun.star.rdf.URI"/>
</implementation>
<implementation name="librdf_Repository">
<implementation name="librdf_Repository"
constructor="unoxml_rdfRepository_get_implementation">
<service name="com.sun.star.rdf.Repository"/>
</implementation>
</component>
-85
View File
@@ -1,85 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* 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 .
*/
#include <rtl/ustring.hxx>
#include <com/sun/star/uno/Reference.h>
#include <com/sun/star/uno/Reference.hxx>
#include <cppuhelper/factory.hxx>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include "../dom/documentbuilder.hxx"
#include "../dom/saxbuilder.hxx"
#include "../xpath/xpathapi.hxx"
using namespace ::DOM;
using namespace ::XPath;
using namespace css::uno;
using namespace css::lang;
using namespace css::registry;
extern "C"
{
SAL_DLLPUBLIC_EXPORT void* unoxml_component_getFactory(const char *pImplementationName, void *pServiceManager, void * /*pRegistryKey*/)
{
void* pReturn = nullptr ;
if ( pImplementationName && pServiceManager )
{
// Define variables which are used in following macros.
Reference< XSingleServiceFactory > xFactory;
Reference< XMultiServiceFactory > xServiceManager(
static_cast< XMultiServiceFactory* >(pServiceManager));
if (CDocumentBuilder::_getImplementationName().equalsAscii( pImplementationName ) )
{
xFactory.set(
cppu::createOneInstanceFactory(
xServiceManager, CDocumentBuilder::_getImplementationName(),
CDocumentBuilder::_getInstance, CDocumentBuilder::_getSupportedServiceNames()));
}
else if (CSAXDocumentBuilder::_getImplementationName().equalsAscii( pImplementationName ) )
{
xFactory.set(
cppu::createSingleFactory(
xServiceManager, CSAXDocumentBuilder::_getImplementationName(),
CSAXDocumentBuilder::_getInstance, CSAXDocumentBuilder::_getSupportedServiceNames()));
}
else if (CXPathAPI::_getImplementationName().equalsAscii( pImplementationName ) )
{
xFactory.set(
cppu::createSingleFactory(
xServiceManager, CXPathAPI::_getImplementationName(),
CXPathAPI::_getInstance, CXPathAPI::_getSupportedServiceNames()));
}
// Factory is valid - service was found.
if ( xFactory.is() )
{
xFactory->acquire();
pReturn = xFactory.get();
}
}
// Return with result of this operation.
return pReturn ;
}
} // extern "C"
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+7 -4
View File
@@ -18,14 +18,17 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="unoxml" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.xml.dom.DocumentBuilder">
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.xml.dom.DocumentBuilder"
constructor="unoxml_CDocumentBuilder_get_implementation">
<service name="com.sun.star.xml.dom.DocumentBuilder"/>
</implementation>
<implementation name="com.sun.star.comp.xml.dom.SAXDocumentBuilder">
<implementation name="com.sun.star.comp.xml.dom.SAXDocumentBuilder"
constructor="unoxml_CSAXDocumentBuilder_get_implementation">
<service name="com.sun.star.xml.dom.SAXDocumentBuilder"/>
</implementation>
<implementation name="com.sun.star.comp.xml.xpath.XPathAPI">
<implementation name="com.sun.star.comp.xml.xpath.XPathAPI"
constructor="unoxml_CXPathAPI_get_implementation">
<service name="com.sun.star.xml.xpath.XPathAPI"/>
</implementation>
</component>
+12 -22
View File
@@ -44,40 +44,23 @@ using namespace css::io;
using namespace css::uno;
using namespace css::xml::dom;
using namespace css::xml::xpath;
using css::lang::XMultiServiceFactory;
namespace XPath
{
// factory
Reference< XInterface > CXPathAPI::_getInstance(const Reference< XMultiServiceFactory >& rSMgr)
{
return static_cast<XXPathAPI*>(new CXPathAPI(rSMgr));
}
// ctor
CXPathAPI::CXPathAPI(const Reference< XMultiServiceFactory >& rSMgr)
: m_aFactory(rSMgr)
CXPathAPI::CXPathAPI(const Reference< XComponentContext >& rxContext)
: m_xContext(rxContext)
{
}
OUString CXPathAPI::_getImplementationName()
{
return "com.sun.star.comp.xml.xpath.XPathAPI";
}
Sequence<OUString> CXPathAPI::_getSupportedServiceNames()
{
return { "com.sun.star.xml.xpath.XPathAPI" };
}
Sequence< OUString > SAL_CALL CXPathAPI::getSupportedServiceNames()
{
return CXPathAPI::_getSupportedServiceNames();
return { "com.sun.star.xml.xpath.XPathAPI" };
}
OUString SAL_CALL CXPathAPI::getImplementationName()
{
return CXPathAPI::_getImplementationName();
return "com.sun.star.comp.xml.xpath.XPathAPI";
}
sal_Bool SAL_CALL CXPathAPI::supportsService(const OUString& aServiceName)
@@ -386,7 +369,7 @@ namespace XPath
// get extension from service manager
Reference< XXPathExtension > const xExtension(
m_aFactory->createInstance(aName), UNO_QUERY_THROW);
m_xContext->getServiceManager()->createInstanceWithContext(aName, m_xContext), UNO_QUERY_THROW);
m_extensions.push_back(xExtension);
}
@@ -405,4 +388,11 @@ namespace XPath
}
}
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
unoxml_CXPathAPI_get_implementation(
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new XPath::CXPathAPI(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+3 -12
View File
@@ -37,7 +37,7 @@
#include <com/sun/star/xml/xpath/XXPathObject.hpp>
#include <com/sun/star/xml/xpath/XXPathExtension.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
namespace XPath
{
@@ -56,21 +56,12 @@ namespace XPath
private:
::osl::Mutex m_Mutex;
nsmap_t m_nsmap;
const css::uno::Reference< css::lang::XMultiServiceFactory > m_aFactory;
const css::uno::Reference< css::uno::XComponentContext > m_xContext;
extensions_t m_extensions;
public:
// ctor
explicit CXPathAPI(
const css::uno::Reference< css::lang::XMultiServiceFactory >&
rSMgr);
// static helpers for service info and component management
static OUString _getImplementationName();
static css::uno::Sequence< OUString > _getSupportedServiceNames();
static css::uno::Reference< XInterface > _getInstance(
const css::uno::Reference< css::lang::XMultiServiceFactory >&
rSMgr);
explicit CXPathAPI( const css::uno::Reference< css::uno::XComponentContext >& );
// XServiceInfo
virtual OUString SAL_CALL getImplementationName() override;