merge the formfield patch from ooo-build
[ooovba.git] / dtrans / source / win32 / dnd / dndentry.cxx
blob8b87c673e6ce5d368b2cb79d132225f52cb708f9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dndentry.cxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_dtrans.hxx"
33 #include <cppuhelper/factory.hxx>
34 #include <com/sun/star/container/XSet.hpp>
35 #include <osl/diagnose.h>
37 #include "source.hxx"
38 #include "target.hxx"
40 using namespace ::rtl ;
41 using namespace ::com::sun::star::uno ;
42 using namespace ::com::sun::star::registry ;
43 using namespace ::cppu ;
44 using namespace ::com::sun::star::lang;
46 rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
48 Reference< XInterface > SAL_CALL createDragSource( const Reference< XMultiServiceFactory >& rServiceManager )
50 DragSource* pSource= new DragSource( rServiceManager );
51 return Reference<XInterface>( static_cast<XInitialization*>(pSource), UNO_QUERY);
54 Reference< XInterface > SAL_CALL createDropTarget( const Reference< XMultiServiceFactory >& rServiceManager )
56 DropTarget* pTarget= new DropTarget( rServiceManager );
57 return Reference<XInterface>( static_cast<XInitialization*>(pTarget), UNO_QUERY);
61 extern "C"
63 sal_Bool SAL_CALL component_canUnload( TimeValue *pTime )
65 return g_moduleCount.canUnload( &g_moduleCount , pTime );
68 //----------------------------------------------------------------------
69 // component_getImplementationEnvironment
70 //----------------------------------------------------------------------
72 void SAL_CALL component_getImplementationEnvironment(
73 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
75 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
78 //-------------------------------------------------------------------------
79 // component_writeInfo - to register a UNO-Service
80 // to register a UNO-Service use: regcomp -register -r *.rdb -c *.dll
81 // to view the registry use: regview *.rdb /SERVICES/ServiceName
82 // (you must use the full services name e.g. com.sun.star.frame.FilePicker
83 //-------------------------------------------------------------------------
85 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
87 sal_Bool bRetVal = sal_False;
89 if ( pRegistryKey )
91 try
93 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
94 pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( DNDSOURCE_REGKEY_NAME ) ) );
95 bRetVal = sal_True;
97 pXNewKey= static_cast< XRegistryKey* >( pRegistryKey );
98 pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_REGKEY_NAME ) ) );
99 bRetVal = sal_True;
101 catch( InvalidRegistryException& )
103 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
104 bRetVal = sal_False;
108 return bRetVal;
111 //----------------------------------------------------------------------
112 // component_getFactory
113 // returns a factory to create XFilePicker-Services
114 //----------------------------------------------------------------------
116 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
118 void* pRet = 0;
119 Reference< XSingleServiceFactory > xFactory;
121 if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDSOURCE_IMPL_NAME ) ) )
123 Sequence< OUString > aSNS( 1 );
124 aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( DNDSOURCE_SERVICE_NAME ) );
126 xFactory= createSingleFactory(
127 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
128 OUString::createFromAscii( pImplName ),
129 createDragSource,
130 aSNS,
131 &g_moduleCount.modCnt);
134 else if( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDTARGET_IMPL_NAME ) ) )
136 Sequence< OUString > aSNS( 1 );
137 aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_SERVICE_NAME ) );
139 xFactory= createSingleFactory(
140 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
141 OUString::createFromAscii( pImplName ),
142 createDropTarget,
143 aSNS);
147 if ( xFactory.is() )
149 xFactory->acquire();
150 pRet = xFactory.get();
153 return pRet;
156 } // extern "C"