Class: IsoDoc::Ogc::WordConvert
- Inherits:
-
WordConvert
- Object
- WordConvert
- IsoDoc::Ogc::WordConvert
show all
- Includes:
- BaseConvert
- Defined in:
- lib/isodoc/ogc/word_convert.rb
Overview
A Converter implementation that generates Word output, and a document schema encapsulation of the document for validation
Constant Summary
collapse
- WORD_TOC_RECOMMENDATION_PREFACE1 =
<<~TOC.freeze
<span lang="EN-GB"><span
style='mso-element:field-begin'></span><span
style='mso-spacerun:yes'> </span>TOC
\\h \\z \\t "RecommendationTitle,1" <span
style='mso-element:field-separator'></span></span>
TOC
- WORD_TOC_TABLE_PREFACE1 =
<<~TOC.freeze
<span lang="EN-GB"><span
style='mso-element:field-begin'></span><span
style='mso-spacerun:yes'> </span>TOC
\\h \\z \\t "TableTitle,1" <span
style='mso-element:field-separator'></span></span>
TOC
- WORD_TOC_FIGURE_PREFACE1 =
<<~TOC.freeze
<span lang="EN-GB"><span
style='mso-element:field-begin'></span><span
style='mso-spacerun:yes'> </span>TOC
\\h \\z \\t "FigureTitle,1" <span
style='mso-element:field-separator'></span></span>
TOC
Constants included
from BaseConvert
BaseConvert::MIDDLE_CLAUSE, BaseConvert::REQ_TBL_ATTR, BaseConvert::SUBMITTINGORGS
Instance Method Summary
collapse
#abstract, #anchor_names, #annex_name, #cleanup, #conformance, #error_parse, #example_parse, #fileloc, #foreword, #info, #initial_anchor_names, #keywords, #load_yaml, #middle, #middle_section_asset_names, #permission_anchor_names, #permission_label, #permission_parse, #preface_names, #recommend_name_parse, #recommend_table_attr, #recommendation_anchor_names, #recommendation_label, #recommendation_parse, #requirement_anchor_names, #requirement_label, #requirement_parse, #submitters, #submittingorgs, #term_cleanup, #term_defs_boilerplate
Constructor Details
#initialize(options) ⇒ WordConvert
Returns a new instance of WordConvert.
12
13
14
15
16
|
# File 'lib/isodoc/ogc/word_convert.rb', line 12
def initialize(options)
@libdir = File.dirname(__FILE__)
super
end
|
Instance Method Details
#default_file_locations(options) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/isodoc/ogc/word_convert.rb', line 26
def default_file_locations(options)
{
wordstylesheet: html_doc_path("wordstyle.scss"),
standardstylesheet: html_doc_path("ogc.scss"),
header: html_doc_path("header.html"),
wordcoverpage: html_doc_path("word_ogc_titlepage.html"),
wordintropage: html_doc_path("word_ogc_intro.html"),
ulstyle: "l3",
olstyle: "l2",
}
end
|
#default_fonts(options) ⇒ Object
18
19
20
21
22
23
24
|
# File 'lib/isodoc/ogc/word_convert.rb', line 18
def default_fonts(options)
{
bodyfont: (options[:script] == "Hans" ? '"SimSun",serif' : '"Times New Roman",serif'),
headerfont: (options[:script] == "Hans" ? '"SimHei",sans-serif' : '"Times New Roman",serif'),
monospacefont: '"Courier New",monospace'
}
end
|
104
105
106
107
|
# File 'lib/isodoc/ogc/word_convert.rb', line 104
def (h)
h = h.to_s.gsub(/<\/?p[^>]*>/, "")
super
end
|
#insert_toc(intro, docxml, level) ⇒ Object
def make_body2(body, docxml)
body.div **{ class: "WordSection2" } do |div2|
info docxml, div2
div2.p { |p| p << " " } # placeholder
end
section_break(body)
end
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/isodoc/ogc/word_convert.rb', line 62
def insert_toc(intro, docxml, level)
toc = ""
toc += make_WordToC(docxml, level)
if docxml.at("//p[@class = 'TableTitle']")
toc += %{<p class="TOCTitle">List of Tables</p>}
toc += make_TableWordToC(docxml)
end
if docxml.at("//p[@class = 'FigureTitle']")
toc += %{<p class="TOCTitle">List of Figures</p>}
toc += make_FigureWordToC(docxml)
end
if docxml.at("//p[@class = 'RecommendationTitle']")
toc += %{<p class="TOCTitle">List of Recommendations</p>}
toc += make_RecommendationWordToC(docxml)
end
intro.sub(/WORDTOC/, toc)
end
|
#make_body(xml, docxml) ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/isodoc/ogc/word_convert.rb', line 43
def make_body(xml, docxml)
body_attr = { lang: "EN-US", link: "blue", vlink: "#954F72" }
xml.body **body_attr do |body|
make_body1(body, docxml)
make_body2(body, docxml)
make_body3(body, docxml)
end
end
|
#make_body2(body, docxml) ⇒ Object
136
137
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/isodoc/ogc/word_convert.rb', line 136
def make_body2(body, docxml)
body.div **{ class: "WordSection2" } do |div2|
@prefacenum = 0
info docxml, div2
abstract docxml, div2
keywords docxml, div2
foreword docxml, div2
submittingorgs docxml, div2
submitters docxml, div2
div2.p { |p| p << " " } end
section_break(body)
end
|
118
119
120
121
122
123
124
125
|
# File 'lib/isodoc/ogc/word_convert.rb', line 118
def make_FigureWordToC(docxml)
toc = ""
docxml.xpath("//p[@class = 'FigureTitle']").each do |h|
toc += word_toc_entry(1, (h))
end
toc.sub(/(<p class="MsoToc1">)/,
%{\\1#{WORD_TOC_FIGURE_PREFACE1}}) + WORD_TOC_SUFFIX1
end
|
#make_RecommendationWordToC(docxml) ⇒ Object
127
128
129
130
131
132
133
134
|
# File 'lib/isodoc/ogc/word_convert.rb', line 127
def make_RecommendationWordToC(docxml)
toc = ""
docxml.xpath("//p[@class = 'RecommendationTitle']").each do |h|
toc += word_toc_entry(1, (h))
end
toc.sub(/(<p class="MsoToc1">)/,
%{\\1#{WORD_TOC_RECOMMENDATION_PREFACE1}}) + WORD_TOC_SUFFIX1
end
|
#make_TableWordToC(docxml) ⇒ Object
109
110
111
112
113
114
115
116
|
# File 'lib/isodoc/ogc/word_convert.rb', line 109
def make_TableWordToC(docxml)
toc = ""
docxml.xpath("//p[@class = 'TableTitle']").each do |h|
toc += word_toc_entry(1, (h))
end
toc.sub(/(<p class="MsoToc1">)/,
%{\\1#{WORD_TOC_TABLE_PREFACE1}}) + WORD_TOC_SUFFIX1
end
|
39
40
41
|
# File 'lib/isodoc/ogc/word_convert.rb', line 39
def metadata_init(lang, script, labels)
@meta = Metadata.new(lang, script, labels)
end
|