xref: /trunk/main/dtrans/source/cnttype/mctfentry.cxx (revision e8183b3f)
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 //-----------------------------------------------------------------
28 //	includes of other projects
29 //-----------------------------------------------------------------
30 #include <cppuhelper/factory.hxx>
31 #include <com/sun/star/container/XSet.hpp>
32 #include <osl/diagnose.h>
33 #include <com/sun/star/datatransfer/XMimeContentTypeFactory.hpp>
34 #include "mcnttfactory.hxx"
35 
36 //-----------------------------------------------------------------
37 // some defines
38 //-----------------------------------------------------------------
39 
40 // the service names
41 #define MIMECONTENTTYPEFACTORY_SERVICE_NAME  "com.sun.star.datatransfer.MimeContentTypeFactory"
42 
43 // the implementation names
44 #define MIMECONTENTTYPEFACTORY_IMPL_NAME  "com.sun.star.datatransfer.MimeCntTypeFactory"
45 
46 // the registry key names
47 // a key under which this service will be registered, Format: -> "/ImplName/UNO/SERVICES/ServiceName"
48 //                        <     Implementation-Name    ></UNO/SERVICES/><    Service-Name           >
49 #define MIMECONTENTTYPEFACTORY_REGKEY_NAME  "/com.sun.star.datatransfer.MimeCntTypeFactory/UNO/SERVICES/com.sun.star.datatransfer.MimeContentTypeFactory"
50 
51 //-----------------------------------------------------------------------------------------------------------
52 // namespace directives
53 //-----------------------------------------------------------------------------------------------------------
54 
55 using namespace ::rtl						;
56 using namespace ::cppu					    ;
57 using namespace ::com::sun::star::uno		;
58 using namespace ::com::sun::star::registry	;
59 using namespace ::com::sun::star::lang;
60 using namespace ::com::sun::star::datatransfer;
61 
62 //-----------------------------------------------------------------
63 // create a static object to initialize the shell9x library
64 //-----------------------------------------------------------------
65 
66 namespace
67 {
68 
69 	//-----------------------------------------------------------------------------------------------------------
70     // functions to create a new Clipboad instance; is needed by factory helper implementation
71     // @param rServiceManager - service manager, useful if the component needs other uno services
72     // so we should give it to every UNO-Implementation component
73     //-----------------------------------------------------------------------------------------------------------
74 
createInstance(const Reference<XMultiServiceFactory> & rServiceManager)75 	Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
76 	{
77 		return Reference< XInterface >( static_cast< XMimeContentTypeFactory* >( new CMimeContentTypeFactory( rServiceManager ) ) );
78 	}
79 }
80 
81 //-----------------------------------------------------------------------------------------------------------
82 // the 3 important functions which will be exported
83 //-----------------------------------------------------------------------------------------------------------
84 
85 extern "C"
86 {
87 
88 //----------------------------------------------------------------------
89 // component_getImplementationEnvironment
90 //----------------------------------------------------------------------
91 
component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName,uno_Environment **)92 SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
93 	const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ )
94 {
95 	*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
96 }
97 
98 //----------------------------------------------------------------------
99 // component_getFactory
100 // returns a factory to create XFilePicker-Services
101 //----------------------------------------------------------------------
102 
component_getFactory(const sal_Char * pImplName,uno_Interface * pSrvManager,uno_Interface *)103 SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, uno_Interface* pSrvManager, uno_Interface* /*pRegistryKey*/ )
104 {
105 	void* pRet = 0;
106 
107 	if ( pSrvManager && ( 0 == rtl_str_compare( pImplName, MIMECONTENTTYPEFACTORY_IMPL_NAME ) ) )
108 	{
109 		Sequence< OUString > aSNS( 1 );
110 		aSNS.getArray( )[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( MIMECONTENTTYPEFACTORY_SERVICE_NAME ) );
111 
112 		Reference< XSingleServiceFactory > xFactory ( createSingleFactory(
113 			reinterpret_cast< XMultiServiceFactory* > ( pSrvManager ),
114 			OUString::createFromAscii( pImplName ),
115 			createInstance,
116 			aSNS ) );
117 		if ( xFactory.is() )
118 		{
119 			xFactory->acquire();
120 			pRet = xFactory.get();
121 		}
122 	}
123 
124 	return pRet;
125 }
126 
127 } // extern "C"
128