1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include "svl/svldllapi.h"
24 #include <tools/inetmime.hxx>
25 #include <i18nlangtag/languagetag.hxx>
27 //============================================================================
28 /** Definitions for frequently used media type names.
30 #define CONTENT_TYPE_STR_APP_OCTSTREAM "application/octet-stream"
31 #define CONTENT_TYPE_STR_APP_PDF "application/pdf"
32 #define CONTENT_TYPE_STR_APP_RTF "application/rtf"
33 #define CONTENT_TYPE_STR_APP_VND_CALC "application/vnd.stardivision.calc"
34 #define CONTENT_TYPE_STR_APP_VND_CHART "application/vnd.stardivision.chart"
35 #define CONTENT_TYPE_STR_APP_VND_DRAW "application/vnd.stardivision.draw"
36 #define CONTENT_TYPE_STR_APP_VND_IMAGE "application/vnd.stardivision.image"
37 #define CONTENT_TYPE_STR_APP_VND_IMPRESSPACKED "application/vnd.stardivision.impress-packed"
38 #define CONTENT_TYPE_STR_APP_VND_IMPRESS "application/vnd.stardivision.impress"
39 #define CONTENT_TYPE_STR_APP_VND_MAIL "application/vnd.stardivision.mail"
40 #define CONTENT_TYPE_STR_APP_VND_MATH "application/vnd.stardivision.math"
41 #define CONTENT_TYPE_STR_APP_VND_NEWS "application/vnd.stardivision.news"
42 #define CONTENT_TYPE_STR_APP_VND_OUTTRAY "application/vnd.stardivision.outtray"
43 #define CONTENT_TYPE_STR_APP_VND_TEMPLATE "application/vnd.stardivision.template"
44 #define CONTENT_TYPE_STR_APP_VND_WRITER_GLOBAL "application/vnd.stardivision.writer-global"
45 #define CONTENT_TYPE_STR_APP_VND_WRITER_WEB "application/vnd.stardivision.writer-web"
46 #define CONTENT_TYPE_STR_APP_VND_WRITER "application/vnd.stardivision.writer"
47 #define CONTENT_TYPE_STR_APP_FRAMESET "application/x-frameset"
48 #define CONTENT_TYPE_STR_APP_GALLERY_THEME "application/x-gallery-theme"
49 #define CONTENT_TYPE_STR_APP_GALLERY "application/x-gallery"
50 #define CONTENT_TYPE_STR_APP_JAR "application/x-jar"
51 #define CONTENT_TYPE_STR_APP_MACRO "application/x-macro"
52 #define CONTENT_TYPE_STR_APP_MSEXCEL_TEMPL "application/x-msexcel-template"
53 #define CONTENT_TYPE_STR_APP_MSEXCEL "application/x-msexcel"
54 #define CONTENT_TYPE_STR_APP_MSPPOINT_TEMPL "application/x-mspowerpoint-template"
55 #define CONTENT_TYPE_STR_APP_MSPPOINT "application/x-mspowerpoint"
56 #define CONTENT_TYPE_STR_APP_MSWORD_TEMPL "application/x-msword-template"
57 #define CONTENT_TYPE_STR_APP_MSWORD "application/x-msword"
58 #define CONTENT_TYPE_STR_APP_SCHEDULE_EVT "application/x-schedule-event"
59 #define CONTENT_TYPE_STR_APP_SCHEDULE_FEVT "application/x-schedule-form-event"
60 #define CONTENT_TYPE_STR_APP_SCHEDULE_FTASK "application/x-schedule-form-task"
61 #define CONTENT_TYPE_STR_APP_SCHEDULE_TASK "application/x-schedule-task"
62 #define CONTENT_TYPE_STR_APP_SCHEDULE_CMB "application/x-schedule"
63 #define CONTENT_TYPE_STR_APP_STARCALC "application/x-starcalc"
64 #define CONTENT_TYPE_STR_APP_STARCHART "application/x-starchart"
65 #define CONTENT_TYPE_STR_APP_STARDRAW "application/x-stardraw"
66 #define CONTENT_TYPE_STR_APP_STARHELP "application/x-starhelp"
67 #define CONTENT_TYPE_STR_APP_STARIMAGE "application/x-starimage"
68 #define CONTENT_TYPE_STR_APP_STARIMPRESS "application/x-starimpress"
69 #define CONTENT_TYPE_STR_APP_STARMAIL_SDM "application/x-starmail-sdm"
70 #define CONTENT_TYPE_STR_APP_STARMAIL_SMD "application/x-starmail-smd"
71 #define CONTENT_TYPE_STR_APP_STARMATH "application/x-starmath"
72 #define CONTENT_TYPE_STR_APP_STARWRITER_GLOB "application/x-starwriter-global"
73 #define CONTENT_TYPE_STR_APP_STARWRITER "application/x-starwriter"
74 #define CONTENT_TYPE_STR_APP_CDE_CALENDAR_APP "application/x-sun-ae-file"
75 #define CONTENT_TYPE_STR_APP_ZIP "application/x-zip-compressed"
76 #define CONTENT_TYPE_STR_AUDIO_AIFF "audio/aiff"
77 #define CONTENT_TYPE_STR_AUDIO_BASIC "audio/basic"
78 #define CONTENT_TYPE_STR_AUDIO_MIDI "audio/midi"
79 #define CONTENT_TYPE_STR_AUDIO_VORBIS "audio/vorbis"
80 #define CONTENT_TYPE_STR_AUDIO_WAV "audio/wav"
81 #define CONTENT_TYPE_STR_AUDIO_WEBM "audio/webm"
82 #define CONTENT_TYPE_STR_X_CNT_FSYSBOX ".chaos/fsys-box"
83 #define CONTENT_TYPE_STR_X_CNT_FSYSFOLDER ".chaos/fsys-folder"
84 #define CONTENT_TYPE_STR_X_CNT_FSYSSPECIALFOLDER ".chaos/fsys-special-folder"
85 #define CONTENT_TYPE_STR_IMAGE_GENERIC "image/generic"
86 #define CONTENT_TYPE_STR_IMAGE_GIF "image/gif"
87 #define CONTENT_TYPE_STR_IMAGE_JPEG "image/jpeg"
88 #define CONTENT_TYPE_STR_IMAGE_PCX "image/pcx"
89 #define CONTENT_TYPE_STR_IMAGE_PNG "image/png"
90 #define CONTENT_TYPE_STR_IMAGE_TIFF "image/tiff"
91 #define CONTENT_TYPE_STR_IMAGE_BMP "image/x-MS-bmp"
92 #define CONTENT_TYPE_STR_INET_MSG_RFC822 "message/rfc822"
93 #define CONTENT_TYPE_STR_INET_MULTI_ALTERNATIVE "multipart/alternative"
94 #define CONTENT_TYPE_STR_INET_MULTI_DIGEST "multipart/digest"
95 #define CONTENT_TYPE_STR_INET_MULTI_MIXED "multipart/mixed"
96 #define CONTENT_TYPE_STR_INET_MULTI_PARALLEL "multipart/parallel"
97 #define CONTENT_TYPE_STR_INET_MULTI_RELATED "multipart/related"
98 #define CONTENT_TYPE_STR_TEXT_ICALENDAR "text/calendar"
99 #define CONTENT_TYPE_STR_TEXT_HTML "text/html"
100 #define CONTENT_TYPE_STR_TEXT_PLAIN "text/plain"
101 #define CONTENT_TYPE_STR_TEXT_XMLICALENDAR "text/x-icalxml"
102 #define CONTENT_TYPE_STR_TEXT_URL "text/x-url"
103 #define CONTENT_TYPE_STR_TEXT_VCALENDAR "text/x-vCalendar"
104 #define CONTENT_TYPE_STR_TEXT_VCARD "text/x-vCard"
105 #define CONTENT_TYPE_STR_VIDEO_MSVIDEO "video/x-msvideo"
106 #define CONTENT_TYPE_STR_VIDEO_THEORA "video/theora"
107 #define CONTENT_TYPE_STR_VIDEO_VDO "video/vdo"
108 #define CONTENT_TYPE_STR_VIDEO_WEBM "audio/webm"
109 #define CONTENT_TYPE_STR_X_STARMAIL "x-starmail"
110 #define CONTENT_TYPE_STR_X_VRML "x-world/x-vrml"
111 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER "application/vnd.sun.xml.writer"
112 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_CALC "application/vnd.sun.xml.calc"
113 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESS "application/vnd.sun.xml.impress"
114 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_DRAW "application/vnd.sun.xml.draw"
115 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_CHART "application/vnd.sun.xml.chart"
116 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_MATH "application/vnd.sun.xml.math"
117 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_WRITER_GLOBAL "application/vnd.sun.xml.writer-global"
118 #define CONTENT_TYPE_STR_APP_VND_SUN_XML_IMPRESSPACKED "application/vnd.sun.xml.impress-packed"
120 //============================================================================
121 /** Definitions for matching parts of URIs.
123 #define INETTYPE_URL_PROT_COMPONENT ".component"
124 #define INETTYPE_URL_PROT_DATA "data"
125 #define INETTYPE_URL_PROT_FILE "file"
126 #define INETTYPE_URL_PROT_HTTP "http"
127 #define INETTYPE_URL_PROT_HTTPS "https"
128 #define INETTYPE_URL_PROT_MACRO "macro"
129 #define INETTYPE_URL_PROT_MAILTO "mailto"
130 #define INETTYPE_URL_PROT_PRIVATE "private"
132 #define INETTYPE_URL_SUB_FACTORY "factory"
133 #define INETTYPE_URL_SUB_HELPID "helpid"
135 #define INETTYPE_URL_SSUB_FRAMESET "frameset"
136 #define INETTYPE_URL_SSUB_SCALC "scalc"
137 #define INETTYPE_URL_SSUB_SCHART "schart"
138 #define INETTYPE_URL_SSUB_SDRAW "sdraw"
139 #define INETTYPE_URL_SSUB_SIMAGE "simage"
140 #define INETTYPE_URL_SSUB_SIMPRESS "simpress"
141 #define INETTYPE_URL_SSUB_SMATH "smath"
142 #define INETTYPE_URL_SSUB_SS "ss"
143 #define INETTYPE_URL_SSUB_SWRITER "swriter"
145 #define INETTYPE_URL_SSSUB_GLOB "GlobalDocument"
146 #define INETTYPE_URL_SSSUB_WEB "web"
148 #define INETTYPE_URL_SCHED_CMB "cmbview"
149 #define INETTYPE_URL_SCHED_FORM "formular"
150 #define INETTYPE_URL_SCHED_TASK "type=task"
152 //============================================================================
155 CONTENT_TYPE_UNKNOWN
,
156 CONTENT_TYPE_APP_OCTSTREAM
,
157 CONTENT_TYPE_APP_PDF
,
158 CONTENT_TYPE_APP_RTF
,
159 CONTENT_TYPE_APP_MSWORD
,
160 CONTENT_TYPE_APP_MSWORD_TEMPL
,
161 CONTENT_TYPE_APP_STARCALC
,
162 CONTENT_TYPE_APP_STARCHART
,
163 CONTENT_TYPE_APP_STARDRAW
,
164 CONTENT_TYPE_APP_STARHELP
,
165 CONTENT_TYPE_APP_STARIMAGE
,
166 CONTENT_TYPE_APP_STARIMPRESS
,
167 CONTENT_TYPE_APP_STARMATH
,
168 CONTENT_TYPE_APP_STARWRITER
,
169 CONTENT_TYPE_APP_ZIP
,
170 CONTENT_TYPE_AUDIO_AIFF
,
171 CONTENT_TYPE_AUDIO_BASIC
,
172 CONTENT_TYPE_AUDIO_MIDI
,
173 CONTENT_TYPE_AUDIO_VORBIS
,
174 CONTENT_TYPE_AUDIO_WAV
,
175 CONTENT_TYPE_AUDIO_WEBM
,
176 CONTENT_TYPE_IMAGE_GIF
,
177 CONTENT_TYPE_IMAGE_JPEG
,
178 CONTENT_TYPE_IMAGE_PCX
,
179 CONTENT_TYPE_IMAGE_PNG
,
180 CONTENT_TYPE_IMAGE_TIFF
,
181 CONTENT_TYPE_IMAGE_BMP
,
182 CONTENT_TYPE_TEXT_HTML
,
183 CONTENT_TYPE_TEXT_PLAIN
,
184 CONTENT_TYPE_TEXT_URL
,
185 CONTENT_TYPE_TEXT_VCARD
,
186 CONTENT_TYPE_VIDEO_MSVIDEO
,
187 CONTENT_TYPE_VIDEO_THEORA
,
188 CONTENT_TYPE_VIDEO_VDO
,
189 CONTENT_TYPE_VIDEO_WEBM
,
190 CONTENT_TYPE_X_CNT_FSYSBOX
,
191 CONTENT_TYPE_X_CNT_FSYSFOLDER
,
192 CONTENT_TYPE_X_STARMAIL
,
194 CONTENT_TYPE_APP_GALLERY
,
195 CONTENT_TYPE_APP_GALLERY_THEME
,
196 CONTENT_TYPE_APP_STARWRITER_GLOB
,
197 CONTENT_TYPE_APP_STARMAIL_SDM
,
198 CONTENT_TYPE_APP_STARMAIL_SMD
,
199 CONTENT_TYPE_APP_VND_CALC
,
200 CONTENT_TYPE_APP_VND_CHART
,
201 CONTENT_TYPE_APP_VND_DRAW
,
202 CONTENT_TYPE_APP_VND_IMAGE
,
203 CONTENT_TYPE_APP_VND_IMPRESS
,
204 CONTENT_TYPE_APP_VND_MAIL
,
205 CONTENT_TYPE_APP_VND_MATH
,
206 CONTENT_TYPE_APP_VND_WRITER
,
207 CONTENT_TYPE_APP_VND_WRITER_GLOBAL
,
208 CONTENT_TYPE_APP_VND_WRITER_WEB
,
209 CONTENT_TYPE_APP_SCHEDULE
,
210 CONTENT_TYPE_APP_SCHEDULE_EVT
,
211 CONTENT_TYPE_APP_SCHEDULE_TASK
,
212 CONTENT_TYPE_APP_SCHEDULE_FORM_EVT
,
213 CONTENT_TYPE_APP_SCHEDULE_FORM_TASK
,
214 CONTENT_TYPE_APP_FRAMESET
,
215 CONTENT_TYPE_APP_MACRO
,
216 CONTENT_TYPE_X_CNT_FSYSSPECIALFOLDER
,
217 CONTENT_TYPE_APP_VND_TEMPLATE
,
218 CONTENT_TYPE_IMAGE_GENERIC
,
219 CONTENT_TYPE_APP_VND_NEWS
,
220 CONTENT_TYPE_APP_VND_OUTTRAY
,
221 CONTENT_TYPE_APP_MSEXCEL
,
222 CONTENT_TYPE_APP_MSEXCEL_TEMPL
,
223 CONTENT_TYPE_APP_MSPPOINT
,
224 CONTENT_TYPE_APP_MSPPOINT_TEMPL
,
225 CONTENT_TYPE_TEXT_VCALENDAR
,
226 CONTENT_TYPE_TEXT_ICALENDAR
,
227 CONTENT_TYPE_TEXT_XMLICALENDAR
,
228 CONTENT_TYPE_APP_CDE_CALENDAR_APP
,
229 CONTENT_TYPE_INET_MESSAGE_RFC822
,
230 CONTENT_TYPE_INET_MULTIPART_ALTERNATIVE
,
231 CONTENT_TYPE_INET_MULTIPART_DIGEST
,
232 CONTENT_TYPE_INET_MULTIPART_PARALLEL
,
233 CONTENT_TYPE_INET_MULTIPART_RELATED
,
234 CONTENT_TYPE_INET_MULTIPART_MIXED
,
235 CONTENT_TYPE_APP_VND_IMPRESSPACKED
,
236 CONTENT_TYPE_APP_JAR
,
237 CONTENT_TYPE_APP_VND_SUN_XML_WRITER
,
238 CONTENT_TYPE_APP_VND_SUN_XML_CALC
,
239 CONTENT_TYPE_APP_VND_SUN_XML_IMPRESS
,
240 CONTENT_TYPE_APP_VND_SUN_XML_DRAW
,
241 CONTENT_TYPE_APP_VND_SUN_XML_CHART
,
242 CONTENT_TYPE_APP_VND_SUN_XML_MATH
,
243 CONTENT_TYPE_APP_VND_SUN_XML_WRITER_GLOBAL
,
244 CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED
,
245 CONTENT_TYPE_LAST
= CONTENT_TYPE_APP_VND_SUN_XML_IMPRESSPACKED
248 //============================================================================
249 class SVL_DLLPUBLIC INetContentTypes
252 static INetContentType
RegisterContentType(OUString
const & rTypeName
,
253 OUString
const & rPresentation
,
254 OUString
const * pExtension
= 0,
255 OUString
const * pSystemFileType
= 0);
257 static INetContentType
GetContentType(OUString
const & rTypeName
);
259 static OUString
GetContentType(INetContentType eTypeID
);
261 static OUString
GetPresentation(INetContentType eTypeID
,
262 const LanguageTag
& aLocale
);
264 static INetContentType
GetContentType4Extension(OUString
const & rExtension
);
266 static INetContentType
GetContentTypeFromURL(OUString
const & rURL
);
268 static bool GetExtensionFromURL(OUString
const & rURL
, OUString
& rExtension
);
270 /** Parse the body of an RFC 2045 Content-Type header field.
272 @param rMediaType The body of the Content-Type header field. It must
275 token "/" token *(";" token "=" (token / quoted-string))
277 with intervening linear white space and comments (cf. RFCs 822, 2045).
278 The RFC 2231 extension are supported. The encoding of rMediaType
279 should be US-ASCII, but any Unicode values in the range U+0080..U+FFFF
280 are interpretet 'as appropriate.'
282 @param rType Returns the type (the first of the above tokens), in US-
283 ASCII encoding and converted to lower case.
285 @param rSubType Returns the sub type (the second of the above
286 tokens), in US-ASCII encoding and converted to lower case.
288 @param rParameters If not null, returns the parameters as a list of
289 INetContentTypeParameters (the attributes are in US-ASCII encoding and
290 converted to lower case, the values are in Unicode encoding). If
291 null, only the syntax of the parameters is checked, but they are not
294 @return True if the syntax of the field body is correct. If false is
295 returned, none of the output parameters will be modified!
297 static bool parse(OUString
const & rMediaType
, OUString
& rType
,
299 INetContentTypeParameterList
* pParameters
= 0);
302 #endif // _INETTYPE_HXX
304 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */