xref: /aoo41x/main/dtrans/source/win32/dnd/dndentry.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_dtrans.hxx"
30 #include <cppuhelper/factory.hxx>
31 #include <com/sun/star/container/XSet.hpp>
32 #include <osl/diagnose.h>
33 
34 #include "source.hxx"
35 #include "target.hxx"
36 
37 using namespace ::rtl						;
38 using namespace ::com::sun::star::uno		;
39 using namespace ::com::sun::star::registry	;
40 using namespace ::cppu					    ;
41 using namespace ::com::sun::star::lang;
42 
43 rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
44 
45 Reference< XInterface > SAL_CALL createDragSource( const Reference< XMultiServiceFactory >& rServiceManager )
46 {
47 	DragSource* pSource= new DragSource( rServiceManager );
48 	return Reference<XInterface>( static_cast<XInitialization*>(pSource), UNO_QUERY);
49 }
50 
51 Reference< XInterface > SAL_CALL createDropTarget( const Reference< XMultiServiceFactory >& rServiceManager )
52 {
53 	DropTarget* pTarget= new DropTarget( rServiceManager );
54 	return Reference<XInterface>( static_cast<XInitialization*>(pTarget), UNO_QUERY);
55 }
56 
57 
58 extern "C"
59 {
60 sal_Bool SAL_CALL component_canUnload( TimeValue *pTime )
61 {
62 	return g_moduleCount.canUnload( &g_moduleCount , pTime );
63 }
64 
65 //----------------------------------------------------------------------
66 // component_getImplementationEnvironment
67 //----------------------------------------------------------------------
68 
69 void SAL_CALL component_getImplementationEnvironment(
70 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
71 {
72 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
73 }
74 
75 //----------------------------------------------------------------------
76 // component_getFactory
77 // returns a factory to create XFilePicker-Services
78 //----------------------------------------------------------------------
79 
80 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
81 {
82 	void* pRet = 0;
83 	Reference< XSingleServiceFactory > xFactory;
84 
85 	if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDSOURCE_IMPL_NAME ) ) )
86 	{
87 		Sequence< OUString > aSNS( 1 );
88 		aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( DNDSOURCE_SERVICE_NAME ) );
89 
90 		xFactory= createSingleFactory(
91 			reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
92 			OUString::createFromAscii( pImplName ),
93 			createDragSource,
94 			aSNS,
95 			&g_moduleCount.modCnt);
96 
97 	}
98 	else if( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDTARGET_IMPL_NAME ) ) )
99 	{
100 		Sequence< OUString > aSNS( 1 );
101 		aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_SERVICE_NAME ) );
102 
103 		xFactory= createSingleFactory(
104 			reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
105 			OUString::createFromAscii( pImplName ),
106 			createDropTarget,
107 			aSNS);
108 
109 	}
110 
111 	if ( xFactory.is() )
112 	{
113 		xFactory->acquire();
114 		pRet = xFactory.get();
115 	}
116 
117 	return pRet;
118 }
119 
120 } // extern "C"
121