summaryrefslogtreecommitdiff
path: root/dtrans
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-11 15:06:06 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-11 18:33:18 +0200
commit92cccb9a7ead4a7f106db8c79e142013dd214441 (patch)
treedde6256f36ac09067bae754d85ceafb57c166811 /dtrans
parent45c8885705afd585b1d59bf793ceaa39abef3eae (diff)
dtrans/mcnttype: create instances with uno constructors
See tdf#74608 for motivation. Also drop mutex, no need to lock when we're just constructing something. Change-Id: I5e845ae2fbb03fc4f38d0ee85b2061891fa0993f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98560 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dtrans')
-rw-r--r--dtrans/Library_mcnttype.mk1
-rw-r--r--dtrans/source/cnttype/mcnttfactory.cxx27
-rw-r--r--dtrans/source/cnttype/mcnttfactory.hxx3
-rw-r--r--dtrans/source/cnttype/mctfentry.cxx78
-rw-r--r--dtrans/util/mcnttype.component5
5 files changed, 16 insertions, 98 deletions
diff --git a/dtrans/Library_mcnttype.mk b/dtrans/Library_mcnttype.mk
index 2442a01cb721..fd023a7eb4eb 100644
--- a/dtrans/Library_mcnttype.mk
+++ b/dtrans/Library_mcnttype.mk
@@ -33,7 +33,6 @@ $(eval $(call gb_Library_use_libraries,mcnttype,\
$(eval $(call gb_Library_add_exception_objects,mcnttype,\
dtrans/source/cnttype/mcnttfactory \
dtrans/source/cnttype/mcnttype \
- dtrans/source/cnttype/mctfentry \
))
# vim: set noet sw=4 ts=4:
diff --git a/dtrans/source/cnttype/mcnttfactory.cxx b/dtrans/source/cnttype/mcnttfactory.cxx
index 49db6274619b..4a3e6fbb4d95 100644
--- a/dtrans/source/cnttype/mcnttfactory.cxx
+++ b/dtrans/source/cnttype/mcnttfactory.cxx
@@ -18,33 +18,22 @@
*/
#include <cppuhelper/supportsservice.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include "mcnttfactory.hxx"
#include "mcnttype.hxx"
-#define MIMECONTENTTYPEFACTORY_IMPL_NAME "com.sun.star.datatransfer.MimeCntTypeFactory"
-
using namespace ::osl;
using namespace ::cppu;
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::datatransfer;
-namespace
-{
- Sequence< OUString > MimeContentTypeFactory_getSupportedServiceNames( )
- {
- Sequence< OUString > aRet { "com.sun.star.datatransfer.MimeContentTypeFactory" };
- return aRet;
- }
-}
-
CMimeContentTypeFactory::CMimeContentTypeFactory()
{
}
Reference< XMimeContentType > CMimeContentTypeFactory::createMimeContentType( const OUString& aContentType )
{
- MutexGuard aGuard( m_aMutex );
return Reference< XMimeContentType >( new CMimeContentType( aContentType ) );
}
@@ -52,7 +41,7 @@ Reference< XMimeContentType > CMimeContentTypeFactory::createMimeContentType( co
OUString SAL_CALL CMimeContentTypeFactory::getImplementationName( )
{
- return MIMECONTENTTYPEFACTORY_IMPL_NAME;
+ return "com.sun.star.datatransfer.MimeCntTypeFactory";
}
sal_Bool SAL_CALL CMimeContentTypeFactory::supportsService( const OUString& ServiceName )
@@ -62,7 +51,17 @@ sal_Bool SAL_CALL CMimeContentTypeFactory::supportsService( const OUString& Serv
Sequence< OUString > SAL_CALL CMimeContentTypeFactory::getSupportedServiceNames( )
{
- return MimeContentTypeFactory_getSupportedServiceNames( );
+ return { "com.sun.star.datatransfer.MimeContentTypeFactory" };
+}
+
+
+// returns a factory to create XFilePicker-Services
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+dtrans_CMimeContentTypeFactory_get_implementation(
+ css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire( new CMimeContentTypeFactory() );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/source/cnttype/mcnttfactory.hxx b/dtrans/source/cnttype/mcnttfactory.hxx
index d79cd6063ff4..06d671c6bb1a 100644
--- a/dtrans/source/cnttype/mcnttfactory.hxx
+++ b/dtrans/source/cnttype/mcnttfactory.hxx
@@ -45,9 +45,6 @@ public:
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
-
-private:
- ::osl::Mutex m_aMutex;
};
#endif
diff --git a/dtrans/source/cnttype/mctfentry.cxx b/dtrans/source/cnttype/mctfentry.cxx
deleted file mode 100644
index 43d165876230..000000000000
--- a/dtrans/source/cnttype/mctfentry.cxx
+++ /dev/null
@@ -1,78 +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 <com/sun/star/container/XSet.hpp>
-#include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
-#include "mcnttfactory.hxx"
-
-#define MIMECONTENTTYPEFACTORY_IMPL_NAME "com.sun.star.datatransfer.MimeCntTypeFactory"
-
-using namespace ::cppu;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::registry;
-using namespace ::com::sun::star::lang;
-using namespace ::com::sun::star::datatransfer;
-
-namespace
-{
-
- // functions to create a new Clipboard instance; is needed by factory helper implementation
- // @param rServiceManager - service manager, useful if the component needs other uno services
- // so we should give it to every UNO-Implementation component
-
- Reference< XInterface > createInstance( const Reference< XMultiServiceFactory >& )
- {
- return Reference< XInterface >( static_cast< XMimeContentTypeFactory* >( new CMimeContentTypeFactory() ) );
- }
-}
-
-extern "C"
-{
-
-// component_getFactory
-// returns a factory to create XFilePicker-Services
-
-SAL_DLLPUBLIC_EXPORT void* mcnttype_component_getFactory( const char* pImplName, void* pSrvManager, void* /*pRegistryKey*/ )
-{
- void* pRet = nullptr;
-
- if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, MIMECONTENTTYPEFACTORY_IMPL_NAME ) ) )
- {
- Sequence<OUString> aSNS { "com.sun.star.datatransfer.MimeContentTypeFactory" };
-
- Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
- static_cast< XMultiServiceFactory* > ( pSrvManager ),
- OUString::createFromAscii( pImplName ),
- createInstance,
- aSNS ) );
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
- }
-
- return pRet;
-}
-
-} // extern "C"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/dtrans/util/mcnttype.component b/dtrans/util/mcnttype.component
index faca00cefcda..077181d422b0 100644
--- a/dtrans/util/mcnttype.component
+++ b/dtrans/util/mcnttype.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="mcnttype" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.datatransfer.MimeCntTypeFactory">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.datatransfer.MimeCntTypeFactory"
+ constructor="dtrans_CMimeContentTypeFactory_get_implementation">
<service name="com.sun.star.datatransfer.MimeContentTypeFactory"/>
</implementation>
</component>