xref: /aoo41x/main/vcl/source/components/factory.cxx (revision 9f62ea84)
1*9f62ea84SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*9f62ea84SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*9f62ea84SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*9f62ea84SAndrew Rist  * distributed with this work for additional information
6*9f62ea84SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*9f62ea84SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*9f62ea84SAndrew Rist  * "License"); you may not use this file except in compliance
9*9f62ea84SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*9f62ea84SAndrew Rist  *
11*9f62ea84SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*9f62ea84SAndrew Rist  *
13*9f62ea84SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*9f62ea84SAndrew Rist  * software distributed under the License is distributed on an
15*9f62ea84SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*9f62ea84SAndrew Rist  * KIND, either express or implied.  See the License for the
17*9f62ea84SAndrew Rist  * specific language governing permissions and limitations
18*9f62ea84SAndrew Rist  * under the License.
19*9f62ea84SAndrew Rist  *
20*9f62ea84SAndrew Rist  *************************************************************/
21*9f62ea84SAndrew Rist 
22*9f62ea84SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_vcl.hxx"
26cdf0e10cSrcweir #include <tools/debug.hxx>
27cdf0e10cSrcweir #ifndef _OSL_MUTEX_HXX
28cdf0e10cSrcweir #include <osl/mutex.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _RTL_USTRBUF_HXX
31cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #include <uno/dispatcher.h> // declaration of generic uno interface
34cdf0e10cSrcweir #include <uno/mapping.hxx> // mapping stuff
35cdf0e10cSrcweir #include <cppuhelper/factory.hxx>
36cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
37cdf0e10cSrcweir #include <vcl/dllapi.h>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir using ::rtl::OUString;
40cdf0e10cSrcweir using ::rtl::OUStringBuffer;
41cdf0e10cSrcweir using namespace com::sun::star::uno;
42cdf0e10cSrcweir using namespace com::sun::star::lang;
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // service implementation
45cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL vcl_session_getSupportedServiceNames();
46cdf0e10cSrcweir extern OUString SAL_CALL vcl_session_getImplementationName();
47cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL vcl_session_createInstance( const Reference< XMultiServiceFactory > & );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace vcl
50cdf0e10cSrcweir {
51cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL DisplayAccess_getSupportedServiceNames();
52cdf0e10cSrcweir extern OUString SAL_CALL DisplayAccess_getImplementationName();
53cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL DisplayAccess_createInstance( const Reference< XMultiServiceFactory > & );
54cdf0e10cSrcweir 
55cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL FontIdentificator_getSupportedServiceNames();
56cdf0e10cSrcweir extern OUString SAL_CALL FontIdentificator_getImplementationName();
57cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL FontIdentificator_createInstance( const Reference< XMultiServiceFactory > & );
58cdf0e10cSrcweir 
59cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL StringMirror_getSupportedServiceNames();
60cdf0e10cSrcweir extern OUString SAL_CALL StringMirror_getImplementationName();
61cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL StringMirror_createInstance( const Reference< XMultiServiceFactory > & );
62cdf0e10cSrcweir 
63cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL Clipboard_getSupportedServiceNames();
64cdf0e10cSrcweir extern OUString SAL_CALL Clipboard_getImplementationName();
65cdf0e10cSrcweir extern Reference< XSingleServiceFactory > SAL_CALL Clipboard_createFactory( const Reference< XMultiServiceFactory > & );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL DragSource_getSupportedServiceNames();
68cdf0e10cSrcweir extern OUString SAL_CALL DragSource_getImplementationName();
69cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL DragSource_createInstance( const Reference< XMultiServiceFactory > & );
70cdf0e10cSrcweir 
71cdf0e10cSrcweir extern Sequence< OUString > SAL_CALL DropTarget_getSupportedServiceNames();
72cdf0e10cSrcweir extern OUString SAL_CALL DropTarget_getImplementationName();
73cdf0e10cSrcweir extern Reference< XInterface > SAL_CALL DropTarget_createInstance( const Reference< XMultiServiceFactory > & );
74cdf0e10cSrcweir 
75cdf0e10cSrcweir namespace rsvg
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	extern Sequence< OUString > SAL_CALL Rasterizer_getSupportedServiceNames();
78cdf0e10cSrcweir 	extern OUString SAL_CALL Rasterizer_getImplementationName();
79cdf0e10cSrcweir 	extern Reference< XInterface > SAL_CALL Rasterizer_createInstance( const Reference< XMultiServiceFactory > & );
80cdf0e10cSrcweir }
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
83cdf0e10cSrcweir extern "C" {
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 	VCL_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment(
86cdf0e10cSrcweir 		const sal_Char** ppEnvTypeName,
87cdf0e10cSrcweir 		uno_Environment** /*ppEnv*/ )
88cdf0e10cSrcweir 	{
89cdf0e10cSrcweir 		*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
90cdf0e10cSrcweir 	}
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	VCL_DLLPUBLIC void* SAL_CALL component_getFactory(
93cdf0e10cSrcweir 		const sal_Char* pImplementationName,
94cdf0e10cSrcweir 		void* pXUnoSMgr,
95cdf0e10cSrcweir 		void* /*pXUnoKey*/
96cdf0e10cSrcweir 		)
97cdf0e10cSrcweir 	{
98cdf0e10cSrcweir 		void* pRet = 0;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 		if( pXUnoSMgr )
101cdf0e10cSrcweir 		{
102cdf0e10cSrcweir 			Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
103cdf0e10cSrcweir 				reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
104cdf0e10cSrcweir 				);
105cdf0e10cSrcweir 			Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
106cdf0e10cSrcweir 			if( vcl_session_getImplementationName().equalsAscii( pImplementationName ) )
107cdf0e10cSrcweir 			{
108cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
109cdf0e10cSrcweir 					xMgr, vcl_session_getImplementationName(), vcl_session_createInstance,
110cdf0e10cSrcweir 					vcl_session_getSupportedServiceNames() );
111cdf0e10cSrcweir 			}
112cdf0e10cSrcweir 			else if( vcl::DisplayAccess_getImplementationName().equalsAscii( pImplementationName ) )
113cdf0e10cSrcweir 			{
114cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
115cdf0e10cSrcweir 					xMgr, vcl::DisplayAccess_getImplementationName(), vcl::DisplayAccess_createInstance,
116cdf0e10cSrcweir 					vcl::DisplayAccess_getSupportedServiceNames() );
117cdf0e10cSrcweir 			}
118cdf0e10cSrcweir             else if( vcl::FontIdentificator_getImplementationName().equalsAscii( pImplementationName ) )
119cdf0e10cSrcweir             {
120cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
121cdf0e10cSrcweir 					xMgr, vcl::FontIdentificator_getImplementationName(), vcl::FontIdentificator_createInstance,
122cdf0e10cSrcweir 					vcl::FontIdentificator_getSupportedServiceNames() );
123cdf0e10cSrcweir             }
124cdf0e10cSrcweir             else if( vcl::StringMirror_getImplementationName().equalsAscii( pImplementationName ) )
125cdf0e10cSrcweir             {
126cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
127cdf0e10cSrcweir 					xMgr, vcl::StringMirror_getImplementationName(), vcl::StringMirror_createInstance,
128cdf0e10cSrcweir 					vcl::StringMirror_getSupportedServiceNames() );
129cdf0e10cSrcweir             }
130cdf0e10cSrcweir             else if( vcl::Clipboard_getImplementationName().equalsAscii( pImplementationName ) )
131cdf0e10cSrcweir             {
132cdf0e10cSrcweir 				xFactory = vcl::Clipboard_createFactory( xMgr );
133cdf0e10cSrcweir             }
134cdf0e10cSrcweir             else if( vcl::DragSource_getImplementationName().equalsAscii( pImplementationName ) )
135cdf0e10cSrcweir             {
136cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
137cdf0e10cSrcweir 					xMgr, vcl::DragSource_getImplementationName(), vcl::DragSource_createInstance,
138cdf0e10cSrcweir 					vcl::DragSource_getSupportedServiceNames() );
139cdf0e10cSrcweir             }
140cdf0e10cSrcweir             else if( vcl::DropTarget_getImplementationName().equalsAscii( pImplementationName ) )
141cdf0e10cSrcweir             {
142cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
143cdf0e10cSrcweir 					xMgr, vcl::DropTarget_getImplementationName(), vcl::DropTarget_createInstance,
144cdf0e10cSrcweir 					vcl::DropTarget_getSupportedServiceNames() );
145cdf0e10cSrcweir             }
146cdf0e10cSrcweir             else if( vcl::rsvg::Rasterizer_getImplementationName().equalsAscii( pImplementationName ) )
147cdf0e10cSrcweir             {
148cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
149cdf0e10cSrcweir 					xMgr, vcl::rsvg::Rasterizer_getImplementationName(), vcl::rsvg::Rasterizer_createInstance,
150cdf0e10cSrcweir 					vcl::rsvg::Rasterizer_getSupportedServiceNames() );
151cdf0e10cSrcweir             }
152cdf0e10cSrcweir 			if( xFactory.is() )
153cdf0e10cSrcweir 			{
154cdf0e10cSrcweir 				xFactory->acquire();
155cdf0e10cSrcweir 				pRet = xFactory.get();
156cdf0e10cSrcweir 			}
157cdf0e10cSrcweir 		}
158cdf0e10cSrcweir 		return pRet;
159cdf0e10cSrcweir 	}
160cdf0e10cSrcweir 
161cdf0e10cSrcweir } /* extern "C" */
162