merge the formfield patch from ooo-build
[ooovba.git] / dtrans / source / cnttype / mctfentry.cxx
blob95c4a399ad59780f014996d3c802fca23312e114
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: mctfentry.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"
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>
40 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
41 #include "mcnttfactory.hxx"
43 //-----------------------------------------------------------------
44 // some defines
45 //-----------------------------------------------------------------
47 // the service names
48 #define MIMECONTENTTYPEFACTORY_SERVICE_NAME "com.sun.star.datatransfer.MimeContentTypeFactory"
50 // the implementation names
51 #define MIMECONTENTTYPEFACTORY_IMPL_NAME "com.sun.star.datatransfer.MimeCntTypeFactory"
53 // the registry key names
54 // a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName"
55 // < Implementation-Name ></UNO/SERVICES/>< Service-Name >
56 #define MIMECONTENTTYPEFACTORY_REGKEY_NAME "/com.sun.star.datatransfer.MimeCntTypeFactory/UNO/SERVICES/com.sun.star.datatransfer.MimeContentTypeFactory"
58 //-----------------------------------------------------------------------------------------------------------
59 // namespace directives
60 //-----------------------------------------------------------------------------------------------------------
62 using namespace ::rtl ;
63 using namespace ::cppu ;
64 using namespace ::com::sun::star::uno ;
65 using namespace ::com::sun::star::registry ;
66 using namespace ::com::sun::star::lang;
67 using namespace ::com::sun::star::datatransfer;
69 //-----------------------------------------------------------------
70 // create a static object to initialize the shell9x library
71 //-----------------------------------------------------------------
73 namespace
76 //-----------------------------------------------------------------------------------------------------------
77 // functions to create a new Clipboad instance; is needed by factory helper implementation
78 // @param rServiceManager - service manager, useful if the component needs other uno services
79 // so we should give it to every UNO-Implementation component
80 //-----------------------------------------------------------------------------------------------------------
82 Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
84 return Reference< XInterface >( static_cast< XMimeContentTypeFactory* >( new CMimeContentTypeFactory( rServiceManager ) ) );
88 //-----------------------------------------------------------------------------------------------------------
89 // the 3 important functions which will be exported
90 //-----------------------------------------------------------------------------------------------------------
92 extern "C"
95 //----------------------------------------------------------------------
96 // component_getImplementationEnvironment
97 //----------------------------------------------------------------------
99 void SAL_CALL component_getImplementationEnvironment(
100 const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
102 *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
105 //-------------------------------------------------------------------------
106 // component_writeInfo - to register a UNO-Service
107 // to register a UNO-Service use: regcomp -register -r *.rdb -c *.dll
108 // to view the registry use: regview *.rdb /SERVICES/ServiceName
109 // (you must use the full services name e.g. com.sun.star.frame.FilePicker
110 //-------------------------------------------------------------------------
112 sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey )
114 sal_Bool bRetVal = sal_False;
116 if ( pRegistryKey )
120 Reference< XRegistryKey > pXNewKey( static_cast< XRegistryKey* >( pRegistryKey ) );
121 pXNewKey->createKey( OUString( RTL_CONSTASCII_USTRINGPARAM( MIMECONTENTTYPEFACTORY_REGKEY_NAME ) ) );
122 bRetVal = sal_True;
124 catch( InvalidRegistryException& )
126 OSL_ENSURE(sal_False, "InvalidRegistryException caught");
127 bRetVal = sal_False;
131 return bRetVal;
134 //----------------------------------------------------------------------
135 // component_getFactory
136 // returns a factory to create XFilePicker-Services
137 //----------------------------------------------------------------------
139 void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
141 void* pRet = 0;
143 if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, MIMECONTENTTYPEFACTORY_IMPL_NAME ) ) )
145 Sequence< OUString > aSNS( 1 );
146 aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( MIMECONTENTTYPEFACTORY_SERVICE_NAME ) );
148 Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
149 reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
150 OUString::createFromAscii( pImplName ),
151 createInstance,
152 aSNS ) );
153 if ( xFactory.is() )
155 xFactory->acquire();
156 pRet = xFactory.get();
160 return pRet;
163 } // extern "C"