redmine_api_helper 0.3.24

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of redmine_api_helper might be problematic. Click here for more details.

Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +2 -0
  3. data/.gitignore +11 -0
  4. data/CODE_OF_CONDUCT.md +74 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE +339 -0
  7. data/README.md +30 -0
  8. data/Rakefile +2 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/date_helper/date.rb +311 -0
  12. data/lib/odf_writer/bookmark.rb +110 -0
  13. data/lib/odf_writer/bookmark_reader.rb +77 -0
  14. data/lib/odf_writer/document.rb +372 -0
  15. data/lib/odf_writer/field.rb +174 -0
  16. data/lib/odf_writer/field_reader.rb +78 -0
  17. data/lib/odf_writer/image.rb +158 -0
  18. data/lib/odf_writer/image_reader.rb +76 -0
  19. data/lib/odf_writer/images.rb +89 -0
  20. data/lib/odf_writer/list_style.rb +331 -0
  21. data/lib/odf_writer/nested.rb +156 -0
  22. data/lib/odf_writer/odf_helper.rb +56 -0
  23. data/lib/odf_writer/parser/default.rb +685 -0
  24. data/lib/odf_writer/path_finder.rb +114 -0
  25. data/lib/odf_writer/section.rb +120 -0
  26. data/lib/odf_writer/section_reader.rb +61 -0
  27. data/lib/odf_writer/style.rb +417 -0
  28. data/lib/odf_writer/table.rb +135 -0
  29. data/lib/odf_writer/table_reader.rb +61 -0
  30. data/lib/odf_writer/template.rb +222 -0
  31. data/lib/odf_writer/text.rb +97 -0
  32. data/lib/odf_writer/text_reader.rb +77 -0
  33. data/lib/odf_writer/version.rb +29 -0
  34. data/lib/redmine_api_helper/api_helper.rb +333 -0
  35. data/lib/redmine_api_helper/args_helper.rb +106 -0
  36. data/lib/redmine_api_helper/attachments_api_helper.rb +52 -0
  37. data/lib/redmine_api_helper/define_api_helpers.rb +78 -0
  38. data/lib/redmine_api_helper/document_categories_api_helper.rb +38 -0
  39. data/lib/redmine_api_helper/groups_api_helper.rb +80 -0
  40. data/lib/redmine_api_helper/helpers.rb +50 -0
  41. data/lib/redmine_api_helper/issue_priorities_api_helper.rb +38 -0
  42. data/lib/redmine_api_helper/issue_relations_api_helper.rb +66 -0
  43. data/lib/redmine_api_helper/issue_statuses_api_helper.rb +36 -0
  44. data/lib/redmine_api_helper/issues_api_helper.rb +124 -0
  45. data/lib/redmine_api_helper/my_account_api_helper.rb +45 -0
  46. data/lib/redmine_api_helper/news_api_helper.rb +73 -0
  47. data/lib/redmine_api_helper/project_memberships_api_helper.rb +77 -0
  48. data/lib/redmine_api_helper/projects_api_helper.rb +73 -0
  49. data/lib/redmine_api_helper/roles_api_helper.rb +52 -0
  50. data/lib/redmine_api_helper/scripts_api_helper.rb +87 -0
  51. data/lib/redmine_api_helper/search_api_helper.rb +38 -0
  52. data/lib/redmine_api_helper/time_entries_api_helper.rb +73 -0
  53. data/lib/redmine_api_helper/time_entry_activities_api_helper.rb +38 -0
  54. data/lib/redmine_api_helper/trackers_api_helper.rb +38 -0
  55. data/lib/redmine_api_helper/users_api_helper.rb +73 -0
  56. data/lib/redmine_api_helper/version.rb +24 -0
  57. data/lib/redmine_api_helper/wiki_pages_api_helper.rb +66 -0
  58. data/lib/redmine_api_helper.rb +88 -0
  59. data/redmine_api_helper.gemspec +35 -0
  60. metadata +148 -0
@@ -0,0 +1,114 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Ruby Gem to create a self populating Open Document Format (.odf) text file.
4
+ #
5
+ # Copyright 2021 Stephan Wenzel <stephan.wenzel@drwpatent.de>
6
+ #
7
+ # This program is free software; you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License
9
+ # as published by the Free Software Foundation; either version 2
10
+ # of the License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
+ #
21
+
22
+ module ODFWriter
23
+
24
+ ########################################################################################
25
+ #
26
+ # PathFinder: find all fields and set name
27
+ #
28
+ ########################################################################################
29
+ class PathFinder
30
+
31
+ ######################################################################################
32
+ #
33
+ # constants
34
+ #
35
+ ######################################################################################
36
+ IGNORE = {
37
+ :fields => /\A_/,
38
+ :texts => /\A_/,
39
+ :bookmarks => /\A_/,
40
+ :images => /\A_/,
41
+ :tables => /\A_|\ATable/i,
42
+ :sections => /\A_|\ASection/i
43
+ }.freeze
44
+
45
+ class << self
46
+ ####################################################################################
47
+ #
48
+ # trail: find path in odt document, whereby only sections and tabes are searched as ancestors
49
+ #
50
+ # node: Nokogiri node
51
+ # leaf: hash, f.i. {:fields => ["NAME", "STREET", "ZIP", "PLACE"]}
52
+ #
53
+ # options:
54
+ # :root => :content | :styles, defaults to :root
55
+ # :paths => :auto vivifying-hash, defaults to it
56
+ #
57
+ ####################################################################################
58
+ def trail( node, leaf, options={})
59
+
60
+ # ignore
61
+ ignore = IGNORE.merge(options[:ignore].to_h)
62
+
63
+ # determine root
64
+ root = options[:root] || :root
65
+
66
+ # create auto-vivifying hash
67
+ paths = options[:paths] || Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
68
+
69
+ # for tables and sections add level with node name
70
+ ancestors = node.ancestors.reverse.select{|ancestor| %w(section table).include?(ancestor.name)}
71
+
72
+ path = [:files, root] + ancestors.map do |ancestor|
73
+ filter_node(ancestor, ignore)
74
+ end.flatten #map
75
+
76
+ # add each field in a nested hash
77
+ paths.dig(*path)[leaf.keys.first] = paths.dig(*path)[leaf.keys.first].presence || [] # cannot do '||=''
78
+ paths.dig(*path)[leaf.keys.first] += filter_leafs(leaf, ignore)
79
+ paths
80
+ end #def
81
+
82
+ ###################################################################################
83
+ #
84
+ # private
85
+ #
86
+ ###################################################################################
87
+ private
88
+
89
+ def filter_node(node, ignore)
90
+ case node.name
91
+ when "section"
92
+ node.attr("text:name").to_s.match?(Regexp.new(ignore[:sections].to_s)) ? [] : [:sections, node.attr("text:name")]
93
+ when "table"
94
+ node.attr("table:name").to_s.match?(Regexp.new(ignore[:tables].to_s)) ? [] : [:tables, node.attr("table:name")]
95
+ else
96
+ []
97
+ end #case
98
+ end #def
99
+
100
+ def filter_leafs(leaf, ignore)
101
+ case leaf.keys.first
102
+ when :fields
103
+ Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:fields].to_s))}
104
+ when :texts
105
+ Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:texts].to_s))}
106
+ when :bookmarks
107
+ Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:bookmarks].to_s))}
108
+ when :images
109
+ Array(leaf.values.first).select{|val| !val.match?(Regexp.new(ignore[:images].to_s))}
110
+ end #case
111
+ end #def
112
+ end #self
113
+ end #class
114
+ end #module
@@ -0,0 +1,120 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Ruby Gem to create a self populating Open Document Format (.odf) text file.
4
+ #
5
+ # Copyright 2021 Stephan Wenzel <stephan.wenzel@drwpatent.de>
6
+ #
7
+ # This program is free software; you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License
9
+ # as published by the Free Software Foundation; either version 2
10
+ # of the License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
+ #
21
+
22
+ module ODFWriter
23
+
24
+ ########################################################################################
25
+ #
26
+ # Section: poulate and grow sections
27
+ #
28
+ ########################################################################################
29
+ class Section
30
+ include Nested
31
+
32
+ attr_accessor :name, :collection, :proc
33
+
34
+ ######################################################################################
35
+ #
36
+ # initialize
37
+ #
38
+ ######################################################################################
39
+ def initialize(options)
40
+ @name = options[:name]
41
+ @field = options[:field]
42
+ @key = @field || @name
43
+ @collection = options[:collection]
44
+ @proc = options[:proc]
45
+
46
+ @fields = []
47
+ @bookmarks = []
48
+ @images = []
49
+ @texts = []
50
+ @tables = []
51
+ @sections = []
52
+ end #def
53
+
54
+ ######################################################################################
55
+ #
56
+ # get_section_content
57
+ #
58
+ ######################################################################################
59
+ def get_section_content( doc )
60
+ return unless @section_node = find_section_node(doc)
61
+ @section_node.content
62
+ end #def
63
+
64
+ ######################################################################################
65
+ #
66
+ # replace!
67
+ #
68
+ ######################################################################################
69
+ def replace!(doc, manifest, file, row = nil)
70
+
71
+ return unless @section_node = find_section_node(doc)
72
+
73
+ @collection = items(row, @key, @proc) if row
74
+
75
+ @collection.each do |item|
76
+
77
+ new_section = get_section_node
78
+ #
79
+ # experimental: new node must be added to doc prior to replace!
80
+ # else new_section does not have a name space
81
+ #
82
+ @section_node.before(new_section)
83
+
84
+ @tables.each { |t| t.replace!(new_section, manifest, file, item) }
85
+ @sections.each { |s| s.replace!(new_section, manifest, file, item) }
86
+ @texts.each { |t| t.replace!(new_section, item) }
87
+ @fields.each { |f| f.replace!(new_section, item) }
88
+ @bookmarks.each { |b| b.replace!(new_section, item) }
89
+ @images.each { |b| b.replace!(new_section, manifest, file, item) }
90
+
91
+ end
92
+
93
+ Image.unique_image_names( doc) if @images.present?
94
+
95
+ @section_node.remove
96
+
97
+ end #def
98
+
99
+ ######################################################################################
100
+ #
101
+ # private
102
+ #
103
+ ######################################################################################
104
+ private
105
+
106
+ def find_section_node(doc)
107
+ sections = doc.xpath(".//text:section[@text:name='#{@name}']")
108
+ sections.empty? ? nil : sections.first
109
+ end #def
110
+
111
+ def get_section_node
112
+ node = @section_node.dup
113
+ name = node.get_attribute('text:name').to_s
114
+ @idx ||=0; @idx +=1
115
+ node.set_attribute('text:name', "#{name}_#{@idx}")
116
+ node
117
+ end #def
118
+
119
+ end #class
120
+ end #module
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Ruby Gem to create a self populating Open Document Format (.odf) text file.
4
+ #
5
+ # Copyright 2021 Stephan Wenzel <stephan.wenzel@drwpatent.de>
6
+ #
7
+ # This program is free software; you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License
9
+ # as published by the Free Software Foundation; either version 2
10
+ # of the License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
+ #
21
+
22
+ module ODFWriter
23
+
24
+ ########################################################################################
25
+ #
26
+ # SectionReader: find all sections and set name
27
+ #
28
+ ########################################################################################
29
+ class SectionReader
30
+
31
+ attr_accessor :name
32
+
33
+ ######################################################################################
34
+ #
35
+ # initialize
36
+ #
37
+ ######################################################################################
38
+ def initialize(opts)
39
+ @name = opts[:name]
40
+ end #def
41
+
42
+ ######################################################################################
43
+ #
44
+ # sections
45
+ #
46
+ ######################################################################################
47
+ def sections( doc )
48
+ nodes( doc ).keys
49
+ end #def
50
+
51
+ ######################################################################################
52
+ #
53
+ # nodes
54
+ #
55
+ ######################################################################################
56
+ def nodes( doc )
57
+ doc.xpath(".//text:section").map{|node| [node.attr("text:name"), node] }.to_h
58
+ end #def
59
+
60
+ end #class
61
+ end #module
@@ -0,0 +1,417 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Ruby Gem to create a self populating Open Document Format (.odf) text file.
4
+ #
5
+ # Copyright 2021 Stephan Wenzel <stephan.wenzel@drwpatent.de>
6
+ #
7
+ # This program is free software; you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License
9
+ # as published by the Free Software Foundation; either version 2
10
+ # of the License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program; if not, write to the Free Software
19
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
+ #
21
+
22
+ module ODFWriter
23
+
24
+ ########################################################################################
25
+ #
26
+ # Style: add styles to styles.xml
27
+ #
28
+ ########################################################################################
29
+ class Style
30
+
31
+ ######################################################################################
32
+ #
33
+ # constants
34
+ #
35
+ ######################################################################################
36
+ ALL_STYLES = [:h1, :h2, :h3, :h4, :h5, :h6, :p, :mono, :monoright, :subparagraph,
37
+ :center, :left, :right, :justify, :cling, :bold, :underline, :italic,
38
+ :strikethrough, :sup, :sub, :a, :pre, :quote, :code, :table, :thrifty,
39
+ :list, :listmedium, :invoice, :boxes, :caption, :tiny, :tr, :td,
40
+ :tdbott, :tdbox, :tdhead, :tdfoot, :tc, :tcnarrow, :tcwide, :large,
41
+ :medium, :small]
42
+ LIST_STYLES = [:ul, :ol]
43
+
44
+ ######################################################################################
45
+ #
46
+ # initialize
47
+ #
48
+ ######################################################################################
49
+ def initialize( *styles )
50
+ @styles = *styles
51
+ @font = {}
52
+ end #def
53
+
54
+
55
+ ######################################################################################
56
+ #
57
+ # add_style
58
+ #
59
+ ######################################################################################
60
+ def add_style( doc )
61
+ ns = doc.collect_namespaces
62
+ automatic_styles = doc.at("//office:automatic-styles", ns)
63
+ font_declarations = doc.at("//office:font-face-decls", ns)
64
+
65
+ @styles.each do |style|
66
+
67
+ @font = nil # will be set in create_style
68
+
69
+ automatic_styles << create_style( doc, style ) if automatic_styles.present?
70
+
71
+ if @font.present?
72
+ font_declarations << create_font( doc, @font ) if font_declarations.present?
73
+ end
74
+ end
75
+
76
+ end #def
77
+
78
+ ######################################################################################
79
+ #
80
+ # private
81
+ #
82
+ ######################################################################################
83
+ private
84
+
85
+ def create_font( xml, font )
86
+ node = Nokogiri::XML::Node.new('style:font-face', xml)
87
+ node["style:name"] = font[:font_name]
88
+ node["svg:font-family"] = font[:font_family]
89
+ node["style:font-family-generic"] = font[:font_family_generic]
90
+ node["style:font-pitch"] = font[:font_pitch]
91
+ node
92
+ end #def
93
+
94
+ def create_style( xml, style )
95
+
96
+ node = Nokogiri::XML::Node.new('style:style', xml)
97
+
98
+ #
99
+ # common properties
100
+ #
101
+ case style
102
+
103
+ when :bold, :underline, :italic, :strikethrough, :sub, :sup, :code, :a, :large, :medium, :small
104
+ node["style:name"] =style.to_s
105
+ node["style:family"] ="text"
106
+
107
+ text_properties = Nokogiri::XML::Node.new('style:text-properties', xml)
108
+ node << text_properties
109
+
110
+ when /h(\d)/i
111
+ node["style:name"] =style.to_s
112
+ node["style:family"] ="paragraph"
113
+ node["style:parent-style-name"] ="body"
114
+ node["style:next-style-name"] ="subparagraph"
115
+ node["style:default-outline-level"] =$1
116
+
117
+ paragraph_properties = Nokogiri::XML::Node.new('style:paragraph-properties', xml)
118
+ node << paragraph_properties
119
+
120
+ text_properties = Nokogiri::XML::Node.new('style:text-properties', xml)
121
+ node << text_properties
122
+
123
+ when :p, :mono, :monoright, :cling
124
+ node["style:name"] =style.to_s
125
+ node["style:family"] ="paragraph"
126
+ node["style:parent-style-name"] ="body"
127
+ node["style:next-style-name"] ="paragraph"
128
+ node["style:default-outline-level"] =$1
129
+
130
+ paragraph_properties = Nokogiri::XML::Node.new('style:paragraph-properties', xml)
131
+ node << paragraph_properties
132
+
133
+ text_properties = Nokogiri::XML::Node.new('style:text-properties', xml)
134
+ node << text_properties
135
+
136
+ when :subparagraph
137
+ node["style:name"] =style.to_s
138
+ node["style:family"] ="paragraph"
139
+ node["style:parent-style-name"] ="paragraph"
140
+ node["style:next-style-name"] ="subparagraph"
141
+ node["style:default-outline-level"] =$1
142
+
143
+ paragraph_properties = Nokogiri::XML::Node.new('style:paragraph-properties', xml)
144
+ node << paragraph_properties
145
+
146
+ text_properties = Nokogiri::XML::Node.new('style:text-properties', xml)
147
+ node << text_properties
148
+
149
+ when :center, :left, :right, :justify
150
+ node["style:name"] =style.to_s
151
+ node["style:family"] ="paragraph"
152
+ node["style:parent-style-name"] ="paragraph"
153
+
154
+ paragraph_properties = Nokogiri::XML::Node.new('style:paragraph-properties', xml)
155
+ node << paragraph_properties
156
+
157
+ when :quote, :pre
158
+ node["style:name"] =style.to_s
159
+ node["style:family"] ="paragraph"
160
+ node["style:parent-style-name"] ="body"
161
+
162
+ paragraph_properties = Nokogiri::XML::Node.new('style:paragraph-properties', xml)
163
+ node << paragraph_properties
164
+
165
+ text_properties = Nokogiri::XML::Node.new('style:text-properties', xml)
166
+ node << text_properties
167
+
168
+ when :table, :list, :listmedium, :invoice, :boxes, :caption, :thrifty, :tiny
169
+ node["style:name"] =style.to_s
170
+ node["style:family"] ="table"
171
+
172
+ table_properties = Nokogiri::XML::Node.new('style:table-properties', xml)
173
+ node << table_properties
174
+
175
+ when :tr
176
+ node["style:name"] =style.to_s
177
+ node["style:family"] ="table-row"
178
+
179
+ table_row_properties = Nokogiri::XML::Node.new('style:table-row-properties', xml)
180
+ node << table_row_properties
181
+
182
+ when :tc, :tcnarrow, :tcwide
183
+ node["style:name"] =style.to_s
184
+ node["style:family"] ="table-column"
185
+
186
+ table_column_properties = Nokogiri::XML::Node.new('style:table-column-properties', xml)
187
+ node << table_column_properties
188
+
189
+ when :td, :tdbott, :tdhead, :tdfoot, :tdbox
190
+ node["style:name"] =style.to_s
191
+ node["style:family"] ="table-cell"
192
+
193
+ table_cell_properties = Nokogiri::XML::Node.new('style:table-cell-properties', xml)
194
+ node << table_cell_properties
195
+
196
+ end
197
+
198
+ #
199
+ # individual properties
200
+ #
201
+ case style
202
+
203
+ when :bold
204
+ text_properties["fo:font-weight"] ="bold"
205
+ text_properties["fo:font-weight-asian"] ="bold"
206
+
207
+ when :underline
208
+ text_properties["style:text-underline-type"] ="single"
209
+ text_properties["style:text-underline-style"] ="solid"
210
+ text_properties["style:text-underline-width"] ="auto"
211
+ text_properties["style:text-underline-mode"] ="continuous"
212
+
213
+ when :italic
214
+ text_properties["fo:font-style"] ="italic"
215
+ text_properties["fo:font-style-asian"] ="italic"
216
+
217
+ when :strikethrough
218
+ text_properties["style:text-line-through-style"] ="solid"
219
+ text_properties["style:text-line-through-type"] ="single"
220
+
221
+ when /h(\d)/i
222
+ paragraph_properties["fo:text-align"] ="left"
223
+ paragraph_properties["fo:line-height"] ="100%"
224
+ paragraph_properties["fo:margin-left"] ="0cm"
225
+ paragraph_properties["fo:margin-right"] ="0cm"
226
+ paragraph_properties["fo:keep-with-next"] ="always"
227
+ paragraph_properties["fo:margin-top"] ="1.25cm"
228
+ paragraph_properties["fo:margin-right"] ="0cm"
229
+ paragraph_properties["fo:margin-bottom"] ="0.5cm"
230
+ paragraph_properties["fo:margin-left"] ="1.25cm"
231
+ paragraph_properties["fo:text-indent"] ="-1.25cm"
232
+ paragraph_properties["style:auto-text-indent"] ="false"
233
+
234
+ text_properties["fo:font-weight"] ="bold"
235
+ text_properties["fo:font-weight-asian"] ="bold"
236
+ text_properties["fo:hyphenate"] ="true"
237
+
238
+ when :center, :left, :right, :justify
239
+ paragraph_properties["fo:text-align"] =style.to_s
240
+
241
+ when :quote
242
+ paragraph_properties["fo:text-align"] ="justify"
243
+ paragraph_properties["fo:line-height"] ="150%"
244
+ paragraph_properties["fo:margin-top"] ="0.5cm"
245
+ paragraph_properties["fo:margin-right"] ="1cm"
246
+ paragraph_properties["fo:margin-bottom"] ="0.5cm"
247
+ paragraph_properties["fo:margin-left"] ="1cm"
248
+
249
+ text_properties["fo:hyphenate"] ="true"
250
+ text_properties["fo:font-style"] ="italic"
251
+ text_properties["fo:font-style-asian"] ="italic"
252
+
253
+ when :mono
254
+ paragraph_properties["fo:text-align"] ="left"
255
+ paragraph_properties["fo:line-height"] ="100%"
256
+ paragraph_properties["fo:margin-top"] ="0cm"
257
+ paragraph_properties["fo:margin-right"] ="0.5cm"
258
+ paragraph_properties["fo:margin-bottom"] ="0cm"
259
+ paragraph_properties["fo:margin-left"] ="0cm"
260
+
261
+ text_properties["fo:hyphenate"] ="false"
262
+ text_properties["fo:font-weight"] ="bold"
263
+ text_properties["fo:font-weight-asian"] ="bold"
264
+
265
+ when :monoright
266
+ paragraph_properties["fo:text-align"] ="right"
267
+ paragraph_properties["fo:line-height"] ="100%"
268
+ paragraph_properties["fo:margin-top"] ="0cm"
269
+ paragraph_properties["fo:margin-right"] ="0cm"
270
+ paragraph_properties["fo:margin-bottom"] ="0cm"
271
+ paragraph_properties["fo:margin-left"] ="0cm"
272
+
273
+ text_properties["fo:hyphenate"] ="false"
274
+ text_properties["fo:font-weight"] ="bold"
275
+ text_properties["fo:font-weight-asian"] ="bold"
276
+
277
+ when :pre
278
+ paragraph_properties["fo:text-align"] ="left"
279
+ paragraph_properties["fo:line-height"] ="100%"
280
+ paragraph_properties["fo:margin-top"] ="0.5cm"
281
+ paragraph_properties["fo:margin-right"] ="1cm"
282
+ paragraph_properties["fo:margin-bottom"] ="0.5cm"
283
+ paragraph_properties["fo:margin-left"] ="1cm"
284
+ paragraph_properties["fo:background-color"] ="transparent"
285
+ paragraph_properties["fo:padding"] ="0.05cm"
286
+ paragraph_properties["fo:border"] ="0.06pt solid #000000"
287
+
288
+ text_properties["fo:hyphenate"] ="true"
289
+ text_properties["fo:font-style"] ="normal"
290
+ text_properties["fo:font-style-asian"] ="normal"
291
+ text_properties["style:font-name"] ="Courier New"
292
+ @font = {
293
+ :font_name => "'Courier New'",
294
+ :font_family => "'Courier New'",
295
+ :font_family_generic => "system",
296
+ :font_pitch => "fixed"
297
+ }
298
+
299
+ when :code
300
+ text_properties["fo:font-name"] ="Courier New"
301
+ @font = {
302
+ :font_name => "'Courier New'",
303
+ :font_family => "'Courier New'",
304
+ :font_family_generic => "system",
305
+ :font_pitch => "fixed"
306
+ }
307
+
308
+ when :cling
309
+ paragraph_properties["fo:keep-together"] ="always"
310
+ paragraph_properties["fo:keep-with-next"] ="always"
311
+
312
+ when :sup
313
+ text_properties["style:text-position"] ="super 58%"
314
+
315
+ when :sub
316
+ text_properties["style:text-position"] ="sub 58%"
317
+
318
+ when :a
319
+ text_properties["fo:color"] ="#0000ff"
320
+ text_properties["style:text-underline-type"] ="single"
321
+ text_properties["style:text-underline-style"] ="solid"
322
+ text_properties["style:text-underline-width"] ="auto"
323
+ text_properties["style:text-underline-mode"] ="continuous"
324
+
325
+ when :large
326
+ text_properties["fo:font-size"] ="18pt"
327
+ text_properties["style:font-size-asian"] ="18pt"
328
+ text_properties["style:font-size-complex"] ="18pt"
329
+
330
+ when :medium
331
+ text_properties["fo:font-size"] ="10pt"
332
+ text_properties["style:font-size-asian"] ="10pt"
333
+ text_properties["style:font-size-complex"] ="10pt"
334
+
335
+ when :small
336
+ text_properties["fo:font-size"] ="8pt"
337
+ text_properties["style:font-size-asian"] ="8pt"
338
+ text_properties["style:font-size-complex"] ="8pt"
339
+
340
+ when :table, :list, :listmedium, :invoice, :boxes, :caption, :tiny
341
+ table_properties["style:rel-width"] ="100%"
342
+ table_properties["fo:margin-top"] ="0cm"
343
+ table_properties["fo:margin-right"] ="0cm"
344
+ table_properties["fo:margin-bottom"] ="0cm"
345
+ table_properties["fo:margin-left"] ="0cm"
346
+ table_properties["fo:text-align"] ="left"
347
+
348
+ when :thrifty
349
+ table_properties["style:rel-width"] ="50%"
350
+ table_properties["fo:margin-top"] ="0cm"
351
+ table_properties["fo:margin-right"] ="0cm"
352
+ table_properties["fo:margin-bottom"] ="0cm"
353
+ table_properties["fo:margin-left"] ="0cm"
354
+ table_properties["fo:text-align"] ="left"
355
+
356
+ when :tr
357
+ # currently, nothing
358
+
359
+ when :tc
360
+ table_column_properties["style:column-width"] ="1cm"
361
+ table_column_properties["style:rel-column-width"] ="1*"
362
+ # MS Word errors, if this parameter is set
363
+ #table_column_properties["style:use-optimal-column-width "] ="true"
364
+
365
+ when :tcnarrow
366
+ table_column_properties["style:column-width"] ="0.5in"
367
+ table_column_properties["style:use-optimal-column-width "] ="false"
368
+
369
+ when :tcwide
370
+ table_column_properties["style:column-width"] ="2.0in"
371
+ table_column_properties["style:use-optimal-column-width "] ="false"
372
+
373
+ when :td
374
+ table_cell_properties["style:writing-mode"] ="lr-tb"
375
+ table_cell_properties["fo:padding-top"] ="0cm"
376
+ table_cell_properties["fo:padding-right"] ="0.2cm"
377
+ table_cell_properties["fo:padding-bottom"] ="0.2cm"
378
+ table_cell_properties["fo:padding-left"] ="0cm"
379
+
380
+ when :tdbott
381
+ table_cell_properties["style:writing-mode"] ="lr-tb"
382
+ table_cell_properties["style:vertical-align"] ="bottom"
383
+ table_cell_properties["fo:padding-top"] ="0cm"
384
+ table_cell_properties["fo:padding-right"] ="0cm"
385
+ table_cell_properties["fo:padding-bottom"] ="0cm"
386
+ table_cell_properties["fo:padding-left"] ="0cm"
387
+
388
+ when :tdhead
389
+ table_cell_properties["style:writing-mode"] ="lr-tb"
390
+ table_cell_properties["fo:padding-top"] ="0cm"
391
+ table_cell_properties["fo:padding-right"] ="0cm"
392
+ table_cell_properties["fo:padding-bottom"] ="0.2cm"
393
+ table_cell_properties["fo:padding-left"] ="0cm"
394
+ table_cell_properties["fo:border-bottom"] ="0.5pt solid #000000"
395
+
396
+ when :tdfoot
397
+ table_cell_properties["style:writing-mode"] ="lr-tb"
398
+ table_cell_properties["fo:padding-top"] ="0.2cm"
399
+ table_cell_properties["fo:padding-right"] ="0cm"
400
+ table_cell_properties["fo:padding-bottom"] ="0cm"
401
+ table_cell_properties["fo:padding-left"] ="0cm"
402
+ table_cell_properties["fo:border-top"] ="0.5pt solid #000000"
403
+
404
+ when :tdbox
405
+ table_cell_properties["style:writing-mode"] ="lr-tb"
406
+ table_cell_properties["fo:padding-top"] ="0cm"
407
+ table_cell_properties["fo:padding-right"] ="0cm"
408
+ table_cell_properties["fo:padding-bottom"] ="0cm"
409
+ table_cell_properties["fo:padding-left"] ="0cm"
410
+ table_cell_properties["fo:border"] ="0.5pt solid #000000"
411
+ end
412
+
413
+ node
414
+ end #def
415
+
416
+ end #class
417
+ end #module