bump product version to 4.1.6.2
[LibreOffice.git] / UnoControls / source / base / registercontrols.cxx
blob94df3e701ba127c425aa6e825d79fb1b9bc9a869
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
27 #include <stdio.h>
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 //=============================================================================
38 //______________________________________________________________________________________________________________
39 // namespaces
40 //______________________________________________________________________________________________________________
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 ;
50 //______________________________________________________________________________________________________________
51 // macros
52 //______________________________________________________________________________________________________________
54 //******************************************************************************************************************************
55 #define CREATEINSTANCE(CLASS) \
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) )) ); \
62 //******************************************************************************************************************************
63 #define CREATEFACTORY_SINGLE(CLASS) \
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 ) ; \
74 //******************************************************************************************************************************
75 #define IF_NAME_CREATECOMPONENTFACTORY_SINGLE(CLASS) \
77 if ( CLASS::impl_getStaticImplementationName().equals( OUString::createFromAscii( pImplementationName ) ) ) \
78 { \
79 CREATEFACTORY_SINGLE ( CLASS ) \
82 //______________________________________________________________________________________________________________
83 // declare functions to create a new instance of service
84 //______________________________________________________________________________________________________________
86 //=============================================================================
87 // Add new macro line to use new services.
89 // !!! ATTENTION !!!
90 // Write no ";" at end of line! (see macro)
91 //=============================================================================
92 CREATEINSTANCE ( FrameControl )
93 CREATEINSTANCE ( ProgressBar )
94 CREATEINSTANCE ( ProgressMonitor )
95 CREATEINSTANCE ( StatusIndicator )
96 //=============================================================================
98 //______________________________________________________________________________________________________________
99 // create right component factory
100 //______________________________________________________________________________________________________________
102 extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL ctl_component_getFactory( const sal_Char* pImplementationName,
103 void* pServiceManager ,
104 void* /*pRegistryKey*/ )
106 // Set default return value for this operation - if it failed.
107 void* pReturn = NULL ;
109 if (
110 ( pImplementationName != NULL ) &&
111 ( pServiceManager != NULL )
114 // Define variables which are used in following macros.
115 Reference< XSingleServiceFactory > xFactory ;
116 Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
118 //=============================================================================
119 // Add new macro line to handle new service.
121 // !!! ATTENTION !!!
122 // Write no ";" at end of line and dont forget "else" ! (see macro)
123 //=============================================================================
124 IF_NAME_CREATECOMPONENTFACTORY_SINGLE( FrameControl )
125 else IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressBar )
126 else IF_NAME_CREATECOMPONENTFACTORY_SINGLE( ProgressMonitor )
127 else IF_NAME_CREATECOMPONENTFACTORY_SINGLE( StatusIndicator )
128 //=============================================================================
130 // Factory is valid - service was found.
131 if ( xFactory.is() )
133 xFactory->acquire();
134 pReturn = xFactory.get();
138 // Return with result of this operation.
139 return pReturn ;
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */