package: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: I17627bdd2f4f595343ad9bf524dc57cd03170b2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98921 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
parent
c33f3ede4a
commit
2fc112e98d
12 changed files with 54 additions and 196 deletions
|
@ -46,7 +46,6 @@ $(eval $(call gb_Library_add_exception_objects,package2,\
|
|||
package/source/manifest/ManifestImport \
|
||||
package/source/manifest/ManifestReader \
|
||||
package/source/manifest/ManifestWriter \
|
||||
package/source/manifest/UnoRegister \
|
||||
package/source/zipapi/blowfishcontext \
|
||||
package/source/zipapi/ByteChucker \
|
||||
package/source/zipapi/ByteGrabber \
|
||||
|
|
|
@ -161,11 +161,6 @@ public:
|
|||
virtual OUString SAL_CALL getImplementationName( ) override;
|
||||
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
|
||||
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
|
||||
|
||||
// Uno componentiseralation
|
||||
static OUString static_getImplementationName();
|
||||
static css::uno::Sequence < OUString > static_getSupportedServiceNames();
|
||||
static css::uno::Reference < css::lang::XSingleServiceFactory > createServiceFactory( css::uno::Reference < css::lang::XMultiServiceFactory > const & rServiceFactory );
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -61,13 +61,6 @@ public:
|
|||
static bool StringGoodForPattern_Impl( const OUString& aString,
|
||||
const css::uno::Sequence< OUString >& aPattern );
|
||||
|
||||
static css::uno::Sequence< OUString > impl_staticGetSupportedServiceNames();
|
||||
|
||||
static OUString impl_staticGetImplementationName();
|
||||
|
||||
static css::uno::Reference< css::uno::XInterface > impl_staticCreateSelfInstance(
|
||||
const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMSF );
|
||||
|
||||
// XInitialization
|
||||
virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
|
||||
|
||||
|
|
|
@ -81,24 +81,10 @@ Sequence< Sequence< PropertyValue > > SAL_CALL ManifestReader::readManifestSeque
|
|||
}
|
||||
// Component functions
|
||||
|
||||
static Reference < XInterface > ManifestReader_createInstance( Reference< XMultiServiceFactory > const & rServiceFactory )
|
||||
{
|
||||
return *new ManifestReader( comphelper::getComponentContext(rServiceFactory) );
|
||||
}
|
||||
OUString ManifestReader::static_getImplementationName()
|
||||
{
|
||||
return "com.sun.star.packages.manifest.comp.ManifestReader";
|
||||
}
|
||||
|
||||
Sequence < OUString > ManifestReader::static_getSupportedServiceNames()
|
||||
{
|
||||
Sequence < OUString > aNames { "com.sun.star.packages.manifest.ManifestReader" };
|
||||
return aNames;
|
||||
}
|
||||
|
||||
OUString ManifestReader::getImplementationName()
|
||||
{
|
||||
return static_getImplementationName();
|
||||
return "com.sun.star.packages.manifest.comp.ManifestReader";
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL ManifestReader::supportsService(OUString const & rServiceName)
|
||||
|
@ -108,14 +94,16 @@ sal_Bool SAL_CALL ManifestReader::supportsService(OUString const & rServiceName)
|
|||
|
||||
Sequence < OUString > ManifestReader::getSupportedServiceNames()
|
||||
{
|
||||
return static_getSupportedServiceNames();
|
||||
}
|
||||
Reference < XSingleServiceFactory > ManifestReader::createServiceFactory( Reference < XMultiServiceFactory > const & rServiceFactory )
|
||||
{
|
||||
return cppu::createSingleFactory (rServiceFactory,
|
||||
static_getImplementationName(),
|
||||
ManifestReader_createInstance,
|
||||
static_getSupportedServiceNames());
|
||||
return { "com.sun.star.packages.manifest.ManifestReader" };
|
||||
}
|
||||
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
package_ManifestReader_get_implementation(
|
||||
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new ManifestReader(context));
|
||||
}
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -49,11 +49,6 @@ public:
|
|||
virtual OUString SAL_CALL getImplementationName( ) override;
|
||||
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
|
||||
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
|
||||
|
||||
// Component constructor
|
||||
static OUString static_getImplementationName();
|
||||
static css::uno::Sequence < OUString > static_getSupportedServiceNames();
|
||||
static css::uno::Reference < css::lang::XSingleServiceFactory > createServiceFactory( css::uno::Reference < css::lang::XMultiServiceFactory > const & rServiceFactory );
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -72,26 +72,9 @@ void SAL_CALL ManifestWriter::writeManifestSequence( const Reference< XOutputStr
|
|||
}
|
||||
}
|
||||
|
||||
// Component methods
|
||||
static Reference < XInterface > ManifestWriter_createInstance( Reference< XMultiServiceFactory > const & rServiceFactory )
|
||||
{
|
||||
return *new ManifestWriter( comphelper::getComponentContext(rServiceFactory) );
|
||||
}
|
||||
|
||||
OUString ManifestWriter::static_getImplementationName()
|
||||
{
|
||||
return "com.sun.star.packages.manifest.comp.ManifestWriter";
|
||||
}
|
||||
|
||||
Sequence < OUString > ManifestWriter::static_getSupportedServiceNames()
|
||||
{
|
||||
Sequence<OUString> aNames { "com.sun.star.packages.manifest.ManifestWriter" };
|
||||
return aNames;
|
||||
}
|
||||
|
||||
OUString ManifestWriter::getImplementationName()
|
||||
{
|
||||
return static_getImplementationName();
|
||||
return "com.sun.star.packages.manifest.comp.ManifestWriter";
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL ManifestWriter::supportsService(OUString const & rServiceName)
|
||||
|
@ -100,14 +83,15 @@ sal_Bool SAL_CALL ManifestWriter::supportsService(OUString const & rServiceName)
|
|||
}
|
||||
Sequence < OUString > ManifestWriter::getSupportedServiceNames()
|
||||
{
|
||||
return static_getSupportedServiceNames();
|
||||
return { "com.sun.star.packages.manifest.ManifestWriter" };
|
||||
}
|
||||
Reference < XSingleServiceFactory > ManifestWriter::createServiceFactory( Reference < XMultiServiceFactory > const & rServiceFactory )
|
||||
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
package_ManifestWriter_get_implementation(
|
||||
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::createSingleFactory (rServiceFactory,
|
||||
static_getImplementationName(),
|
||||
ManifestWriter_createInstance,
|
||||
static_getSupportedServiceNames());
|
||||
return cppu::acquire(new ManifestWriter(context));
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -49,11 +49,6 @@ public:
|
|||
virtual OUString SAL_CALL getImplementationName( ) override;
|
||||
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
|
||||
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
|
||||
|
||||
// Component constructor
|
||||
static OUString static_getImplementationName();
|
||||
static css::uno::Sequence < OUString > static_getSupportedServiceNames();
|
||||
static css::uno::Reference < css::lang::XSingleServiceFactory > createServiceFactory( css::uno::Reference < css::lang::XMultiServiceFactory > const & rServiceFactory );
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,70 +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 "ManifestReader.hxx"
|
||||
#include "ManifestWriter.hxx"
|
||||
#include <cppuhelper/factory.hxx>
|
||||
#include <com/sun/star/registry/XRegistryKey.hpp>
|
||||
#include <ZipPackage.hxx>
|
||||
|
||||
#include <zipfileaccess.hxx>
|
||||
|
||||
using namespace ::com::sun::star;
|
||||
using namespace ::com::sun::star::uno;
|
||||
using namespace ::com::sun::star::beans;
|
||||
using namespace ::com::sun::star::lang;
|
||||
using namespace ::com::sun::star::registry;
|
||||
using namespace ::com::sun::star::packages;
|
||||
|
||||
/**
|
||||
* This function is called to get service factories for an implementation.
|
||||
* @param pImplName name of implementation
|
||||
* @param pServiceManager generic uno interface providing a service manager to instantiate components
|
||||
* @param pRegistryKey registry data key to read and write component persistent data
|
||||
* @return a component factory (generic uno interface)
|
||||
*/
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT void * package2_component_getFactory(
|
||||
const char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
|
||||
{
|
||||
void * pRet = nullptr;
|
||||
uno::Reference< XMultiServiceFactory > xSMgr(
|
||||
static_cast< XMultiServiceFactory * >( pServiceManager ) );
|
||||
uno::Reference< XSingleServiceFactory > xFactory;
|
||||
|
||||
if (ManifestReader::static_getImplementationName().equalsAscii( pImplName ) )
|
||||
xFactory = ManifestReader::createServiceFactory ( xSMgr );
|
||||
else if (ManifestWriter::static_getImplementationName().equalsAscii( pImplName ) )
|
||||
xFactory = ManifestWriter::createServiceFactory ( xSMgr );
|
||||
else if (ZipPackage::static_getImplementationName().equalsAscii( pImplName ) )
|
||||
xFactory = ZipPackage::createServiceFactory ( xSMgr );
|
||||
else if ( OZipFileAccess::impl_staticGetImplementationName().equalsAscii( pImplName ) )
|
||||
xFactory = ::cppu::createSingleFactory( xSMgr,
|
||||
OZipFileAccess::impl_staticGetImplementationName(),
|
||||
OZipFileAccess::impl_staticCreateSelfInstance,
|
||||
OZipFileAccess::impl_staticGetSupportedServiceNames() );
|
||||
|
||||
if ( xFactory.is() )
|
||||
{
|
||||
xFactory->acquire();
|
||||
pRet = xFactory.get();
|
||||
}
|
||||
return pRet;
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
|
@ -1661,34 +1661,15 @@ Sequence< ElementChange > SAL_CALL ZipPackage::getPendingChanges()
|
|||
return uno::Sequence < ElementChange > ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to create a new component instance; is needed by factory helper implementation.
|
||||
* @param xMgr service manager to if the components needs other component instances
|
||||
*/
|
||||
static uno::Reference < XInterface > ZipPackage_createInstance(
|
||||
const uno::Reference< XMultiServiceFactory > & xMgr )
|
||||
{
|
||||
return uno::Reference< XInterface >( *new ZipPackage( comphelper::getComponentContext(xMgr) ) );
|
||||
}
|
||||
|
||||
OUString ZipPackage::static_getImplementationName()
|
||||
OUString ZipPackage::getImplementationName()
|
||||
{
|
||||
return "com.sun.star.packages.comp.ZipPackage";
|
||||
}
|
||||
|
||||
Sequence< OUString > ZipPackage::static_getSupportedServiceNames()
|
||||
{
|
||||
return { "com.sun.star.packages.Package" };
|
||||
}
|
||||
|
||||
OUString ZipPackage::getImplementationName()
|
||||
{
|
||||
return static_getImplementationName();
|
||||
}
|
||||
|
||||
Sequence< OUString > ZipPackage::getSupportedServiceNames()
|
||||
{
|
||||
return static_getSupportedServiceNames();
|
||||
return { "com.sun.star.packages.Package" };
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL ZipPackage::supportsService( OUString const & rServiceName )
|
||||
|
@ -1696,14 +1677,6 @@ sal_Bool SAL_CALL ZipPackage::supportsService( OUString const & rServiceName )
|
|||
return cppu::supportsService(this, rServiceName);
|
||||
}
|
||||
|
||||
uno::Reference < XSingleServiceFactory > ZipPackage::createServiceFactory( uno::Reference < XMultiServiceFactory > const & rServiceFactory )
|
||||
{
|
||||
return cppu::createSingleFactory ( rServiceFactory,
|
||||
static_getImplementationName(),
|
||||
ZipPackage_createInstance,
|
||||
static_getSupportedServiceNames() );
|
||||
}
|
||||
|
||||
Sequence< sal_Int8 > ZipPackage::getUnoTunnelId()
|
||||
{
|
||||
static ::cppu::OImplementationId implId;
|
||||
|
@ -1872,4 +1845,11 @@ void SAL_CALL ZipPackage::removeVetoableChangeListener( const OUString& /*Proper
|
|||
{
|
||||
}
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
package_ZipPackage_get_implementation(
|
||||
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new ZipPackage(context));
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -449,28 +449,9 @@ void SAL_CALL OZipFileAccess::removeEventListener( const uno::Reference< lang::X
|
|||
m_pListenersContainer->removeInterface( xListener );
|
||||
}
|
||||
|
||||
uno::Sequence< OUString > OZipFileAccess::impl_staticGetSupportedServiceNames()
|
||||
{
|
||||
uno::Sequence< OUString > aRet(2);
|
||||
aRet[0] = "com.sun.star.packages.zip.ZipFileAccess";
|
||||
aRet[1] = "com.sun.star.comp.packages.zip.ZipFileAccess";
|
||||
return aRet;
|
||||
}
|
||||
|
||||
OUString OZipFileAccess::impl_staticGetImplementationName()
|
||||
{
|
||||
return "com.sun.star.comp.package.zip.ZipFileAccess";
|
||||
}
|
||||
|
||||
uno::Reference< uno::XInterface > OZipFileAccess::impl_staticCreateSelfInstance(
|
||||
const uno::Reference< lang::XMultiServiceFactory >& rxMSF )
|
||||
{
|
||||
return uno::Reference< uno::XInterface >( *new OZipFileAccess( comphelper::getComponentContext(rxMSF) ) );
|
||||
}
|
||||
|
||||
OUString SAL_CALL OZipFileAccess::getImplementationName()
|
||||
{
|
||||
return impl_staticGetImplementationName();
|
||||
return "com.sun.star.comp.package.zip.ZipFileAccess";
|
||||
}
|
||||
|
||||
sal_Bool SAL_CALL OZipFileAccess::supportsService( const OUString& ServiceName )
|
||||
|
@ -480,7 +461,17 @@ sal_Bool SAL_CALL OZipFileAccess::supportsService( const OUString& ServiceName )
|
|||
|
||||
uno::Sequence< OUString > SAL_CALL OZipFileAccess::getSupportedServiceNames()
|
||||
{
|
||||
return impl_staticGetSupportedServiceNames();
|
||||
return { "com.sun.star.packages.zip.ZipFileAccess",
|
||||
"com.sun.star.comp.packages.zip.ZipFileAccess" };
|
||||
}
|
||||
|
||||
|
||||
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
|
||||
package_OZipFileAccess_get_implementation(
|
||||
css::uno::XComponentContext* context , css::uno::Sequence<css::uno::Any> const&)
|
||||
{
|
||||
return cppu::acquire(new OZipFileAccess(context));
|
||||
}
|
||||
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -18,18 +18,22 @@
|
|||
-->
|
||||
|
||||
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
|
||||
prefix="package2" xmlns="http://openoffice.org/2010/uno-components">
|
||||
<implementation name="com.sun.star.comp.package.zip.ZipFileAccess">
|
||||
xmlns="http://openoffice.org/2010/uno-components">
|
||||
<implementation name="com.sun.star.comp.package.zip.ZipFileAccess"
|
||||
constructor="package_OZipFileAccess_get_implementation">
|
||||
<service name="com.sun.star.comp.packages.zip.ZipFileAccess"/>
|
||||
<service name="com.sun.star.packages.zip.ZipFileAccess"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.packages.comp.ZipPackage">
|
||||
<implementation name="com.sun.star.packages.comp.ZipPackage"
|
||||
constructor="package_ZipPackage_get_implementation">
|
||||
<service name="com.sun.star.packages.Package"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.packages.manifest.comp.ManifestReader">
|
||||
<implementation name="com.sun.star.packages.manifest.comp.ManifestReader"
|
||||
constructor="package_ManifestReader_get_implementation">
|
||||
<service name="com.sun.star.packages.manifest.ManifestReader"/>
|
||||
</implementation>
|
||||
<implementation name="com.sun.star.packages.manifest.comp.ManifestWriter">
|
||||
<implementation name="com.sun.star.packages.manifest.comp.ManifestWriter"
|
||||
constructor="package_ManifestWriter_get_implementation">
|
||||
<service name="com.sun.star.packages.manifest.ManifestWriter"/>
|
||||
</implementation>
|
||||
</component>
|
||||
|
|
|
@ -23,7 +23,6 @@ core_factory_list = [
|
|||
("libembobj.a", "embobj_component_getFactory"),
|
||||
("libfilterconfiglo.a", "filterconfig1_component_getFactory"),
|
||||
("libi18npoollo.a", "i18npool_component_getFactory"),
|
||||
("libpackage2.a", "package2_component_getFactory"),
|
||||
("libsmlo.a", "sm_component_getFactory"),
|
||||
("libsrtrs1.a", "srtrs1_component_getFactory"),
|
||||
("libucb1.a", "ucb_component_getFactory"),
|
||||
|
@ -244,6 +243,11 @@ core_constructor_list = [
|
|||
("lingucomponent_SpellChecker_get_implementation", "#ifndef IOS"),
|
||||
"lingucomponent_LangGuess_get_implementation",
|
||||
"lingucomponent_Hyphenator_get_implementation",
|
||||
# package/util/package2.component
|
||||
"package_OZipFileAccess_get_implementation",
|
||||
"package_ZipPackage_get_implementation",
|
||||
"package_ManifestReader_get_implementation",
|
||||
"package_ManifestWriter_get_implementation",
|
||||
# sax/source/expatwrap/expwrap.component
|
||||
"com_sun_star_comp_extensions_xml_sax_FastParser_get_implementation",
|
||||
"com_sun_star_comp_extensions_xml_sax_ParserExpat_get_implementation",
|
||||
|
|
Loading…
Reference in a new issue