xref: /aoo42x/main/dtrans/source/os2/dnd/dndentry.cxx (revision cc13e73e)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
24 #include "precompiled_dtrans.hxx"
25 
26 #include <cppuhelper/factory.hxx>
27 #include <com/sun/star/container/XSet.hpp>
28 #include <osl/diagnose.h>
29 
30 #include "DragSource.hxx"
31 #include "DropTarget.hxx"
32 
33 using namespace rtl;
34 using namespace cppu;
35 using namespace com::sun::star::lang;
36 using namespace com::sun::star::registry;
37 using namespace com::sun::star::uno;
38 
39 rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
40 
41 // -----------------------------------------------------------------------
42 
createDragSource(const Reference<XMultiServiceFactory> & rServiceManager)43 Reference< XInterface > SAL_CALL createDragSource( const Reference< XMultiServiceFactory >& rServiceManager )
44 {
45     DragSource* pSource = new DragSource( rServiceManager);
46     return Reference<XInterface>( static_cast<XInitialization*>(pSource), UNO_QUERY);
47 }
48 
createDropTarget(const Reference<XMultiServiceFactory> & rServiceManager)49 Reference< XInterface > SAL_CALL createDropTarget( const Reference< XMultiServiceFactory >& rServiceManager )
50 {
51     DropTarget* pTarget = new DropTarget( rServiceManager);
52     return Reference<XInterface>( static_cast<XInitialization*>(pTarget), UNO_QUERY);
53 }
54 
55 extern "C" {
56 
component_canUnload(TimeValue * pTime)57 SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_canUnload( TimeValue *pTime)
58 {
59     return g_moduleCount.canUnload( &g_moduleCount, pTime);
60 }
61 
62 //----------------------------------------------------------------------
63 // component_getImplementationEnvironment
64 //----------------------------------------------------------------------
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)65 SAL_DLLPUBLIC_EXPORT 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 //----------------------------------------------------------------------
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)75 SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
76 {
77     void* pRet = 0;
78     Reference< XSingleServiceFactory > xFactory;
79 
80     debug_printf("dnd component_getFactory %s", pImplName);
81 
82     if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, OS2_DNDSOURCE_IMPL_NAME ) ) )
83     {
84         Sequence< OUString > aSNS( 1 );
85         aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( OS2_DNDSOURCE_SERVICE_NAME ) );
86 
87         xFactory = createSingleFactory(
88                     reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
89                     OUString::createFromAscii( pImplName ),
90                     createDragSource,
91                     aSNS,
92                     &g_moduleCount.modCnt);
93 
94     }
95     else if( pSrvManager && ( 0 == rtl_str_compare( pImplName, OS2_DNDTARGET_IMPL_NAME ) ) )
96     {
97         Sequence< OUString > aSNS( 1 );
98         aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( OS2_DNDTARGET_SERVICE_NAME ) );
99 
100         xFactory = createSingleFactory(
101                     reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
102                     OUString::createFromAscii( pImplName ),
103                     createDropTarget,
104                     aSNS);
105 
106     }
107 
108     if ( xFactory.is() )
109     {
110         xFactory->acquire();
111         pRet = xFactory.get();
112     }
113 
114     return pRet;
115 }
116 
117 } // extern "C"
118