27#include <osl/diagnose.h>
40MediaTypeEntry
const * seekEntry(OUString
const & rTypeName,
41 MediaTypeEntry
const * pMap, std::size_t nSize);
137MediaTypeEntry
const aStaticExtensionMap[]
228MediaTypeEntry
const * seekEntry(OUString
const & rTypeName,
229 MediaTypeEntry
const * pMap, std::size_t nSize)
232 for (std::size_t i = 0;
i < nSize - 1; ++
i)
234 pMap[i].m_pTypeName < pMap[i + 1].m_pTypeName,
235 "seekEntry(): Bad map");
238 std::size_t nLow = 0;
239 std::size_t nHigh = nSize;
240 while (nLow != nHigh)
242 std::size_t nMiddle = (nLow + nHigh) / 2;
243 MediaTypeEntry
const * pEntry = pMap + nMiddle;
244 sal_Int32 nCmp = rTypeName.compareToIgnoreAsciiCase(pEntry->m_pTypeName);
263 if (
parse(rTypeName, aType, aSubType))
265 aType +=
"/" + aSubType;
266 MediaTypeEntry
const * pEntry = seekEntry(aType, aStaticTypeNameMap,
279 static std::array<OUString, CONTENT_TYPE_LAST + 1>
aMap = []()
281 std::array<OUString, CONTENT_TYPE_LAST + 1> tmp;
283 tmp[aStaticTypeNameMap[
i].m_eTypeID] = aStaticTypeNameMap[
i].m_pTypeName;
286 "; charset=iso-8859-1";
292 if (aTypeName.isEmpty())
294 OSL_FAIL(
"INetContentTypes::GetContentType(): Bad ID");
303 MediaTypeEntry
const * pEntry = seekEntry(rExtension, aStaticExtensionMap,
306 return pEntry->m_eTypeID;
314 std::size_t nIdx{ 0 };
316 if (!aToken.isEmpty())
319 if (rURL[ rURL.size() - 1 ] ==
'/')
320 if (rURL.size() > RTL_CONSTASCII_LENGTH(
"file:///"))
325 if (rURL.size() == 11
326 && rURL[ rURL.size() - 2 ] ==
'|')
346 if (aToken ==
"factory")
349 if (aToken ==
"swriter")
352 eTypeID = aToken ==
"web" ?
354 aToken ==
"GlobalDocument" ?
358 else if (aToken ==
"scalc")
360 else if (aToken ==
"sdraw")
362 else if (aToken ==
"simpress")
364 else if (aToken ==
"schart")
366 else if (aToken ==
"simage")
368 else if (aToken ==
"smath")
370 else if (aToken ==
"frameset")
373 else if (aToken ==
"helpid")
397 OUString & rExtension)
399 size_t nSlashPos = 0;
401 while (
i != std::u16string_view::npos)
404 i = rURL.find(
'/',
i + 1);
408 size_t nLastDotPos =
i = rURL.find(
'.', nSlashPos);
409 while (
i != std::u16string_view::npos)
412 i = rURL.find(
'.',
i + 1);
414 if (nLastDotPos >- 0)
415 rExtension = rURL.substr(nLastDotPos + 1);
422 OUString
const & rMediaType, OUString & rType, OUString & rSubType,
426 sal_Unicode const * e = b + rMediaType.getLength();
433 if (pParameters !=
nullptr) {
static bool parse(OUString const &rMediaType, OUString &rType, OUString &rSubType, INetContentTypeParameterList *pParameters=nullptr)
static INetContentType GetContentType4Extension(OUString const &rExtension)
static bool GetExtensionFromURL(std::u16string_view rURL, OUString &rExtension)
static INetContentType GetContentType(OUString const &rTypeName)
static INetContentType GetContentTypeFromURL(std::u16string_view aURL)
static sal_Unicode const * scanContentType(std::u16string_view rStr, OUString *pType=nullptr, OUString *pSubType=nullptr, INetContentTypeParameterList *pParameters=nullptr)
#define DBG_ASSERT(sCon, aError)
std::unordered_map< OString, INetContentTypeParameter > INetContentTypeParameterList
constexpr OUStringLiteral CONTENT_TYPE_STR_VIDEO_WEBM
constexpr OUStringLiteral CONTENT_TYPE_STR_TEXT_PLAIN
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_IMPRESSPACKED
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_GALLERY
@ CONTENT_TYPE_APP_FRAMESET
@ CONTENT_TYPE_APP_VND_MATH
@ CONTENT_TYPE_AUDIO_BASIC
@ CONTENT_TYPE_AUDIO_WEBM
@ CONTENT_TYPE_APP_MSWORD_TEMPL
@ CONTENT_TYPE_VIDEO_THEORA
@ CONTENT_TYPE_APP_MSPPOINT
@ CONTENT_TYPE_APP_MSPPOINT_TEMPL
@ CONTENT_TYPE_IMAGE_GENERIC
@ CONTENT_TYPE_VIDEO_MSVIDEO
@ CONTENT_TYPE_INET_MULTIPART_MIXED
@ CONTENT_TYPE_APP_GALLERY
@ CONTENT_TYPE_APP_CDE_CALENDAR_APP
@ CONTENT_TYPE_APP_STARIMPRESS
@ CONTENT_TYPE_APP_VND_NEWS
@ CONTENT_TYPE_APP_STARHELP
@ CONTENT_TYPE_APP_VND_SUN_XML_IMPRESS
@ CONTENT_TYPE_APP_STARMAIL_SMD
@ CONTENT_TYPE_APP_VND_DRAW
@ CONTENT_TYPE_APP_VND_SUN_XML_WRITER_GLOBAL
@ CONTENT_TYPE_APP_VND_CHART
@ CONTENT_TYPE_IMAGE_TIFF
@ CONTENT_TYPE_APP_VND_MAIL
@ CONTENT_TYPE_INET_MESSAGE_RFC822
@ CONTENT_TYPE_APP_OCTSTREAM
@ CONTENT_TYPE_INET_MULTIPART_ALTERNATIVE
@ CONTENT_TYPE_APP_VND_IMPRESSPACKED
@ CONTENT_TYPE_APP_VND_CALC
@ CONTENT_TYPE_APP_STARIMAGE
@ CONTENT_TYPE_APP_VND_WRITER_WEB
@ CONTENT_TYPE_APP_STARWRITER
@ CONTENT_TYPE_TEXT_ICALENDAR
@ CONTENT_TYPE_TEXT_PLAIN
@ CONTENT_TYPE_APP_STARCHART
@ CONTENT_TYPE_IMAGE_JPEG
@ CONTENT_TYPE_APP_VND_SUN_XML_WRITER
@ CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED
@ CONTENT_TYPE_INET_MULTIPART_DIGEST
@ CONTENT_TYPE_AUDIO_MIDI
@ CONTENT_TYPE_APP_VND_SUN_XML_MATH
@ CONTENT_TYPE_APP_VND_TEMPLATE
@ CONTENT_TYPE_APP_VND_IMAGE
@ CONTENT_TYPE_APP_VND_SUN_XML_CHART
@ CONTENT_TYPE_TEXT_VCALENDAR
@ CONTENT_TYPE_AUDIO_AIFF
@ CONTENT_TYPE_VIDEO_WEBM
@ CONTENT_TYPE_APP_VND_WRITER_GLOBAL
@ CONTENT_TYPE_AUDIO_VORBIS
@ CONTENT_TYPE_APP_MSWORD
@ CONTENT_TYPE_APP_VND_SUN_XML_DRAW
@ CONTENT_TYPE_APP_MSEXCEL
@ CONTENT_TYPE_TEXT_XMLICALENDAR
@ CONTENT_TYPE_APP_STARDRAW
@ CONTENT_TYPE_INET_MULTIPART_PARALLEL
@ CONTENT_TYPE_X_CNT_FSYSSPECIALFOLDER
@ CONTENT_TYPE_TEXT_VCARD
@ CONTENT_TYPE_APP_VND_OUTTRAY
@ CONTENT_TYPE_APP_VND_SUN_XML_CALC
@ CONTENT_TYPE_APP_STARCALC
@ CONTENT_TYPE_APP_GALLERY_THEME
@ CONTENT_TYPE_X_CNT_FSYSFOLDER
@ CONTENT_TYPE_APP_STARWRITER_GLOB
@ CONTENT_TYPE_APP_VND_WRITER
@ CONTENT_TYPE_X_CNT_FSYSBOX
@ CONTENT_TYPE_INET_MULTIPART_RELATED
@ CONTENT_TYPE_APP_STARMAIL_SDM
@ CONTENT_TYPE_APP_STARMATH
@ CONTENT_TYPE_X_STARMAIL
@ CONTENT_TYPE_APP_VND_IMPRESS
@ CONTENT_TYPE_APP_MSEXCEL_TEMPL
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_MATH
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_OCTSTREAM
Definitions for frequently used media type names.
constexpr OUStringLiteral CONTENT_TYPE_STR_IMAGE_BMP
constexpr OUStringLiteral CONTENT_TYPE_STR_IMAGE_GIF
constexpr OUStringLiteral CONTENT_TYPE_STR_X_CNT_FSYSBOX
constexpr OUStringLiteral CONTENT_TYPE_STR_AUDIO_MIDI
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_IMAGE
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARIMAGE
constexpr OUStringLiteral CONTENT_TYPE_STR_TEXT_VCARD
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_FRAMESET
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARMATH
constexpr OUStringLiteral CONTENT_TYPE_STR_INET_MULTI_DIGEST
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESS
constexpr OUStringLiteral CONTENT_TYPE_STR_X_CNT_FSYSSPECIALFOLDER
constexpr OUStringLiteral CONTENT_TYPE_STR_TEXT_URL
#define INETTYPE_URL_PROT_FILE
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_OUTTRAY
constexpr OUStringLiteral CONTENT_TYPE_STR_AUDIO_WEBM
constexpr OUStringLiteral CONTENT_TYPE_STR_TEXT_ICALENDAR
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_NEWS
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARHELP
constexpr OUStringLiteral CONTENT_TYPE_STR_TEXT_VCALENDAR
constexpr OUStringLiteral CONTENT_TYPE_STR_IMAGE_PCX
constexpr OUStringLiteral CONTENT_TYPE_STR_INET_MULTI_PARALLEL
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_IMPRESS
#define INETTYPE_URL_PROT_HTTP
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_CALC
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_MAIL
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_MACRO
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_RTF
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_CHART
constexpr OUStringLiteral CONTENT_TYPE_STR_AUDIO_AIFF
#define INETTYPE_URL_PROT_MAILTO
constexpr OUStringLiteral CONTENT_TYPE_STR_IMAGE_JPEG
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_GALLERY_THEME
constexpr OUStringLiteral CONTENT_TYPE_STR_INET_MULTI_ALTERNATIVE
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_WRITER_WEB
constexpr OUStringLiteral CONTENT_TYPE_STR_AUDIO_WAV
constexpr OUStringLiteral CONTENT_TYPE_STR_VIDEO_VDO
constexpr OUStringLiteral CONTENT_TYPE_STR_AUDIO_VORBIS
constexpr OUStringLiteral CONTENT_TYPE_STR_AUDIO_BASIC
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARMAIL_SDM
constexpr OUStringLiteral CONTENT_TYPE_STR_IMAGE_PNG
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_TEMPLATE
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_MSWORD
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_DRAW
constexpr OUStringLiteral CONTENT_TYPE_STR_TEXT_HTML
#define INETTYPE_URL_PROT_PRIVATE
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARWRITER_GLOB
constexpr OUStringLiteral CONTENT_TYPE_STR_INET_MULTI_RELATED
constexpr OUStringLiteral CONTENT_TYPE_STR_X_VRML
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_WRITER_GLOBAL
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARDRAW
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_MSPPOINT_TEMPL
constexpr OUStringLiteral CONTENT_TYPE_STR_X_CNT_FSYSFOLDER
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESSPACKED
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_CHART
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_ZIP
constexpr OUStringLiteral CONTENT_TYPE_STR_INET_MULTI_MIXED
#define INETTYPE_URL_PROT_MACRO
#define INETTYPE_URL_PROT_DATA
Definitions for matching parts of URIs.
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARCALC
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_JAR
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_PDF
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_MSPPOINT
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER_GLOBAL
constexpr OUStringLiteral CONTENT_TYPE_STR_TEXT_XMLICALENDAR
constexpr OUStringLiteral CONTENT_TYPE_STR_IMAGE_GENERIC
constexpr OUStringLiteral CONTENT_TYPE_STR_VIDEO_MSVIDEO
constexpr OUStringLiteral CONTENT_TYPE_STR_VIDEO_THEORA
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_WRITER
constexpr OUStringLiteral CONTENT_TYPE_STR_INET_MSG_RFC822
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_MSEXCEL
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_DRAW
constexpr OUStringLiteral CONTENT_TYPE_STR_X_STARMAIL
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARCHART
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARIMPRESS
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARMAIL_SMD
#define INETTYPE_URL_PROT_HTTPS
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_MATH
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_CDE_CALENDAR_APP
constexpr OUStringLiteral CONTENT_TYPE_STR_IMAGE_TIFF
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_STARWRITER
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_MSEXCEL_TEMPL
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_VND_SUN_XML_CALC
constexpr OUStringLiteral CONTENT_TYPE_STR_APP_MSWORD_TEMPL
#define SAL_N_ELEMENTS(arr)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
HashMap_OWString_Interface aMap