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_framework.hxx"
26 
27 //_________________________________________________________________________________________________________________
28 //	my own includes
29 //_________________________________________________________________________________________________________________
30 #include <services/mediatypedetectionhelper.hxx>
31 #include <services.h>
32 #include <svl/inettype.hxx>
33 #include <tools/string.hxx>
34 #include <rtl/logfile.hxx>
35 
36 //_________________________________________________________________________________________________________________
37 //	interface includes
38 //_________________________________________________________________________________________________________________
39 
40 //_________________________________________________________________________________________________________________
41 //	namespace
42 //_________________________________________________________________________________________________________________
43 
44 namespace framework
45 {
46 
47 using namespace ::com::sun::star		;
48 using namespace ::rtl					;
49 
50 //_________________________________________________________________________________________________________________
51 //	declarations
52 //_________________________________________________________________________________________________________________
53 
54 //*****************************************************************************************************************
55 //	constructor
56 //*****************************************************************************************************************
MediaTypeDetectionHelper(const uno::Reference<lang::XMultiServiceFactory> & xFactory)57 MediaTypeDetectionHelper::MediaTypeDetectionHelper( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
58 	: m_xFactory( xFactory )
59 {
60 }
61 
62 //*****************************************************************************************************************
63 //	destructor
64 //*****************************************************************************************************************
~MediaTypeDetectionHelper()65 MediaTypeDetectionHelper::~MediaTypeDetectionHelper()
66 {
67 }
68 
DEFINE_XSERVICEINFO_ONEINSTANCESERVICE(MediaTypeDetectionHelper,::cppu::OWeakObject,SERVICENAME_MEDIATYPEDETECTIONHELPER,IMPLEMENTATIONNAME_MEDIATYPEDETECTIONHELPER)69 DEFINE_XSERVICEINFO_ONEINSTANCESERVICE	(	MediaTypeDetectionHelper
70                                         , ::cppu::OWeakObject
71 										, SERVICENAME_MEDIATYPEDETECTIONHELPER
72 										, IMPLEMENTATIONNAME_MEDIATYPEDETECTIONHELPER
73 									)
74 
75 DEFINE_INIT_SERVICE                 (   MediaTypeDetectionHelper,
76                                         {
77                                         }
78                                     )
79 
80 //*****************************************************************************************************************
81 //	 XStringMapping
82 //*****************************************************************************************************************
83 
84 //virtual
85 sal_Bool SAL_CALL MediaTypeDetectionHelper::mapStrings(
86 		uno::Sequence< OUString >& rSeq )
87 		throw(uno::RuntimeException)
88 {
89 	sal_Bool bModified = sal_False;
90 	for( sal_Int32 i = rSeq.getLength(); i--; )
91 	{
92 
93 		OUString& rUrl = rSeq[i];
94 		INetContentType eType = INetContentTypes::GetContentTypeFromURL( rUrl );
95 
96 		UniString aType( INetContentTypes::GetContentType( eType ) );
97 		if( aType.Len() )
98 		{
99 			rUrl = aType;
100 			bModified = sal_True;
101 		}
102 	}
103 	return bModified;
104 }
105 
106 }	// namespace framework
107 
108