-
Notifications
You must be signed in to change notification settings - Fork 140
/
odf.c
184 lines (171 loc) · 10.9 KB
/
odf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/**********************************************************************
odf.c - Utility routines to enable ODF support in peg-multimarkdown.
(c) 2011 Fletcher T. Penney (http://fletcherpenney.net/).
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License or the MIT
license. See LICENSE for details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#include "odf.h"
void print_odf_header(GString *out){
/* Insert required XML header */
g_string_append_printf(out,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
"<office:document xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"\n" \
" xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\"\n" \
" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\"\n" \
" xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\"\n" \
" xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\"\n" \
" xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\"\n" \
" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" \
" xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" \
" xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"\n" \
" xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\"\n" \
" xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\"\n" \
" xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\"\n" \
" xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\"\n" \
" xmlns:math=\"http://www.w3.org/1998/Math/MathML\"\n" \
" xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\"\n" \
" xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\"\n" \
" xmlns:config=\"urn:oasis:names:tc:opendocument:xmlns:config:1.0\"\n" \
" xmlns:ooo=\"http://openoffice.org/2004/office\"\n" \
" xmlns:ooow=\"http://openoffice.org/2004/writer\"\n" \
" xmlns:oooc=\"http://openoffice.org/2004/calc\"\n" \
" xmlns:dom=\"http://www.w3.org/2001/xml-events\"\n" \
" xmlns:xforms=\"http://www.w3.org/2002/xforms\"\n" \
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" \
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" \
" xmlns:rpt=\"http://openoffice.org/2005/report\"\n" \
" xmlns:of=\"urn:oasis:names:tc:opendocument:xmlns:of:1.2\"\n" \
" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"\n" \
" xmlns:grddl=\"http://www.w3.org/2003/g/data-view#\"\n" \
" xmlns:tableooo=\"http://openoffice.org/2009/table\"\n" \
" xmlns:field=\"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0\"\n" \
" xmlns:formx=\"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0\"\n" \
" xmlns:css3t=\"http://www.w3.org/TR/css3-text/\"\n" \
" office:version=\"1.2\"\n" \
" grddl:transformation=\"http://docs.oasis-open.org/office/1.2/xslt/odf2rdf.xsl\"\n" \
" office:mimetype=\"application/vnd.oasis.opendocument.text\">\n");
/* Font Declarations */
g_string_append_printf(out, "<office:font-face-decls>\n" \
" <style:font-face style:name=\"Courier New\" svg:font-family=\"'Courier New'\"\n" \
" style:font-adornments=\"Regular\"\n" \
" style:font-family-generic=\"modern\"\n" \
" style:font-pitch=\"fixed\"/>\n" \
"</office:font-face-decls>\n");
/* Append basic style information */
g_string_append_printf(out, "<office:styles>\n" \
"<style:style style:name=\"Standard\" style:family=\"paragraph\" style:class=\"text\">\n" \
" <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.15in\"" \
" fo:text-align=\"justify\" style:justify-single-word=\"false\"/>\n" \
" </style:style>\n" \
"<style:style style:name=\"Preformatted_20_Text\" style:display-name=\"Preformatted Text\"\n" \
" style:family=\"paragraph\"\n" \
" style:parent-style-name=\"Standard\"\n" \
" style:class=\"html\">\n" \
" <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0in\" fo:text-align=\"start\"\n" \
" style:justify-single-word=\"false\"/>\n" \
" <style:text-properties style:font-name=\"Courier New\" fo:font-size=\"11pt\"\n" \
" style:font-name-asian=\"Courier New\"\n" \
" style:font-size-asian=\"11pt\"\n" \
" style:font-name-complex=\"Courier New\"\n" \
" style:font-size-complex=\"11pt\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"Source_20_Text\" style:display-name=\"Source Text\"\n" \
" style:family=\"text\">\n" \
" <style:text-properties style:font-name=\"Courier New\" style:font-name-asian=\"Courier New\"\n" \
" style:font-name-complex=\"Courier New\"\n" \
" fo:font-size=\"11pt\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"List\" style:family=\"paragraph\"\n" \
" style:parent-style-name=\"Standard\"\n" \
" style:class=\"list\">\n" \
" <style:paragraph-properties fo:text-align=\"start\" style:justify-single-word=\"false\"/>\n" \
" <style:text-properties style:font-size-asian=\"12pt\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"Quotations\" style:family=\"paragraph\"\n" \
" style:parent-style-name=\"Standard\"\n" \
" style:class=\"html\">\n" \
" <style:paragraph-properties fo:margin-left=\"0.3937in\" fo:margin-right=\"0.3937in\" fo:margin-top=\"0in\"\n" \
" fo:margin-bottom=\"0.1965in\"\n" \
" fo:text-align=\"justify\"" \
" style:justify-single-word=\"false\"" \
" fo:text-indent=\"0in\"\n" \
" style:auto-text-indent=\"false\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"Table_20_Heading\" style:display-name=\"Table Heading\"\n" \
" style:family=\"paragraph\"\n" \
" style:parent-style-name=\"Table_20_Contents\"\n" \
" style:class=\"extra\">\n" \
" <style:paragraph-properties fo:text-align=\"center\" style:justify-single-word=\"false\"\n" \
" text:number-lines=\"false\"\n" \
" text:line-number=\"0\"/>\n" \
" <style:text-properties fo:font-weight=\"bold\" style:font-weight-asian=\"bold\"\n" \
" style:font-weight-complex=\"bold\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"Horizontal_20_Line\" style:display-name=\"Horizontal Line\"\n" \
" style:family=\"paragraph\"\n" \
" style:parent-style-name=\"Standard\"\n" \
" style:class=\"html\">\n" \
" <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.1965in\"\n" \
" style:border-line-width-bottom=\"0.0008in 0.0138in 0.0008in\"\n" \
" fo:padding=\"0in\"\n" \
" fo:border-left=\"none\"\n" \
" fo:border-right=\"none\"\n" \
" fo:border-top=\"none\"\n" \
" fo:border-bottom=\"0.0154in double #808080\"\n" \
" text:number-lines=\"false\"\n" \
" text:line-number=\"0\"\n" \
" style:join-border=\"false\"/>\n" \
" <style:text-properties fo:font-size=\"6pt\" style:font-size-asian=\"6pt\" style:font-size-complex=\"6pt\"/>\n" \
"</style:style>\n" \
"</office:styles>\n");
/* Automatic style information */
g_string_append_printf(out, "<office:automatic-styles>" \
" <style:style style:name=\"MMD-Italic\" style:family=\"text\">\n" \
" <style:text-properties fo:font-style=\"italic\" style:font-style-asian=\"italic\"\n" \
" style:font-style-complex=\"italic\"/>\n" \
" </style:style>\n" \
" <style:style style:name=\"MMD-Bold\" style:family=\"text\">\n" \
" <style:text-properties fo:font-weight=\"bold\" style:font-weight-asian=\"bold\"\n" \
" style:font-weight-complex=\"bold\"/>\n" \
" </style:style>\n" \
" <style:style style:name=\"StrikeThrough\" style:family=\"text\">\n" \
" <style:text-properties style:text-line-through-style=\"solid\"/>\n" \
" </style:style>\n" \
"<style:style style:name=\"MMD-Table\" style:family=\"paragraph\" style:parent-style-name=\"Standard\">\n" \
" <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.05in\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"MMD-Table-Center\" style:family=\"paragraph\" style:parent-style-name=\"MMD-Table\">\n" \
" <style:paragraph-properties fo:text-align=\"center\" style:justify-single-word=\"false\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"MMD-Table-Right\" style:family=\"paragraph\" style:parent-style-name=\"MMD-Table\">\n" \
" <style:paragraph-properties fo:text-align=\"right\" style:justify-single-word=\"false\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"P2\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"\n" \
" style:list-style-name=\"L2\">\n" \
"<style:paragraph-properties fo:text-align=\"start\" style:justify-single-word=\"false\"/>\n" \
"</style:style>\n" \
"<style:style style:name=\"fr1\" style:family=\"graphic\" style:parent-style-name=\"Frame\">\n" \
" <style:graphic-properties style:print-content=\"false\" style:vertical-pos=\"top\"\n" \
" style:vertical-rel=\"baseline\"\n" \
" fo:padding=\"0in\"\n" \
" fo:border=\"none\"\n" \
" style:shadow=\"none\"/>\n" \
"</style:style>\n" \
"</office:automatic-styles>\n" \
"<style:style style:name=\"P1\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"\n" \
" style:list-style-name=\"L1\"/>\n" \
"<text:list-style style:name=\"L1\">\n" \
" <text:list-level-style-bullet />\n" \
"</text:list-style>\n" \
"<text:list-style style:name=\"L2\">\n" \
" <text:list-level-style-number />\n" \
"</text:list-style>\n");
}
void print_odf_footer(GString *out) {
g_string_append_printf(out, "</office:text>\n</office:body>\n</office:document>");
}