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::FIRST_LVL_REQ, BaseConvert::MIDDLE_CLAUSE, BaseConvert::REQ_TBL_ATTR, BaseConvert::SUBMITTINGORGS
Instance Method Summary
collapse
#abstract, #annex_name, #cleanup, #conformance, #date_render, #example_parse, #extract_city, #extract_publisher, #extract_year, #fileloc, #foreword, #hierarchical_asset_names, #hierarchical_permission_names, #info, #initial_anchor_names, #keywords, #load_yaml, #middle, #middle_section_asset_names, #multiplenames, #multiplenames_and, #nodes_to_span, #nonstd_bibitem, #permission_parse, #preface_names_numbered, #recommend_class, #recommend_table_attr, #recommend_title, #recommendation_attributes, #recommendation_attributes1, #recommendation_header, #recommendation_name, #recommendation_parse, #recommendation_parse1, #reference_format, #reqt_dl, #requirement_component_parse, #requirement_parse, #requirement_table_cleanup, #sequential_asset_names, #sequential_permission_children, #sequential_permission_names, #sequential_permission_names1, #standard_citation, #std_bibitem_entry, #submitters, #submittingorgs, #term_cleanup
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
|
94
95
96
97
|
# File 'lib/isodoc/ogc/word_convert.rb', line 94
def (h)
h = h.to_s.gsub(/<\/?p[^>]*>/, "")
super
end
|
#insert_toc(intro, docxml, level) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/isodoc/ogc/word_convert.rb', line 52
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/isodoc/ogc/word_convert.rb', line 126
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
introduction docxml, div2
submittingorgs docxml, div2
submitters docxml, div2
div2.p { |p| p << " " } end
section_break(body)
end
|
108
109
110
111
112
113
114
115
|
# File 'lib/isodoc/ogc/word_convert.rb', line 108
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
117
118
119
120
121
122
123
124
|
# File 'lib/isodoc/ogc/word_convert.rb', line 117
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
99
100
101
102
103
104
105
106
|
# File 'lib/isodoc/ogc/word_convert.rb', line 99
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
|
#word_cleanup(docxml) ⇒ Object
141
142
143
144
|
# File 'lib/isodoc/ogc/word_convert.rb', line 141
def word_cleanup(docxml)
word_recommend_cleanup(docxml)
super
end
|
#word_recommend_cleanup(docxml) ⇒ Object
146
147
148
149
150
151
152
153
154
155
156
157
|
# File 'lib/isodoc/ogc/word_convert.rb', line 146
def word_recommend_cleanup(docxml)
docxml.xpath("//table[@class = 'recommendtest']/thead/tr").each do |tr|
style_update(tr, "background:#C9C9C9;")
end
docxml.xpath("//table[@class = 'recommend']/thead/tr").each do |tr|
style_update(tr, "background:#A5A5A5;")
end
docxml.xpath("//table[@class = 'recommend']/tbody/tr").
each_slice(2) do |tr1, tr2|
tr2 && style_update(tr2, "background:#C9C9C9;")
end
end
|