odf-report 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,44 +0,0 @@
1
- module ODFReport
2
-
3
- module Images
4
-
5
- IMAGE_DIR_NAME = "Pictures"
6
-
7
- def find_image_name_matches(content)
8
-
9
- @images.each_pair do |image_name, path|
10
- if node = content.xpath("//draw:frame[@draw:name='#{image_name}']/draw:image").first
11
- placeholder_path = node.attribute('href').value
12
- @image_names_replacements[path] = ::File.join(IMAGE_DIR_NAME, ::File.basename(placeholder_path))
13
- end
14
- end
15
-
16
- end
17
-
18
- def include_image_files(file)
19
-
20
- return if @images.empty?
21
-
22
- @image_names_replacements.each_pair do |path, template_image|
23
-
24
- file.output_stream.put_next_entry(template_image)
25
- file.output_stream.write ::File.read(path)
26
-
27
- end
28
-
29
- end # replace_images
30
-
31
- # newer versions of LibreOffice can't open files with duplicates image names
32
- def avoid_duplicate_image_names(content)
33
-
34
- nodes = content.xpath("//draw:frame[@draw:name]")
35
-
36
- nodes.each_with_index do |node, i|
37
- node.attribute('name').value = "pic_#{i}"
38
- end
39
-
40
- end
41
-
42
- end
43
-
44
- end