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 29 //------------------------------------------------------------------------ 30 #include <osl/diagnose.h> 31 #include "mcnttfactory.hxx" 32 #include "mcnttype.hxx" 33 34 //------------------------------------------------------------------------ 35 // defines 36 //------------------------------------------------------------------------ 37 38 #define MIMECONTENTTYPEFACTORY_IMPL_NAME "com.sun.star.datatransfer.MimeCntTypeFactory" 39 40 //------------------------------------------------------------------------ 41 // namespace directives 42 //------------------------------------------------------------------------ 43 44 using namespace ::rtl; 45 using namespace ::osl; 46 using namespace ::cppu; 47 using namespace com::sun::star::uno; 48 using namespace com::sun::star::lang; 49 using namespace com::sun::star::datatransfer; 50 51 //------------------------------------------------------------------------ 52 // helper functions 53 //------------------------------------------------------------------------ 54 55 namespace 56 { MimeContentTypeFactory_getSupportedServiceNames()57 Sequence< OUString > SAL_CALL MimeContentTypeFactory_getSupportedServiceNames( ) 58 { 59 Sequence< OUString > aRet(1); 60 aRet[0] = OUString::createFromAscii("com.sun.star.datatransfer.MimeContentTypeFactory"); 61 return aRet; 62 } 63 } 64 65 //------------------------------------------------------------------------ 66 // ctor 67 //------------------------------------------------------------------------ 68 CMimeContentTypeFactory(const Reference<XMultiServiceFactory> & rSrvMgr)69CMimeContentTypeFactory::CMimeContentTypeFactory( const Reference< XMultiServiceFactory >& rSrvMgr ) : 70 m_SrvMgr( rSrvMgr ) 71 { 72 } 73 74 //------------------------------------------------------------------------ 75 // createMimeContentType 76 //------------------------------------------------------------------------ 77 createMimeContentType(const OUString & aContentType)78Reference< XMimeContentType > CMimeContentTypeFactory::createMimeContentType( const OUString& aContentType ) 79 throw( IllegalArgumentException, RuntimeException ) 80 { 81 MutexGuard aGuard( m_aMutex ); 82 return Reference< XMimeContentType >( new CMimeContentType( aContentType ) ); 83 } 84 85 // ------------------------------------------------- 86 // XServiceInfo 87 // ------------------------------------------------- 88 getImplementationName()89OUString SAL_CALL CMimeContentTypeFactory::getImplementationName( ) 90 throw( RuntimeException ) 91 { 92 return OUString::createFromAscii( MIMECONTENTTYPEFACTORY_IMPL_NAME ); 93 } 94 95 // ------------------------------------------------- 96 // XServiceInfo 97 // ------------------------------------------------- 98 supportsService(const OUString & ServiceName)99sal_Bool SAL_CALL CMimeContentTypeFactory::supportsService( const OUString& ServiceName ) 100 throw( RuntimeException ) 101 { 102 Sequence < OUString > SupportedServicesNames = MimeContentTypeFactory_getSupportedServiceNames(); 103 104 for ( sal_Int32 n = SupportedServicesNames.getLength(); n--; ) 105 if (SupportedServicesNames[n].compareTo(ServiceName) == 0) 106 return sal_True; 107 108 return sal_False; 109 } 110 111 // ------------------------------------------------- 112 // XServiceInfo 113 // ------------------------------------------------- 114 getSupportedServiceNames()115Sequence< OUString > SAL_CALL CMimeContentTypeFactory::getSupportedServiceNames( ) 116 throw( RuntimeException ) 117 { 118 return MimeContentTypeFactory_getSupportedServiceNames( ); 119 } 120