cui,cppcanvas: create instances with uno constructors

See tdf#74608 for motivation

Change-Id: Id603bc26f95d3da86b8c7360a7bde8eee97049ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98141
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2020-07-06 12:25:13 +02:00
committed by Noel Grandin
parent 088b7f419f
commit 29c5e1ccbe
9 changed files with 52 additions and 165 deletions
+3 -2
View File
@@ -8,8 +8,9 @@
*
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="mtfrenderer" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.rendering.MtfRenderer">
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.rendering.MtfRenderer"
constructor="com_sun_star_comp_rendering_MtfRenderer_get_implementation">
<service name="com.sun.star.rendering.MtfRenderer"/>
</implementation>
</component>
+36 -12
View File
@@ -7,13 +7,42 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "uno_mtfrenderer.hxx"
#include <cppcanvas/vclfactory.hxx>
#include <comphelper/servicedecl.hxx>
#include <o3tl/any.hxx>
#include <com/sun/star/rendering/XMtfRenderer.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/XFastPropertySet.hpp>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
#include <vcl/gdimtf.hxx>
using namespace ::com::sun::star;
typedef cppu::WeakComponentImplHelper<css::rendering::XMtfRenderer, css::beans::XFastPropertySet> MtfRendererBase;
namespace {
class MtfRenderer : private cppu::BaseMutex, public MtfRendererBase
{
public:
MtfRenderer (css::uno::Sequence<css::uno::Any> const& args,
css::uno::Reference<css::uno::XComponentContext> const&);
// XMtfRenderer iface
void SAL_CALL setMetafile (const css::uno::Sequence< sal_Int8 >& rMtf) override;
void SAL_CALL draw (double fScaleX, double fScaleY) override;
// XFastPropertySet
// setFastPropertyValue (0, GDIMetaFile*) is used to speedup the rendering
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 /*nHandle*/) override { return css::uno::Any(); }
virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any&) override;
private:
GDIMetaFile* mpMetafile;
css::uno::Reference<css::rendering::XBitmapCanvas> mxCanvas;
};
void MtfRenderer::setMetafile (const uno::Sequence< sal_Int8 >& /*rMtf*/)
{
// printf ("MtfRenderer::setMetafile unimplemented, use fast property set or implement me\n");
@@ -45,18 +74,13 @@ MtfRenderer::MtfRenderer (uno::Sequence<uno::Any> const& aArgs, uno::Reference<u
}
}
namespace sdecl = comphelper::service_decl;
const sdecl::ServiceDecl MtfRendererDecl(
sdecl::class_<MtfRenderer, sdecl::with_args<true> >(),
"com.sun.star.comp.rendering.MtfRenderer",
"com.sun.star.rendering.MtfRenderer" );
} // namespace
// The C shared lib entry points
extern "C"
SAL_DLLPUBLIC_EXPORT void* mtfrenderer_component_getFactory( char const* pImplName,
void*, void* )
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_comp_rendering_MtfRenderer_get_implementation(
css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
{
return sdecl::component_getFactoryHelper( pImplName, {&MtfRendererDecl} );
return cppu::acquire(new MtfRenderer(args, context));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-44
View File
@@ -1,44 +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/.
*/
#ifndef INCLUDED_CPPCANVAS_SOURCE_UNO_UNO_MTFRENDERER_HXX
#define INCLUDED_CPPCANVAS_SOURCE_UNO_UNO_MTFRENDERER_HXX
#include <com/sun/star/rendering/XMtfRenderer.hpp>
#include <com/sun/star/rendering/XBitmapCanvas.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/XFastPropertySet.hpp>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/basemutex.hxx>
#include <vcl/gdimtf.hxx>
typedef cppu::WeakComponentImplHelper<css::rendering::XMtfRenderer, css::beans::XFastPropertySet> MtfRendererBase;
class MtfRenderer : private cppu::BaseMutex, public MtfRendererBase
{
public:
MtfRenderer (css::uno::Sequence<css::uno::Any> const& args,
css::uno::Reference<css::uno::XComponentContext> const&);
// XMtfRenderer iface
void SAL_CALL setMetafile (const css::uno::Sequence< sal_Int8 >& rMtf) override;
void SAL_CALL draw (double fScaleX, double fScaleY) override;
// XFastPropertySet
// setFastPropertyValue (0, GDIMetaFile*) is used to speedup the rendering
virtual css::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 /*nHandle*/) override { return css::uno::Any(); }
virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const css::uno::Any&) override;
private:
GDIMetaFile* mpMetafile;
css::uno::Reference<css::rendering::XBitmapCanvas> mxCanvas;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-1
View File
@@ -226,7 +226,6 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
cui/source/tabpages/tpshadow \
cui/source/tabpages/tptrans \
cui/source/tabpages/transfrm \
cui/source/uno/services \
))
# vim: set noet sw=4 ts=4:
+6 -14
View File
@@ -33,7 +33,6 @@
#include <vcl/weld.hxx>
#include <svx/hexcolorcontrol.hxx>
#include <basegfx/color/bcolortools.hxx>
#include <colorpicker.hxx>
#include <cmath>
#include <o3tl/typed_flags_set.hxx>
@@ -1240,20 +1239,13 @@ private:
}
OUString ColorPicker_getImplementationName()
extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
com_sun_star_cui_ColorPicker_get_implementation(
css::uno::XComponentContext*, css::uno::Sequence<css::uno::Any> const&)
{
return "com.sun.star.cui.ColorPicker";
return cppu::acquire( new ColorPicker );
}
Reference< XInterface > ColorPicker_createInstance( Reference< XComponentContext > const & )
{
return static_cast<XWeak*>( new ColorPicker );
}
Sequence< OUString > ColorPicker_getSupportedServiceNames()
{
return { "com.sun.star.ui.dialogs.ColorPicker" };
}
const OUStringLiteral gsColorKey( "Color" );
const OUStringLiteral gsModeKey( "Mode" );
@@ -1277,7 +1269,7 @@ void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments )
// XInitialization
OUString SAL_CALL ColorPicker::getImplementationName( )
{
return ColorPicker_getImplementationName();
return "com.sun.star.cui.ColorPicker";
}
sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName )
@@ -1287,7 +1279,7 @@ sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName )
Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames( )
{
return ColorPicker_getSupportedServiceNames();
return { "com.sun.star.ui.dialogs.ColorPicker" };
}
// XPropertyAccess
-47
View File
@@ -1,47 +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_CUI_SOURCE_INC_COLORPICKER_HXX
#define INCLUDED_CUI_SOURCE_INC_COLORPICKER_HXX
#include <sal/config.h>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/ustring.hxx>
namespace com::sun::star::uno {
class XComponentContext;
class XInterface;
}
namespace cui {
OUString ColorPicker_getImplementationName();
css::uno::Reference<css::uno::XInterface> ColorPicker_createInstance(
css::uno::Reference<css::uno::XComponentContext> const &);
/// @throws css::uno::RuntimeException
css::uno::Sequence<OUString> ColorPicker_getSupportedServiceNames();
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-41
View File
@@ -1,41 +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/types.h>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <colorpicker.hxx>
using namespace com::sun::star;
namespace
{
cppu::ImplementationEntry const entries[] = {
{ &::cui::ColorPicker_createInstance, &::cui::ColorPicker_getImplementationName, &::cui::ColorPicker_getSupportedServiceNames, &cppu::createSingleComponentFactory, nullptr, 0 },
{ nullptr, nullptr, nullptr, nullptr, nullptr, 0 }
};
}
extern "C" SAL_DLLPUBLIC_EXPORT void * cui_component_getFactory( char const * implName, void * serviceManager, void * registryKey)
{
return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+3 -2
View File
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="cui" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.cui.ColorPicker">
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.cui.ColorPicker"
constructor="com_sun_star_cui_ColorPicker_get_implementation">
<service name="com.sun.star.ui.dialogs.ColorPicker"/>
</implementation>
</component>
+4 -2
View File
@@ -47,7 +47,6 @@ core_factory_list = [
("libutllo.a", "utl_component_getFactory"),
("libxoflo.a", "xof_component_getFactory"),
("libxstor.a", "xstor_component_getFactory"),
("libmtfrendererlo.a", "mtfrenderer_component_getFactory"),
("libxmlfdlo.a", "xmlfd_component_getFactory"),
("libxmlfalo.a", "xmlfa_component_getFactory"),
("libodfflatxmllo.a", "odfflatxml_component_getFactory"),
@@ -59,7 +58,6 @@ core_factory_list = [
("libsvgiolo.a", "svgio_component_getFactory"),
("libsvtlo.a", "svt_component_getFactory"),
("libMacOSXSpelllo.a", "MacOSXSpell_component_getFactory", "#ifdef IOS"),
("libcuilo.a", "cui_component_getFactory"),
("libproxyfaclo.a", "proxyfac_component_getFactory"),
("libguesslanglo.a", "guesslang_component_getFactory"),
("libbiblo.a", "bib_component_getFactory"),
@@ -147,6 +145,10 @@ core_constructor_list = [
"com_sun_star_comp_configuration_ReadOnlyAccess_get_implementation",
"com_sun_star_comp_configuration_ReadWriteAccess_get_implementation",
"com_sun_star_comp_configuration_Update_get_implementation",
# cppcanvas/source/uno/mtfrenderer.component
"com_sun_star_comp_rendering_MtfRenderer_get_implementation",
# cui/util/cui.component
"com_sun_star_cui_ColorPicker_get_implementation",
# dbaccess/util/dba.component
"com_sun_star_comp_dba_ORowSet_get_implementation",
# extensions/source/logging/log.component