summaryrefslogtreecommitdiff
path: root/ucb/source/ucp
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-07-13 15:05:20 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-13 18:32:46 +0200
commit0544ea4ef08272543856d69927d0d666f61679b3 (patch)
tree08f3911b773039da00a5f2101a001e0a16accb74 /ucb/source/ucp
parent1fdd4a27735cc5b9ed35153437e1d5b00c21c2b3 (diff)
ucb/tdoc: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: I669e3b35dd692b974c040b5d076d18f710d5cc28 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98663 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'ucb/source/ucp')
-rw-r--r--ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx52
-rw-r--r--ucb/source/ucp/tdoc/tdoc_documentcontentfactory.hxx15
-rw-r--r--ucb/source/ucp/tdoc/tdoc_provider.cxx28
-rw-r--r--ucb/source/ucp/tdoc/tdoc_provider.hxx7
-rw-r--r--ucb/source/ucp/tdoc/tdoc_services.cxx71
-rw-r--r--ucb/source/ucp/tdoc/ucptdoc1.component8
6 files changed, 36 insertions, 145 deletions
diff --git a/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx b/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx
index eadd8fcd681f..c069fed082e0 100644
--- a/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx
@@ -24,8 +24,10 @@
*************************************************************************/
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx>
+#include <rtl/ref.hxx>
#include "tdoc_documentcontentfactory.hxx"
@@ -37,8 +39,8 @@ using namespace tdoc_ucp;
DocumentContentFactory::DocumentContentFactory(
- const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
-: m_xSMgr( xSMgr )
+ const uno::Reference< uno::XComponentContext >& rxContext )
+: m_xContext( rxContext )
{
}
@@ -55,7 +57,7 @@ DocumentContentFactory::~DocumentContentFactory()
// virtual
OUString SAL_CALL DocumentContentFactory::getImplementationName()
{
- return getImplementationName_Static();
+ return "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory";
}
// virtual
@@ -69,24 +71,7 @@ DocumentContentFactory::supportsService( const OUString& ServiceName )
uno::Sequence< OUString > SAL_CALL
DocumentContentFactory::getSupportedServiceNames()
{
- return getSupportedServiceNames_Static();
-}
-
-
-// static
-OUString DocumentContentFactory::getImplementationName_Static()
-{
- return
- "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory";
-}
-
-
-// static
-uno::Sequence< OUString >
-DocumentContentFactory::getSupportedServiceNames_Static()
-{
- uno::Sequence< OUString > aSNS { "com.sun.star.frame.TransientDocumentsDocumentContentFactory" };
- return aSNS;
+ return { "com.sun.star.frame.TransientDocumentsDocumentContentFactory" };
}
@@ -101,7 +86,7 @@ DocumentContentFactory::createDocumentContent(
uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
try
{
- xDocFac.set( m_xSMgr->createInstance("com.sun.star.ucb.TransientDocumentsContentProvider"),
+ xDocFac.set( m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.ucb.TransientDocumentsContentProvider", m_xContext),
uno::UNO_QUERY );
}
catch ( uno::Exception const & )
@@ -120,25 +105,14 @@ DocumentContentFactory::createDocumentContent(
// Service factory implementation.
-/// @throws uno::Exception
-static uno::Reference< uno::XInterface >
-DocumentContentFactory_CreateInstance(
- const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ucb_tdoc_DocumentContentFactory_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
{
- return static_cast<lang::XServiceInfo*>(new DocumentContentFactory(rSMgr));
+ static rtl::Reference<DocumentContentFactory> g_Instance(new DocumentContentFactory(context));
+ g_Instance->acquire();
+ return static_cast<cppu::OWeakObject*>(g_Instance.get());
}
-// static
-uno::Reference< lang::XSingleServiceFactory >
-DocumentContentFactory::createServiceFactory(
- const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
-{
- return cppu::createOneInstanceFactory(
- rxServiceMgr,
- DocumentContentFactory::getImplementationName_Static(),
- DocumentContentFactory_CreateInstance,
- DocumentContentFactory::getSupportedServiceNames_Static() );
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.hxx b/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.hxx
index 0956541c46e6..6a5218ac4889 100644
--- a/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_documentcontentfactory.hxx
@@ -20,9 +20,8 @@
#ifndef INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_DOCUMENTCONTENTFACTORY_HXX
#define INCLUDED_UCB_SOURCE_UCP_TDOC_TDOC_DOCUMENTCONTENTFACTORY_HXX
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/frame/XTransientDocumentsDocumentContentFactory.hpp>
#include <cppuhelper/implbase.hxx>
@@ -35,7 +34,7 @@ class DocumentContentFactory :
css::lang::XServiceInfo >
{
public:
- explicit DocumentContentFactory( const css::uno::Reference< css::lang::XMultiServiceFactory >& rXSMgr );
+ explicit DocumentContentFactory( const css::uno::Reference< css::uno::XComponentContext >& );
virtual ~DocumentContentFactory() override;
// XServiceInfo
@@ -51,16 +50,8 @@ public:
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
createDocumentContent( const css::uno::Reference< css::frame::XModel >& Model ) override;
- // Non-UNO interfaces
- static OUString
- getImplementationName_Static();
- static css::uno::Sequence< OUString >
- getSupportedServiceNames_Static();
-
- static css::uno::Reference< css::lang::XSingleServiceFactory >
- createServiceFactory( const css::uno::Reference< css::lang::XMultiServiceFactory > & rxServiceMgr );
private:
- css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMgr;
+ css::uno::Reference< css::uno::XComponentContext > m_xContext;
};
} // namespace tdoc_ucp
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx
index d2d8c6ae2035..e1d0f30e1ca9 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx
@@ -102,29 +102,31 @@ XTYPEPROVIDER_IMPL_5( ContentProvider,
// XServiceInfo methods.
+OUString SAL_CALL ContentProvider::getImplementationName()
+{
+ return "com.sun.star.comp.ucb.TransientDocumentsContentProvider";
+}
-XSERVICEINFO_COMMOM_IMPL( ContentProvider,
- "com.sun.star.comp.ucb.TransientDocumentsContentProvider" )
-/// @throws css::uno::Exception
-static css::uno::Reference< css::uno::XInterface >
-ContentProvider_CreateInstance( const css::uno::Reference< css::lang::XMultiServiceFactory> & rSMgr )
+sal_Bool SAL_CALL ContentProvider::supportsService( const OUString& ServiceName )
{
- css::lang::XServiceInfo* pX = new ContentProvider( ucbhelper::getComponentContext(rSMgr) );
- return css::uno::Reference< css::uno::XInterface >::query( pX );
+ return cppu::supportsService( this, ServiceName );
}
-css::uno::Sequence< OUString >
-ContentProvider::getSupportedServiceNames_Static()
+css::uno::Sequence< OUString > SAL_CALL ContentProvider::getSupportedServiceNames()
{
- css::uno::Sequence< OUString > aSNS { "com.sun.star.ucb.TransientDocumentsContentProvider" };
- return aSNS;
+ return { "com.sun.star.ucb.TransientDocumentsContentProvider" };
}
-// Service factory implementation.
+// Service factory implementation.
-ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+ucb_tdoc_ContentProvider_get_implementation(
+ css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new ContentProvider(context));
+}
// XContentProvider methods.
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.hxx b/ucb/source/ucp/tdoc/tdoc_provider.hxx
index c1498cd488f3..b105ac9367a3 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.hxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.hxx
@@ -78,13 +78,6 @@ public:
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
- static OUString getImplementationName_Static();
- static css::uno::Sequence< OUString > getSupportedServiceNames_Static();
-
- static css::uno::Reference< css::lang::XSingleServiceFactory >
- createServiceFactory( const css::uno::Reference<
- css::lang::XMultiServiceFactory >& rxServiceMgr );
-
// XContentProvider
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL
queryContent( const css::uno::Reference< css::ucb::XContentIdentifier >& Identifier ) override;
diff --git a/ucb/source/ucp/tdoc/tdoc_services.cxx b/ucb/source/ucp/tdoc/tdoc_services.cxx
deleted file mode 100644
index c46751bf6d1a..000000000000
--- a/ucb/source/ucp/tdoc/tdoc_services.cxx
+++ /dev/null
@@ -1,71 +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 <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include "tdoc_provider.hxx"
-#include "tdoc_documentcontentfactory.hxx"
-
-using namespace com::sun::star;
-using namespace tdoc_ucp;
-
-
-extern "C" SAL_DLLPUBLIC_EXPORT void * ucptdoc1_component_getFactory(
- const char * pImplName, void * pServiceManager, void * /*pRegistryKey*/ )
-{
- void * pRet = nullptr;
-
- uno::Reference< lang::XMultiServiceFactory > xSMgr(
- static_cast< lang::XMultiServiceFactory * >(
- pServiceManager ) );
- uno::Reference< lang::XSingleServiceFactory > xFactory;
-
-
- // Transient Documents Content Provider.
-
-
- if ( ContentProvider::getImplementationName_Static().
- equalsAscii( pImplName ) )
- {
- xFactory = ContentProvider::createServiceFactory( xSMgr );
- }
-
-
- // Transient Documents Document Content Factory.
-
-
- else if ( DocumentContentFactory::getImplementationName_Static().
- equalsAscii( pImplName ) )
- {
- xFactory = DocumentContentFactory::createServiceFactory( xSMgr );
- }
-
-
- if ( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
-
- return pRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/tdoc/ucptdoc1.component b/ucb/source/ucp/tdoc/ucptdoc1.component
index ebc03a445fbe..331538c432f3 100644
--- a/ucb/source/ucp/tdoc/ucptdoc1.component
+++ b/ucb/source/ucp/tdoc/ucptdoc1.component
@@ -18,11 +18,13 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="ucptdoc1" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.ucb.TransientDocumentsContentProvider">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.ucb.TransientDocumentsContentProvider"
+ constructor="ucb_tdoc_ContentProvider_get_implementation">
<service name="com.sun.star.ucb.TransientDocumentsContentProvider"/>
</implementation>
- <implementation name="com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory">
+ <implementation name="com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory"
+ constructor="ucb_tdoc_DocumentContentFactory_get_implementation">
<service name="com.sun.star.frame.TransientDocumentsDocumentContentFactory"/>
</implementation>
</component>