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