Line data Source code
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 "sal/types.h"
21 : #include "rtl/ustring.hxx"
22 : #include <cppuhelper/factory.hxx>
23 : #include <cppuhelper/weak.hxx>
24 : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
25 : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 : #include <com/sun/star/registry/XRegistryKey.hpp>
27 : #include <osl/diagnose.h>
28 : #include <uno/mapping.hxx>
29 : #include "provider.hxx"
30 : #include "renderer.hxx"
31 : #include "unowizard.hxx"
32 :
33 : #include "comphelper/servicedecl.hxx"
34 :
35 : #include "cppuhelper/implementationentry.hxx"
36 :
37 : using namespace ::com::sun::star::uno;
38 : using namespace ::com::sun::star::registry;
39 : using namespace ::com::sun::star::lang;
40 : using namespace unographic;
41 :
42 : using rtl::OUString;
43 :
44 : namespace sdecl = comphelper::service_decl;
45 :
46 : namespace unographic {
47 : extern sdecl::ServiceDecl const serviceDecl;
48 : }
49 :
50 : // -------------------------------------------------------------------------------------
51 :
52 : // for CreateInstance functions implemented elsewhere
53 : #define DECLARE_CREATEINSTANCE( ImplName ) \
54 : Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& );
55 :
56 : // for CreateInstance functions implemented elsewhere, while the function is within a namespace
57 : #define DECLARE_CREATEINSTANCE_NAMESPACE( nmspe, ImplName ) \
58 : namespace nmspe { \
59 : Reference< XInterface > SAL_CALL ImplName##_CreateInstance( const Reference< XMultiServiceFactory >& ); \
60 : }
61 :
62 : namespace
63 : {
64 : static struct ::cppu::ImplementationEntry s_aServiceEntries[] =
65 : {
66 : {
67 : ::svt::uno::Wizard::Create,
68 : ::svt::uno::Wizard::getImplementationName_static,
69 : ::svt::uno::Wizard::getSupportedServiceNames_static,
70 : ::cppu::createSingleComponentFactory, NULL, 0
71 : },
72 : { 0, 0, 0, 0, 0, 0 }
73 : };
74 : }
75 :
76 : // -------------------------------------------------------------------------------------
77 :
78 : DECLARE_CREATEINSTANCE_NAMESPACE( svt, OAddressBookSourceDialogUno )
79 : DECLARE_CREATEINSTANCE( SvFilterOptionsDialog )
80 : DECLARE_CREATEINSTANCE_NAMESPACE( unographic, GraphicProvider )
81 : DECLARE_CREATEINSTANCE_NAMESPACE( unographic, GraphicRendererVCL )
82 :
83 : // -------------------------------------------------------------------------------------
84 : extern "C"
85 : {
86 :
87 16 : SAL_DLLPUBLIC_EXPORT void * SAL_CALL svt_component_getFactory (
88 : const sal_Char * pImplementationName, void * _pServiceManager, void * pRegistryKey)
89 : {
90 16 : void * pResult = 0;
91 16 : if ( _pServiceManager )
92 : {
93 16 : Reference< XSingleServiceFactory > xFactory;
94 16 : if (rtl_str_compare (
95 16 : pImplementationName, "com.sun.star.comp.svtools.OAddressBookSourceDialogUno") == 0)
96 : {
97 0 : Sequence< OUString > aServiceNames(1);
98 : aServiceNames.getArray()[0] =
99 0 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.AddressBookSourceDialog" ));
100 :
101 : xFactory = ::cppu::createSingleFactory (
102 : reinterpret_cast< XMultiServiceFactory* >( _pServiceManager ),
103 : OUString::createFromAscii( pImplementationName ),
104 : svt::OAddressBookSourceDialogUno_CreateInstance,
105 0 : aServiceNames);
106 : }
107 16 : else if (rtl_str_compare (
108 16 : pImplementationName, "com.sun.star.svtools.SvFilterOptionsDialog") == 0)
109 : {
110 0 : Sequence< OUString > aServiceNames(1);
111 : aServiceNames.getArray()[0] =
112 0 : OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilterOptionsDialog" ));
113 :
114 : xFactory = ::cppu::createSingleFactory (
115 : reinterpret_cast< XMultiServiceFactory* >( _pServiceManager ),
116 : OUString::createFromAscii( pImplementationName ),
117 : SvFilterOptionsDialog_CreateInstance,
118 0 : aServiceNames);
119 : }
120 16 : else if( 0 == GraphicProvider::getImplementationName_Static().compareToAscii( pImplementationName ) )
121 : {
122 : xFactory = ::cppu::createOneInstanceFactory(
123 : reinterpret_cast< lang::XMultiServiceFactory * >( _pServiceManager ),
124 : GraphicProvider::getImplementationName_Static(),
125 : GraphicProvider_CreateInstance,
126 12 : GraphicProvider::getSupportedServiceNames_Static() );
127 : }
128 4 : else if( 0 == GraphicRendererVCL::getImplementationName_Static().compareToAscii( pImplementationName ) )
129 : {
130 : xFactory = ::cppu::createOneInstanceFactory(
131 : reinterpret_cast< lang::XMultiServiceFactory * >( _pServiceManager ),
132 : GraphicRendererVCL::getImplementationName_Static(),
133 : GraphicRendererVCL_CreateInstance,
134 0 : GraphicRendererVCL::getSupportedServiceNames_Static() );
135 : }
136 : else
137 : {
138 4 : pResult = component_getFactoryHelper( pImplementationName, reinterpret_cast< lang::XMultiServiceFactory * >( _pServiceManager ),reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ), serviceDecl );
139 4 : if ( !pResult )
140 0 : pResult = ::cppu::component_getFactoryHelper( pImplementationName, _pServiceManager, pRegistryKey, s_aServiceEntries );
141 : }
142 :
143 16 : if ( xFactory.is() )
144 : {
145 12 : xFactory->acquire();
146 12 : pResult = xFactory.get();
147 16 : }
148 : }
149 16 : return pResult;
150 : }
151 :
152 : } // "C"
153 :
154 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|