diff options
author | Marcel Metz <mmetz@adrian-broher.net> | 2011-12-12 16:50:32 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-12-12 16:50:32 +0000 |
commit | 9fd35cc973e12a07d82e5ca14ec1f4307dbbada9 (patch) | |
tree | 4f192d58276fb4823b0a8ebac4a0060fb4432817 /svl/source/misc | |
parent | 38f83bd0a5ae49ff382c64ea8ee4540435f0eb62 (diff) |
Related: fdo#38832 Replace Table with std::map
Diffstat (limited to 'svl/source/misc')
-rw-r--r-- | svl/source/misc/inettype.cxx | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/svl/source/misc/inettype.cxx b/svl/source/misc/inettype.cxx index 1cba9dcddb0d..b043f0680dbf 100644 --- a/svl/source/misc/inettype.cxx +++ b/svl/source/misc/inettype.cxx @@ -85,8 +85,9 @@ class Registration { typedef boost::ptr_map<UniString, TypeNameMapEntry> TypeNameMap; typedef boost::ptr_map<UniString, ExtensionMapEntry> ExtensionMap; + typedef std::map<INetContentType, TypeIDMapEntry*> TypeIDMap; - Table m_aTypeIDMap; // map TypeID to TypeName, Presentation + TypeIDMap m_aTypeIDMap; // map ContentType to TypeID TypeNameMap m_aTypeNameMap; // map TypeName to TypeID, Extension ExtensionMap m_aExtensionMap; // map Extension to TypeID sal_uInt32 m_nNextDynamicID; @@ -127,8 +128,13 @@ namespace // static inline TypeIDMapEntry * Registration::getEntry(INetContentType eTypeID) { - return static_cast< TypeIDMapEntry * >(theRegistration::get(). - m_aTypeIDMap.Get(eTypeID)); + Registration &rRegistration = theRegistration::get(); + + TypeIDMap::iterator it = rRegistration.m_aTypeIDMap.find( eTypeID ); + if( it != rRegistration.m_aTypeIDMap.end() ) + return it->second; + else + return NULL; } //============================================================================ @@ -526,10 +532,8 @@ MediaTypeEntry const aStaticPresentationMap[] //============================================================================ Registration::~Registration() { - {for (sal_uLong i = 0; i < m_aTypeIDMap.Count(); ++i) - delete static_cast< TypeIDMapEntry * >(m_aTypeIDMap.GetObject(i)); - } - m_aTypeIDMap.Clear(); + for ( TypeIDMap::iterator it = m_aTypeIDMap.begin(); it != m_aTypeIDMap.end(); ++it ) + delete it->second; } //============================================================================ @@ -571,7 +575,7 @@ INetContentType Registration::RegisterContentType(UniString const & rTypeName, pTypeIDMapEntry->m_aPresentation = rPresentation; if (pSystemFileType) pTypeIDMapEntry->m_aSystemFileType = *pSystemFileType; - rRegistration.m_aTypeIDMap.Insert(eTypeID, pTypeIDMapEntry); + rRegistration.m_aTypeIDMap.insert( ::std::make_pair( eTypeID, pTypeIDMapEntry ) ); std::auto_ptr<TypeNameMapEntry> pTypeNameMapEntry(new TypeNameMapEntry()); if (pExtension) @@ -609,10 +613,11 @@ UniString Registration::GetContentType(INetContentType eTypeID) { Registration &rRegistration = theRegistration::get(); - TypeIDMapEntry * pEntry - = static_cast< TypeIDMapEntry * >(rRegistration. - m_aTypeIDMap.Get(eTypeID)); - return pEntry ? pEntry->m_aTypeName : UniString(); + TypeIDMap::iterator pEntry = rRegistration.m_aTypeIDMap.find( eTypeID ); + if( pEntry != rRegistration.m_aTypeIDMap.end() ) + return pEntry->second->m_aTypeName; + else + return UniString(); } //============================================================================ @@ -621,10 +626,11 @@ UniString Registration::GetPresentation(INetContentType eTypeID) { Registration &rRegistration = theRegistration::get(); - TypeIDMapEntry * pEntry - = static_cast< TypeIDMapEntry * >(rRegistration. - m_aTypeIDMap.Get(eTypeID)); - return pEntry ? pEntry->m_aPresentation : UniString(); + TypeIDMap::iterator pEntry = rRegistration.m_aTypeIDMap.find( eTypeID ); + if( pEntry != rRegistration.m_aTypeIDMap.end() ) + return pEntry->second->m_aPresentation; + else + return UniString(); } //============================================================================ |