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