update dev300-m58
[ooovba.git] / framework / source / services / mediatypedetectionhelper.cxx
blobb5b7cfe0625b05256ba07bd68dddcaae7c443542
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: mediatypedetectionhelper.cxx,v $
10 * $Revision: 1.9 $
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_framework.hxx"
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
37 #include <services/mediatypedetectionhelper.hxx>
38 #include <services.h>
39 #include <svtools/inettype.hxx>
40 #include <tools/string.hxx>
41 #include <rtl/logfile.hxx>
43 //_________________________________________________________________________________________________________________
44 // interface includes
45 //_________________________________________________________________________________________________________________
47 //_________________________________________________________________________________________________________________
48 // namespace
49 //_________________________________________________________________________________________________________________
51 namespace framework
54 using namespace ::com::sun::star ;
55 using namespace ::rtl ;
57 //_________________________________________________________________________________________________________________
58 // declarations
59 //_________________________________________________________________________________________________________________
61 //*****************************************************************************************************************
62 // constructor
63 //*****************************************************************************************************************
64 MediaTypeDetectionHelper::MediaTypeDetectionHelper( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
65 : m_xFactory( xFactory )
69 //*****************************************************************************************************************
70 // destructor
71 //*****************************************************************************************************************
72 MediaTypeDetectionHelper::~MediaTypeDetectionHelper()
76 DEFINE_XSERVICEINFO_ONEINSTANCESERVICE ( MediaTypeDetectionHelper
77 , ::cppu::OWeakObject
78 , SERVICENAME_MEDIATYPEDETECTIONHELPER
79 , IMPLEMENTATIONNAME_MEDIATYPEDETECTIONHELPER
82 DEFINE_INIT_SERVICE ( MediaTypeDetectionHelper,
87 //*****************************************************************************************************************
88 // XStringMapping
89 //*****************************************************************************************************************
91 //virtual
92 sal_Bool SAL_CALL MediaTypeDetectionHelper::mapStrings(
93 uno::Sequence< OUString >& rSeq )
94 throw(uno::RuntimeException)
96 sal_Bool bModified = sal_False;
97 for( sal_Int32 i = rSeq.getLength(); i--; )
100 OUString& rUrl = rSeq[i];
101 INetContentType eType = INetContentTypes::GetContentTypeFromURL( rUrl );
103 UniString aType( INetContentTypes::GetContentType( eType ) );
104 if( aType.Len() )
106 rUrl = aType;
107 bModified = sal_True;
110 return bModified;
113 } // namespace framework