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 #include <cppuhelper/factory.hxx>
27 #include <com/sun/star/container/XSet.hpp>
28 #include <osl/diagnose.h>
29 
30 #include "source.hxx"
31 #include "target.hxx"
32 
33 using namespace ::rtl						;
34 using namespace ::com::sun::star::uno		;
35 using namespace ::com::sun::star::registry	;
36 using namespace ::cppu					    ;
37 using namespace ::com::sun::star::lang;
38 
39 rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
40 
createDragSource(const Reference<XMultiServiceFactory> & rServiceManager)41 Reference< XInterface > SAL_CALL createDragSource( const Reference< XMultiServiceFactory >& rServiceManager )
42 {
43 	DragSource* pSource= new DragSource( rServiceManager );
44 	return Reference<XInterface>( static_cast<XInitialization*>(pSource), UNO_QUERY);
45 }
46 
createDropTarget(const Reference<XMultiServiceFactory> & rServiceManager)47 Reference< XInterface > SAL_CALL createDropTarget( const Reference< XMultiServiceFactory >& rServiceManager )
48 {
49 	DropTarget* pTarget= new DropTarget( rServiceManager );
50 	return Reference<XInterface>( static_cast<XInitialization*>(pTarget), UNO_QUERY);
51 }
52 
53 
54 extern "C"
55 {
component_canUnload(TimeValue * pTime)56 sal_Bool SAL_CALL component_canUnload( TimeValue *pTime )
57 {
58 	return g_moduleCount.canUnload( &g_moduleCount , pTime );
59 }
60 
61 //----------------------------------------------------------------------
62 // component_getImplementationEnvironment
63 //----------------------------------------------------------------------
64 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)65 void SAL_CALL component_getImplementationEnvironment(
66 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
67 {
68 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
69 }
70 
71 //----------------------------------------------------------------------
72 // component_getFactory
73 // returns a factory to create XFilePicker-Services
74 //----------------------------------------------------------------------
75 
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)76 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
77 {
78 	void* pRet = 0;
79 	Reference< XSingleServiceFactory > xFactory;
80 
81 	if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDSOURCE_IMPL_NAME ) ) )
82 	{
83 		Sequence< OUString > aSNS( 1 );
84 		aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( DNDSOURCE_SERVICE_NAME ) );
85 
86 		xFactory= createSingleFactory(
87 			reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
88 			OUString::createFromAscii( pImplName ),
89 			createDragSource,
90 			aSNS,
91 			&g_moduleCount.modCnt);
92 
93 	}
94 	else if( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDTARGET_IMPL_NAME ) ) )
95 	{
96 		Sequence< OUString > aSNS( 1 );
97 		aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_SERVICE_NAME ) );
98 
99 		xFactory= createSingleFactory(
100 			reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
101 			OUString::createFromAscii( pImplName ),
102 			createDropTarget,
103 			aSNS);
104 
105 	}
106 
107 	if ( xFactory.is() )
108 	{
109 		xFactory->acquire();
110 		pRet = xFactory.get();
111 	}
112 
113 	return pRet;
114 }
115 
116 } // extern "C"
117