Update ooo320-m1
[ooovba.git] / dtrans / source / os2 / clipb / Os2Service.cxx
blob5775170a48bd2b2ddc3b7a8a09076933c81b3b03
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: Os2Service.cxx,v $
10 * $Revision: 1.4 $
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 #include "Os2Clipboard.hxx"
32 #include <cppuhelper/factory.hxx>
33 #include <com/sun/star/container/XSet.hpp>
34 #include <osl/diagnose.h>
36 using namespace rtl;
37 using namespace com::sun::star::uno;
38 using namespace com::sun::star::registry;
39 using namespace cppu;
40 using namespace com::sun::star::lang;
41 using namespace com::sun::star::datatransfer::clipboard;
42 using namespace os2;
44 namespace os2 {
46 Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
48 return Reference< XInterface >( static_cast< XClipboard* >( new Os2Clipboard() ) );
51 } // namespace os2
53 extern "C"
56 void SAL_CALL component_getImplementationEnvironment(
57 const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
59 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
62 sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey )
64 sal_Bool bRetVal = sal_False;
66 if ( pRegistryKey )
68 try
70 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
71 pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( OS2_CLIPBOARD_REGKEY_NAME ) ) );
72 bRetVal = sal_True;
74 catch( InvalidRegistryException& )
76 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
77 bRetVal = sal_False;
81 return bRetVal;
84 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* pRegistryKey )
86 void* pRet = 0;
88 if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, OS2_CLIPBOARD_IMPL_NAME ) ) )
90 Sequence< OUString > aSNS( 1 );
91 aSNS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( OS2_CLIPBOARD_SERVICE_NAME ) );
93 //OUString( RTL_CONSTASCII_USTRINGPARAM( FPS_IMPL_NAME ) )
94 Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory(
95 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
96 OUString::createFromAscii( pImplName ),
97 createInstance,
98 aSNS ) );
99 if ( xFactory.is() )
101 xFactory->acquire();
102 pRet = xFactory.get();
106 return pRet;
109 } // extern "C"