1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_desktop.hxx"
26 #include <com/sun/star/beans/NamedValue.hpp>
27 #include <com/sun/star/registry/XRegistryKey.hpp>
28 #include <com/sun/star/util/Date.hpp>
29 #include <uno/environment.h>
30 #include <cppuhelper/factory.hxx>
31 #include <unotools/configmgr.hxx>
32
33 #include "splash.hxx"
34 #include "firststart.hxx"
35
36
37 using namespace rtl;
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::beans;
41 using namespace ::com::sun::star::registry;
42 using namespace ::desktop;
43
44 static const char* pServices[] =
45 {
46 SplashScreen::serviceName,
47 FirstStart::serviceName,
48 NULL
49 };
50
51 static const char* pImplementations[] =
52 {
53 SplashScreen::implementationName,
54 FirstStart::implementationName,
55 NULL
56 };
57
58 typedef Reference<XInterface>(* fProvider)(const Reference<XMultiServiceFactory>&);
59
60 static const fProvider pInstanceProviders[] =
61 {
62 SplashScreen::getInstance,
63 FirstStart::CreateInstance,
64 NULL
65 };
66
67
68 static const char** pSupportedServices[] =
69 {
70 SplashScreen::interfaces,
71 FirstStart::interfaces,
72 NULL
73 };
74
75 static Sequence<OUString>
getSupportedServiceNames(int p)76 getSupportedServiceNames(int p) {
77 const char **names = pSupportedServices[p];
78 Sequence<OUString> aSeq;
79 for(int i = 0; names[i] != NULL; i++) {
80 aSeq.realloc(i+1);
81 aSeq[i] = OUString::createFromAscii(names[i]);
82 }
83 return aSeq;
84 }
85
86 extern "C"
87 {
88 void SAL_CALL
component_getImplementationEnvironment(const sal_Char ** ppEnvironmentTypeName,uno_Environment **)89 component_getImplementationEnvironment(
90 const sal_Char** ppEnvironmentTypeName,
91 uno_Environment**)
92 {
93 *ppEnvironmentTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
94 }
95
96 void* SAL_CALL
component_getFactory(const sal_Char * pImplementationName,void * pServiceManager,void *)97 component_getFactory(
98 const sal_Char* pImplementationName,
99 void* pServiceManager,
100 void*)
101 {
102 // Set default return value for this operation - if it failed.
103 if ( pImplementationName && pServiceManager )
104 {
105 Reference< XSingleServiceFactory > xFactory;
106 Reference< XMultiServiceFactory > xServiceManager(
107 reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ;
108
109 // search implementation
110 for (int i = 0; (pImplementations[i]!=NULL); i++) {
111 if ( strcmp(pImplementations[i], pImplementationName ) == 0 ) {
112 // found implementation
113 xFactory = Reference<XSingleServiceFactory>(cppu::createSingleFactory(
114 xServiceManager, OUString::createFromAscii(pImplementationName),
115 pInstanceProviders[i], getSupportedServiceNames(i)));
116 if ( xFactory.is() ) {
117 // Factory is valid - service was found.
118 xFactory->acquire();
119 return xFactory.get();
120 }
121 }
122 } // for()
123 }
124 // Return with result of this operation.
125 return NULL;
126 }
127 } // extern "C"
128