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: ftranslentry.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"
34 //-----------------------------------------------------------------
35 // includes of other projects
36 //-----------------------------------------------------------------
37 #include <cppuhelper/factory.hxx>
38 #include <com/sun/star/container/XSet.hpp>
39 #include <osl/diagnose.h>
41 #ifndef _COM_SUN_STAR_DATATRANSFER_XDATAFLAVORCONTAINER_HPP_
42 #include <com/sun/star/datatransfer/XDataFormatTranslator.hpp>
44 #include "ftransl.hxx"
46 //-----------------------------------------------------------------
48 //-----------------------------------------------------------------
51 #define SERVICE_NAME "com.sun.star.datatransfer.DataFormatTranslator"
53 // the implementation names
54 #define IMPL_NAME "com.sun.star.datatransfer.DataFormatTranslator"
56 // the registry key names
57 // a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName"
58 // < Implementation-Name ></UNO/SERVICES/>< Service-Name >
59 #define REGKEY_NAME "/com.sun.star.datatransfer.DataFormatTranslator/UNO/SERVICES/com.sun.star.datatransfer.DataFormatTranslator"
61 //-----------------------------------------------------------------------------------------------------------
62 // namespace directives
63 //-----------------------------------------------------------------------------------------------------------
65 using namespace ::rtl
;
66 using namespace ::cppu
;
67 using namespace ::com::sun::star::uno
;
68 using namespace ::com::sun::star::registry
;
69 using namespace ::com::sun::star::lang
;
70 using namespace ::com::sun::star::datatransfer
;
72 //-----------------------------------------------------------------
73 // create a static object to initialize the shell9x library
74 //-----------------------------------------------------------------
79 //-----------------------------------------------------------------------------------------------------------
80 // functions to create a new Clipboad instance; is needed by factory helper implementation
81 // @param rServiceManager - service manager, useful if the component needs other uno services
82 // so we should give it to every UNO-Implementation component
83 //-----------------------------------------------------------------------------------------------------------
85 Reference
< XInterface
> SAL_CALL
createInstance( const Reference
< XMultiServiceFactory
>& rServiceManager
)
87 return Reference
< XInterface
>( static_cast< XDataFormatTranslator
* >( new CDataFormatTranslator( rServiceManager
) ) );
91 //-----------------------------------------------------------------------------------------------------------
92 // the 3 important functions which will be exported
93 //-----------------------------------------------------------------------------------------------------------
98 //----------------------------------------------------------------------
99 // component_getImplementationEnvironment
100 //----------------------------------------------------------------------
102 void SAL_CALL
component_getImplementationEnvironment(
103 const sal_Char
** ppEnvTypeName
, uno_Environment
** /*ppEnv*/ )
105 *ppEnvTypeName
= CPPU_CURRENT_LANGUAGE_BINDING_NAME
;
108 //-------------------------------------------------------------------------
109 // component_writeInfo - to register a UNO-Service
110 // to register a UNO-Service use: regcomp -register -r *.rdb -c *.dll
111 // to view the registry use: regview *.rdb /SERVICES/ServiceName
112 // (you must use the full services name e.g. com.sun.star.frame.FilePicker
113 //-------------------------------------------------------------------------
115 sal_Bool SAL_CALL
component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey
)
117 sal_Bool bRetVal
= sal_False
;
123 Reference
< XRegistryKey
> pXNewKey( static_cast< XRegistryKey
* >( pRegistryKey
) );
124 pXNewKey
->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( REGKEY_NAME
) ) );
127 catch( InvalidRegistryException
& )
129 OSL_ENSURE(sal_False
, "InvalidRegistryException caught");
137 //----------------------------------------------------------------------
138 // component_getFactory
139 // returns a factory to create XFilePicker-Services
140 //----------------------------------------------------------------------
142 void* SAL_CALL
component_getFactory( const sal_Char
* pImplName
, uno_Interface
* pSrvManager
, uno_Interface
* /*pRegistryKey*/ )
146 if ( pSrvManager
&& ( 0 == rtl_str_compare( pImplName
, IMPL_NAME
) ) )
148 Sequence
< OUString
> aSNS( 1 );
149 aSNS
.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME
) );
151 Reference
< XSingleServiceFactory
> xFactory ( createOneInstanceFactory(
152 reinterpret_cast< XMultiServiceFactory
* > ( pSrvManager
),
153 OUString::createFromAscii( pImplName
),
159 pRet
= xFactory
.get();