merge the formfield patch from ooo-build
[ooovba.git] / shell / source / backends / kde4be / kde4becdef.cxx
blob277e3910b73d50d5d6af98ed8487ff4a593109d8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: kde4becdef.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_shell.hxx"
33 #include "kde4backend.hxx"
35 #include <kapplication.h>
37 #include <cppuhelper/implementationentry.hxx>
39 #include <com/sun/star/registry/XRegistryKey.hpp>
40 #include <com/sun/star/uno/XComponentContext.hpp>
42 #include "uno/current_context.hxx"
44 namespace css = com::sun::star ;
45 namespace uno = css::uno ;
46 namespace lang = css::lang ;
47 namespace backend = css::configuration::backend ;
49 //==============================================================================
51 static uno::Reference<uno::XInterface> SAL_CALL createKDEBackend(const uno::Reference<uno::XComponentContext>& xContext)
53 try {
54 uno::Reference< uno::XCurrentContext > xCurrentContext(uno::getCurrentContext());
56 if (xCurrentContext.is())
58 uno::Any aValue = xCurrentContext->getValueByName(
59 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "system.desktop-environment" ) ) );
61 rtl::OUString aDesktopEnvironment;
62 if ( (aValue >>= aDesktopEnvironment) && (aDesktopEnvironment.equalsAscii("KDE")) && (KApplication::kApplication() != NULL) )
63 return * KDEBackend::createInstance(xContext);
66 return uno::Reference<uno::XInterface>();
68 } catch (uno::RuntimeException e) {
69 return uno::Reference<uno::XInterface>();
74 //==============================================================================
76 static const cppu::ImplementationEntry kImplementations_entries[] =
79 createKDEBackend,
80 KDEBackend::getBackendName,
81 KDEBackend::getBackendServiceNames,
82 cppu::createSingleComponentFactory,
83 NULL,
86 { NULL, NULL, NULL, NULL, NULL, 0 }
87 } ;
88 //------------------------------------------------------------------------------
90 extern "C" void SAL_CALL component_getImplementationEnvironment(
91 const sal_Char **aEnvTypeName,
92 uno_Environment **) {
93 *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
96 //------------------------------------------------------------------------------
98 extern "C" sal_Bool SAL_CALL component_writeInfo(void *,
99 void *pRegistryKey) {
101 using namespace ::com::sun::star::registry;
102 if (pRegistryKey)
106 uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey(
107 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + KDEBackend::getBackendName()
110 // Register associated service names
111 uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey(
112 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") )
115 uno::Sequence<rtl::OUString> sServiceNames = KDEBackend::getBackendServiceNames();
116 for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i)
117 xServicesKey->createKey(sServiceNames[i]);
119 return sal_True;
122 catch( InvalidRegistryException& )
124 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
128 return sal_False;
131 //------------------------------------------------------------------------------
133 extern "C" void *component_getFactory(const sal_Char *aImplementationName,
134 void *aServiceManager,
135 void *aRegistryKey) {
137 return cppu::component_getFactoryHelper(
138 aImplementationName,
139 aServiceManager,
140 aRegistryKey,
141 kImplementations_entries) ;
143 //------------------------------------------------------------------------------