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