xref: /aoo41x/main/vcl/source/components/factory.cxx (revision 498ce991)
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 
76cdf0e10cSrcweir extern "C" {
77cdf0e10cSrcweir 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)78cdf0e10cSrcweir 	VCL_DLLPUBLIC void SAL_CALL component_getImplementationEnvironment(
79cdf0e10cSrcweir 		const sal_Char** ppEnvTypeName,
80cdf0e10cSrcweir 		uno_Environment** /*ppEnv*/ )
81cdf0e10cSrcweir 	{
82cdf0e10cSrcweir 		*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
83cdf0e10cSrcweir 	}
84cdf0e10cSrcweir 
component_getFactory(const sal_Char * pImplementationName,void * pXUnoSMgr,void *)85cdf0e10cSrcweir 	VCL_DLLPUBLIC void* SAL_CALL component_getFactory(
86cdf0e10cSrcweir 		const sal_Char* pImplementationName,
87cdf0e10cSrcweir 		void* pXUnoSMgr,
88cdf0e10cSrcweir 		void* /*pXUnoKey*/
89cdf0e10cSrcweir 		)
90cdf0e10cSrcweir 	{
91cdf0e10cSrcweir 		void* pRet = 0;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir 		if( pXUnoSMgr )
94cdf0e10cSrcweir 		{
95cdf0e10cSrcweir 			Reference< ::com::sun::star::lang::XMultiServiceFactory > xMgr(
96cdf0e10cSrcweir 				reinterpret_cast< ::com::sun::star::lang::XMultiServiceFactory* >( pXUnoSMgr )
97cdf0e10cSrcweir 				);
98cdf0e10cSrcweir 			Reference< ::com::sun::star::lang::XSingleServiceFactory > xFactory;
99cdf0e10cSrcweir 			if( vcl_session_getImplementationName().equalsAscii( pImplementationName ) )
100cdf0e10cSrcweir 			{
101cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
102cdf0e10cSrcweir 					xMgr, vcl_session_getImplementationName(), vcl_session_createInstance,
103cdf0e10cSrcweir 					vcl_session_getSupportedServiceNames() );
104cdf0e10cSrcweir 			}
105cdf0e10cSrcweir 			else if( vcl::DisplayAccess_getImplementationName().equalsAscii( pImplementationName ) )
106cdf0e10cSrcweir 			{
107cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
108cdf0e10cSrcweir 					xMgr, vcl::DisplayAccess_getImplementationName(), vcl::DisplayAccess_createInstance,
109cdf0e10cSrcweir 					vcl::DisplayAccess_getSupportedServiceNames() );
110cdf0e10cSrcweir 			}
111cdf0e10cSrcweir             else if( vcl::FontIdentificator_getImplementationName().equalsAscii( pImplementationName ) )
112cdf0e10cSrcweir             {
113cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
114cdf0e10cSrcweir 					xMgr, vcl::FontIdentificator_getImplementationName(), vcl::FontIdentificator_createInstance,
115cdf0e10cSrcweir 					vcl::FontIdentificator_getSupportedServiceNames() );
116cdf0e10cSrcweir             }
117cdf0e10cSrcweir             else if( vcl::StringMirror_getImplementationName().equalsAscii( pImplementationName ) )
118cdf0e10cSrcweir             {
119cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
120cdf0e10cSrcweir 					xMgr, vcl::StringMirror_getImplementationName(), vcl::StringMirror_createInstance,
121cdf0e10cSrcweir 					vcl::StringMirror_getSupportedServiceNames() );
122cdf0e10cSrcweir             }
123cdf0e10cSrcweir             else if( vcl::Clipboard_getImplementationName().equalsAscii( pImplementationName ) )
124cdf0e10cSrcweir             {
125cdf0e10cSrcweir 				xFactory = vcl::Clipboard_createFactory( xMgr );
126cdf0e10cSrcweir             }
127cdf0e10cSrcweir             else if( vcl::DragSource_getImplementationName().equalsAscii( pImplementationName ) )
128cdf0e10cSrcweir             {
129cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
130cdf0e10cSrcweir 					xMgr, vcl::DragSource_getImplementationName(), vcl::DragSource_createInstance,
131cdf0e10cSrcweir 					vcl::DragSource_getSupportedServiceNames() );
132cdf0e10cSrcweir             }
133cdf0e10cSrcweir             else if( vcl::DropTarget_getImplementationName().equalsAscii( pImplementationName ) )
134cdf0e10cSrcweir             {
135cdf0e10cSrcweir 				xFactory = ::cppu::createSingleFactory(
136cdf0e10cSrcweir 					xMgr, vcl::DropTarget_getImplementationName(), vcl::DropTarget_createInstance,
137cdf0e10cSrcweir 					vcl::DropTarget_getSupportedServiceNames() );
138cdf0e10cSrcweir             }
139cdf0e10cSrcweir 			if( xFactory.is() )
140cdf0e10cSrcweir 			{
141cdf0e10cSrcweir 				xFactory->acquire();
142cdf0e10cSrcweir 				pRet = xFactory.get();
143cdf0e10cSrcweir 			}
144cdf0e10cSrcweir 		}
145cdf0e10cSrcweir 		return pRet;
146cdf0e10cSrcweir 	}
147cdf0e10cSrcweir 
148cdf0e10cSrcweir } /* extern "C" */
149