diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-07-12 14:38:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-07-12 21:50:05 +0200 |
commit | 5653791d74b9ddc405a90f51801e95926224b204 (patch) | |
tree | 9b131a1400e0627109916ac0f1249cd07fe68539 /filter | |
parent | 220cebe66c8eab3a74cd127aea172eb79c9cc68e (diff) |
filter/pdf: create instances with uno constructors
See tdf#74608 for motivation.
Change-Id: Ieb73f2a75804013383195130e16472cc671a4ac8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98598
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'filter')
-rw-r--r-- | filter/Library_pdffilter.mk | 1 | ||||
-rw-r--r-- | filter/source/pdf/pdfdecomposer.cxx | 21 | ||||
-rw-r--r-- | filter/source/pdf/pdfdecomposer.hxx | 22 | ||||
-rw-r--r-- | filter/source/pdf/pdfdialog.cxx | 36 | ||||
-rw-r--r-- | filter/source/pdf/pdfdialog.hxx | 7 | ||||
-rw-r--r-- | filter/source/pdf/pdffilter.component | 14 | ||||
-rw-r--r-- | filter/source/pdf/pdffilter.cxx | 28 | ||||
-rw-r--r-- | filter/source/pdf/pdffilter.hxx | 10 | ||||
-rw-r--r-- | filter/source/pdf/pdfinteract.cxx | 30 | ||||
-rw-r--r-- | filter/source/pdf/pdfinteract.hxx | 10 | ||||
-rw-r--r-- | filter/source/pdf/pdfuno.cxx | 84 |
11 files changed, 43 insertions, 220 deletions
diff --git a/filter/Library_pdffilter.mk b/filter/Library_pdffilter.mk index 9694490655de..a7cb47a65231 100644 --- a/filter/Library_pdffilter.mk +++ b/filter/Library_pdffilter.mk @@ -59,7 +59,6 @@ $(eval $(call gb_Library_add_exception_objects,pdffilter,\ filter/source/pdf/pdfexport \ filter/source/pdf/pdffilter \ filter/source/pdf/pdfinteract \ - filter/source/pdf/pdfuno \ )) # vim: set noet sw=4 ts=4: diff --git a/filter/source/pdf/pdfdecomposer.cxx b/filter/source/pdf/pdfdecomposer.cxx index e053fd215369..b2f572fe6c6f 100644 --- a/filter/source/pdf/pdfdecomposer.cxx +++ b/filter/source/pdf/pdfdecomposer.cxx @@ -7,8 +7,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "pdfdecomposer.hxx" - #include <vector> #include <basegfx/matrix/b2dhommatrixtools.hxx> @@ -92,7 +90,7 @@ uno::Sequence<uno::Reference<graphic::XPrimitive2D>> SAL_CALL XPdfDecomposer::ge OUString SAL_CALL XPdfDecomposer::getImplementationName() { - return PDFDecomposer_getImplementationName(); + return "com.sun.star.comp.PDF.PDFDecomposer"; } sal_Bool SAL_CALL XPdfDecomposer::supportsService(const OUString& rServiceName) @@ -102,22 +100,15 @@ sal_Bool SAL_CALL XPdfDecomposer::supportsService(const OUString& rServiceName) uno::Sequence<OUString> SAL_CALL XPdfDecomposer::getSupportedServiceNames() { - return PDFDecomposer_getSupportedServiceNames(); -} + return { "com.sun.star.graphic.PdfTools" }; } - -OUString PDFDecomposer_getImplementationName() { return "com.sun.star.comp.PDF.PDFDecomposer"; } - -uno::Sequence<OUString> PDFDecomposer_getSupportedServiceNames() -{ - return uno::Sequence<OUString>{ "com.sun.star.graphic.PdfTools" }; } -uno::Reference<uno::XInterface> -PDFDecomposer_createInstance(const uno::Reference<lang::XMultiServiceFactory>& rSMgr) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +filter_PdfDecomposer_get_implementation(css::uno::XComponentContext* context, + css::uno::Sequence<css::uno::Any> const&) { - return static_cast<cppu::OWeakObject*>( - new XPdfDecomposer(comphelper::getComponentContext(rSMgr))); + return cppu::acquire(new XPdfDecomposer(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/filter/source/pdf/pdfdecomposer.hxx b/filter/source/pdf/pdfdecomposer.hxx deleted file mode 100644 index 7e1bd3954692..000000000000 --- a/filter/source/pdf/pdfdecomposer.hxx +++ /dev/null @@ -1,22 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * 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_FILTER_SOURCE_PDF_PDFDECOMPOSER_HXX -#define INCLUDED_FILTER_SOURCE_PDF_PDFDECOMPOSER_HXX - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - -OUString PDFDecomposer_getImplementationName(); -css::uno::Sequence<OUString> PDFDecomposer_getSupportedServiceNames(); -css::uno::Reference<css::uno::XInterface> -PDFDecomposer_createInstance(const css::uno::Reference<css::lang::XMultiServiceFactory>& rSMgr); - -#endif // INCLUDED_FILTER_SOURCE_PDF_PDFDECOMPOSER_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ diff --git a/filter/source/pdf/pdfdialog.cxx b/filter/source/pdf/pdfdialog.cxx index 5a9fc177dc2c..fb2dd7d0859b 100644 --- a/filter/source/pdf/pdfdialog.cxx +++ b/filter/source/pdf/pdfdialog.cxx @@ -28,31 +28,6 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::beans; -#define SERVICE_NAME "com.sun.star.document.PDFDialog" - - -OUString PDFDialog_getImplementationName () -{ - return "com.sun.star.comp.PDF.PDFDialog"; -} - - -Sequence< OUString > PDFDialog_getSupportedServiceNames() -{ - Sequence<OUString> aRet { SERVICE_NAME }; - return aRet; -} - - -Reference< XInterface > PDFDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr) -{ - return static_cast<cppu::OWeakObject*>(new PDFDialog( comphelper::getComponentContext(rSMgr) )); -} - - -#undef SERVICE_NAME - - PDFDialog::PDFDialog( const Reference< XComponentContext > &rxContext ) : PDFDialog_Base( rxContext ) { @@ -72,13 +47,13 @@ Sequence< sal_Int8 > SAL_CALL PDFDialog::getImplementationId() OUString SAL_CALL PDFDialog::getImplementationName() { - return PDFDialog_getImplementationName(); + return "com.sun.star.comp.PDF.PDFDialog"; } Sequence< OUString > SAL_CALL PDFDialog::getSupportedServiceNames() { - return PDFDialog_getSupportedServiceNames(); + return { "com.sun.star.document.PDFDialog" }; } std::unique_ptr<weld::DialogController> PDFDialog::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) @@ -154,4 +129,11 @@ void SAL_CALL PDFDialog::setSourceDocument( const Reference< XComponent >& xDoc mxSrcDoc = xDoc; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +filter_PDFDialog_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new PDFDialog(context)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/pdf/pdfdialog.hxx b/filter/source/pdf/pdfdialog.hxx index 0179467b1320..47a915a728b4 100644 --- a/filter/source/pdf/pdfdialog.hxx +++ b/filter/source/pdf/pdfdialog.hxx @@ -73,13 +73,6 @@ public: virtual ~PDFDialog() override; }; -/// @throws RuntimeException -OUString PDFDialog_getImplementationName (); -/// @throws RuntimeException -Sequence< OUString > PDFDialog_getSupportedServiceNames(); -/// @throws Exception -Reference< XInterface > PDFDialog_createInstance( const Reference< XMultiServiceFactory > & rSMgr); - #endif // INCLUDED_FILTER_SOURCE_PDF_PDFDIALOG_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/pdf/pdffilter.component b/filter/source/pdf/pdffilter.component index bc6d8006be24..5f3dc78796ff 100644 --- a/filter/source/pdf/pdffilter.component +++ b/filter/source/pdf/pdffilter.component @@ -18,17 +18,21 @@ --> <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="pdffilter" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.PDF.PDFDialog"> + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.PDF.PDFDialog" + constructor="filter_PDFDialog_get_implementation"> <service name="com.sun.star.document.PDFDialog"/> </implementation> - <implementation name="com.sun.star.comp.PDF.PDFFilter"> + <implementation name="com.sun.star.comp.PDF.PDFFilter" + constructor="filter_PDFFilter_get_implementation"> <service name="com.sun.star.document.PDFFilter"/> </implementation> - <implementation name="com.sun.star.comp.PDF.PDFExportInteractionHandler"> + <implementation name="com.sun.star.comp.PDF.PDFExportInteractionHandler" + constructor="filter_PDFExportInteractionHandler_get_implementation"> <service name="com.sun.star.filter.pdfexport.PDFExportInteractionHandler"/> </implementation> - <implementation name="com.sun.star.comp.PDF.PDFDecomposer"> + <implementation name="com.sun.star.comp.PDF.PDFDecomposer" + constructor="filter_PdfDecomposer_get_implementation"> <service name="com.sun.star.graphic.PdfTools"/> </implementation> </component> diff --git a/filter/source/pdf/pdffilter.cxx b/filter/source/pdf/pdffilter.cxx index fdbdae95784b..0e2ea643d727 100644 --- a/filter/source/pdf/pdffilter.cxx +++ b/filter/source/pdf/pdffilter.cxx @@ -243,39 +243,29 @@ void SAL_CALL PDFFilter::initialize( const css::uno::Sequence< css::uno::Any >& } -OUString PDFFilter_getImplementationName () +OUString SAL_CALL PDFFilter::getImplementationName() { return "com.sun.star.comp.PDF.PDFFilter"; } -Sequence< OUString > PDFFilter_getSupportedServiceNames( ) -{ - return { "com.sun.star.document.PDFFilter" }; -} - - -Reference< XInterface > PDFFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr) -{ - return static_cast<cppu::OWeakObject*>(new PDFFilter( comphelper::getComponentContext(rSMgr) )); -} - - -OUString SAL_CALL PDFFilter::getImplementationName() +sal_Bool SAL_CALL PDFFilter::supportsService( const OUString& rServiceName ) { - return PDFFilter_getImplementationName(); + return cppu::supportsService( this, rServiceName ); } -sal_Bool SAL_CALL PDFFilter::supportsService( const OUString& rServiceName ) +css::uno::Sequence< OUString > SAL_CALL PDFFilter::getSupportedServiceNames( ) { - return cppu::supportsService( this, rServiceName ); + return { "com.sun.star.document.PDFFilter" }; } -css::uno::Sequence< OUString > SAL_CALL PDFFilter::getSupportedServiceNames( ) +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +filter_PDFFilter_get_implementation( + css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - return PDFFilter_getSupportedServiceNames(); + return cppu::acquire(new PDFFilter(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/pdf/pdffilter.hxx b/filter/source/pdf/pdffilter.hxx index f6c48af0b2f4..d63f5f4c7355 100644 --- a/filter/source/pdf/pdffilter.hxx +++ b/filter/source/pdf/pdffilter.hxx @@ -68,16 +68,6 @@ public: virtual ~PDFFilter() override; }; -/// @throws RuntimeException -OUString PDFFilter_getImplementationName (); - -/// @throws RuntimeException -Sequence< OUString > PDFFilter_getSupportedServiceNames( ); - -/// @throws Exception -Reference< XInterface > -PDFFilter_createInstance( const Reference< XMultiServiceFactory > & rSMgr); - #endif // INCLUDED_FILTER_SOURCE_PDF_PDFFILTER_HXX diff --git a/filter/source/pdf/pdfinteract.cxx b/filter/source/pdf/pdfinteract.cxx index cc1c205eaac3..cf38cf4a0711 100644 --- a/filter/source/pdf/pdfinteract.cxx +++ b/filter/source/pdf/pdfinteract.cxx @@ -68,28 +68,10 @@ sal_Bool SAL_CALL PDFInteractionHandler::handleInteractionRequest( const Referen } -OUString PDFInteractionHandler_getImplementationName () -{ - return "com.sun.star.comp.PDF.PDFExportInteractionHandler"; -} - - -Sequence< OUString > PDFInteractionHandler_getSupportedServiceNames( ) -{ - Sequence<OUString> aRet { "com.sun.star.filter.pdfexport.PDFExportInteractionHandler" }; - return aRet; -} - - -Reference< XInterface > PDFInteractionHandler_createInstance( const Reference< XMultiServiceFactory > & ) -{ - return static_cast<cppu::OWeakObject*>(new PDFInteractionHandler); -} - OUString SAL_CALL PDFInteractionHandler::getImplementationName() { - return PDFInteractionHandler_getImplementationName(); + return "com.sun.star.comp.PDF.PDFExportInteractionHandler"; } @@ -101,7 +83,15 @@ sal_Bool SAL_CALL PDFInteractionHandler::supportsService( const OUString& rServi css::uno::Sequence< OUString > SAL_CALL PDFInteractionHandler::getSupportedServiceNames( ) { - return PDFInteractionHandler_getSupportedServiceNames(); + return { "com.sun.star.filter.pdfexport.PDFExportInteractionHandler" }; } +extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* +filter_PDFExportInteractionHandler_get_implementation( + css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&) +{ + return cppu::acquire(new PDFInteractionHandler()); +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/pdf/pdfinteract.hxx b/filter/source/pdf/pdfinteract.hxx index ccc2339ff448..18deba69dfce 100644 --- a/filter/source/pdf/pdfinteract.hxx +++ b/filter/source/pdf/pdfinteract.hxx @@ -60,16 +60,6 @@ public: virtual ~PDFInteractionHandler() override; }; -/// @throws RuntimeException -OUString PDFInteractionHandler_getImplementationName (); - -/// @throws RuntimeException -Sequence< OUString > PDFInteractionHandler_getSupportedServiceNames( ); - -/// @throws Exception -Reference< XInterface > -PDFInteractionHandler_createInstance( const Reference< XMultiServiceFactory > & rSMgr); - #endif // INCLUDED_FILTER_SOURCE_PDF_PDFINTERACT_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/pdf/pdfuno.cxx b/filter/source/pdf/pdfuno.cxx deleted file mode 100644 index e4f185ffbfef..000000000000 --- a/filter/source/pdf/pdfuno.cxx +++ /dev/null @@ -1,84 +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 <cppuhelper/factory.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -#include "pdfdecomposer.hxx" -#include "pdffilter.hxx" -#include "pdfdialog.hxx" -#include "pdfinteract.hxx" - -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::registry; - -extern "C" -{ - SAL_DLLPUBLIC_EXPORT void* pdffilter_component_getFactory( const char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ ) - { - OUString aImplName( OUString::createFromAscii( pImplName ) ); - void* pRet = nullptr; - - if( pServiceManager ) - { - Reference< XSingleServiceFactory > xFactory; - - if( aImplName == PDFFilter_getImplementationName() ) - { - xFactory = createSingleFactory( static_cast< XMultiServiceFactory* >( pServiceManager ), - OUString::createFromAscii( pImplName ), - PDFFilter_createInstance, PDFFilter_getSupportedServiceNames() ); - - } - else if( aImplName == PDFDialog_getImplementationName() ) - { - xFactory = createSingleFactory( static_cast< XMultiServiceFactory* >( pServiceManager ), - OUString::createFromAscii( pImplName ), - PDFDialog_createInstance, PDFDialog_getSupportedServiceNames() ); - - } - else if( aImplName == PDFInteractionHandler_getImplementationName() ) - { - xFactory = createSingleFactory( static_cast< XMultiServiceFactory* >( pServiceManager ), - OUString::createFromAscii( pImplName ), - PDFInteractionHandler_createInstance, PDFInteractionHandler_getSupportedServiceNames() ); - - } - else if (aImplName == PDFDecomposer_getImplementationName()) - { - xFactory = createSingleFactory(static_cast<XMultiServiceFactory*>(pServiceManager), - OUString::createFromAscii(pImplName), - PDFDecomposer_createInstance, PDFDecomposer_getSupportedServiceNames()); - } - - if( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |