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_dtrans.hxx"
26 
27 //-----------------------------------------------------------------
28 //	includes of other projects
29 //-----------------------------------------------------------------
30 #include <cppuhelper/factory.hxx>
31 #include <com/sun/star/container/XSet.hpp>
32 #include <osl/diagnose.h>
33 
34 #ifndef _COM_SUN_STAR_DATATRANSFER_XDATAFLAVORCONTAINER_HPP_
35 #include <com/sun/star/datatransfer/XDataFormatTranslator.hpp>
36 #endif
37 #include "ftransl.hxx"
38 
39 //-----------------------------------------------------------------
40 // some defines
41 //-----------------------------------------------------------------
42 
43 // the service names
44 #define SERVICE_NAME  "com.sun.star.datatransfer.DataFormatTranslator"
45 
46 // the implementation names
47 #define IMPL_NAME  "com.sun.star.datatransfer.DataFormatTranslator"
48 
49 // the registry key names
50 // a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName"
51 //                        <     Implementation-Name    ></UNO/SERVICES/><    Service-Name           >
52 #define REGKEY_NAME  "/com.sun.star.datatransfer.DataFormatTranslator/UNO/SERVICES/com.sun.star.datatransfer.DataFormatTranslator"
53 
54 //-----------------------------------------------------------------------------------------------------------
55 // namespace directives
56 //-----------------------------------------------------------------------------------------------------------
57 
58 using namespace ::rtl						;
59 using namespace ::cppu					    ;
60 using namespace ::com::sun::star::uno		;
61 using namespace ::com::sun::star::registry	;
62 using namespace ::com::sun::star::lang;
63 using namespace ::com::sun::star::datatransfer;
64 
65 //-----------------------------------------------------------------
66 // create a static object to initialize the shell9x library
67 //-----------------------------------------------------------------
68 
69 namespace
70 {
71 
72 	//-----------------------------------------------------------------------------------------------------------
73     // functions to create a new Clipboad instance; is needed by factory helper implementation
74     // @param rServiceManager - service manager, useful if the component needs other uno services
75     // so we should give it to every UNO-Implementation component
76     //-----------------------------------------------------------------------------------------------------------
77 
createInstance(const Reference<XMultiServiceFactory> & rServiceManager)78 	Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
79 	{
80 		return Reference< XInterface >( static_cast< XDataFormatTranslator* >( new CDataFormatTranslator( rServiceManager ) ) );
81 	}
82 }
83 
84 //-----------------------------------------------------------------------------------------------------------
85 // the 3 important functions which will be exported
86 //-----------------------------------------------------------------------------------------------------------
87 
88 extern "C"
89 {
90 
91 //----------------------------------------------------------------------
92 // component_getImplementationEnvironment
93 //----------------------------------------------------------------------
94 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)95 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
96 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
97 {
98 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
99 }
100 
101 //----------------------------------------------------------------------
102 // component_getFactory
103 // returns a factory to create XFilePicker-Services
104 //----------------------------------------------------------------------
105 
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)106 SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
107 {
108 	void* pRet = 0;
109 
110 	if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, IMPL_NAME ) ) )
111 	{
112 		Sequence< OUString > aSNS( 1 );
113 		aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME ) );
114 
115 		Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
116 			reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
117 			OUString::createFromAscii( pImplName ),
118 			createInstance,
119 			aSNS ) );
120 		if ( xFactory.is() )
121 		{
122 			xFactory->acquire();
123 			pRet = xFactory.get();
124 		}
125 	}
126 
127 	return pRet;
128 }
129 
130 } // extern "C"
131