diff options
author | Chris Sherlock <chris.sherlock@collabora.com> | 2015-02-24 14:06:26 +1100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-02-26 14:22:00 +0100 |
commit | 94fc8ec1b1fb6571a1ef898fb5198161e021b3a0 (patch) | |
tree | 542daafaffd472323617dd86da4066fbc8546283 /sw | |
parent | 50a0cca89bd86a36c4ee043cd92e2f84f5a6e0d1 (diff) |
sw: convert swd.component to constructor usage
Whilst we are about it, need to expand the macro
SFX_DECL_XSERVICEINFO_NOFACTORY and remove the impl_createInstance
function. Also removed factory parameter from constructor as not
needed.
Change-Id: I400274fa9aaaa95be1c9929bce9dd6f25c780196
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/Library_swd.mk | 1 | ||||
-rw-r--r-- | sw/source/ui/uno/detreg.cxx | 66 | ||||
-rw-r--r-- | sw/source/ui/uno/swdetect.cxx | 9 | ||||
-rw-r--r-- | sw/source/ui/uno/swdetect.hxx | 11 | ||||
-rw-r--r-- | sw/util/swd.component | 3 |
5 files changed, 16 insertions, 74 deletions
diff --git a/sw/Library_swd.mk b/sw/Library_swd.mk index 8657cf17704f..6396a286c509 100644 --- a/sw/Library_swd.mk +++ b/sw/Library_swd.mk @@ -42,7 +42,6 @@ $(eval $(call gb_Library_use_libraries,swd,\ )) $(eval $(call gb_Library_add_exception_objects,swd,\ - sw/source/ui/uno/detreg \ sw/source/ui/uno/swdetect \ )) diff --git a/sw/source/ui/uno/detreg.cxx b/sw/source/ui/uno/detreg.cxx deleted file mode 100644 index d6d6208d8c9e..000000000000 --- a/sw/source/ui/uno/detreg.cxx +++ /dev/null @@ -1,66 +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 "swdetect.hxx" - -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; - -extern "C" { - -SAL_DLLPUBLIC_EXPORT void* SAL_CALL swd_component_getFactory( - const sal_Char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/ ) -{ - // Set default return value for this operation - if it failed. - void* pReturn = NULL ; - - if ( - ( pImplementationName != NULL ) && - ( pServiceManager != NULL ) - ) - { - // Define variables which are used in following macros. - Reference< XSingleServiceFactory > xFactory ; - Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; - - if( SwFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName ) ) - { - xFactory = ::cppu::createSingleFactory( xServiceManager, - SwFilterDetect::impl_getStaticImplementationName(), - SwFilterDetect::impl_createInstance, - SwFilterDetect::impl_getStaticSupportedServiceNames() ); - } - - // Factory is valid - service was found. - if ( xFactory.is() ) - { - xFactory->acquire(); - pReturn = xFactory.get(); - } - } - - // Return with result of this operation. - return pReturn ; -} -} // extern "C" - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/uno/swdetect.cxx b/sw/source/ui/uno/swdetect.cxx index eff1d64ea0b9..ed91a6d0e9a6 100644 --- a/sw/source/ui/uno/swdetect.cxx +++ b/sw/source/ui/uno/swdetect.cxx @@ -34,7 +34,7 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using utl::MediaDescriptor; -SwFilterDetect::SwFilterDetect( const Reference < XMultiServiceFactory >& /*xFactory*/ ) +SwFilterDetect::SwFilterDetect() { } @@ -144,10 +144,11 @@ OUString SwFilterDetect::impl_getStaticImplementationName() return OUString("com.sun.star.comp.writer.FormatDetector" ); } -/* Helper for registry */ -Reference< XInterface > SAL_CALL SwFilterDetect::impl_createInstance( const Reference< XMultiServiceFactory >& xServiceManager ) throw( Exception ) +extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL +com_sun_star_comp_writer_FormatDetector_get_implementation(::com::sun::star::uno::XComponentContext* component, + ::com::sun::star::uno::Sequence<css::uno::Any> const &) { - return Reference< XInterface >( *new SwFilterDetect( xServiceManager ) ); + return cppu::acquire(new SwFilterDetect()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/uno/swdetect.hxx b/sw/source/ui/uno/swdetect.hxx index ea28ccfffd1d..eba07537684b 100644 --- a/sw/source/ui/uno/swdetect.hxx +++ b/sw/source/ui/uno/swdetect.hxx @@ -58,10 +58,17 @@ class SfxFilter; class SwFilterDetect : public ::cppu::WeakImplHelper2< css::document::XExtendedFilterDetection, css::lang::XServiceInfo > { public: - SwFilterDetect( const css::uno::Reference < css::lang::XMultiServiceFactory >& xFactory ); + SwFilterDetect(); virtual ~SwFilterDetect(); - SFX_DECL_XSERVICEINFO_NOFACTORY + /* XServiceInfo */ + virtual OUString SAL_CALL getImplementationName() throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE; + + /* Helper for XServiceInfo */ + static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); + static OUString impl_getStaticImplementationName(); // XExtendedFilterDetect virtual OUString SAL_CALL detect( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) throw( css::uno::RuntimeException, std::exception ) SAL_OVERRIDE; diff --git a/sw/util/swd.component b/sw/util/swd.component index a342f059fc25..e09b38524654 100644 --- a/sw/util/swd.component +++ b/sw/util/swd.component @@ -19,7 +19,8 @@ <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" prefix="swd" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.writer.FormatDetector"> + <implementation name="com.sun.star.comp.writer.FormatDetector" + constructor="com_sun_star_comp_writer_FormatDetector_get_implementation"> <service name="com.sun.star.frame.ExtendedTypeDetection"/> <service name="com.sun.star.text.FormatDetector"/> <service name="com.sun.star.text.W4WFormatDetector"/> |