1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: dndentry.cxx,v $
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>
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
);
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
;
93 Reference
< XRegistryKey
> pXNewKey( static_cast< XRegistryKey
* >( pRegistryKey
) );
94 pXNewKey
->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( DNDSOURCE_REGKEY_NAME
) ) );
97 pXNewKey
= static_cast< XRegistryKey
* >( pRegistryKey
);
98 pXNewKey
->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( DNDTARGET_REGKEY_NAME
) ) );
101 catch( InvalidRegistryException
& )
103 OSL_ENSURE(sal_False
, "InvalidRegistryException caught");
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*/ )
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
),
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
),
150 pRet
= xFactory
.get();