LibreOffice Module sw (master)  1
unofreg.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <config_features.h>
21 
22 #include <swdll.hxx>
23 #include <unofreg.hxx>
24 #include <unomailmerge.hxx>
25 #include <sal/types.h>
26 #include <cppuhelper/factory.hxx>
27 #include <sfx2/sfxmodelfactory.hxx>
28 #include <vcl/svapp.hxx>
29 
30 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
31 
32 #include <string.h>
33 
34 using namespace ::com::sun::star;
35 using namespace ::com::sun::star::lang;
36 
37 extern "C"
38 {
39 
40 SAL_DLLPUBLIC_EXPORT void * sw_component_getFactory(
41  const char * pImplName,
42  void * pServiceManager,
43  void * )
44 {
45  void * pRet = nullptr;
46  if( pServiceManager )
47  {
48  uno::Reference< XMultiServiceFactory > xMSF(
49  static_cast< XMultiServiceFactory * >( pServiceManager ) );
50 
51  uno::Reference< XSingleServiceFactory > xFactory;
52 
53  const sal_Int32 nImplNameLen = strlen( pImplName );
54  if( SwTextDocument_getImplementationName().equalsAsciiL(
55  pImplName, nImplNameLen ) )
56  {
57  xFactory = ::sfx2::createSfxModelFactory( xMSF,
61  }
62 
63  if( xFactory.is())
64  {
65  xFactory->acquire();
66  pRet = xFactory.get();
67  }
68  }
69  return pRet;
70 }
71 
72 } // extern "C"
73 
74 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
75 SwXMailMerge_get_implementation(css::uno::XComponentContext*,
76  css::uno::Sequence<css::uno::Any> const &)
77 {
78 #if HAVE_FEATURE_DBCONNECTIVITY
79  SolarMutexGuard aGuard;
80 
81  //the module may not be loaded
83  return cppu::acquire(new SwXMailMerge());
84 #else
85  return nullptr;
86 #endif
87 }
88 
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Sequence< OUString > SwTextDocument_getSupportedServiceNames()
Definition: unodoc.cxx:35
css::uno::Reference< css::uno::XInterface > SwTextDocument_createInstance(const css::uno::Reference< css::lang::XMultiServiceFactory > &rSMgr, SfxModelFlags _nCreationFlags)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SwXMailMerge_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Definition: unofreg.cxx:75
void ensure()
Definition: swdll.cxx:67
SAL_DLLPUBLIC_EXPORT void * sw_component_getFactory(const char *pImplName, void *pServiceManager, void *)
Definition: unofreg.cxx:40
OUString SwTextDocument_getImplementationName()
Definition: unodoc.cxx:43
Reference< XSingleServiceFactory > xFactory