xref: /aoo42x/main/vcl/source/components/factory.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_vcl.hxx"
30*cdf0e10cSrcweir #include <tools/debug.hxx>
31*cdf0e10cSrcweir #ifndef _OSL_MUTEX_HXX
32*cdf0e10cSrcweir #include <osl/mutex.hxx>
33*cdf0e10cSrcweir #endif
34*cdf0e10cSrcweir #ifndef _RTL_USTRBUF_HXX
35*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
36*cdf0e10cSrcweir #endif
37*cdf0e10cSrcweir #include <uno/dispatcher.h> // declaration of generic uno interface
38*cdf0e10cSrcweir #include <uno/mapping.hxx> // mapping stuff
39*cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
40*cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
41*cdf0e10cSrcweir #include <vcl/dllapi.h>
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir using ::rtl::OUString;
44*cdf0e10cSrcweir using ::rtl::OUStringBuffer;
45*cdf0e10cSrcweir using namespace com::sun::star::uno;
46*cdf0e10cSrcweir using namespace com::sun::star::lang;
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir // service implementation
49*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL vcl_session_getSupportedServiceNames();
50*cdf0e10cSrcweir extern OUString SAL_CALL vcl_session_getImplementationName();
51*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL vcl_session_createInstance( const Reference< XMultiServiceFactory > & );
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir namespace vcl
54*cdf0e10cSrcweir {
55*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL DisplayAccess_getSupportedServiceNames();
56*cdf0e10cSrcweir extern OUString SAL_CALL DisplayAccess_getImplementationName();
57*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL DisplayAccess_createInstance( const Reference< XMultiServiceFactory > & );
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL FontIdentificator_getSupportedServiceNames();
60*cdf0e10cSrcweir extern OUString SAL_CALL FontIdentificator_getImplementationName();
61*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL FontIdentificator_createInstance( const Reference< XMultiServiceFactory > & );
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL StringMirror_getSupportedServiceNames();
64*cdf0e10cSrcweir extern OUString SAL_CALL StringMirror_getImplementationName();
65*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL StringMirror_createInstance( const Reference< XMultiServiceFactory > & );
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL Clipboard_getSupportedServiceNames();
68*cdf0e10cSrcweir extern OUString SAL_CALL Clipboard_getImplementationName();
69*cdf0e10cSrcweir extern Reference< XSingleServiceFactory > SAL_CALL Clipboard_createFactory( const Reference< XMultiServiceFactory > & );
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL DragSource_getSupportedServiceNames();
72*cdf0e10cSrcweir extern OUString SAL_CALL DragSource_getImplementationName();
73*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL DragSource_createInstance( const Reference< XMultiServiceFactory > & );
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL DropTarget_getSupportedServiceNames();
76*cdf0e10cSrcweir extern OUString SAL_CALL DropTarget_getImplementationName();
77*cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL DropTarget_createInstance( const Reference< XMultiServiceFactory > & );
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir namespace rsvg
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir 	extern Sequence< OUString > SAL_CALL Rasterizer_getSupportedServiceNames();
82*cdf0e10cSrcweir 	extern OUString SAL_CALL Rasterizer_getImplementationName();
83*cdf0e10cSrcweir 	extern Reference< XInterface > SAL_CALL Rasterizer_createInstance( const Reference< XMultiServiceFactory > & );
84*cdf0e10cSrcweir }
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir extern "C" {
88*cdf0e10cSrcweir 
89*cdf0e10cSrcweir 	VCL_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment(
90*cdf0e10cSrcweir 		const sal_Char** ppEnvTypeName,
91*cdf0e10cSrcweir 		uno_Environment** /*ppEnv*/ )
92*cdf0e10cSrcweir 	{
93*cdf0e10cSrcweir 		*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
94*cdf0e10cSrcweir 	}
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir 	VCL_DLLPUBLIC void* SAL_CALL component_getFactory(
97*cdf0e10cSrcweir 		const sal_Char* pImplementationName,
98*cdf0e10cSrcweir 		void* pXUnoSMgr,
99*cdf0e10cSrcweir 		void* /*pXUnoKey*/
100*cdf0e10cSrcweir 		)
101*cdf0e10cSrcweir 	{
102*cdf0e10cSrcweir 		void* pRet = 0;
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir 		if( pXUnoSMgr )
105*cdf0e10cSrcweir 		{
106*cdf0e10cSrcweir 			Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
107*cdf0e10cSrcweir 				reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
108*cdf0e10cSrcweir 				);
109*cdf0e10cSrcweir 			Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
110*cdf0e10cSrcweir 			if( vcl_session_getImplementationName().equalsAscii( pImplementationName ) )
111*cdf0e10cSrcweir 			{
112*cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
113*cdf0e10cSrcweir 					xMgr, vcl_session_getImplementationName(), vcl_session_createInstance,
114*cdf0e10cSrcweir 					vcl_session_getSupportedServiceNames() );
115*cdf0e10cSrcweir 			}
116*cdf0e10cSrcweir 			else if( vcl::DisplayAccess_getImplementationName().equalsAscii( pImplementationName ) )
117*cdf0e10cSrcweir 			{
118*cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
119*cdf0e10cSrcweir 					xMgr, vcl::DisplayAccess_getImplementationName(), vcl::DisplayAccess_createInstance,
120*cdf0e10cSrcweir 					vcl::DisplayAccess_getSupportedServiceNames() );
121*cdf0e10cSrcweir 			}
122*cdf0e10cSrcweir             else if( vcl::FontIdentificator_getImplementationName().equalsAscii( pImplementationName ) )
123*cdf0e10cSrcweir             {
124*cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
125*cdf0e10cSrcweir 					xMgr, vcl::FontIdentificator_getImplementationName(), vcl::FontIdentificator_createInstance,
126*cdf0e10cSrcweir 					vcl::FontIdentificator_getSupportedServiceNames() );
127*cdf0e10cSrcweir             }
128*cdf0e10cSrcweir             else if( vcl::StringMirror_getImplementationName().equalsAscii( pImplementationName ) )
129*cdf0e10cSrcweir             {
130*cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
131*cdf0e10cSrcweir 					xMgr, vcl::StringMirror_getImplementationName(), vcl::StringMirror_createInstance,
132*cdf0e10cSrcweir 					vcl::StringMirror_getSupportedServiceNames() );
133*cdf0e10cSrcweir             }
134*cdf0e10cSrcweir             else if( vcl::Clipboard_getImplementationName().equalsAscii( pImplementationName ) )
135*cdf0e10cSrcweir             {
136*cdf0e10cSrcweir 				xFactory = vcl::Clipboard_createFactory( xMgr );
137*cdf0e10cSrcweir             }
138*cdf0e10cSrcweir             else if( vcl::DragSource_getImplementationName().equalsAscii( pImplementationName ) )
139*cdf0e10cSrcweir             {
140*cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
141*cdf0e10cSrcweir 					xMgr, vcl::DragSource_getImplementationName(), vcl::DragSource_createInstance,
142*cdf0e10cSrcweir 					vcl::DragSource_getSupportedServiceNames() );
143*cdf0e10cSrcweir             }
144*cdf0e10cSrcweir             else if( vcl::DropTarget_getImplementationName().equalsAscii( pImplementationName ) )
145*cdf0e10cSrcweir             {
146*cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
147*cdf0e10cSrcweir 					xMgr, vcl::DropTarget_getImplementationName(), vcl::DropTarget_createInstance,
148*cdf0e10cSrcweir 					vcl::DropTarget_getSupportedServiceNames() );
149*cdf0e10cSrcweir             }
150*cdf0e10cSrcweir             else if( vcl::rsvg::Rasterizer_getImplementationName().equalsAscii( pImplementationName ) )
151*cdf0e10cSrcweir             {
152*cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
153*cdf0e10cSrcweir 					xMgr, vcl::rsvg::Rasterizer_getImplementationName(), vcl::rsvg::Rasterizer_createInstance,
154*cdf0e10cSrcweir 					vcl::rsvg::Rasterizer_getSupportedServiceNames() );
155*cdf0e10cSrcweir             }
156*cdf0e10cSrcweir 			if( xFactory.is() )
157*cdf0e10cSrcweir 			{
158*cdf0e10cSrcweir 				xFactory->acquire();
159*cdf0e10cSrcweir 				pRet = xFactory.get();
160*cdf0e10cSrcweir 			}
161*cdf0e10cSrcweir 		}
162*cdf0e10cSrcweir 		return pRet;
163*cdf0e10cSrcweir 	}
164*cdf0e10cSrcweir 
165*cdf0e10cSrcweir } /* extern "C" */
166