summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-26 16:16:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-26 17:10:24 +0200
commitc6046e915df2496357a84736ad6a1962394a6378 (patch)
tree351d58f366556d8cdc580685f3c87af4ceffe1d4 /sd
parent31b8db1d143b25400e307030f9672a556e69573a (diff)
sd: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: I92d19e8f01f759568756af85f2d76c226948ef68 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99457 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/Library_sd.mk1
-rw-r--r--sd/source/ui/inc/facreg.hxx44
-rw-r--r--sd/source/ui/unoidl/facreg.cxx123
-rw-r--r--sd/source/ui/unoidl/unodoc.cxx59
-rw-r--r--sd/util/sd.component8
5 files changed, 30 insertions, 205 deletions
diff --git a/sd/Library_sd.mk b/sd/Library_sd.mk
index 43b168be8d8c..9d399e8e3f5a 100644
--- a/sd/Library_sd.mk
+++ b/sd/Library_sd.mk
@@ -418,7 +418,6 @@ $(eval $(call gb_Library_add_exception_objects,sd,\
sd/source/ui/unoidl/SdUnoOutlineView \
sd/source/ui/unoidl/SdUnoSlideView \
sd/source/ui/unoidl/UnoDocumentSettings \
- sd/source/ui/unoidl/facreg \
sd/source/ui/unoidl/randomnode \
sd/source/ui/unoidl/unocpres \
sd/source/ui/unoidl/unodoc \
diff --git a/sd/source/ui/inc/facreg.hxx b/sd/source/ui/inc/facreg.hxx
deleted file mode 100644
index aee3924d3d44..000000000000
--- a/sd/source/ui/inc/facreg.hxx
+++ /dev/null
@@ -1,44 +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 .
- */
-
-#ifndef INCLUDED_SD_SOURCE_UI_INC_FACREG_HXX
-#define INCLUDED_SD_SOURCE_UI_INC_FACREG_HXX
-
-#include <sal/config.h>
-#include <sfx2/sfxmodelfactory.hxx>
-
-namespace com::sun::star {
- namespace lang { class XMultiServiceFactory; }
-}
-
-css::uno::Reference< css::uno::XInterface > SdDrawingDocument_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & _rxFactory, SfxModelFlags _nCreationFlags );
-/// @throws css::uno::RuntimeException
-OUString SdDrawingDocument_getImplementationName();
-/// @throws css::uno::RuntimeException
-css::uno::Sequence< OUString >SdDrawingDocument_getSupportedServiceNames();
-
-css::uno::Reference< css::uno::XInterface > SdPresentationDocument_createInstance( const css::uno::Reference< css::lang::XMultiServiceFactory > & _rxFactory, SfxModelFlags _nCreationFlags );
-/// @throws css::uno::RuntimeException
-OUString SdPresentationDocument_getImplementationName();
-/// @throws css::uno::RuntimeException
-css::uno::Sequence< OUString > SdPresentationDocument_getSupportedServiceNames();
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/unoidl/facreg.cxx b/sd/source/ui/unoidl/facreg.cxx
deleted file mode 100644
index 6fffe8a3bec5..000000000000
--- a/sd/source/ui/unoidl/facreg.cxx
+++ /dev/null
@@ -1,123 +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/XSingleComponentFactory.hpp>
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-#include <facreg.hxx>
-#include <sddll.hxx>
-
-#include <sfx2/sfxmodelfactory.hxx>
-#include <sal/types.h>
-
-#include <unordered_map>
-
-using namespace com::sun::star;
-
-// Declaration and initialization of a map from service names to locally
-// unique factory identifiers.
-
-namespace {
-
-enum FactoryId
-{
- SdDrawingDocumentFactoryId,
- SdPresentationDocumentFactoryId,
-};
-
-}
-
-typedef std::unordered_map<OUString, FactoryId> FactoryMap;
-
-namespace {
-FactoryMap const & GetFactoryMap()
-{
- static FactoryMap aFactoryMap
- {
- { SdDrawingDocument_getImplementationName(), SdDrawingDocumentFactoryId },
- { SdPresentationDocument_getImplementationName(), SdPresentationDocumentFactoryId }
- };
- return aFactoryMap;
-};
-} // end of anonymous namespace
-
-extern "C"
-{
-
-SAL_DLLPUBLIC_EXPORT void * sd_component_getFactory(
- const char * pImplName,
- void * pServiceManager,
- void * )
-{
- void * pRet = nullptr;
-
- if( pServiceManager )
- {
- uno::Reference< lang::XMultiServiceFactory > xMSF( static_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
-
- uno::Reference<lang::XSingleServiceFactory> xFactory;
- uno::Reference<lang::XSingleComponentFactory> xComponentFactory;
-
- const FactoryMap& rFactoryMap (GetFactoryMap());
- OUString sImplementationName (OUString::createFromAscii(pImplName));
- FactoryMap::const_iterator iFactory (rFactoryMap.find(sImplementationName));
- if (iFactory != rFactoryMap.end())
- {
- switch (iFactory->second)
- {
- case SdDrawingDocumentFactoryId:
- xFactory = ::sfx2::createSfxModelFactory(
- xMSF,
- SdDrawingDocument_getImplementationName(),
- SdDrawingDocument_createInstance,
- SdDrawingDocument_getSupportedServiceNames());
- break;
-
- case SdPresentationDocumentFactoryId:
- xFactory = ::sfx2::createSfxModelFactory(
- xMSF,
- SdPresentationDocument_getImplementationName(),
- SdPresentationDocument_createInstance,
- SdPresentationDocument_getSupportedServiceNames());
- break;
-
- default:
- break;
- }
- if (xComponentFactory.is())
- {
- xComponentFactory->acquire();
- pRet = xComponentFactory.get();
- }
- else if (xFactory.is())
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
- }
- }
-
- if (pRet != nullptr)
- SdDLL::Init();
- return pRet;
-}
-
-} // end of extern "C"
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/source/ui/unoidl/unodoc.cxx b/sd/source/ui/unoidl/unodoc.cxx
index bbc7fc1e6313..44eae1c2a46b 100644
--- a/sd/source/ui/unoidl/unodoc.cxx
+++ b/sd/source/ui/unoidl/unodoc.cxx
@@ -23,7 +23,6 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <sddll.hxx>
-#include <facreg.hxx>
#include <DrawDocShell.hxx>
#include <GraphicDocShell.hxx>
#include <vcl/svapp.hxx>
@@ -32,53 +31,45 @@ using namespace ::com::sun::star;
// com.sun.star.comp.Draw.DrawingDocument
-OUString SdDrawingDocument_getImplementationName()
-{
- return "com.sun.star.comp.Draw.DrawingDocument";
-}
-
-uno::Sequence< OUString > SdDrawingDocument_getSupportedServiceNames()
-{
- return { "com.sun.star.drawing.DrawingDocument", "com.sun.star.drawing.DrawingDocumentFactory" };
-}
-
-uno::Reference< uno::XInterface > SdDrawingDocument_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > &, SfxModelFlags _nCreationFlags )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+sd_DrawingDocument_get_implementation(
+ css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& args)
{
SolarMutexGuard aGuard;
SdDLL::Init();
- SfxObjectShell* pShell = new ::sd::GraphicDocShell( _nCreationFlags );
- return uno::Reference< uno::XInterface >( pShell->GetModel() );
+ css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
+ [&](SfxModelFlags _nCreationFlags)
+ {
+ SfxObjectShell* pShell = new ::sd::GraphicDocShell( _nCreationFlags );
+ return uno::Reference< uno::XInterface >( pShell->GetModel() );
+ });
+ xInterface->acquire();
+ return xInterface.get();
}
-// com.sun.star.comp.Draw.PresentationDocument
-OUString SdPresentationDocument_getImplementationName()
-{
- return "com.sun.star.comp.Draw.PresentationDocument";
-}
-
-uno::Sequence< OUString > SdPresentationDocument_getSupportedServiceNames()
-{
- return uno::Sequence<OUString>{
- "com.sun.star.drawing.DrawingDocumentFactory",
- "com.sun.star.presentation.PresentationDocument"
- };
-}
+// com.sun.star.comp.Draw.PresentationDocument
-uno::Reference< uno::XInterface > SdPresentationDocument_createInstance(
- const uno::Reference< lang::XMultiServiceFactory > &, SfxModelFlags _nCreationFlags )
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+sd_PresentationDocument_get_implementation(
+ css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const& args)
{
SolarMutexGuard aGuard;
SdDLL::Init();
- SfxObjectShell* pShell =
- new ::sd::DrawDocShell(
- _nCreationFlags, false, DocumentType::Impress );
- return uno::Reference< uno::XInterface >( pShell->GetModel() );
+ css::uno::Reference<css::uno::XInterface> xInterface = sfx2::createSfxModelInstance(args,
+ [&](SfxModelFlags _nCreationFlags)
+ {
+ SfxObjectShell* pShell =
+ new ::sd::DrawDocShell(
+ _nCreationFlags, false, DocumentType::Impress );
+ return pShell->GetModel();
+ });
+ xInterface->acquire();
+ return xInterface.get();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sd/util/sd.component b/sd/util/sd.component
index fb70297d12f9..f1937a04873a 100644
--- a/sd/util/sd.component
+++ b/sd/util/sd.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="sd" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.Draw.DrawingDocument">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.Draw.DrawingDocument"
+ constructor="sd_DrawingDocument_get_implementation">
<service name="com.sun.star.drawing.DrawingDocument"/>
<service name="com.sun.star.drawing.DrawingDocumentFactory"/>
</implementation>
@@ -27,7 +28,8 @@
constructor="com_sun_star_comp_Draw_DrawingModule_get_implementation">
<service name="com.sun.star.drawing.ModuleDispatcher"/>
</implementation>
- <implementation name="com.sun.star.comp.Draw.PresentationDocument">
+ <implementation name="com.sun.star.comp.Draw.PresentationDocument"
+ constructor="sd_PresentationDocument_get_implementation">
<service name="com.sun.star.drawing.DrawingDocumentFactory"/>
<service name="com.sun.star.presentation.PresentationDocument"/>
</implementation>