UnoControl: create instances with uno constructors

See tdf#74608 for motivation.

Change-Id: I3df173e3c7064d3d925d3abe5c652b8cbe6c8ea5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97892
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2020-07-03 19:39:03 +02:00 committed by Noel Grandin
parent 7dcc18b5ac
commit 78639945da
12 changed files with 42 additions and 210 deletions

View file

@ -31,7 +31,6 @@ $(eval $(call gb_Library_add_exception_objects,ctl,\
UnoControls/source/base/basecontainercontrol \
UnoControls/source/base/basecontrol \
UnoControls/source/base/multiplexer \
UnoControls/source/base/registercontrols \
UnoControls/source/controls/OConnectionPointContainerHelper \
UnoControls/source/controls/OConnectionPointHelper \
UnoControls/source/controls/framecontrol \

View file

@ -1,122 +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 <sal/config.h>
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <comphelper/processfactory.hxx>
#include <cppuhelper/factory.hxx>
#include <framecontrol.hxx>
#include <progressbar.hxx>
#include <progressmonitor.hxx>
#include <statusindicator.hxx>
namespace com::sun::star::lang { class XMultiServiceFactory; }
namespace {
/// @throws css::uno::Exception
css::uno::Reference<css::uno::XInterface> FrameControl_createInstance(
css::uno::Reference<css::lang::XMultiServiceFactory> const &
rServiceManager)
{
return static_cast<cppu::OWeakObject *>(
new unocontrols::FrameControl(
comphelper::getComponentContext(rServiceManager)));
}
/// @throws css::uno::Exception
css::uno::Reference<css::uno::XInterface> ProgressBar_createInstance(
css::uno::Reference<css::lang::XMultiServiceFactory> const &
rServiceManager)
{
return static_cast<cppu::OWeakObject *>(
new unocontrols::ProgressBar(
comphelper::getComponentContext(rServiceManager)));
}
/// @throws css::uno::Exception
css::uno::Reference<css::uno::XInterface>
ProgressMonitor_createInstance(
css::uno::Reference<css::lang::XMultiServiceFactory> const &
rServiceManager)
{
return static_cast<cppu::OWeakObject *>(
new unocontrols::ProgressMonitor(
comphelper::getComponentContext(rServiceManager)));
}
/// @throws css::uno::Exception
css::uno::Reference<css::uno::XInterface>
StatusIndicator_createInstance(
css::uno::Reference<css::lang::XMultiServiceFactory> const &
rServiceManager)
{
return static_cast<cppu::OWeakObject *>(
new unocontrols::StatusIndicator(
comphelper::getComponentContext(rServiceManager)));
}
}
extern "C" SAL_DLLPUBLIC_EXPORT void * ctl_component_getFactory(
char const * pImplName, void * pServiceManager, SAL_UNUSED_PARAMETER void *)
{
css::uno::Reference<css::lang::XMultiServiceFactory > smgr(
static_cast<css::lang::XMultiServiceFactory *>(pServiceManager));
css::uno::Reference<css::lang::XSingleServiceFactory> fac;
if (unocontrols::FrameControl::impl_getStaticImplementationName()
.equalsAscii(pImplName))
{
fac = cppu::createSingleFactory(
smgr, unocontrols::FrameControl::impl_getStaticImplementationName(),
&FrameControl_createInstance,
unocontrols::FrameControl::impl_getStaticSupportedServiceNames());
} else if (unocontrols::ProgressBar::impl_getStaticImplementationName()
.equalsAscii(pImplName))
{
fac = cppu::createSingleFactory(
smgr, unocontrols::ProgressBar::impl_getStaticImplementationName(),
&ProgressBar_createInstance,
unocontrols::ProgressBar::impl_getStaticSupportedServiceNames());
} else if (unocontrols::ProgressMonitor::impl_getStaticImplementationName()
.equalsAscii(pImplName))
{
fac = cppu::createSingleFactory(
smgr,
unocontrols::ProgressMonitor::impl_getStaticImplementationName(),
&ProgressMonitor_createInstance,
unocontrols::ProgressMonitor::impl_getStaticSupportedServiceNames());
} else if (unocontrols::StatusIndicator::impl_getStaticImplementationName()
.equalsAscii(pImplName))
{
fac = cppu::createSingleFactory(
smgr,
unocontrols::StatusIndicator::impl_getStaticImplementationName(),
&StatusIndicator_createInstance,
unocontrols::StatusIndicator::impl_getStaticSupportedServiceNames());
}
if (fac.is()) {
fac->acquire();
}
return fac.get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -155,12 +155,12 @@ Any SAL_CALL FrameControl::queryAggregation( const Type& aType )
OUString FrameControl::getImplementationName()
{
return impl_getStaticImplementationName();
return "stardiv.UnoControls.FrameControl";
}
css::uno::Sequence<OUString> FrameControl::getSupportedServiceNames()
{
return impl_getStaticSupportedServiceNames();
return { "com.sun.star.frame.FrameControl" };
}
// XControl
@ -252,20 +252,6 @@ void SAL_CALL FrameControl::unadvise( const Type& aTyp
m_aConnectionPointContainer->unadvise( aType, xListener );
}
// impl but public method to register service
Sequence< OUString > FrameControl::impl_getStaticSupportedServiceNames()
{
return { "com.sun.star.frame.FrameControl" };
}
// impl but public method to register service
OUString FrameControl::impl_getStaticImplementationName()
{
return "stardiv.UnoControls.FrameControl";
}
// OPropertySetHelper
sal_Bool FrameControl::convertFastPropertyValue( Any& rConvertedValue ,
@ -467,4 +453,10 @@ void FrameControl::impl_deleteFrame()
} // namespace unocontrols
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
stardiv_UnoControls_FrameControl_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new unocontrols::FrameControl(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -283,20 +283,6 @@ Reference< XControlModel > SAL_CALL ProgressBar::getModel()
return Reference< XControlModel >();
}
// impl but public method to register service
Sequence< OUString > ProgressBar::impl_getStaticSupportedServiceNames()
{
return css::uno::Sequence<OUString>();
}
// impl but public method to register service
OUString ProgressBar::impl_getStaticImplementationName()
{
return "stardiv.UnoControls.ProgressBar";
}
// protected method
void ProgressBar::impl_paint ( sal_Int32 nX, sal_Int32 nY, const Reference< XGraphics > & rGraphics )
@ -407,4 +393,10 @@ void ProgressBar::impl_recalcRange ()
} // namespace unocontrols
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
stardiv_UnoControls_ProgressBar_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new unocontrols::ProgressBar(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -530,18 +530,6 @@ void SAL_CALL ProgressMonitor::setPosSize ( sal_Int32 nX, sal_Int32 nY, sal_Int3
}
}
// impl but public method to register service
Sequence< OUString > ProgressMonitor::impl_getStaticSupportedServiceNames()
{
return css::uno::Sequence<OUString>();
}
// impl but public method to register service
OUString ProgressMonitor::impl_getStaticImplementationName()
{
return "stardiv.UnoControls.ProgressMonitor";
}
// protected method
void ProgressMonitor::impl_paint ( sal_Int32 nX, sal_Int32 nY, const css::uno::Reference< XGraphics > & rGraphics )
{
@ -865,4 +853,10 @@ bool ProgressMonitor::impl_debug_checkParameter ( const OUString& rTopic )
} // namespace unocontrols
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
stardiv_UnoControls_ProgressMonitor_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new unocontrols::ProgressMonitor(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -343,20 +343,6 @@ void SAL_CALL StatusIndicator::setPosSize (
}
}
// impl but public method to register service
Sequence< OUString > StatusIndicator::impl_getStaticSupportedServiceNames()
{
return css::uno::Sequence<OUString>();
}
// impl but public method to register service
OUString StatusIndicator::impl_getStaticImplementationName()
{
return "stardiv.UnoControls.StatusIndicator";
}
// protected method
WindowDescriptor StatusIndicator::impl_getWindowDescriptor( const css::uno::Reference< XWindowPeer >& xParentPeer )
@ -459,4 +445,11 @@ void StatusIndicator::impl_recalcLayout ( const WindowEvent& aEvent )
} // namespace unocontrols
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
stardiv_UnoControls_StatusIndicator_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
return cppu::acquire(new unocontrols::StatusIndicator(context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View file

@ -124,12 +124,6 @@ public:
const css::uno::Reference< css::uno::XInterface >& xListener
) override;
// impl but public methods to register service!
static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
static OUString impl_getStaticImplementationName();
private:
using OPropertySetHelper::getFastPropertyValue;

View file

@ -112,12 +112,6 @@ public:
virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() override;
// BaseControl
static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
static OUString impl_getStaticImplementationName();
private:
virtual void impl_paint(
sal_Int32 nX ,

View file

@ -206,12 +206,6 @@ public:
sal_Int32 nHeight ,
sal_Int16 nFlags ) override;
// BaseControl
static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
static OUString impl_getStaticImplementationName();
private:
virtual void impl_paint( sal_Int32 nX ,
sal_Int32 nY ,

View file

@ -148,12 +148,6 @@ public:
sal_Int32 nHeight ,
sal_Int16 nFlags ) override;
// BaseControl
static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames();
static OUString impl_getStaticImplementationName();
private:
virtual css::awt::WindowDescriptor impl_getWindowDescriptor(
const css::uno::Reference< css::awt::XWindowPeer >& xParentPeer

View file

@ -18,11 +18,15 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="ctl" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="stardiv.UnoControls.FrameControl">
<service name="com.sun.star.frame.FrameControl"/>
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="stardiv.UnoControls.FrameControl"
constructor="stardiv_UnoControls_FrameControl_get_implementation">
<service name="com.sun.star.frame.FrameControl" />
</implementation>
<implementation name="stardiv.UnoControls.ProgressBar"/>
<implementation name="stardiv.UnoControls.ProgressMonitor"/>
<implementation name="stardiv.UnoControls.StatusIndicator"/>
<implementation name="stardiv.UnoControls.ProgressBar"
constructor="stardiv_UnoControls_ProgressBar_get_implementation"/>
<implementation name="stardiv.UnoControls.ProgressMonitor"
constructor="stardiv_UnoControls_ProgressMonitor_get_implementation"/>
<implementation name="stardiv.UnoControls.StatusIndicator"
constructor="stardiv_UnoControls_StatusIndicator_get_implementation"/>
</component>

View file

@ -61,7 +61,6 @@ core_factory_list = [
("libpdffilterlo.a", "pdffilter_component_getFactory"),
("libsvgiolo.a", "svgio_component_getFactory"),
("libsvtlo.a", "svt_component_getFactory"),
("libctllo.a", "ctl_component_getFactory"),
("libMacOSXSpelllo.a", "MacOSXSpell_component_getFactory", "#ifdef IOS"),
("libcuilo.a", "cui_component_getFactory"),
("libproxyfaclo.a", "proxyfac_component_getFactory"),
@ -71,6 +70,11 @@ core_factory_list = [
]
core_constructor_list = [
# UnoControls/util/ctl.component
"stardiv_UnoControls_FrameControl_get_implementation",
"stardiv_UnoControls_ProgressBar_get_implementation",
"stardiv_UnoControls_ProgressMonitor_get_implementation",
"stardiv_UnoControls_StatusIndicator_get_implementation",
# canvas/source/factory/canvasfactory.component
"com_sun_star_comp_rendering_CanvasFactory_get_implementation",
# chart2/source/chartcore.component