1 /* This file is part of the KDE project
2    Copyright (C) 2007 Thorsten Zachmann <zachmann@kde.org>
3    Copyright (C) 2010 Thomas Zander <zander@kde.org>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
10    This library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public License
16    along with this library; see the file COPYING.LIB.  If not, write to
17    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19 */
20 
21 #include "KoOdf.h"
22 
23 namespace KoOdf
24 {
25 struct DocumentData {
26     const char * mimeType;
27     const char * templateMimeType;
28     const char * bodyContentElement;
29 };
30 
31 const DocumentData s_documentData[] = {
32     { "application/vnd.oasis.opendocument.text", "application/vnd.oasis.opendocument.text-template", "office:text" },
33     { "application/vnd.oasis.opendocument.graphics", "application/vnd.oasis.opendocument.graphics-template", "office:drawing" },
34     { "application/vnd.oasis.opendocument.presentation", "application/vnd.oasis.opendocument.presentation-template", "office:presentation" },
35     { "application/vnd.oasis.opendocument.spreadsheet", "application/vnd.oasis.opendocument.spreadsheet-template", "office:spreadsheet" },
36     { "application/vnd.oasis.opendocument.chart", "application/vnd.oasis.opendocument.chart-template", "office:chart" },
37     { "application/vnd.oasis.opendocument.image", "application/vnd.oasis.opendocument.image-template", "office:image" },
38     // TODO what is the element for a formula check if bodyContentElement is ok
39     { "application/vnd.oasis.opendocument.formula", "application/vnd.oasis.opendocument.formula-template", "office:XXX" },
40     { "application/x-openoffice-embed-source-xml;windows_formatname=\"Star Embed Source (XML)\"", "", "office:text" }
41 };
42 //"application/vnd.oasis.opendocument.text-master"
43 //"application/vnd.oasis.opendocument.text-web"
44 
mimeType(DocumentType documentType)45 const char * mimeType(DocumentType documentType)
46 {
47     return s_documentData[documentType].mimeType;
48 }
49 
templateMimeType(DocumentType documentType)50 const char * templateMimeType(DocumentType documentType)
51 {
52     return s_documentData[documentType].templateMimeType;
53 }
54 
bodyContentElement(DocumentType documentType,bool withNamespace)55 const char * bodyContentElement(DocumentType documentType, bool withNamespace)
56 {
57     return withNamespace ? s_documentData[documentType].bodyContentElement : s_documentData[documentType].bodyContentElement + 7;
58 }
59 
60 }
61