merge the formfield patch from ooo-build
[ooovba.git] / shell / source / backends / gconfbe / gconfbecdef.cxx
blob54faf1caebc22e010a8c9f16f37205aea9f0cdee
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: gconfbecdef.cxx,v $
10 * $Revision: 1.11 $
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 "gconfbackend.hxx"
34 #include <com/sun/star/registry/XRegistryKey.hpp>
36 #ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
37 #include <cppuhelper/implementationentry.hxx>
38 #endif // _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_
39 #include <com/sun/star/uno/XComponentContext.hpp>
40 #include <rtl/ustrbuf.hxx>
42 #include "uno/current_context.hxx"
43 #include <stdio.h>
44 #include "orbit.h"
46 namespace css = com::sun::star ;
47 namespace uno = css::uno ;
48 namespace lang = css::lang ;
49 namespace backend = css::configuration::backend ;
51 //==============================================================================
53 static uno::Reference<uno::XInterface> SAL_CALL createGconfBackend(const uno::Reference<uno::XComponentContext>& xContext)
55 try {
56 uno::Reference< uno::XCurrentContext > xCurrentContext(uno::getCurrentContext());
58 if (xCurrentContext.is())
60 uno::Any aValue = xCurrentContext->getValueByName(
61 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "system.desktop-environment" ) ) );
63 rtl::OUString aDesktopEnvironment;
64 if ( (aValue >>= aDesktopEnvironment) && (aDesktopEnvironment.equalsAscii("GNOME")) )
66 // ORBit-2 versions < 2.8 cause a deadlock with the gtk+ VCL plugin
67 if ( (orbit_major_version >= 2) && (orbit_minor_version >= 8) )
69 return * GconfBackend::createInstance(xContext);
74 return uno::Reference<uno::XInterface>();
76 } catch (uno::RuntimeException e) {
77 return uno::Reference<uno::XInterface>();
82 //==============================================================================
84 static const cppu::ImplementationEntry kImplementations_entries[] =
87 createGconfBackend,
88 GconfBackend::getBackendName,
89 GconfBackend::getBackendServiceNames,
90 cppu::createSingleComponentFactory,
91 NULL,
94 { NULL, NULL, NULL, NULL, NULL, 0 }
95 } ;
96 //------------------------------------------------------------------------------
98 extern "C" void SAL_CALL component_getImplementationEnvironment(
99 const sal_Char **aEnvTypeName,
100 uno_Environment **/*aEnvironment*/) {
101 *aEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ;
104 //------------------------------------------------------------------------------
106 extern "C" sal_Bool SAL_CALL component_writeInfo(void */*pServiceManager*/,
107 void *pRegistryKey) {
109 using namespace ::com::sun::star::registry;
110 if (pRegistryKey)
114 uno::Reference< XRegistryKey > xImplKey = static_cast< XRegistryKey* >( pRegistryKey )->createKey(
115 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") ) + GconfBackend::getBackendName()
118 // Register associated service names
119 uno::Reference< XRegistryKey > xServicesKey = xImplKey->createKey(
120 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES") )
123 uno::Sequence<rtl::OUString> sServiceNames = GconfBackend::getBackendServiceNames();
124 for (sal_Int32 i = 0 ; i < sServiceNames.getLength() ; ++ i)
125 xServicesKey->createKey(sServiceNames[i]);
127 return sal_True;
130 catch( InvalidRegistryException& )
132 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
136 return sal_False;
139 //------------------------------------------------------------------------------
141 extern "C" void *component_getFactory(const sal_Char *aImplementationName,
142 void *aServiceManager,
143 void *aRegistryKey) {
145 return cppu::component_getFactoryHelper(
146 aImplementationName,
147 aServiceManager,
148 aRegistryKey,
149 kImplementations_entries) ;
151 //------------------------------------------------------------------------------