diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2018-12-19 21:55:12 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2018-12-20 08:56:44 +0100 |
commit | ae270343e29084ca94e82d85d5c76e1ec05184dc (patch) | |
tree | d2a3d138b77f3790bbec8f08cf793aec05c15b60 /starmath/source | |
parent | 6c9effd0e5a76ce18a211c5f8b41e00187e67ed4 (diff) |
starmath: create SmFilterDetect instances with an uno constructor
Change-Id: I11ffe5153bc9ea263cde63093544584f01a344d2
Reviewed-on: https://gerrit.libreoffice.org/65464
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/detreg.cxx | 69 | ||||
-rw-r--r-- | starmath/source/smdetect.cxx | 24 | ||||
-rw-r--r-- | starmath/source/smdetect.hxx | 14 |
3 files changed, 8 insertions, 99 deletions
diff --git a/starmath/source/detreg.cxx b/starmath/source/detreg.cxx deleted file mode 100644 index 74d25aa3d762..000000000000 --- a/starmath/source/detreg.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 <cppuhelper/factory.hxx> -#include <rtl/ustring.hxx> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -#include "smdetect.hxx" - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; - -extern "C" { - -SAL_DLLPUBLIC_EXPORT void* smd_component_getFactory( const sal_Char* pImplementationName, - void* pServiceManager, - void* /*pRegistryKey*/ ) -{ - // Set default return value for this operation - if it failed. - void* pReturn = nullptr ; - - if ( - ( pImplementationName != nullptr ) && - ( pServiceManager != nullptr ) - ) - { - // Define variables which are used in following macros. - Reference< XSingleServiceFactory > xFactory ; - Reference< XMultiServiceFactory > xServiceManager( static_cast< XMultiServiceFactory* >( pServiceManager ) ) ; - - if( SmFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName ) ) - { - xFactory = ::cppu::createSingleFactory( xServiceManager, - SmFilterDetect::impl_getStaticImplementationName(), - SmFilterDetect::impl_createInstance, - SmFilterDetect::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/starmath/source/smdetect.cxx b/starmath/source/smdetect.cxx index 8cff53e43e95..ad5dacfb8821 100644 --- a/starmath/source/smdetect.cxx +++ b/starmath/source/smdetect.cxx @@ -21,6 +21,7 @@ #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/ucb/ContentCreationException.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> #include <sfx2/docfile.hxx> #include <unotools/mediadescriptor.hxx> #include <sal/log.hxx> @@ -35,7 +36,7 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::lang; using utl::MediaDescriptor; -SmFilterDetect::SmFilterDetect( const Reference < XMultiServiceFactory >& /*xFactory*/ ) +SmFilterDetect::SmFilterDetect() { } @@ -121,7 +122,7 @@ OUString SAL_CALL SmFilterDetect::detect( Sequence< PropertyValue >& lDescriptor /* XServiceInfo */ OUString SAL_CALL SmFilterDetect::getImplementationName() { - return impl_getStaticImplementationName(); + return OUString("com.sun.star.comp.math.FormatDetector"); } /* XServiceInfo */ @@ -133,25 +134,14 @@ sal_Bool SAL_CALL SmFilterDetect::supportsService( const OUString& sServiceName /* XServiceInfo */ Sequence< OUString > SAL_CALL SmFilterDetect::getSupportedServiceNames() { - return impl_getStaticSupportedServiceNames(); -} - -/* Helper for XServiceInfo */ -Sequence< OUString > SmFilterDetect::impl_getStaticSupportedServiceNames() -{ return Sequence< OUString >{ "com.sun.star.frame.ExtendedTypeDetection" }; } -/* Helper for XServiceInfo */ -OUString SmFilterDetect::impl_getStaticImplementationName() -{ - return OUString("com.sun.star.comp.math.FormatDetector"); -} - -/* Helper for registry */ -Reference< XInterface > SmFilterDetect::impl_createInstance( const Reference< XMultiServiceFactory >& xServiceManager ) +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +math_FormatDetector_get_implementation(uno::XComponentContext* /*pCtx*/, + uno::Sequence<uno::Any> const& /*rSeq*/) { - return Reference< XInterface >( *new SmFilterDetect( xServiceManager ) ); + return cppu::acquire(new SmFilterDetect); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/starmath/source/smdetect.hxx b/starmath/source/smdetect.hxx index 3386365e2759..fa616773bca1 100644 --- a/starmath/source/smdetect.hxx +++ b/starmath/source/smdetect.hxx @@ -34,10 +34,6 @@ namespace com { namespace star { - namespace lang - { - class XMultiServiceFactory; - } namespace beans { struct PropertyValue; @@ -49,7 +45,7 @@ namespace com class SmFilterDetect : public ::cppu::WeakImplHelper< css::document::XExtendedFilterDetection, css::lang::XServiceInfo > { public: - explicit SmFilterDetect( const css::uno::Reference < css::lang::XMultiServiceFactory >& xFactory ); + explicit SmFilterDetect(); virtual ~SmFilterDetect() override; /* XServiceInfo */ @@ -57,14 +53,6 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - /* Helper for XServiceInfo */ - static css::uno::Sequence< OUString > impl_getStaticSupportedServiceNames(); - static OUString impl_getStaticImplementationName(); - - /* Helper for registry */ - /// @throws css::uno::Exception - static css::uno::Reference< css::uno::XInterface > impl_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager ); - // XExtendedFilterDetect virtual OUString SAL_CALL detect( css::uno::Sequence< css::beans::PropertyValue >& lDescriptor ) override; }; |