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