1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wcbentry.cxx,v $
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"
33 //______________________________________________________________________________________________________________
34 // includes of other projects
35 //______________________________________________________________________________________________________________
36 #include <cppuhelper/factory.hxx>
37 #include <com/sun/star/container/XSet.hpp>
38 #include <osl/diagnose.h>
39 #include "WinClipboard.hxx"
41 //-----------------------------------------------------------------
43 //-----------------------------------------------------------------
46 #define WINCLIPBOARD_SERVICE_NAME "com.sun.star.datatransfer.clipboard.SystemClipboard"
48 // the implementation names
49 #define WINCLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.ClipboardW32"
51 // the registry key names
52 // a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName"
53 // < Implementation-Name ></UNO/SERVICES/>< Service-Name >
54 #define WINCLIPBOARD_REGKEY_NAME "/com.sun.star.datatransfer.clipboard.ClipboardW32/UNO/SERVICES/com.sun.star.datatransfer.clipboard.SystemClipboard"
56 //-----------------------------------------------------------------------------------------------------------
57 // namespace directives
58 //-----------------------------------------------------------------------------------------------------------
60 using namespace ::rtl
;
61 using namespace ::com::sun::star::uno
;
62 using namespace ::com::sun::star::registry
;
63 using namespace ::cppu
;
64 using namespace ::com::sun::star::lang
;
65 using namespace ::com::sun::star::datatransfer::clipboard
;
67 //-----------------------------------------------------------------
68 // create a static object to initialize the shell9x library
69 //-----------------------------------------------------------------
74 //-----------------------------------------------------------------------------------------------------------
75 // functions to create a new Clipboad instance; is needed by factory helper implementation
76 // @param rServiceManager - service manager, useful if the component needs other uno services
77 // so we should give it to every UNO-Implementation component
78 //-----------------------------------------------------------------------------------------------------------
80 Reference
< XInterface
> SAL_CALL
createInstance( const Reference
< XMultiServiceFactory
>& rServiceManager
)
82 return Reference
< XInterface
>( static_cast< XClipboard
* >( new CWinClipboard( rServiceManager
, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) ) ) ) );
86 //-----------------------------------------------------------------------------------------------------------
87 // the 3 important functions which will be exported
88 //-----------------------------------------------------------------------------------------------------------
93 //----------------------------------------------------------------------
94 // component_getImplementationEnvironment
95 //----------------------------------------------------------------------
97 void SAL_CALL
component_getImplementationEnvironment(
98 const sal_Char
** ppEnvTypeName
, uno_Environment
** /*ppEnv*/ )
100 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
103 //-------------------------------------------------------------------------
104 // component_writeInfo - to register a UNO-Service
105 // to register a UNO-Service use: regcomp -register -r *.rdb -c *.dll
106 // to view the registry use: regview *.rdb /SERVICES/ServiceName
107 // (you must use the full services name e.g. com.sun.star.frame.FilePicker
108 //-------------------------------------------------------------------------
110 sal_Bool SAL_CALL
component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey
)
112 sal_Bool bRetVal
= sal_False
;
118 Reference
< XRegistryKey
> pXNewKey( static_cast< XRegistryKey
* >( pRegistryKey
) );
119 pXNewKey
->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( WINCLIPBOARD_REGKEY_NAME
) ) );
122 catch( InvalidRegistryException
& )
124 OSL_ENSURE(sal_False
, "InvalidRegistryException caught");
132 //----------------------------------------------------------------------
133 // component_getFactory
134 // returns a factory to create XFilePicker-Services
135 //----------------------------------------------------------------------
137 void* SAL_CALL
component_getFactory( const sal_Char
* pImplName
, uno_Interface
* pSrvManager
, uno_Interface
* /*pRegistryKey*/ )
141 if ( pSrvManager
&& ( 0 == rtl_str_compare( pImplName
, WINCLIPBOARD_IMPL_NAME
) ) )
143 Sequence
< OUString
> aSNS( 1 );
144 aSNS
.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( WINCLIPBOARD_SERVICE_NAME
) );
146 //OUString( RTL_CONSTASCII_USTRINGPARAM( FPS_IMPL_NAME ) )
147 Reference
< XSingleServiceFactory
> xFactory ( createOneInstanceFactory(
148 reinterpret_cast< XMultiServiceFactory
* > ( pSrvManager
),
149 OUString::createFromAscii( pImplName
),
155 pRet
= xFactory
.get();