powerpoint 1.5 → 1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +8 -8
  2. data/.codeclimate.yml +9 -0
  3. data/.gitignore +1 -0
  4. data/Gemfile +1 -1
  5. data/lib/powerpoint.rb +3 -6
  6. data/lib/powerpoint/presentation.rb +37 -22
  7. data/lib/powerpoint/slide/intro.rb +21 -11
  8. data/lib/powerpoint/slide/pictorial.rb +42 -94
  9. data/lib/powerpoint/slide/textual.rb +20 -14
  10. data/lib/powerpoint/util.rb +26 -0
  11. data/lib/powerpoint/version.rb +1 -1
  12. data/lib/powerpoint/views/content_type.xml.erb +30 -0
  13. data/lib/powerpoint/views/intro_slide.xml.erb +74 -0
  14. data/lib/powerpoint/views/pictorial_rel.xml.erb +5 -0
  15. data/lib/powerpoint/views/pictorial_slide.xml.erb +87 -0
  16. data/lib/powerpoint/views/presentation.xml.erb +124 -0
  17. data/lib/powerpoint/views/presentation.xml.rel.erb +12 -0
  18. data/lib/powerpoint/views/textual_rel.xml.erb +4 -0
  19. data/lib/powerpoint/views/textual_slide.xml.erb +78 -0
  20. data/powerpoint.gemspec +4 -1
  21. data/samples/pptx/sample.pptx +0 -0
  22. data/spec/test_spec.rb +1 -2
  23. data/template/_rels/.rels +5 -1
  24. data/template/docProps/app.xml +2 -0
  25. data/template/docProps/core.xml +7 -0
  26. data/template/ppt/{media/README → _rels/.keep} +0 -0
  27. data/template/ppt/media/.keep +0 -0
  28. data/template/ppt/presProps.xml +13 -1
  29. data/template/ppt/slideLayouts/_rels/slideLayout1.xml.rels +0 -0
  30. data/template/ppt/slideLayouts/_rels/slideLayout10.xml.rels +0 -0
  31. data/template/ppt/slideLayouts/_rels/slideLayout11.xml.rels +0 -0
  32. data/template/ppt/slideLayouts/_rels/slideLayout2.xml.rels +0 -0
  33. data/template/ppt/slideLayouts/_rels/slideLayout3.xml.rels +0 -0
  34. data/template/ppt/slideLayouts/_rels/slideLayout4.xml.rels +0 -0
  35. data/template/ppt/slideLayouts/_rels/slideLayout5.xml.rels +0 -0
  36. data/template/ppt/slideLayouts/_rels/slideLayout6.xml.rels +0 -0
  37. data/template/ppt/slideLayouts/_rels/slideLayout7.xml.rels +0 -0
  38. data/template/ppt/slideLayouts/_rels/slideLayout8.xml.rels +0 -0
  39. data/template/ppt/slideLayouts/_rels/slideLayout9.xml.rels +0 -0
  40. data/template/ppt/slideLayouts/slideLayout1.xml +236 -1
  41. data/template/ppt/slideLayouts/slideLayout10.xml +1 -1
  42. data/template/ppt/slideLayouts/slideLayout11.xml +1 -1
  43. data/template/ppt/slideLayouts/slideLayout2.xml +164 -1
  44. data/template/ppt/slideLayouts/slideLayout3.xml +1 -1
  45. data/template/ppt/slideLayouts/slideLayout4.xml +1 -1
  46. data/template/ppt/slideLayouts/slideLayout5.xml +1 -1
  47. data/template/ppt/slideLayouts/slideLayout6.xml +1 -1
  48. data/template/ppt/slideLayouts/slideLayout7.xml +1 -1
  49. data/template/ppt/slideLayouts/slideLayout8.xml +1 -1
  50. data/template/ppt/slideLayouts/slideLayout9.xml +1 -1
  51. data/template/ppt/slideMasters/_rels/slideMaster1.xml.rels +1 -1
  52. data/template/ppt/slideMasters/slideMaster1.xml +504 -1
  53. data/template/ppt/slides/_rels/.keep +0 -0
  54. data/template/ppt/tableStyles.xml +0 -0
  55. data/template/ppt/theme/theme1.xml +0 -0
  56. data/template/ppt/viewProps.xml +31 -1
  57. metadata +45 -15
  58. data/lib/powerpoint/content_type.rb +0 -14
  59. data/lib/powerpoint/meta.rb +0 -14
  60. data/lib/powerpoint/relationship.rb +0 -14
  61. data/lib/powerpoint/slide/relationship.rb +0 -15
  62. data/samples/images/sample_svg.svg +0 -69
  63. data/template/[Content_Types].xml +0 -32
  64. data/template/ppt/_rels/presentation.xml.rels +0 -2
  65. data/template/ppt/presentation.xml +0 -2
  66. data/template/ppt/slides/_rels/slide1.xml.rels +0 -2
  67. data/template/ppt/slides/_rels/slide2.xml.rels +0 -2
  68. data/template/ppt/slides/slide1.xml +0 -6
  69. data/template/ppt/slides/slide2.xml +0 -6
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mjk0N2U2ODk3YjIzNDkzY2Q4NTdiODBkNDc4Zjc0YWYyYzc3NzJlZQ==
4
+ ZmRkNjczMjVlMGFjMWMxMWYxOTNhY2NhNDFiMjA3MmU1NjU1ODNhZg==
5
5
  data.tar.gz: !binary |-
6
- MzY5NWE3NGMyMzI1YTM0MWJlMDBlMTBlZGRmYjFlZWVhNjFlNTM0NA==
6
+ Mjg1OGZiYmFjY2ZiNjExY2JmYjkxNDk2MWJkMGYyMmI3MTk2ZDM5Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODc4MjM2MDMxZWQ4OWM4ZWY4ZmMwZmVkYzY1MzAzZTMzMDMzNTdmYjJiMTcw
10
- MTgyYzc4NDQyNDY5YTY0ZDQyNGJkM2MzMWUwYWUzMDk1YjIxMGIwNmRhNDA1
11
- NjA1MWQ0NTU3YzI4NGE0OTViMzg5OTJkMjMyYWUwNjQ2NDFiOWI=
9
+ NTRhMmJiYjI0YWY4MDBhYTliZTYzOTU5ZjU4ODI5N2E0Yzk1OGM4NTI3YjEx
10
+ NmY2ZjBlZDVjZjZmNzY0YThmMWQ4N2VkYTE5OTdiNjRjOWUxMmZiYmU5ZjIy
11
+ ZGVjMDhmY2I5ZmM5NmE0Nzc3NzVjZWM4NzI1NmUzZTQxZDJjNTU=
12
12
  data.tar.gz: !binary |-
13
- ZjdkMzhjZDMwOTkxZGQ0NWUyNWFhMWM5ODdhMDhhMTJiYmI2ZjM4MThiYTY2
14
- MzE5NTFlNzdmMDdkODljMzVhYWI5NDcxZjc5ZjZkMTAyYjdlYTIxZWI5ZTUy
15
- NjdjNGI0ZDdjOTNhOTAxMmNiZTM3ZmZiYWM0MjM5ZWQ1ZTJjZDA=
13
+ MWJhZjNkODJkYmUwNGZlMDgxNGZlYzg1NGRhNzMyNGQ0N2JiYmEwZDczMGVk
14
+ ZjU1Y2UwYjUwYzdhNmYyNTc4ODdiOTczNGIxNmQ1YTlhMzFiN2I3YzZjMzdj
15
+ ZjljYTZmYjI5MzI1OTM3OTk2ZmZkZDUyMTU0YzRlMDI0YzJlNTI=
@@ -0,0 +1,9 @@
1
+ ---
2
+ engines:
3
+ rubocop:
4
+ enabled: true
5
+ ratings:
6
+ paths:
7
+ - powerpoint/**
8
+ exclude_paths:
9
+ - spec/**/*
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .pryrc
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in powerpoint.gemspec
4
- gemspec
4
+ gemspec
@@ -1,18 +1,15 @@
1
1
  require "powerpoint/version"
2
+ require 'powerpoint/util'
2
3
  require 'powerpoint/slide/intro'
3
4
  require 'powerpoint/slide/textual'
4
5
  require 'powerpoint/slide/pictorial'
5
- require 'powerpoint/relationship'
6
- require 'powerpoint/slide/relationship'
7
- require 'powerpoint/content_type'
8
- require 'powerpoint/meta'
9
6
  require 'powerpoint/presentation'
10
7
 
11
8
  module Powerpoint
12
9
 
13
10
  spec = Gem::Specification.find_by_name("powerpoint")
14
- gem_root = spec.gem_dir
15
- TEMPLATE_PATH = "#{gem_root}/template/"
11
+ ROOT_PATH = spec.gem_dir
12
+ TEMPLATE_PATH = "#{ROOT_PATH}/template/"
16
13
 
17
14
  def self.decompress_pptx in_path, out_path
18
15
  Zip::File.open(in_path) do |zip_file|
@@ -3,48 +3,63 @@ require 'fileutils'
3
3
  require 'tmpdir'
4
4
 
5
5
  module Powerpoint
6
- class Powerpoint::Presentation
6
+ class Presentation
7
+ include Powerpoint::Util
7
8
 
8
- attr_reader :pptx_path, :extract_path
9
+ attr_reader :pptx_path, :extract_path, :slides
9
10
 
10
11
  def initialize
11
- @slide_count = 0
12
- @extract_path = File.join Dir.tmpdir, "extract_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}"
13
- FileUtils.copy_entry TEMPLATE_PATH, @extract_path
12
+ @slides = []
14
13
  end
15
14
 
16
15
  def add_intro title, subtitile=nil
17
- @slide_count += 1
18
- Powerpoint::Slide::Intro.new @extract_path, title, subtitile
16
+ existing_intro_slide = @slides.select {|s| s.class == Powerpoint::Slide::Intro}[0]
17
+ slide = Powerpoint::Slide::Intro.new(presentation: self, title: title, subtitile: subtitile)
18
+ if existing_intro_slide
19
+ @slides[@slides.index(existing_intro_slide)] = slide
20
+ else
21
+ @slides.insert 0, slide
22
+ end
19
23
  end
20
24
 
21
25
  def add_textual_slide title, content=[]
22
- @slide_count += 1
23
- Powerpoint::Slide::Textual.new @extract_path, title, content, @slide_count
24
- Powerpoint::Slide::Relationship.new @extract_path, @slide_count
25
- setablish_relationships
26
+ @slides << Powerpoint::Slide::Textual.new(presentation: self, title: title, content: content)
26
27
  end
27
28
 
28
29
  def add_pictorial_slide title, image_path, coords={}
29
- @slide_count += 1
30
- Powerpoint::Slide::Pictorial.new @extract_path, title, image_path, @slide_count, coords
31
- setablish_relationships
32
- end
33
-
34
- def setablish_relationships
35
- if @slide_count > 2
36
- Powerpoint::ContentType.new @extract_path, @slide_count
37
- Powerpoint::Relationship.new @extract_path, @slide_count
38
- Powerpoint::Meta.new @extract_path, @slide_count
39
- end
30
+ @slides << Powerpoint::Slide::Pictorial.new(presentation: self, title: title, image_path: image_path, coords: coords)
40
31
  end
41
32
 
42
33
  def save path
34
+ # Copy template to temp path
35
+ @extract_path = File.join(Dir.tmpdir, "extract_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}")
36
+ FileUtils.copy_entry TEMPLATE_PATH, @extract_path
37
+
38
+ # Remove keep files
39
+ FileUtils.rm_rf("#{@extract_path}/ppt/_rels/.keep")
40
+ FileUtils.rm_rf("#{@extract_path}/ppt/media/.keep")
41
+ FileUtils.rm_rf("#{@extract_path}/ppt/slides/_rels/.keep")
42
+
43
+ # Render/save generic stuff
44
+ File.open("#{extract_path}/[Content_Types].xml", 'w') { |f| f << render_view('content_type.xml.erb') }
45
+ File.open("#{extract_path}/ppt/_rels/presentation.xml.rels", 'w') { |f| f << render_view('presentation.xml.rel.erb') }
46
+ File.open("#{extract_path}/ppt/presentation.xml", 'w') { |f| f << render_view('presentation.xml.erb') }
47
+
48
+ # Save slides
49
+ slides.each_with_index do |slide, index|
50
+ slide.save(index + 1)
51
+ end
52
+
53
+ # Create .pptx file
43
54
  @pptx_path = path
44
55
  File.delete(path) if File.exist?(path)
45
56
  Powerpoint.compress_pptx @extract_path, @pptx_path
46
57
  FileUtils.rm_rf(@extract_path)
47
58
  path
48
59
  end
60
+
61
+ def file_types
62
+ slides.select {|slide| slide.class == Powerpoint::Slide::Pictorial}.map(&:file_type).uniq
63
+ end
49
64
  end
50
65
  end
@@ -1,21 +1,31 @@
1
- require 'zip/filesystem'
2
1
  require 'fileutils'
2
+ require 'erb'
3
3
 
4
4
  module Powerpoint
5
5
  module Slide
6
- class Powerpoint::Slide::Intro
7
- def initialize extract_path, title, subtitile=nil
8
- template_path = "#{TEMPLATE_PATH}/ppt/slides/slide1.xml"
9
- xml = File.read template_path
6
+ class Intro
7
+ include Powerpoint::Util
8
+
9
+ attr_reader :title, :subtitile
10
10
 
11
- xml_title = '<a:p><a:r><a:rPr lang="en-US" dirty="0" smtClean="0"/><a:t>' + title.to_s + '</a:t></a:r><a:endParaRPr lang="en-US" dirty="0"/></a:p>'
12
- xml.gsub!('PRESENTATION_TITLE_PACEHOLDER', xml_title)
11
+ def initialize(options={})
12
+ require_arguments [:title, :subtitile], options
13
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
14
+ end
15
+
16
+ def save(index)
17
+ save_rel_xml(index)
18
+ save_slide_xml(index)
19
+ end
13
20
 
14
- xml_subtitle = '<a:p><a:r><a:rPr lang="en-US" dirty="0" smtClean="0"/><a:t>' + subtitile.to_s+ '</a:t></a:r><a:endParaRPr lang="en-US" dirty="0"/></a:p>'
15
- xml.gsub!('PRESENTATION_SUBTITLE_PACEHOLDER', xml_subtitle)
21
+ private
22
+
23
+ def save_rel_xml index
24
+ File.open("#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", 'w'){ |f| f << render_view('textual_rel.xml.erb') }
25
+ end
16
26
 
17
- intro_slide_path = "#{extract_path}/ppt/slides/slide1.xml"
18
- File.open(intro_slide_path, 'w'){ |f| f << xml }
27
+ def save_slide_xml index
28
+ File.open("#{extract_path}/ppt/slides/slide#{index}.xml", 'w'){ |f| f << render_view('intro_slide.xml.erb') }
19
29
  end
20
30
  end
21
31
  end
@@ -1,108 +1,56 @@
1
1
  require 'zip/filesystem'
2
2
  require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
3
5
 
4
6
  module Powerpoint
5
7
  module Slide
6
- class Powerpoint::Slide::Pictorial
7
- def initialize extract_path, title, image_path, slide_number, coords={}
8
-
9
- image_name = File.basename(image_path)
10
- FileUtils.copy_file(image_path, "#{extract_path}/ppt/media/#{image_name}")
8
+ class Pictorial
9
+ include Powerpoint::Util
11
10
 
12
- coords_tag = (coords.empty?) ? '' : '<p:spPr>
13
- <a:xfrm>
14
- <a:off x="' + coords[:x].to_s + '" y="' + coords[:y].to_s + '" />
15
- <a:ext cx="' + coords[:cx].to_s + '" cy="' + coords[:cy].to_s + '" />
16
- </a:xfrm>
17
- </p:spPr>'
11
+ attr_reader :image_name, :title, :coords, :image_path
18
12
 
19
- rel_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
20
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
21
- <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/' + image_name + '" />
22
- <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="../slideLayouts/slideLayout2.xml" />
23
- </Relationships>'
13
+ def initialize(options={})
14
+ require_arguments [:presentation, :title, :image_path], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @coords = default_coords unless @coords.any?
17
+ @image_name = File.basename(@image_path)
18
+ end
19
+
20
+ def save(index)
21
+ copy_media_to_extract_path
22
+ save_rel_xml(index)
23
+ save_slide_xml(index)
24
+ end
24
25
 
25
- rel_path = "#{extract_path}/ppt/slides/_rels/slide#{slide_number}.xml.rels"
26
- File.open(rel_path, 'w'){ |f| f << rel_xml }
26
+ def file_type
27
+ File.extname(image_name).gsub('.', '')
28
+ end
29
+
30
+ private
27
31
 
28
- slide_xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
29
- <p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
30
- <p:cSld>
31
- <p:spTree>
32
- <p:nvGrpSpPr>
33
- <p:cNvPr id="1" name="" />
34
- <p:cNvGrpSpPr />
35
- <p:nvPr />
36
- </p:nvGrpSpPr>
37
- <p:grpSpPr>
38
- <a:xfrm>
39
- <a:off x="0" y="0" />
40
- <a:ext cx="0" cy="0" />
41
- <a:chOff x="0" y="0" />
42
- <a:chExt cx="0" cy="0" />
43
- </a:xfrm>
44
- </p:grpSpPr>
45
- <p:sp>
46
- <p:nvSpPr>
47
- <p:cNvPr id="2" name="Title 1" />
48
- <p:cNvSpPr>
49
- <a:spLocks noGrp="1" />
50
- </p:cNvSpPr>
51
- <p:nvPr>
52
- <p:ph type="title" />
53
- </p:nvPr>
54
- </p:nvSpPr>
55
- <p:spPr />
56
- <p:txBody>
57
- <a:bodyPr />
58
- <a:lstStyle />
59
- <a:p>
60
- <a:r>
61
- <a:rPr lang="en-US" dirty="0" smtClean="0" />
62
- <a:t>' + title + '</a:t>
63
- </a:r>
64
- <a:endParaRPr lang="en-US" dirty="0" />
65
- </a:p>
66
- </p:txBody>
67
- </p:sp>
68
- <p:pic>
69
- <p:nvPicPr>
70
- <p:cNvPr id="4" name="Content Placeholder 3" />
71
- <p:cNvPicPr>
72
- <a:picLocks noGrp="1" noChangeAspect="1" />
73
- </p:cNvPicPr>
74
- <p:nvPr>
75
- <p:ph idx="1" />
76
- </p:nvPr>
77
- </p:nvPicPr>
78
- <p:blipFill>
79
- <a:blip r:embed="rId2">
80
- <a:extLst>
81
- <a:ext uri="{28A0092B-C50C-407E-A947-70E740481C1C}">
82
- <a14:useLocalDpi xmlns:a14="http://schemas.microsoft.com/office/drawing/2010/main" val="0" />
83
- </a:ext>
84
- </a:extLst>
85
- </a:blip>
86
- <a:stretch>
87
- <a:fillRect />
88
- </a:stretch>
89
- </p:blipFill>' + coords_tag +
90
- '</p:pic>
91
- </p:spTree>
92
- <p:extLst>
93
- <p:ext uri="{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}">
94
- <p14:creationId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main" val="1474098577" />
95
- </p:ext>
96
- </p:extLst>
97
- </p:cSld>
98
- <p:clrMapOvr>
99
- <a:masterClrMapping />
100
- </p:clrMapOvr>
101
- </p:sld>'
32
+ def default_coords
33
+ slide_width = pixle_to_pt(720); slide_height = pixle_to_pt(540); default_width = pixle_to_pt(550)
34
+ return {} unless dimensions = FastImage.size(image_path)
35
+ image_width, image_height = dimensions.map {|d| pixle_to_pt(d)}
36
+ new_width = default_width < image_width ? default_width : image_width
37
+ ratio = new_width / image_width.to_f
38
+ new_height = (image_height.to_f * ratio).round
39
+ {x: (slide_width / 2) - (new_width/2), y: pixle_to_pt(120), cx: new_width, cy: new_height}
40
+ end
102
41
 
103
- slide_path = "#{extract_path}/ppt/slides/slide#{slide_number}.xml"
104
- File.open(slide_path, 'w'){ |f| f << slide_xml }
42
+ def copy_media_to_extract_path
43
+ FileUtils.copy_file(@image_path, "#{extract_path}/ppt/media/#{@image_name}")
105
44
  end
45
+
46
+ def save_rel_xml index
47
+ File.open("#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", 'w'){ |f| f << render_view('pictorial_rel.xml.erb') }
48
+ end
49
+
50
+ def save_slide_xml index
51
+ File.open("#{extract_path}/ppt/slides/slide#{index}.xml", 'w'){ |f| f << render_view('pictorial_slide.xml.erb') }
52
+ end
53
+
106
54
  end
107
55
  end
108
56
  end
@@ -1,25 +1,31 @@
1
- require 'zip/filesystem'
2
1
  require 'fileutils'
2
+ require 'erb'
3
3
 
4
4
  module Powerpoint
5
5
  module Slide
6
- class Powerpoint::Slide::Textual
7
- def initialize extract_path, title, content, slide_number
8
- template_path = "#{TEMPLATE_PATH}/ppt/slides/slide2.xml"
9
- xml = File.read template_path
6
+ class Textual
7
+ include Powerpoint::Util
8
+
9
+ attr_reader :title, :content
10
10
 
11
- title_xml = '<a:p><a:r><a:rPr lang="en-US" dirty="0" smtClean="0"/><a:t>'+ title.to_s + '</a:t></a:r><a:endParaRPr lang="en-US" dirty="0"/></a:p>'
12
- xml.gsub!('SLIDE_TITLE_PACEHOLDER', title_xml)
11
+ def initialize(options={})
12
+ require_arguments [:title, :content], options
13
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
14
+ end
15
+
16
+ def save(index)
17
+ save_rel_xml(index)
18
+ save_slide_xml(index)
19
+ end
13
20
 
14
- content_xml = ''
15
- content.each do |i|
16
- content_xml += '<a:p><a:r><a:rPr lang="en-US" dirty="0" smtClean="0"/><a:t>' + i.to_s + '</a:t></a:r></a:p>'
17
- end
21
+ private
18
22
 
19
- xml.gsub!('CONTENT_PACEHOLDER', content_xml)
23
+ def save_rel_xml index
24
+ File.open("#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", 'w'){ |f| f << render_view('textual_rel.xml.erb') }
25
+ end
20
26
 
21
- slide_path = "#{extract_path}/ppt/slides/slide#{slide_number}.xml"
22
- File.open(slide_path, 'w'){ |f| f << xml }
27
+ def save_slide_xml index
28
+ File.open("#{extract_path}/ppt/slides/slide#{index}.xml", 'w'){ |f| f << render_view('textual_slide.xml.erb') }
23
29
  end
24
30
  end
25
31
  end
@@ -0,0 +1,26 @@
1
+ module Powerpoint
2
+ module Util
3
+
4
+ def pixle_to_pt(px)
5
+ px * 12700
6
+ end
7
+
8
+ def render_view(filename)
9
+ view_contents = read_template(filename)
10
+ renderer = ERB.new(view_contents)
11
+ renderer.result( binding )
12
+ end
13
+
14
+ def read_template(filename)
15
+ File.read(Powerpoint::ROOT_PATH + "/lib/powerpoint/views/#{filename}")
16
+ end
17
+
18
+ def require_arguments(required_argements, argements)
19
+ raise ArgumentError unless required_argements.all? {|required_key| argements.keys.include? required_key}
20
+ end
21
+
22
+ def extract_path
23
+ @presentation.extract_path
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module Powerpoint
2
- VERSION = "1.5"
2
+ VERSION = "1.6"
3
3
  end
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
3
+ <Default ContentType="application/xml" Extension="xml"/>
4
+ <Default ContentType="application/vnd.openxmlformats-package.relationships+xml" Extension="rels"/>
5
+ <% file_types.each do |type| %>
6
+ <Default ContentType="image/<%= type %>" Extension="<%= type %>"/>
7
+ <% end %>
8
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" PartName="/ppt/presentation.xml"/>
9
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml" PartName="/ppt/slideMasters/slideMaster1.xml"/>
10
+ <% slides.each_with_index do |slide, index| %>
11
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml" PartName="/ppt/slides/slide<%= index + 1 %>.xml"/>
12
+ <% end %>
13
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.presProps+xml" PartName="/ppt/presProps.xml"/>
14
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml" PartName="/ppt/viewProps.xml"/>
15
+ <Override ContentType="application/vnd.openxmlformats-officedocument.theme+xml" PartName="/ppt/theme/theme1.xml"/>
16
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml" PartName="/ppt/tableStyles.xml"/>
17
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout1.xml"/>
18
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout2.xml"/>
19
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout3.xml"/>
20
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout4.xml"/>
21
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout5.xml"/>
22
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout6.xml"/>
23
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout7.xml"/>
24
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout8.xml"/>
25
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout9.xml"/>
26
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout10.xml"/>
27
+ <Override ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml" PartName="/ppt/slideLayouts/slideLayout11.xml"/>
28
+ <Override ContentType="application/vnd.openxmlformats-package.core-properties+xml" PartName="/docProps/core.xml"/>
29
+ <Override ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml" PartName="/docProps/app.xml"/>
30
+ </Types>