sync master with lastest vba changes
[ooovba.git] / sc / source / ui / vba / service.cxx
blob37b6fb35fa72da9295b0ed7f289456b137cb8ebf
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: service.cxx,v $
10 * $Revision: 1.4 $
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 ************************************************************************/
30 #include "cppuhelper/implementationentry.hxx"
31 #include "com/sun/star/lang/XMultiServiceFactory.hpp"
32 #include "com/sun/star/registry/XRegistryKey.hpp"
33 #include "comphelper/servicedecl.hxx"
35 // =============================================================================
36 // component exports
37 // =============================================================================
38 using namespace ::com::sun::star;
39 using namespace ::com::sun::star::uno;
41 namespace sdecl = comphelper::service_decl;
43 // reference service helper(s)
44 namespace range
46 extern sdecl::ServiceDecl const serviceDecl;
48 namespace workbook
50 extern sdecl::ServiceDecl const serviceDecl;
52 namespace worksheet
54 extern sdecl::ServiceDecl const serviceDecl;
56 namespace window
58 extern sdecl::ServiceDecl const serviceDecl;
60 namespace globals
62 extern sdecl::ServiceDecl const serviceDecl;
64 namespace hyperlink
66 extern sdecl::ServiceDecl const serviceDecl;
68 namespace application
70 extern sdecl::ServiceDecl const serviceDecl;
72 namespace vbaeventshelper
74 extern sdecl::ServiceDecl const serviceDecl;
76 namespace textframe
78 extern sdecl::ServiceDecl const serviceDecl;
81 extern "C"
83 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
84 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
86 OSL_TRACE("In component_getImplementationEnv");
87 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
90 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
91 lang::XMultiServiceFactory * pServiceManager, registry::XRegistryKey * pRegistryKey )
93 OSL_TRACE("In component_writeInfo");
94 #if 0
95 // Component registration
96 if ( component_writeInfoHelper( pServiceManager, pRegistryKey,
97 range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl ) )
99 // Singleton registration
102 registry::XRegistryKey * pKey =
103 reinterpret_cast< registry::XRegistryKey * >(pRegistryKey);
105 Reference< registry::XRegistryKey >xKey = pKey->createKey(
106 rtl::OUString::createFromAscii( ("ooo.vba.Globals/UNO/SINGLETONS/ooo.vba.theGlobals") ) );
107 xKey->setStringValue( ::rtl::OUString::createFromAscii(
108 ("ooo.vba.Globals") ) );
109 return sal_True;
111 catch( uno::Exception& /*e*/ )
113 //recomp & friends will detect false returned and fail
116 return sal_False;
117 #else
118 // Component registration
119 return component_writeInfoHelper( pServiceManager, pRegistryKey,
120 range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl ) && component_writeInfoHelper( pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl );
121 #endif
125 SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
126 const sal_Char * pImplName, lang::XMultiServiceFactory * pServiceManager,
127 registry::XRegistryKey * pRegistryKey )
129 OSL_TRACE("In component_getFactory for %s", pImplName );
130 void* pRet = component_getFactoryHelper(
131 pImplName, pServiceManager, pRegistryKey, range::serviceDecl, workbook::serviceDecl, worksheet::serviceDecl, globals::serviceDecl, window::serviceDecl, hyperlink::serviceDecl, application::serviceDecl );
132 if( !pRet )
133 pRet = component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey, vbaeventshelper::serviceDecl, textframe::serviceDecl );
134 OSL_TRACE("Ret is 0x%x", pRet);
135 return pRet;