redmine_api_helper 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of redmine_api_helper might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.gitattributes +2 -0
- data/.gitignore +11 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +339 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/date_helper/date.rb +311 -0
- data/lib/odf_writer/bookmark.rb +110 -0
- data/lib/odf_writer/bookmark_reader.rb +77 -0
- data/lib/odf_writer/document.rb +372 -0
- data/lib/odf_writer/field.rb +174 -0
- data/lib/odf_writer/field_reader.rb +78 -0
- data/lib/odf_writer/image.rb +158 -0
- data/lib/odf_writer/image_reader.rb +76 -0
- data/lib/odf_writer/images.rb +89 -0
- data/lib/odf_writer/list_style.rb +331 -0
- data/lib/odf_writer/nested.rb +156 -0
- data/lib/odf_writer/odf_helper.rb +56 -0
- data/lib/odf_writer/parser/default.rb +685 -0
- data/lib/odf_writer/path_finder.rb +114 -0
- data/lib/odf_writer/section.rb +120 -0
- data/lib/odf_writer/section_reader.rb +61 -0
- data/lib/odf_writer/style.rb +417 -0
- data/lib/odf_writer/table.rb +135 -0
- data/lib/odf_writer/table_reader.rb +61 -0
- data/lib/odf_writer/template.rb +222 -0
- data/lib/odf_writer/text.rb +97 -0
- data/lib/odf_writer/text_reader.rb +77 -0
- data/lib/odf_writer/version.rb +29 -0
- data/lib/redmine_api_helper/api_helper.rb +333 -0
- data/lib/redmine_api_helper/args_helper.rb +106 -0
- data/lib/redmine_api_helper/attachments_api_helper.rb +52 -0
- data/lib/redmine_api_helper/define_api_helpers.rb +78 -0
- data/lib/redmine_api_helper/document_categories_api_helper.rb +38 -0
- data/lib/redmine_api_helper/groups_api_helper.rb +80 -0
- data/lib/redmine_api_helper/helpers.rb +50 -0
- data/lib/redmine_api_helper/issue_priorities_api_helper.rb +38 -0
- data/lib/redmine_api_helper/issue_relations_api_helper.rb +66 -0
- data/lib/redmine_api_helper/issue_statuses_api_helper.rb +36 -0
- data/lib/redmine_api_helper/issues_api_helper.rb +124 -0
- data/lib/redmine_api_helper/my_account_api_helper.rb +45 -0
- data/lib/redmine_api_helper/news_api_helper.rb +73 -0
- data/lib/redmine_api_helper/project_memberships_api_helper.rb +77 -0
- data/lib/redmine_api_helper/projects_api_helper.rb +73 -0
- data/lib/redmine_api_helper/roles_api_helper.rb +52 -0
- data/lib/redmine_api_helper/scripts_api_helper.rb +87 -0
- data/lib/redmine_api_helper/search_api_helper.rb +38 -0
- data/lib/redmine_api_helper/time_entries_api_helper.rb +73 -0
- data/lib/redmine_api_helper/time_entry_activities_api_helper.rb +38 -0
- data/lib/redmine_api_helper/trackers_api_helper.rb +38 -0
- data/lib/redmine_api_helper/users_api_helper.rb +73 -0
- data/lib/redmine_api_helper/version.rb +24 -0
- data/lib/redmine_api_helper/wiki_pages_api_helper.rb +66 -0
- data/lib/redmine_api_helper.rb +88 -0
- data/redmine_api_helper.gemspec +35 -0
- metadata +148 -0
@@ -0,0 +1,78 @@
|
|
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
|
+
# FieldReader: find all fields and set name
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
class FieldReader
|
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
|
+
# paths
|
45
|
+
#
|
46
|
+
######################################################################################
|
47
|
+
def paths( file, doc)
|
48
|
+
|
49
|
+
# find nodes with matching field elements matching [FIELD] pattern
|
50
|
+
nodes = doc.xpath("//text()").select{|node| scan(node).present? }
|
51
|
+
|
52
|
+
|
53
|
+
# find path for each field
|
54
|
+
paths = nil
|
55
|
+
nodes.each do |node|
|
56
|
+
leaf = {:fields => scan(node)}
|
57
|
+
paths = PathFinder.trail(node, leaf, :root => file, :paths => paths)
|
58
|
+
end #each
|
59
|
+
paths.to_h
|
60
|
+
|
61
|
+
end #def
|
62
|
+
|
63
|
+
######################################################################################
|
64
|
+
# private
|
65
|
+
######################################################################################
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def scan(node)
|
70
|
+
if name
|
71
|
+
node.text.scan(/(?<=#{Regexp.escape Field::DELIMITERS[0]})#{name.upcase}(?=#{Regexp.escape Field::DELIMITERS[1]})/)
|
72
|
+
else
|
73
|
+
node.text.scan(/(?<=#{Regexp.escape Field::DELIMITERS[0]})[A-Z0-9_]+?(?=#{Regexp.escape Field::DELIMITERS[1]})/)
|
74
|
+
end
|
75
|
+
end #def
|
76
|
+
|
77
|
+
end #class
|
78
|
+
end #module
|
@@ -0,0 +1,158 @@
|
|
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
|
+
# Image: replace images
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
class Image < Field
|
30
|
+
|
31
|
+
######################################################################################
|
32
|
+
#
|
33
|
+
# constants
|
34
|
+
#
|
35
|
+
######################################################################################
|
36
|
+
IMAGE_DIR_NAME = "Pictures"
|
37
|
+
|
38
|
+
######################################################################################
|
39
|
+
#
|
40
|
+
# replace!
|
41
|
+
#
|
42
|
+
######################################################################################
|
43
|
+
def replace!(doc, manifest, template, item=nil )
|
44
|
+
|
45
|
+
image_data = value(item)
|
46
|
+
|
47
|
+
if is_image?(image_data)
|
48
|
+
|
49
|
+
# find placeholder image
|
50
|
+
nodes = find_image_nodes( doc )
|
51
|
+
return if nodes.blank?
|
52
|
+
|
53
|
+
# find manifest
|
54
|
+
man = manifest.xpath("//manifest:manifest") rescue nil
|
55
|
+
return if man.blank?
|
56
|
+
|
57
|
+
# each placeholder image
|
58
|
+
nodes.each do |node|
|
59
|
+
|
60
|
+
# create unique filename for image in .odt file
|
61
|
+
path = ::File.join(IMAGE_DIR_NAME, "#{SecureRandom.hex(20).upcase}#{::File.extname(image_data[:filename])}")
|
62
|
+
mime = Rack::Mime.mime_type(File.extname(image_data[:filename]))
|
63
|
+
|
64
|
+
# set path and mime type of placeholder image
|
65
|
+
node.attribute('href').value = path
|
66
|
+
if node.attribute('mime-type').present?
|
67
|
+
node.attribute('mime-type').value = mime
|
68
|
+
else
|
69
|
+
node.set_attribute('mime-type', mime)
|
70
|
+
end
|
71
|
+
|
72
|
+
# set width and height of placeholder image
|
73
|
+
parent = node.parent
|
74
|
+
if parent.name == "frame"
|
75
|
+
width = parent.attribute('width').value
|
76
|
+
height = parent.attribute('height').value
|
77
|
+
parent.attribute('height').value = recalc_height(:x => image_data[:width], :y => image_data[:height], :newx => width, :newy => height)
|
78
|
+
end
|
79
|
+
|
80
|
+
# add image to .odt file
|
81
|
+
add_image_file( image_data[:bytes], path, mime, doc, man, template )
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end #def
|
87
|
+
|
88
|
+
def self.unique_image_names(doc)
|
89
|
+
nodes = doc.xpath("//draw:frame[@draw:name='#{@name}']")
|
90
|
+
padding = Math.log10(nodes.length).to_i + 1 if nodes.present?
|
91
|
+
nodes.each_with_index do |node, i|
|
92
|
+
num = "%.#{padding}i" % i
|
93
|
+
node.attribute('name').value = "IMAGE_#{num}_" + node.attribute('name').value
|
94
|
+
end
|
95
|
+
end #def
|
96
|
+
|
97
|
+
######################################################################################
|
98
|
+
#
|
99
|
+
# private
|
100
|
+
#
|
101
|
+
######################################################################################
|
102
|
+
private
|
103
|
+
|
104
|
+
######################################################################################
|
105
|
+
# is_image?
|
106
|
+
######################################################################################
|
107
|
+
def is_image?(obj)
|
108
|
+
obj.is_a?(Hash) && (obj.keys & [:filename, :width, :height, :bytes]).length == 4
|
109
|
+
end #def
|
110
|
+
|
111
|
+
######################################################################################
|
112
|
+
# find_image_nodes
|
113
|
+
######################################################################################
|
114
|
+
def find_image_nodes(doc)
|
115
|
+
doc.xpath(".//draw:frame[@draw:name='#{@name}']/draw:image")
|
116
|
+
end #def
|
117
|
+
|
118
|
+
######################################################################################
|
119
|
+
# recalc_height
|
120
|
+
######################################################################################
|
121
|
+
def recalc_height(nums)
|
122
|
+
|
123
|
+
numericals = {}
|
124
|
+
dimensions = {}
|
125
|
+
|
126
|
+
#remove dimensions like 'px' or 'cm' or 'in' or 'pt'
|
127
|
+
[:x, :y, :newx, :newy].each do |v|
|
128
|
+
num = nums[v].to_s.match(/[0-9.]+/)
|
129
|
+
numericals[v] = num[0].to_f if num
|
130
|
+
dimensions[v] = nums[v].to_s.gsub(/\A[0-9.]+/, "")
|
131
|
+
end
|
132
|
+
|
133
|
+
if [:x, :y, :newx, :newy].all?{|i| numericals[i].present? }
|
134
|
+
y = numericals[:newx] / numericals[:x] * numericals[:y]
|
135
|
+
end
|
136
|
+
|
137
|
+
y ? "#{'%.3f'%y}#{dimensions[:newy]}" : nums[:newy]
|
138
|
+
|
139
|
+
end #def
|
140
|
+
|
141
|
+
######################################################################################
|
142
|
+
# add_image_file
|
143
|
+
######################################################################################
|
144
|
+
def add_image_file(bytes, path, mime, doc, manifest, template )
|
145
|
+
|
146
|
+
file_entry = Nokogiri::XML::Node.new('manifest:file-entry', doc)
|
147
|
+
file_entry.set_attribute('manifest:full-path', path)
|
148
|
+
file_entry.set_attribute('manifest:media-type', mime)
|
149
|
+
manifest.children.after file_entry
|
150
|
+
|
151
|
+
template.output_stream.put_next_entry(path)
|
152
|
+
template.output_stream.write bytes
|
153
|
+
|
154
|
+
end #def
|
155
|
+
|
156
|
+
|
157
|
+
end #class
|
158
|
+
end #module
|
@@ -0,0 +1,76 @@
|
|
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
|
+
# ImageReader: find all images and set name
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
class ImageReader
|
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
|
+
# get_paths: limit to paths with ancestors 'text '(content.xml) and master-styles (styles.xml)
|
45
|
+
#
|
46
|
+
######################################################################################
|
47
|
+
def paths( root, doc)
|
48
|
+
|
49
|
+
# find nodes with matching field elements matching [BOOKMARK] pattern
|
50
|
+
nodes = doc.xpath("//draw:frame[draw:image]").select{|node| scan(node).present? }
|
51
|
+
|
52
|
+
# find path for each field
|
53
|
+
paths = nil
|
54
|
+
nodes.each do |node|
|
55
|
+
leaf = {:images => scan(node)}
|
56
|
+
paths = PathFinder.trail(node, leaf, :root => root, :paths => paths)
|
57
|
+
end #each
|
58
|
+
paths.to_h
|
59
|
+
|
60
|
+
end #def
|
61
|
+
|
62
|
+
######################################################################################
|
63
|
+
# private
|
64
|
+
######################################################################################
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def scan(node)
|
69
|
+
if name
|
70
|
+
node.attr("draw:name") == name.upcase ? [node.attr("draw:name")] : []
|
71
|
+
else
|
72
|
+
[node.attr("draw:name")]
|
73
|
+
end
|
74
|
+
end #def
|
75
|
+
end #class
|
76
|
+
end #module
|
@@ -0,0 +1,89 @@
|
|
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
|
+
# Images: replace images
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
module Images
|
30
|
+
|
31
|
+
######################################################################################
|
32
|
+
#
|
33
|
+
# constants
|
34
|
+
#
|
35
|
+
######################################################################################
|
36
|
+
IMAGE_DIR_NAME = "Pictures"
|
37
|
+
|
38
|
+
######################################################################################
|
39
|
+
#
|
40
|
+
# find_image_name_matches
|
41
|
+
#
|
42
|
+
######################################################################################
|
43
|
+
def find_image_name_matches(content)
|
44
|
+
|
45
|
+
@images.each_pair do |image_name, img_data|
|
46
|
+
if node = content.xpath("//draw:frame[@draw:name='#{image_name}']/draw:image").first
|
47
|
+
placeholder_path = node.attribute('href').value
|
48
|
+
@image_names_replacements[path] = ::File.join(IMAGE_DIR_NAME, ::File.basename(placeholder_path))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end #def
|
53
|
+
|
54
|
+
######################################################################################
|
55
|
+
#
|
56
|
+
# include_image_files
|
57
|
+
#
|
58
|
+
######################################################################################
|
59
|
+
def include_image_files(file)
|
60
|
+
|
61
|
+
return if @images.empty?
|
62
|
+
|
63
|
+
@image_names_replacements.each_pair do |path, template_image|
|
64
|
+
|
65
|
+
file.output_stream.put_next_entry(template_image)
|
66
|
+
file.output_stream.write ::File.read(path)
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end #def
|
71
|
+
|
72
|
+
######################################################################################
|
73
|
+
#
|
74
|
+
# avoid_duplicate_image_names
|
75
|
+
#
|
76
|
+
######################################################################################
|
77
|
+
# newer versions of LibreOffice can't open files with duplicates image names
|
78
|
+
def avoid_duplicate_image_names(content)
|
79
|
+
|
80
|
+
nodes = content.xpath("//draw:frame[@draw:name]")
|
81
|
+
|
82
|
+
nodes.each_with_index do |node, i|
|
83
|
+
node.attribute('name').value = "pic_#{i}"
|
84
|
+
end
|
85
|
+
|
86
|
+
end #def
|
87
|
+
|
88
|
+
end #class
|
89
|
+
end #module
|
@@ -0,0 +1,331 @@
|
|
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
|
+
# ListStyle: add style for ul, ol up to 6 levels deep
|
27
|
+
#
|
28
|
+
########################################################################################
|
29
|
+
class ListStyle
|
30
|
+
|
31
|
+
######################################################################################
|
32
|
+
#
|
33
|
+
# initialize
|
34
|
+
#
|
35
|
+
######################################################################################
|
36
|
+
def initialize( list_style )
|
37
|
+
@list_style = list_style
|
38
|
+
@font = {}
|
39
|
+
end #def
|
40
|
+
|
41
|
+
######################################################################################
|
42
|
+
#
|
43
|
+
# add_list_style
|
44
|
+
#
|
45
|
+
######################################################################################
|
46
|
+
def add_list_style( xml )
|
47
|
+
|
48
|
+
ns = xml.collect_namespaces
|
49
|
+
automatic_styles = xml.at("//office:automatic-styles", ns)
|
50
|
+
automatic_styles << create_list( xml ) if automatic_styles.present?
|
51
|
+
|
52
|
+
if @font.present?
|
53
|
+
font_declarations = xml.at("//office:font-face-decls", ns)
|
54
|
+
font_declarations << create_font( xml ) if font_declarations.present?
|
55
|
+
end
|
56
|
+
|
57
|
+
end #def
|
58
|
+
|
59
|
+
######################################################################################
|
60
|
+
#
|
61
|
+
# private
|
62
|
+
#
|
63
|
+
######################################################################################
|
64
|
+
private
|
65
|
+
|
66
|
+
def create_font( xml )
|
67
|
+
node = Nokogiri::XML::Node.new('style:font-face', xml)
|
68
|
+
node["style:name"] = @font[:font_name]
|
69
|
+
node["svg:font-family"] = @font[:font_family]
|
70
|
+
node["style:font-family-generic"] = @font[:font_family_generic]
|
71
|
+
node["style:font-pitch"] = @font[:font_pitch]
|
72
|
+
node
|
73
|
+
end #def
|
74
|
+
|
75
|
+
def create_list( xml )
|
76
|
+
|
77
|
+
list_style = Nokogiri::XML::Node.new('text:list-style', xml)
|
78
|
+
|
79
|
+
#
|
80
|
+
# common properties
|
81
|
+
#
|
82
|
+
case @list_style
|
83
|
+
|
84
|
+
when :ul
|
85
|
+
list_style['style:name'] = "ul"
|
86
|
+
|
87
|
+
#
|
88
|
+
# Level 1
|
89
|
+
#
|
90
|
+
list_bullet = Nokogiri::XML::Node.new('text:list-level-style-bullet', xml)
|
91
|
+
list_bullet['text:level'] = "1"
|
92
|
+
list_bullet['text:bullet-char'] = "•"
|
93
|
+
list_style << list_bullet
|
94
|
+
|
95
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
96
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
97
|
+
list_bullet << list_level
|
98
|
+
|
99
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
100
|
+
list_label['text:label-followed-by'] = "listtab"
|
101
|
+
list_label['text:list-tab-stop-position'] = "1cm"
|
102
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
103
|
+
list_label['fo:margin-left'] = "1cm"
|
104
|
+
list_level << list_label
|
105
|
+
|
106
|
+
#
|
107
|
+
# Level 2
|
108
|
+
#
|
109
|
+
list_bullet = Nokogiri::XML::Node.new('text:list-level-style-bullet', xml)
|
110
|
+
list_bullet['text:level'] = "2"
|
111
|
+
list_bullet['text:bullet-char'] = "◦"
|
112
|
+
list_style << list_bullet
|
113
|
+
|
114
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
115
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
116
|
+
list_bullet << list_level
|
117
|
+
|
118
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
119
|
+
list_label['text:label-followed-by'] = "listtab"
|
120
|
+
list_label['text:list-tab-stop-position'] = "1.5cm"
|
121
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
122
|
+
list_label['fo:margin-left'] = "1.5cm"
|
123
|
+
list_level << list_label
|
124
|
+
|
125
|
+
#
|
126
|
+
# Level 3
|
127
|
+
#
|
128
|
+
list_bullet = Nokogiri::XML::Node.new('text:list-level-style-bullet', xml)
|
129
|
+
list_bullet['text:level'] = "3"
|
130
|
+
list_bullet['text:bullet-char'] = "▪"
|
131
|
+
list_style << list_bullet
|
132
|
+
|
133
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
134
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
135
|
+
list_bullet << list_level
|
136
|
+
|
137
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
138
|
+
list_label['text:label-followed-by'] = "listtab"
|
139
|
+
list_label['text:list-tab-stop-position'] = "2cm"
|
140
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
141
|
+
list_label['fo:margin-left'] = "2cm"
|
142
|
+
list_level << list_label
|
143
|
+
|
144
|
+
#
|
145
|
+
# Level 4
|
146
|
+
#
|
147
|
+
list_bullet = Nokogiri::XML::Node.new('text:list-level-style-bullet', xml)
|
148
|
+
list_bullet['text:level'] = "4"
|
149
|
+
list_bullet['text:bullet-char'] = "•"
|
150
|
+
list_style << list_bullet
|
151
|
+
|
152
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
153
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
154
|
+
list_bullet << list_level
|
155
|
+
|
156
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
157
|
+
list_label['text:label-followed-by'] = "listtab"
|
158
|
+
list_label['text:list-tab-stop-position'] = "2.5cm"
|
159
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
160
|
+
list_label['fo:margin-left'] = "2.5cm"
|
161
|
+
list_level << list_label
|
162
|
+
|
163
|
+
#
|
164
|
+
# Level 5
|
165
|
+
#
|
166
|
+
list_bullet = Nokogiri::XML::Node.new('text:list-level-style-bullet', xml)
|
167
|
+
list_bullet['text:level'] = "5"
|
168
|
+
list_bullet['text:bullet-char'] = "◦"
|
169
|
+
list_style << list_bullet
|
170
|
+
|
171
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
172
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
173
|
+
list_bullet << list_level
|
174
|
+
|
175
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
176
|
+
list_label['text:label-followed-by'] = "listtab"
|
177
|
+
list_label['text:list-tab-stop-position'] = "3cm"
|
178
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
179
|
+
list_label['fo:margin-left'] = "3cm"
|
180
|
+
list_level << list_label
|
181
|
+
|
182
|
+
#
|
183
|
+
# Level 6
|
184
|
+
#
|
185
|
+
list_bullet = Nokogiri::XML::Node.new('text:list-level-style-bullet', xml)
|
186
|
+
list_bullet['text:level'] = "6"
|
187
|
+
list_bullet['text:bullet-char'] = "▪"
|
188
|
+
list_style << list_bullet
|
189
|
+
|
190
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
191
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
192
|
+
list_bullet << list_level
|
193
|
+
|
194
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
195
|
+
list_label['text:label-followed-by'] = "listtab"
|
196
|
+
list_label['text:list-tab-stop-position'] = "3.5cm"
|
197
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
198
|
+
list_label['fo:margin-left'] = "3.5cm"
|
199
|
+
list_level << list_label
|
200
|
+
|
201
|
+
when :ol
|
202
|
+
list_style['style:name'] = "ol"
|
203
|
+
|
204
|
+
#
|
205
|
+
# Level 1
|
206
|
+
#
|
207
|
+
list_number = Nokogiri::XML::Node.new('text:list-level-style-number', xml)
|
208
|
+
list_number['text:level'] = "1"
|
209
|
+
list_number['style:num-suffix'] = "."
|
210
|
+
list_number['style:num-format'] = "1"
|
211
|
+
list_style << list_number
|
212
|
+
|
213
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
214
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
215
|
+
list_number << list_level
|
216
|
+
|
217
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
218
|
+
list_label['text:label-followed-by'] = "listtab"
|
219
|
+
list_label['text:list-tab-stop-position'] = "1cm"
|
220
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
221
|
+
list_label['fo:margin-left'] = "1cm"
|
222
|
+
list_level << list_label
|
223
|
+
|
224
|
+
#
|
225
|
+
# Level 2
|
226
|
+
#
|
227
|
+
list_number = Nokogiri::XML::Node.new('text:list-level-style-number', xml)
|
228
|
+
list_number['text:level'] = "2"
|
229
|
+
list_number['style:num-suffix'] = "."
|
230
|
+
list_number['style:num-format'] = "1"
|
231
|
+
list_style << list_number
|
232
|
+
|
233
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
234
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
235
|
+
list_number << list_level
|
236
|
+
|
237
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
238
|
+
list_label['text:label-followed-by'] = "listtab"
|
239
|
+
list_label['text:list-tab-stop-position'] = "1.5cm"
|
240
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
241
|
+
list_label['fo:margin-left'] = "1.5cm"
|
242
|
+
list_level << list_label
|
243
|
+
|
244
|
+
#
|
245
|
+
# Level 3
|
246
|
+
#
|
247
|
+
list_number = Nokogiri::XML::Node.new('text:list-level-style-number', xml)
|
248
|
+
list_number['text:level'] = "3"
|
249
|
+
list_number['style:num-suffix'] = "."
|
250
|
+
list_number['style:num-format'] = "1"
|
251
|
+
list_style << list_number
|
252
|
+
|
253
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
254
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
255
|
+
list_number << list_level
|
256
|
+
|
257
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
258
|
+
list_label['text:label-followed-by'] = "listtab"
|
259
|
+
list_label['text:list-tab-stop-position'] = "2cm"
|
260
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
261
|
+
list_label['fo:margin-left'] = "2cm"
|
262
|
+
list_level << list_label
|
263
|
+
|
264
|
+
#
|
265
|
+
# Level 4
|
266
|
+
#
|
267
|
+
list_number = Nokogiri::XML::Node.new('text:list-level-style-number', xml)
|
268
|
+
list_number['text:level'] = "4"
|
269
|
+
list_number['style:num-suffix'] = "."
|
270
|
+
list_number['style:num-format'] = "1"
|
271
|
+
list_style << list_number
|
272
|
+
|
273
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
274
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
275
|
+
list_number << list_level
|
276
|
+
|
277
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
278
|
+
list_label['text:label-followed-by'] = "listtab"
|
279
|
+
list_label['text:list-tab-stop-position'] = "2.5cm"
|
280
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
281
|
+
list_label['fo:margin-left'] = "2.5cm"
|
282
|
+
list_level << list_label
|
283
|
+
|
284
|
+
#
|
285
|
+
# Level 5
|
286
|
+
#
|
287
|
+
list_number = Nokogiri::XML::Node.new('text:list-level-style-number', xml)
|
288
|
+
list_number['text:level'] = "5"
|
289
|
+
list_number['style:num-suffix'] = "."
|
290
|
+
list_number['style:num-format'] = "1"
|
291
|
+
list_style << list_number
|
292
|
+
|
293
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
294
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
295
|
+
list_number << list_level
|
296
|
+
|
297
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
298
|
+
list_label['text:label-followed-by'] = "listtab"
|
299
|
+
list_label['text:list-tab-stop-position'] = "3cm"
|
300
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
301
|
+
list_label['fo:margin-left'] = "3cm"
|
302
|
+
list_level << list_label
|
303
|
+
|
304
|
+
#
|
305
|
+
# Level 6
|
306
|
+
#
|
307
|
+
list_number = Nokogiri::XML::Node.new('text:list-level-style-number', xml)
|
308
|
+
list_number['text:level'] = "6"
|
309
|
+
list_number['style:num-suffix'] = "."
|
310
|
+
list_number['style:num-format'] = "1"
|
311
|
+
list_style << list_number
|
312
|
+
|
313
|
+
list_level = Nokogiri::XML::Node.new('style:list-level-properties', xml)
|
314
|
+
list_level['text:list-level-position-and-space-mode'] = "label-alignment"
|
315
|
+
list_number << list_level
|
316
|
+
|
317
|
+
list_label = Nokogiri::XML::Node.new('style:list-level-label-alignment', xml)
|
318
|
+
list_label['text:label-followed-by'] = "listtab"
|
319
|
+
list_label['text:list-tab-stop-position'] = "3.5cm"
|
320
|
+
list_label['fo:text-indent'] = "-0.5cm"
|
321
|
+
list_label['fo:margin-left'] = "3.5cm"
|
322
|
+
list_level << list_label
|
323
|
+
|
324
|
+
end
|
325
|
+
|
326
|
+
list_style
|
327
|
+
|
328
|
+
end #def
|
329
|
+
|
330
|
+
end #class
|
331
|
+
end #module
|