Kaydet (Commit) ae270343 authored tarafından Miklos Vajna's avatar Miklos Vajna

starmath: create SmFilterDetect instances with an uno constructor

Change-Id: I11ffe5153bc9ea263cde63093544584f01a344d2
Reviewed-on: https://gerrit.libreoffice.org/65464
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.com>
üst 6c9effd0
......@@ -299,6 +299,8 @@ edit_constructor_list = [
"Math_XMLImporter_get_implementation",
"Math_XMLOasisMetaImporter_get_implementation",
"Math_XMLOasisSettingsImporter_get_implementation",
# starmath/util/smd.component
"math_FormatDetector_get_implementation",
# sw/util/sw.component
"com_sun_star_comp_Writer_XMLOasisContentExporter_get_implementation",
"com_sun_star_comp_Writer_XMLOasisMetaExporter_get_implementation",
......
......@@ -32,7 +32,6 @@ $(eval $(call gb_Library_use_libraries,smd,\
))
$(eval $(call gb_Library_add_exception_objects,smd,\
starmath/source/detreg \
starmath/source/smdetect \
starmath/source/eqnolefilehdr \
))
......
/* -*- 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: */
......@@ -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 */
......@@ -132,26 +133,15 @@ 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: */
......@@ -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;
};
......
......@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="smd" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.math.FormatDetector">
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.math.FormatDetector"
constructor="math_FormatDetector_get_implementation">
<service name="com.sun.star.frame.ExtendedTypeDetection"/>
</implementation>
</component>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment