LibreOffice Module dtrans (master)  1
dndentry.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <cppuhelper/factory.hxx>
22 #include <com/sun/star/container/XSet.hpp>
23 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
24 
25 #include "source.hxx"
26 #include "target.hxx"
27 
28 using namespace ::com::sun::star::uno ;
29 using namespace ::com::sun::star::registry ;
30 using namespace ::cppu ;
31 using namespace ::com::sun::star::lang;
32 
34 {
35  DragSource* pSource= new DragSource( comphelper::getComponentContext(rServiceManager) );
36  return Reference<XInterface>( static_cast<XInitialization*>(pSource), UNO_QUERY);
37 }
38 
40 {
41  DropTarget* pTarget= new DropTarget( comphelper::getComponentContext(rServiceManager) );
42  return Reference<XInterface>( static_cast<XInitialization*>(pTarget), UNO_QUERY);
43 }
44 
45 extern "C"
46 {
47 
48 SAL_DLLPUBLIC_EXPORT void*
49 dnd_component_getFactory( const sal_Char* pImplName, void* pSrvManager, void* /*pRegistryKey*/ )
50 {
51  void* pRet = nullptr;
52  Reference< XSingleServiceFactory > xFactory;
53 
54  if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDSOURCE_IMPL_NAME ) ) )
55  {
57 
58  xFactory= createSingleFactory(
59  static_cast< XMultiServiceFactory* > ( pSrvManager ),
60  OUString::createFromAscii( pImplName ),
62  aSNS);
63 
64  }
65  else if( pSrvManager && ( 0 == rtl_str_compare( pImplName, DNDTARGET_IMPL_NAME ) ) )
66  {
68 
69  xFactory= createSingleFactory(
70  static_cast< XMultiServiceFactory* > ( pSrvManager ),
71  OUString::createFromAscii( pImplName ),
73  aSNS);
74 
75  }
76 
77  if ( xFactory.is() )
78  {
79  xFactory->acquire();
80  pRet = xFactory.get();
81  }
82 
83  return pRet;
84 }
85 
86 } // extern "C"
87 
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static Reference< XInterface > createDragSource(const Reference< XMultiServiceFactory > &rServiceManager)
Definition: dndentry.cxx:33
#define DNDTARGET_IMPL_NAME
Definition: globals.hxx:38
#define DNDTARGET_SERVICE_NAME
Definition: globals.hxx:37
char sal_Char
static Reference< XInterface > createDropTarget(const Reference< XMultiServiceFactory > &rServiceManager)
Definition: dndentry.cxx:39
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
css::uno::Reference< css::uno::XInterface >(SAL_CALL *ComponentInstantiation)(const css CPPUHELPER_DLLPUBLIC css::uno::Reference< css::lang::XSingleServiceFactory > SAL_CALL createSingleFactory(const css::uno::Reference< css::lang::XMultiServiceFactory > &rServiceManager, const ::rtl::OUString &rImplementationName, ComponentInstantiation pCreateFunction, const css::uno::Sequence< ::rtl::OUString > &rServiceNames, rtl_ModuleCount *pModCount=NULL)
#define DNDSOURCE_IMPL_NAME
Definition: globals.hxx:35
SAL_DLLPUBLIC_EXPORT void * dnd_component_getFactory(const sal_Char *pImplName, void *pSrvManager, void *)
Definition: dndentry.cxx:49
#define DNDSOURCE_SERVICE_NAME
Definition: globals.hxx:34