[Libreoffice-commits] core.git: canvas/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jul 14 19:03:42 UTC 2020
canvas/source/directx/dx_canvas.cxx | 89 +++++++++++++-------------
canvas/source/directx/dx_canvas.hxx | 16 ++++
canvas/source/directx/gdipluscanvas.component | 8 +-
3 files changed, 65 insertions(+), 48 deletions(-)
New commits:
commit 7ef6dee499e6a705e022fc8159789599f9cbc1c0
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Tue Jul 14 14:35:49 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue Jul 14 21:03:05 2020 +0200
canvas/gdiplus: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: Ie1f1736ceda372a53e1065d4829f019338f5b7bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98730
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/canvas/source/directx/dx_canvas.cxx b/canvas/source/directx/dx_canvas.cxx
index 1f4f1218beb9..cb7a3199e126 100644
--- a/canvas/source/directx/dx_canvas.cxx
+++ b/canvas/source/directx/dx_canvas.cxx
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+// /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
@@ -33,9 +33,7 @@
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
-#include <comphelper/servicedecl.hxx>
-#include <cppuhelper/factory.hxx>
-#include <cppuhelper/implementationentry.hxx>
+#include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx>
#include <tools/diagnose_ex.h>
#include <vcl/sysdata.hxx>
@@ -48,16 +46,8 @@
#include "dx_graphicsprovider.hxx"
#include "dx_winstuff.hxx"
-#define CANVAS_SERVICE_NAME "com.sun.star.rendering.Canvas.GDI+"
-#define CANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.Canvas.GDI+"
-#define BITMAPCANVAS_SERVICE_NAME "com.sun.star.rendering.BitmapCanvas.GDI+"
-#define BITMAPCANVAS_IMPLEMENTATION_NAME "com.sun.star.comp.rendering.BitmapCanvas.GDI+"
-
-
using namespace ::com::sun::star;
-namespace sdecl = comphelper::service_decl;
-
namespace dxcanvas
{
namespace {
@@ -133,7 +123,21 @@ namespace dxcanvas
OUString SAL_CALL Canvas::getServiceName( )
{
- return CANVAS_SERVICE_NAME;
+ return "com.sun.star.rendering.Canvas.GDI+";
+ }
+
+ // XServiceInfo
+ css::uno::Sequence<OUString> Canvas::getSupportedServiceNames( )
+ {
+ return { "com.sun.star.rendering.Canvas.GDI+" };
+ }
+ OUString Canvas::getImplementationName( )
+ {
+ return "com.sun.star.comp.rendering.Canvas.GDI+";
+ }
+ sal_Bool Canvas::supportsService( const OUString& sServiceName )
+ {
+ return cppu::supportsService(this, sServiceName);
}
BitmapCanvas::BitmapCanvas( const uno::Sequence< uno::Any >& aArguments,
@@ -209,7 +213,21 @@ namespace dxcanvas
OUString SAL_CALL BitmapCanvas::getServiceName( )
{
- return BITMAPCANVAS_SERVICE_NAME;
+ return "com.sun.star.rendering.BitmapCanvas.GDI+";
+ }
+
+ // XServiceInfo
+ css::uno::Sequence<OUString> BitmapCanvas::getSupportedServiceNames( )
+ {
+ return { "com.sun.star.rendering.BitmapCanvas.GDI+" };
+ }
+ OUString BitmapCanvas::getImplementationName( )
+ {
+ return "com.sun.star.comp.rendering.BitmapCanvas.GDI+";
+ }
+ sal_Bool BitmapCanvas::supportsService( const OUString& sServiceName )
+ {
+ return cppu::supportsService(this, sServiceName);
}
IBitmapSharedPtr BitmapCanvas::getBitmap() const
@@ -217,40 +235,25 @@ namespace dxcanvas
return mpTarget;
}
- static uno::Reference<uno::XInterface> initCanvas( Canvas* pCanvas )
+ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ canvas_gdiplus_Canvas_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
{
- uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pCanvas));
- pCanvas->initialize();
- return xRet;
+ rtl::Reference<Canvas> xCanvas(new Canvas(args, context));
+ xCanvas->initialize();
+ xCanvas->acquire();
+ return static_cast<cppu::OWeakObject*>(xCanvas.get());
}
- sdecl::class_<Canvas, sdecl::with_args<true> > const serviceImpl1(&initCanvas);
- const sdecl::ServiceDecl dxCanvasDecl(
- serviceImpl1,
- CANVAS_IMPLEMENTATION_NAME,
- CANVAS_SERVICE_NAME );
-
- static uno::Reference<uno::XInterface> initBitmapCanvas( BitmapCanvas* pCanvas )
+ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ canvas_gdiplus_BitmapCanvas_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& args)
{
- uno::Reference<uno::XInterface> xRet(static_cast<cppu::OWeakObject*>(pCanvas));
- pCanvas->initialize();
- return xRet;
+ rtl::Reference<BitmapCanvas> xCanvas(new BitmapCanvas(args, context));
+ xCanvas->initialize();
+ xCanvas->acquire();
+ return static_cast<cppu::OWeakObject*>(xCanvas.get());
}
-
- namespace sdecl = comphelper::service_decl;
- sdecl::class_<BitmapCanvas, sdecl::with_args<true> > const serviceImpl2(&initBitmapCanvas);
- const sdecl::ServiceDecl dxBitmapCanvasDecl(
- serviceImpl2,
- BITMAPCANVAS_IMPLEMENTATION_NAME,
- BITMAPCANVAS_SERVICE_NAME );
-}
-
-// The C shared lib entry points
-extern "C"
-SAL_DLLPUBLIC_EXPORT void* gdipluscanvas_component_getFactory( char const* pImplName,
- void*, void* )
-{
- return sdecl::component_getFactoryHelper( pImplName, {&dxcanvas::dxCanvasDecl, &dxcanvas::dxBitmapCanvasDecl} );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/canvas/source/directx/dx_canvas.hxx b/canvas/source/directx/dx_canvas.hxx
index 4db2b16a5d25..acea85c762c5 100644
--- a/canvas/source/directx/dx_canvas.hxx
+++ b/canvas/source/directx/dx_canvas.hxx
@@ -54,7 +54,8 @@ namespace dxcanvas
css::lang::XMultiServiceFactory,
css::util::XUpdatable,
css::beans::XPropertySet,
- css::lang::XServiceName > GraphicDeviceBase1_Base;
+ css::lang::XServiceName,
+ css::lang::XServiceInfo> GraphicDeviceBase1_Base;
typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase1_Base >,
DeviceHelper,
::osl::MutexGuard,
@@ -96,6 +97,11 @@ namespace dxcanvas
// XServiceName
virtual OUString SAL_CALL getServiceName( ) override;
+ // XServiceInfo
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames( ) override;
+ virtual OUString SAL_CALL getImplementationName( ) override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ) override;
+
private:
css::uno::Sequence< css::uno::Any > maArguments;
css::uno::Reference< css::uno::XComponentContext > mxComponentContext;
@@ -107,7 +113,8 @@ namespace dxcanvas
css::lang::XMultiServiceFactory,
css::util::XUpdatable,
css::beans::XPropertySet,
- css::lang::XServiceName > GraphicDeviceBase2_Base;
+ css::lang::XServiceName,
+ css::lang::XServiceInfo > GraphicDeviceBase2_Base;
typedef ::canvas::GraphicDeviceBase< ::canvas::BaseMutexHelper< GraphicDeviceBase2_Base >,
DeviceHelper,
::osl::MutexGuard,
@@ -149,6 +156,11 @@ namespace dxcanvas
// XServiceName
virtual OUString SAL_CALL getServiceName( ) override;
+ // XServiceInfo
+ virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames( ) override;
+ virtual OUString SAL_CALL getImplementationName( ) override;
+ virtual sal_Bool SAL_CALL supportsService( const OUString& ) override;
+
// BitmapProvider
virtual IBitmapSharedPtr getBitmap() const override;
diff --git a/canvas/source/directx/gdipluscanvas.component b/canvas/source/directx/gdipluscanvas.component
index 701c888830bd..0ee68a1ad7c4 100644
--- a/canvas/source/directx/gdipluscanvas.component
+++ b/canvas/source/directx/gdipluscanvas.component
@@ -18,11 +18,13 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="gdipluscanvas" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.rendering.BitmapCanvas.GDI+">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.rendering.BitmapCanvas.GDI+"
+ constructor="canvas_gdiplus_BitmapCanvas_get_implementation">
<service name="com.sun.star.rendering.BitmapCanvas.GDI+"/>
</implementation>
- <implementation name="com.sun.star.comp.rendering.Canvas.GDI+">
+ <implementation name="com.sun.star.comp.rendering.Canvas.GDI+"
+ constructor="canvas_gdiplus_Canvas_get_implementation">
<service name="com.sun.star.rendering.Canvas.GDI+"/>
</implementation>
</component>
More information about the Libreoffice-commits
mailing list