update dev300-m58
[ooovba.git] / dtrans / source / aqua / service_entry.cxx
blob9552d9c39f1020fa9e6ac891e150dffecb6deeb1
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: service_entry.cxx,v $
10 * $Revision: 1.3 $
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"
34 #include "DragSource.hxx"
35 #include "DropTarget.hxx"
36 #include "aqua_clipboard.hxx"
37 #include <com/sun/star/lang/XSingleComponentFactory.hpp>
38 #include <cppuhelper/factory.hxx>
39 #include <cppuhelper/compbase1.hxx>
40 #include <osl/diagnose.h>
42 #include "cppuhelper/implementationentry.hxx"
44 using namespace ::osl;
45 using namespace ::rtl;
46 using namespace ::com::sun::star::uno;
47 using namespace ::com::sun::star::registry;
48 using namespace ::cppu;
49 using namespace ::com::sun::star::lang;
50 using namespace ::com::sun::star::datatransfer::clipboard;
53 rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT;
56 extern rtl::OUString dragSource_getImplementationName();
57 extern com::sun::star::uno::Sequence<rtl::OUString> dragSource_getSupportedServiceNames();
58 extern rtl::OUString dropTarget_getImplementationName();
59 extern com::sun::star::uno::Sequence<rtl::OUString> dropTarget_getSupportedServiceNames();
60 extern rtl::OUString clipboard_getImplementationName();
61 extern com::sun::star::uno::Sequence<rtl::OUString> clipboard_getSupportedServiceNames();
64 Reference<XInterface> SAL_CALL createDragSource(const Reference<XComponentContext>& rComponentContext);
65 Reference<XInterface> SAL_CALL createDropTarget(const Reference<XComponentContext>& rComponentContext);
66 Reference<XInterface> SAL_CALL createClipboard(const Reference<XComponentContext>& rComponentContext);
69 cppu::ImplementationEntry entries[] = {
70 { createDragSource,
71 dragSource_getImplementationName,
72 dragSource_getSupportedServiceNames,
73 cppu::createSingleComponentFactory, 0, 0 },
74 { createDropTarget,
75 dropTarget_getImplementationName,
76 dropTarget_getSupportedServiceNames,
77 cppu::createSingleComponentFactory, 0, 0 },
78 { createClipboard,
79 clipboard_getImplementationName,
80 clipboard_getSupportedServiceNames,
81 cppu::createSingleComponentFactory, 0, 0 },
82 { 0, 0, 0, 0, 0, 0 }
86 class AquaClipboardFactory : public WeakComponentImplHelper1<XSingleComponentFactory>
88 public:
89 AquaClipboardFactory();
90 virtual ~AquaClipboardFactory();
93 * XSingleComponentFactory
95 virtual Reference<XInterface> createInstanceWithContext(const Reference<XComponentContext>& Context)
96 throw (Exception);
98 virtual Reference<XInterface> createInstanceWithArgumentsAndContext(const Sequence<Any>& rArgs,
99 const Reference<XComponentContext>& Context)
100 throw(Exception);
102 private:
103 static Mutex m_aMutex;
104 static Reference<XInterface> mSingleInstance;
107 Reference<XInterface> AquaClipboardFactory::mSingleInstance;
108 Mutex AquaClipboardFactory::m_aMutex;
110 // ------------------------------------------------------------------------
112 AquaClipboardFactory::AquaClipboardFactory() :
113 WeakComponentImplHelper1<XSingleComponentFactory>(m_aMutex)
117 // ------------------------------------------------------------------------
119 AquaClipboardFactory::~AquaClipboardFactory()
123 // ------------------------------------------------------------------------
125 Reference<XInterface> AquaClipboardFactory::createInstanceWithContext(const Reference<XComponentContext>& Context) throw(Exception)
127 return createInstanceWithArgumentsAndContext(Sequence<Any>(), Context);
130 // ------------------------------------------------------------------------
132 Reference< XInterface > AquaClipboardFactory::createInstanceWithArgumentsAndContext(const Sequence<Any>& arguments,
133 const Reference<XComponentContext>& Context) throw(Exception)
135 MutexGuard aGuard(m_aMutex);
137 if (!mSingleInstance.is())
139 AquaClipboardFactory::mSingleInstance = createClipboard(Context);
142 return AquaClipboardFactory::mSingleInstance;
146 Reference<XInterface> SAL_CALL createDragSource( const Reference< XComponentContext >& rComponentContext)
148 return Reference<XInterface>(static_cast< XInitialization* >(new DragSource(rComponentContext)), UNO_QUERY);
151 Reference<XInterface> SAL_CALL createDropTarget( const Reference< XComponentContext >& rComponentContext)
153 return Reference<XInterface>(static_cast< XInitialization* >(new DropTarget(rComponentContext)), UNO_QUERY);
156 Reference< XInterface > SAL_CALL createClipboard( const Reference< XComponentContext >& rComponentContext)
158 return Reference<XInterface>(static_cast< XClipboard* >(new AquaClipboard(rComponentContext)), UNO_QUERY);
162 extern "C" sal_Bool SAL_CALL component_writeInfo(
163 void * serviceManager, void * registryKey)
165 return cppu::component_writeInfoHelper(
166 serviceManager, registryKey, entries);
170 extern "C" void * SAL_CALL component_getFactory(
171 char const * implName, void * serviceManager, void * registryKey)
173 void* pRet = NULL;
174 OUString iName = OUString::createFromAscii(implName);
175 Reference<XSingleComponentFactory> xFac;
177 if (iName.equalsIgnoreAsciiCase(clipboard_getImplementationName()))
179 xFac = new AquaClipboardFactory();
181 else
183 return component_getFactoryHelper(implName,
184 serviceManager,
185 registryKey,
186 entries);
189 if (xFac.is())
191 xFac->acquire();
192 pRet = xFac.get();
195 return pRet;
199 extern "C" void SAL_CALL component_getImplementationEnvironment(
200 char const ** envTypeName, uno_Environment **)
202 *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
206 extern "C" sal_Bool SAL_CALL component_canUnload( TimeValue *pTime )
208 return g_moduleCount.canUnload( &g_moduleCount , pTime );