aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/io_out/odt.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2024-03-12 22:39:09 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2024-03-12 22:56:34 -0400
commite9e17be24eba558c30fcdc41ea5bb9a1da7fd4e7 (patch)
tree1ed3c4b528b0a8e54d0eb9babc391e562578c7b4 /src/doc_reform/io_out/odt.d
parentnix flake & env upkeep (diff)
mark modules as @safe: (& identify what is not)
Diffstat (limited to 'src/doc_reform/io_out/odt.d')
-rw-r--r--src/doc_reform/io_out/odt.d79
1 files changed, 40 insertions, 39 deletions
diff --git a/src/doc_reform/io_out/odt.d b/src/doc_reform/io_out/odt.d
index 15e7e8e..c17158a 100644
--- a/src/doc_reform/io_out/odt.d
+++ b/src/doc_reform/io_out/odt.d
@@ -48,6 +48,7 @@
+/
module doc_reform.io_out.odt;
+@safe:
template formatODT() {
import
doc_reform.io_out,
@@ -69,7 +70,7 @@ template formatODT() {
struct formatODT {
static auto rgx = RgxO();
static auto rgx_xhtml = RgxXHTML();
- @safe string _tags(O)(const O obj) {
+ string _tags(O)(const O obj) {
string _tags = "";
if (obj.tags.anchor_tags.length > 0) {
foreach (tag_; obj.tags.anchor_tags) {
@@ -87,7 +88,7 @@ template formatODT() {
}
return _tags;
}
- @safe string _xhtml_anchor_tags(O)(O obj) {
+ string _xhtml_anchor_tags(O)(O obj) {
const(string[]) anchor_tags = obj.tags.anchor_tags;
string tags="";
if (anchor_tags.length > 0) {
@@ -99,7 +100,7 @@ template formatODT() {
}
return tags;
}
- @safe string obj_num(O)(const O obj) { // TODO
+ string obj_num(O)(const O obj) { // TODO
string _on;
_on = (obj.metainfo.object_number.empty)
? ""
@@ -109,7 +110,7 @@ template formatODT() {
));
return _on;
}
- @safe string _footnotes()(string _txt) {
+ string _footnotes()(string _txt) {
static auto rgx = RgxO();
static auto rgx_xhtml = RgxXHTML();
_txt = _txt.replaceAll(
@@ -129,14 +130,14 @@ template formatODT() {
);
return _txt;
}
- @safe string _bullet(O)(const O obj) {
+ string _bullet(O)(const O obj) {
string _b = "";
if (obj.attrib.bullet) {
_b = format(q"┃● ┃",);
}
return _b;
}
- @safe string _indent(O)(string _txt, const O obj) { // TODO
+ string _indent(O)(string _txt, const O obj) { // TODO
// if (obj.attrib.indent_base > 0 ||
// obj.attrib.indent_hang > 0
// ) {
@@ -244,7 +245,7 @@ template formatODT() {
}
return _txt;
}
- @safe string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO
+ string _block_type_delimiters(O)(string[] _block_lines, const O obj) { // TODO
string _block = "";
foreach (i, _line; _block_lines) {
_line = _footnotes(_line);
@@ -277,7 +278,7 @@ template formatODT() {
obj_num(obj));
return _block;
}
- @safe string _special_characters(O)(string _txt, const O obj) {
+ string _special_characters(O)(string _txt, const O obj) {
_txt = _txt
.replaceAll(rgx_xhtml.ampersand, "&amp;")
.replaceAll(rgx_xhtml.quotation, "&#34;")
@@ -286,7 +287,7 @@ template formatODT() {
.replaceAll(rgx.nbsp_char, "&#160;");
return _txt;
}
- @safe string _preserve_white_spaces(O)(string _txt, const O obj) {
+ string _preserve_white_spaces(O)(string _txt, const O obj) {
if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") {
_txt = _txt
.replaceAll(rgx.space, "&#160;");
@@ -307,9 +308,9 @@ template formatODT() {
.replaceAll(rgx.inline_mono, format(q"┃<text:span text:style-name="Span_monospace">%s</text:span>┃", "$1"));
return _txt;
}
- @safe auto _obj_num(O)(O obj) { // NOT USED YET
+ auto _obj_num(O)(O obj) { // NOT USED YET
struct objNum {
- @safe string reference() {
+ string reference() {
return format(q"┃<text:span text:style-name="Span_subscript">
<text:bookmark-start text:name="%s"/>
<text:bookmark-end text:name="%s"/>
@@ -318,7 +319,7 @@ template formatODT() {
obj.object_number,
);
}
- @safe string display() {
+ string display() {
return format(q"┃<text:span text:style-name="Span_subscript">
%s%s%s
</text:span>┃",
@@ -330,20 +331,20 @@ template formatODT() {
}
return objNum();
}
- @safe string _break_page()() {
+ string _break_page()() {
return format(q"┃
<text:p text:style-name="P_normal_page_new"/>
┃",
);
}
- @safe string _empty_line_break(O)(string _txt, const O obj) {
+ string _empty_line_break(O)(string _txt, const O obj) {
if (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block") {
_txt = _txt
.replaceAll(rgx.br_empty_line, "<br />");
}
return _txt;
}
- @safe string _links(O)(string _txt, const O obj) {
+ string _links(O)(string _txt, const O obj) {
if (obj.metainfo.is_a != "code") {
if (obj.metainfo.is_a == "toc") {
_txt = replaceAll!(m =>
@@ -383,7 +384,7 @@ template formatODT() {
}
return _txt;
}
- @safe string _images(O)(string _txt, const O obj) {
+ string _images(O)(string _txt, const O obj) {
if (_txt.match(rgx.inline_image)) {
_txt = _txt
.replaceAll(rgx.inline_image,
@@ -394,7 +395,7 @@ template formatODT() {
}
return _txt;
}
- @safe string markup(O)(const O obj) {
+ string markup(O)(const O obj) {
/+ markup TODO +/
string _txt = obj.text;
_txt = _special_characters(_txt, obj); // TODO & why both obj & obj.text, consider also in output_xmls.org
@@ -408,7 +409,7 @@ template formatODT() {
_txt = _empty_line_break(_txt, obj); // (obj.metainfo.is_a == "code" || obj.metainfo.is_a == "verse" || obj.metainfo.is_a == "block")
return _txt;
}
- @safe string heading(O,M)(
+ string heading(O,M)(
const O obj,
const M doc_matters,
) {
@@ -452,7 +453,7 @@ template formatODT() {
}
return _o_txt_odt;
}
- @safe string para(O,M)(
+ string para(O,M)(
const O obj,
const M doc_matters,
) {
@@ -471,7 +472,7 @@ template formatODT() {
}
return _o_txt_odt;
}
- @safe string quote(O,M)(
+ string quote(O,M)(
const O obj,
const M doc_matters,
) {
@@ -483,7 +484,7 @@ template formatODT() {
_o_txt_odt = _footnotes(_o_txt_odt); // decide
return _o_txt_odt;
}
- @safe string group(O,M)(
+ string group(O,M)(
const O obj,
const M doc_matters,
) {
@@ -501,7 +502,7 @@ template formatODT() {
_o_txt_odt = _block_type_delimiters(_block_lines, obj);
return _o_txt_odt;
}
- @safe string block(O,M)(
+ string block(O,M)(
const O obj,
const M doc_matters,
) {
@@ -514,7 +515,7 @@ template formatODT() {
_o_txt_odt = _block_type_delimiters(_block_lines, obj);
return _o_txt_odt;
}
- @safe string verse(O,M)(
+ string verse(O,M)(
const O obj,
const M doc_matters,
) {
@@ -527,7 +528,7 @@ template formatODT() {
_o_txt_odt = _block_type_delimiters(_block_lines, obj);
return _o_txt_odt;
}
- @safe string code(O,M)(
+ string code(O,M)(
const O obj,
const M doc_matters,
) {
@@ -574,7 +575,7 @@ template formatODT() {
_o_txt_odt = _block;
return _o_txt_odt;
}
- @safe Tuple!(string, string) tablarize(O)(
+ Tuple!(string, string) tablarize(O)(
const O obj,
string _txt,
) {
@@ -609,7 +610,7 @@ template formatODT() {
return t;
}
int _table_number = 0;
- @safe string table(O,M)(
+ string table(O,M)(
const O obj,
const M doc_matters,
) {
@@ -666,7 +667,7 @@ template outputODT() {
static auto rgx = RgxO();
static auto rgx_xhtml = RgxXHTML();
// mixin outputXmlODT;
- @safe string odt_head(I)(I doc_matters) {
+ string odt_head(I)(I doc_matters) {
string _has_tables = format(q"┃
<style:style style:name="Table1" style:family="table">
<style:table-properties style:width="16.999cm" table:align="margins"/>
@@ -774,7 +775,7 @@ template outputODT() {
);
return _odt_head;
}
- @safe string odt_body(D,I)(
+ string odt_body(D,I)(
const D doc_abstraction,
I doc_matters,
) {
@@ -900,12 +901,12 @@ template outputODT() {
return doc_odt;
}
- @safe string odt_tail() {
+ string odt_tail() {
string _odt_tail = format(q"┃<text:p text:style-name="P_normal">spine: &lt;<text:a xl:type="simple" xl:href="https://www.doc_reform.org">www.doc_reform.org</text:a>&gt; and &lt;<text:a xl:type="simple" xl:href="https://www.sisudoc.org">www.sisudoc.org</text:a>&gt;</text:p>
</office:text></office:body></office:document-content>┃",);
return _odt_tail;
}
- @safe string content_xml(D,I)(
+ string content_xml(D,I)(
const D doc_abstraction,
I doc_matters,
) {
@@ -918,7 +919,7 @@ template outputODT() {
_content_xml ~= odt_tail;
return _content_xml;
}
- @safe string manifest_xml(M)(
+ string manifest_xml(M)(
auto ref M doc_matters,
) {
string _bullet = format(q"┃<manifest:file-entry manifest:media-type="" manifest:full-path="Pictures/bullet_09.png"/>┃");
@@ -942,7 +943,7 @@ template outputODT() {
);
return _manifest_xml;
}
- @safe void images_cp(M)(
+ void images_cp(M)(
auto ref M doc_matters,
) {
{ /+ (copy odt images) +/
@@ -963,7 +964,7 @@ template outputODT() {
}
// return 0;
}
- @safe string meta_xml(M)(
+ string meta_xml(M)(
auto ref M doc_matters,
) {
/+ (meta_xml includes output time-stamp) +/
@@ -1011,11 +1012,11 @@ template outputODT() {
}
// return 0;
}
- @safe string mimetype() {
+ string mimetype() {
string mimetype_ = format(q"┃application/vnd.oasis.opendocument.text┃");
return mimetype_;
}
- @safe string manifest_rdf() {
+ string manifest_rdf() {
string _manifest_rdf = format(q"┃<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="https://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="styles.xml">
@@ -1037,7 +1038,7 @@ template outputODT() {
┃");
return _manifest_rdf;
}
- @safe string settings_xml() {
+ string settings_xml() {
string _settings_xml = format(q"┃<?xml version="1.0" encoding="UTF-8"?>
<office:document-settings xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xl="https://www.w3.org/1999/xlink" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="https://openoffice.org/2004/office" office:version="1.2">
<office:settings>
@@ -1137,7 +1138,7 @@ template outputODT() {
┃");
return _settings_xml;
}
- @safe string styles_xml() {
+ string styles_xml() {
string _styles_xml = format(q"┃<?xml version="1.0" encoding="UTF-8"?>
<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="https://www.w3.org/1999/xlink" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="https://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="https://openoffice.org/2004/office" xmlns:ooow="https://openoffice.org/2004/writer" xmlns:oooc="https://openoffice.org/2004/calc" xmlns:dom="https://www.w3.org/2001/xml-events" xmlns:rpt="https://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="https://www.w3.org/1999/xhtml" xmlns:grddl="https://www.w3.org/2003/g/data-view#" xmlns:tableooo="https://openoffice.org/2009/table" xmlns:css3t="https://www.w3.org/TR/css3-text/" office:version="1.2">
<office:font-face-decls>
@@ -2033,7 +2034,7 @@ template outputODT() {
┃");
return _styles_xml;
}
- void writeOutputODT(W,I)(
+ @trusted void writeOutputODT(W,I)(
const W odt_content,
I doc_matters,
) {
@@ -2092,7 +2093,7 @@ template outputODT() {
auto zip_arc_member_file = new ArchiveMember();
zip_arc_member_file.name = fn_out;
auto zip_data = new OutBuffer();
- zip_data.write(cast(char[]) ((fn_src).read));
+ zip_data.write(cast(char[]) ((fn_src).read)); // trusted?
zip_arc_member_file.expandedData = zip_data.toBytes();
zip.addMember(zip_arc_member_file);
createZipFile!()(fn_odt, zip.build());