update dev300-m58
[ooovba.git] / dtrans / source / generic / dtrans.cxx
blob2f1d1d6a99eaef8d4180f568f41ebb3e3f5d1835
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: dtrans.cxx,v $
10 * $Revision: 1.7 $
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"
35 #include <cppuhelper/factory.hxx>
36 #include <clipboardmanager.hxx>
37 #include <generic_clipboard.hxx>
39 using namespace com::sun::star::lang;
40 using namespace com::sun::star::registry;
41 using namespace com::sun::star::uno;
42 using namespace cppu;
43 using namespace rtl;
45 extern "C"
48 //==================================================================================================
50 void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,
51 uno_Environment ** /*ppEnv*/ )
53 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
56 //==================================================================================================
58 sal_Bool SAL_CALL component_writeInfo(void * /*pServiceManager*/, void * pRegistryKey )
60 if (pRegistryKey)
62 try
64 Reference< XRegistryKey > xNewKey(
65 reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
66 OUString::createFromAscii("/" CLIPBOARDMANAGER_IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
68 const Sequence< OUString > & rSNL = ClipboardManager_getSupportedServiceNames();
69 const OUString * pArray = rSNL.getConstArray();
70 sal_Int32 nPos;
71 for ( nPos = rSNL.getLength(); nPos--; )
72 xNewKey->createKey( pArray[nPos] );
74 xNewKey = reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
75 OUString::createFromAscii("/" GENERIC_CLIPBOARD_IMPLEMENTATION_NAME "/UNO/SERVICES" ) );
77 const Sequence< OUString > & rSNL2 = GenericClipboard_getSupportedServiceNames();
78 pArray = rSNL2.getConstArray();
79 for ( nPos = rSNL2.getLength(); nPos--; )
80 xNewKey->createKey( pArray[nPos] );
82 return sal_True;
84 catch (InvalidRegistryException &)
86 OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
90 return sal_False;
93 //==================================================================================================
95 void * SAL_CALL component_getFactory(
96 const sal_Char * pImplName,
97 void * pServiceManager,
98 void * /*pRegistryKey*/
101 void * pRet = 0;
103 if (pServiceManager)
105 Reference< XSingleServiceFactory > xFactory;
107 if (rtl_str_compare( pImplName, CLIPBOARDMANAGER_IMPLEMENTATION_NAME ) == 0)
109 xFactory = createOneInstanceFactory(
110 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
111 OUString::createFromAscii( pImplName ),
112 ClipboardManager_createInstance,
113 ClipboardManager_getSupportedServiceNames() );
115 else if (rtl_str_compare( pImplName, GENERIC_CLIPBOARD_IMPLEMENTATION_NAME ) == 0)
117 xFactory = createSingleFactory(
118 reinterpret_cast< XMultiServiceFactory * >( pServiceManager ),
119 OUString::createFromAscii( pImplName ),
120 GenericClipboard_createInstance,
121 GenericClipboard_getSupportedServiceNames() );
124 if (xFactory.is())
126 xFactory->acquire();
127 pRet = xFactory.get();
131 return pRet;