Branch data 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 <cppuhelper/factory.hxx>
21 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
22 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
23 : : #include <com/sun/star/registry/XRegistryKey.hpp>
24 : : #include <com/sun/star/container/XSet.hpp>
25 : :
26 : : #include <stdio.h>
27 : :
28 : : //=============================================================================
29 : : // Add new include line to use new services.
30 : : //=============================================================================
31 : : #include "framecontrol.hxx"
32 : : #include "progressbar.hxx"
33 : : #include "progressmonitor.hxx"
34 : : #include "statusindicator.hxx"
35 : : //=============================================================================
36 : :
37 : : //______________________________________________________________________________________________________________
38 : : // namespaces
39 : : //______________________________________________________________________________________________________________
40 : :
41 : : using namespace ::rtl ;
42 : : using namespace ::cppu ;
43 : : using namespace ::unocontrols ;
44 : : using namespace ::com::sun::star::uno ;
45 : : using namespace ::com::sun::star::container ;
46 : : using namespace ::com::sun::star::lang ;
47 : : using namespace ::com::sun::star::registry ;
48 : :
49 : : //______________________________________________________________________________________________________________
50 : : // macros
51 : : //______________________________________________________________________________________________________________
52 : :
53 : : //******************************************************************************************************************************
54 : : #define CREATEINSTANCE(CLASS) \
55 : : \
56 : : static Reference< XInterface > SAL_CALL CLASS##_createInstance ( const Reference< XMultiServiceFactory >& rServiceManager ) throw ( Exception ) \
57 : : { \
58 : : return Reference< XInterface >( *(OWeakObject*)(new CLASS( rServiceManager )) ); \
59 : : }
60 : :
61 : : //******************************************************************************************************************************
62 : : #define CREATEFACTORY_SINGLE(CLASS) \
63 : : \
64 : : /* Create right factory ... */ \
65 : : xFactory = Reference< XSingleServiceFactory > \
66 : : ( \
67 : : cppu::createSingleFactory ( xServiceManager , \
68 : : CLASS::impl_getStaticImplementationName () , \
69 : : CLASS##_createInstance , \
70 : : CLASS::impl_getStaticSupportedServiceNames () ) \
71 : : ) ; \
72 : :
73 : : //******************************************************************************************************************************
74 : : #define IF_NAME_CREATECOMPONENTFACTORY_SINGLE(CLASS) \
75 : : \
76 : : if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \
77 : : { \
78 : : CREATEFACTORY_SINGLE ( CLASS ) \
79 : : }
80 : :
81 : : //______________________________________________________________________________________________________________
82 : : // declare functions to create a new instance of service
83 : : //______________________________________________________________________________________________________________
84 : :
85 : : //=============================================================================
86 : : // Add new macro line to use new services.
87 : : //
88 : : // !!! ATTENTION !!!
89 : : // Write no ";" at end of line! (see macro)
90 : : //=============================================================================
91 : 0 : CREATEINSTANCE ( FrameControl )
92 : 0 : CREATEINSTANCE ( ProgressBar )
93 : 0 : CREATEINSTANCE ( ProgressMonitor )
94 : 0 : CREATEINSTANCE ( StatusIndicator )
95 : : //=============================================================================
96 : :
97 : : //______________________________________________________________________________________________________________
98 : : // create right component factory
99 : : //______________________________________________________________________________________________________________
100 : :
101 : 0 : extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplementationName ,
102 : : void* pServiceManager ,
103 : : void* /*pRegistryKey*/ )
104 : : {
105 : : // Set default return value for this operation - if it failed.
106 : 0 : void* pReturn = NULL ;
107 : :
108 : 0 : if (
109 : : ( pImplementationName != NULL ) &&
110 : : ( pServiceManager != NULL )
111 : : )
112 : : {
113 : : // Define variables which are used in following macros.
114 : 0 : Reference< XSingleServiceFactory > xFactory ;
115 : 0 : Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
116 : :
117 : : //=============================================================================
118 : : // Add new macro line to handle new service.
119 : : //
120 : : // !!! ATTENTION !!!
121 : : // Write no ";" at end of line and dont forget "else" ! (see macro)
122 : : //=============================================================================
123 : 0 : IF_NAME_CREATECOMPONENTFACTORY_SINGLE( FrameControl )
124 : : else
125 : 0 : IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressBar )
126 : : else
127 : 0 : IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressMonitor )
128 : : else
129 : 0 : IF_NAME_CREATECOMPONENTFACTORY_SINGLE( StatusIndicator )
130 : : //=============================================================================
131 : :
132 : : // Factory is valid - service was found.
133 : 0 : if ( xFactory.is() )
134 : : {
135 : 0 : xFactory->acquire();
136 : 0 : pReturn = xFactory.get();
137 : 0 : }
138 : : }
139 : :
140 : : // Return with result of this operation.
141 : 0 : return pReturn ;
142 : : }
143 : :
144 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|