1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_dtrans.hxx" 26 //______________________________________________________________________________________________________________ 27 // includes of other projects 28 //______________________________________________________________________________________________________________ 29 #include <cppuhelper/factory.hxx> 30 #include <com/sun/star/container/XSet.hpp> 31 #include <osl/diagnose.h> 32 #include "WinClipboard.hxx" 33 34 //----------------------------------------------------------------- 35 // some defines 36 //----------------------------------------------------------------- 37 38 // the service names 39 #define WINCLIPBOARD_SERVICE_NAME "com.sun.star.datatransfer.clipboard.SystemClipboard" 40 41 // the implementation names 42 #define WINCLIPBOARD_IMPL_NAME "com.sun.star.datatransfer.clipboard.ClipboardW32" 43 44 // the registry key names 45 // a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName" 46 // < Implementation-Name ></UNO/SERVICES/>< Service-Name > 47 #define WINCLIPBOARD_REGKEY_NAME "/com.sun.star.datatransfer.clipboard.ClipboardW32/UNO/SERVICES/com.sun.star.datatransfer.clipboard.SystemClipboard" 48 49 //----------------------------------------------------------------------------------------------------------- 50 // namespace directives 51 //----------------------------------------------------------------------------------------------------------- 52 53 using namespace ::rtl ; 54 using namespace ::com::sun::star::uno ; 55 using namespace ::com::sun::star::registry ; 56 using namespace ::cppu ; 57 using namespace ::com::sun::star::lang; 58 using namespace ::com::sun::star::datatransfer::clipboard; 59 60 //----------------------------------------------------------------- 61 // create a static object to initialize the shell9x library 62 //----------------------------------------------------------------- 63 64 namespace 65 { 66 67 //----------------------------------------------------------------------------------------------------------- 68 // functions to create a new Clipboad instance; is needed by factory helper implementation 69 // @param rServiceManager - service manager, useful if the component needs other uno services 70 // so we should give it to every UNO-Implementation component 71 //----------------------------------------------------------------------------------------------------------- 72 73 Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager ) 74 { 75 return Reference< XInterface >( static_cast< XClipboard* >( new CWinClipboard( rServiceManager, rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) ) ) ) ); 76 } 77 } 78 79 //----------------------------------------------------------------------------------------------------------- 80 // the 3 important functions which will be exported 81 //----------------------------------------------------------------------------------------------------------- 82 83 extern "C" 84 { 85 86 //---------------------------------------------------------------------- 87 // component_getImplementationEnvironment 88 //---------------------------------------------------------------------- 89 90 void SAL_CALL component_getImplementationEnvironment( 91 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) 92 { 93 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; 94 } 95 96 //---------------------------------------------------------------------- 97 // component_getFactory 98 // returns a factory to create XFilePicker-Services 99 //---------------------------------------------------------------------- 100 101 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ ) 102 { 103 void* pRet = 0; 104 105 if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, WINCLIPBOARD_IMPL_NAME ) ) ) 106 { 107 Sequence< OUString > aSNS( 1 ); 108 aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( WINCLIPBOARD_SERVICE_NAME ) ); 109 110 //OUString( RTL_CONSTASCII_USTRINGPARAM( FPS_IMPL_NAME ) ) 111 Reference< XSingleServiceFactory > xFactory ( createOneInstanceFactory( 112 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ), 113 OUString::createFromAscii( pImplName ), 114 createInstance, 115 aSNS ) ); 116 if ( xFactory.is() ) 117 { 118 xFactory->acquire(); 119 pRet = xFactory.get(); 120 } 121 } 122 123 return pRet; 124 } 125 126 } // extern "C" 127