From 87e5ee310959d535c53a083258edff1b3b1335bd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sat, 4 Jul 2020 12:48:14 +0200 Subject: canvas/vcl: create instances with uno constructors See tdf#74608 for motivation Change-Id: Ifcd31616228234433d8d46fef50707de9d17f3b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98092 Tested-by: Jenkins Reviewed-by: Noel Grandin --- canvas/Library_vclcanvas.mk | 1 - canvas/source/vcl/canvas.cxx | 12 +++++- canvas/source/vcl/canvas.hxx | 3 -- canvas/source/vcl/services.cxx | 69 ----------------------------------- canvas/source/vcl/spritecanvas.cxx | 12 +++++- canvas/source/vcl/spritecanvas.hxx | 3 -- canvas/source/vcl/vclcanvas.component | 8 ++-- 7 files changed, 27 insertions(+), 81 deletions(-) delete mode 100644 canvas/source/vcl/services.cxx (limited to 'canvas') diff --git a/canvas/Library_vclcanvas.mk b/canvas/Library_vclcanvas.mk index 40e5de9eb61d..27a54ba651a6 100644 --- a/canvas/Library_vclcanvas.mk +++ b/canvas/Library_vclcanvas.mk @@ -59,7 +59,6 @@ $(eval $(call gb_Library_add_exception_objects,vclcanvas,\ canvas/source/vcl/canvashelper \ canvas/source/vcl/devicehelper \ canvas/source/vcl/impltools \ - canvas/source/vcl/services \ canvas/source/vcl/spritecanvas \ canvas/source/vcl/spritecanvashelper \ canvas/source/vcl/spritedevicehelper \ diff --git a/canvas/source/vcl/canvas.cxx b/canvas/source/vcl/canvas.cxx index 4713f8ab9d34..e8f6ffe0c62a 100644 --- a/canvas/source/vcl/canvas.cxx +++ b/canvas/source/vcl/canvas.cxx @@ -114,7 +114,7 @@ namespace vclcanvas OUString SAL_CALL Canvas::getServiceName( ) { - return CANVAS_SERVICE_NAME; + return "com.sun.star.rendering.Canvas.VCL"; } bool Canvas::repaint( const GraphicObjectSharedPtr& rGrf, @@ -130,4 +130,14 @@ namespace vclcanvas } } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_rendering_Canvas_VCL_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const& args) +{ + auto p = new vclcanvas::Canvas(args, context); + cppu::acquire(p); + p->initialize(); + return static_cast(p); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/source/vcl/canvas.hxx b/canvas/source/vcl/canvas.hxx index 6a3c66b00d75..62f71b216848 100644 --- a/canvas/source/vcl/canvas.hxx +++ b/canvas/source/vcl/canvas.hxx @@ -41,9 +41,6 @@ #include "devicehelper.hxx" #include "repainttarget.hxx" -#define CANVAS_SERVICE_NAME "com.sun.star.rendering.Canvas.VCL" -#define CANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.Canvas.VCL" - namespace vclcanvas { typedef ::cppu::WeakComponentImplHelper< css::rendering::XBitmapCanvas, diff --git a/canvas/source/vcl/services.cxx b/canvas/source/vcl/services.cxx deleted file mode 100644 index 7b130c6fda32..000000000000 --- a/canvas/source/vcl/services.cxx +++ /dev/null @@ -1,69 +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 - -#include - -#include "canvas.hxx" -#include "spritecanvas.hxx" - - -using namespace ::com::sun::star; - -namespace sdecl = comphelper::service_decl; - -namespace vclcanvas -{ - static uno::Reference initCanvas( Canvas* pCanvas ) - { - uno::Reference xRet(static_cast(pCanvas)); - pCanvas->initialize(); - return xRet; - } - - sdecl::class_ > const serviceImpl1(&initCanvas); - const sdecl::ServiceDecl vclCanvasDecl( - serviceImpl1, - CANVAS_IMPLEMENTATION_NAME, - CANVAS_SERVICE_NAME ); - - static uno::Reference initSpriteCanvas( SpriteCanvas* pCanvas ) - { - uno::Reference xRet(static_cast(pCanvas)); - pCanvas->initialize(); - return xRet; - } - - sdecl::class_ > const serviceImpl2(&initSpriteCanvas); - const sdecl::ServiceDecl vclSpriteCanvasDecl( - serviceImpl2, - SPRITECANVAS_IMPLEMENTATION_NAME, - SPRITECANVAS_SERVICE_NAME ); -} - -// The C shared lib entry points -extern "C" -SAL_DLLPUBLIC_EXPORT void* vclcanvas_component_getFactory( char const* pImplName, - void*, void* ) -{ - return sdecl::component_getFactoryHelper( pImplName, {&vclcanvas::vclCanvasDecl, &vclcanvas::vclSpriteCanvasDecl} ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/source/vcl/spritecanvas.cxx b/canvas/source/vcl/spritecanvas.cxx index 90aa55228b28..a82bf0d4db18 100644 --- a/canvas/source/vcl/spritecanvas.cxx +++ b/canvas/source/vcl/spritecanvas.cxx @@ -128,7 +128,7 @@ namespace vclcanvas OUString SAL_CALL SpriteCanvas::getServiceName( ) { - return SPRITECANVAS_SERVICE_NAME; + return "com.sun.star.rendering.SpriteCanvas.VCL"; } bool SpriteCanvas::repaint( const GraphicObjectSharedPtr& rGrf, @@ -144,4 +144,14 @@ namespace vclcanvas } } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +com_sun_star_comp_rendering_SpriteCanvas_VCL_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence const& args) +{ + auto p = new vclcanvas::SpriteCanvas(args, context); + cppu::acquire(p); + p->initialize(); + return static_cast(p); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/canvas/source/vcl/spritecanvas.hxx b/canvas/source/vcl/spritecanvas.hxx index fcca957dbc5c..06c70faca2c3 100644 --- a/canvas/source/vcl/spritecanvas.hxx +++ b/canvas/source/vcl/spritecanvas.hxx @@ -46,9 +46,6 @@ #include "repainttarget.hxx" -#define SPRITECANVAS_SERVICE_NAME "com.sun.star.rendering.SpriteCanvas.VCL" -#define SPRITECANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.SpriteCanvas.VCL" - namespace vclcanvas { typedef ::cppu::WeakComponentImplHelper< css::rendering::XSpriteCanvas, diff --git a/canvas/source/vcl/vclcanvas.component b/canvas/source/vcl/vclcanvas.component index ecf2fa7b3e77..c2e0ffc09758 100644 --- a/canvas/source/vcl/vclcanvas.component +++ b/canvas/source/vcl/vclcanvas.component @@ -18,11 +18,13 @@ --> - + xmlns="http://openoffice.org/2010/uno-components"> + - + -- cgit