powerpoint-pro 2.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +9 -0
  3. data/.gitignore +19 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +83 -0
  7. data/Rakefile +7 -0
  8. data/lib/powerpoint/compression.rb +25 -0
  9. data/lib/powerpoint/presentation.rb +118 -0
  10. data/lib/powerpoint/slide/collage.rb +47 -0
  11. data/lib/powerpoint/slide/comment.rb +39 -0
  12. data/lib/powerpoint/slide/concept.rb +48 -0
  13. data/lib/powerpoint/slide/custom.rb +50 -0
  14. data/lib/powerpoint/slide/dashboard.rb +45 -0
  15. data/lib/powerpoint/slide/dashboard_user.rb +40 -0
  16. data/lib/powerpoint/slide/extended_intro.rb +38 -0
  17. data/lib/powerpoint/slide/gallery.rb +42 -0
  18. data/lib/powerpoint/slide/intro.rb +36 -0
  19. data/lib/powerpoint/slide/multiple_image.rb +42 -0
  20. data/lib/powerpoint/slide/pictorial.rb +54 -0
  21. data/lib/powerpoint/slide/picture_description.rb +63 -0
  22. data/lib/powerpoint/slide/text_picture_split.rb +56 -0
  23. data/lib/powerpoint/slide/textual.rb +32 -0
  24. data/lib/powerpoint/util.rb +39 -0
  25. data/lib/powerpoint/version.rb +3 -0
  26. data/lib/powerpoint/views/app.xml.erb +51 -0
  27. data/lib/powerpoint/views/collage.xml.erb +211 -0
  28. data/lib/powerpoint/views/collage_rel.xml.erb +9 -0
  29. data/lib/powerpoint/views/comment.xml.erb +257 -0
  30. data/lib/powerpoint/views/comment_rel.xml.erb +6 -0
  31. data/lib/powerpoint/views/concept.xml.erb +271 -0
  32. data/lib/powerpoint/views/concept_rel.xml.erb +9 -0
  33. data/lib/powerpoint/views/content_type.xml.erb +31 -0
  34. data/lib/powerpoint/views/custom.xml.erb +174 -0
  35. data/lib/powerpoint/views/custom_rel.xml.erb +9 -0
  36. data/lib/powerpoint/views/dashboard.xml.erb +976 -0
  37. data/lib/powerpoint/views/dashboard_rel.xml.erb +9 -0
  38. data/lib/powerpoint/views/dashboard_user.xml.erb +221 -0
  39. data/lib/powerpoint/views/dashboard_user_rel.xml.erb +8 -0
  40. data/lib/powerpoint/views/extended_intro_slide.xml.erb +225 -0
  41. data/lib/powerpoint/views/extended_intro_slide_rel.xml.erb +3 -0
  42. data/lib/powerpoint/views/gallery.xml.erb +340 -0
  43. data/lib/powerpoint/views/gallery_rel.xml.erb +9 -0
  44. data/lib/powerpoint/views/intro_slide.xml.erb +74 -0
  45. data/lib/powerpoint/views/multiple_image.xml.erb +319 -0
  46. data/lib/powerpoint/views/multiple_image_rel.xml.erb +9 -0
  47. data/lib/powerpoint/views/pictorial_rel.xml.erb +5 -0
  48. data/lib/powerpoint/views/pictorial_slide.xml.erb +87 -0
  49. data/lib/powerpoint/views/picture_description_rels.xml.erb +5 -0
  50. data/lib/powerpoint/views/picture_description_slide.xml.erb +115 -0
  51. data/lib/powerpoint/views/presentation.xml.erb +124 -0
  52. data/lib/powerpoint/views/presentation.xml.rel.erb +11 -0
  53. data/lib/powerpoint/views/text_picture_split_rel.xml.erb +5 -0
  54. data/lib/powerpoint/views/text_picture_split_slide.xml.erb +114 -0
  55. data/lib/powerpoint/views/textual_rel.xml.erb +4 -0
  56. data/lib/powerpoint/views/textual_slide.xml.erb +78 -0
  57. data/lib/powerpoint.rb +25 -0
  58. data/powerpoint.gemspec +31 -0
  59. data/samples/images/sample_gif.gif +0 -0
  60. data/samples/images/sample_jpg.jpg +0 -0
  61. data/samples/images/sample_png.png +0 -0
  62. data/samples/pptx/sample.pptx +0 -0
  63. data/spec/extended_test_spec.rb +13 -0
  64. data/spec/ranking_spec.rb +13 -0
  65. data/spec/test_spec.rb +22 -0
  66. data/template/_rels/.rels +6 -0
  67. data/template/docProps/core.xml +7 -0
  68. data/template/ppt/_rels/.keep +0 -0
  69. data/template/ppt/media/.keep +0 -0
  70. data/template/ppt/presProps.xml +14 -0
  71. data/template/ppt/slideLayouts/_rels/slideLayout1.xml.rels +2 -0
  72. data/template/ppt/slideLayouts/_rels/slideLayout10.xml.rels +2 -0
  73. data/template/ppt/slideLayouts/_rels/slideLayout11.xml.rels +2 -0
  74. data/template/ppt/slideLayouts/_rels/slideLayout2.xml.rels +2 -0
  75. data/template/ppt/slideLayouts/_rels/slideLayout3.xml.rels +2 -0
  76. data/template/ppt/slideLayouts/_rels/slideLayout4.xml.rels +2 -0
  77. data/template/ppt/slideLayouts/_rels/slideLayout5.xml.rels +2 -0
  78. data/template/ppt/slideLayouts/_rels/slideLayout6.xml.rels +2 -0
  79. data/template/ppt/slideLayouts/_rels/slideLayout7.xml.rels +2 -0
  80. data/template/ppt/slideLayouts/_rels/slideLayout8.xml.rels +2 -0
  81. data/template/ppt/slideLayouts/_rels/slideLayout9.xml.rels +2 -0
  82. data/template/ppt/slideLayouts/slideLayout1.xml +242 -0
  83. data/template/ppt/slideLayouts/slideLayout10.xml +2 -0
  84. data/template/ppt/slideLayouts/slideLayout11.xml +2 -0
  85. data/template/ppt/slideLayouts/slideLayout2.xml +165 -0
  86. data/template/ppt/slideLayouts/slideLayout3.xml +2 -0
  87. data/template/ppt/slideLayouts/slideLayout4.xml +2 -0
  88. data/template/ppt/slideLayouts/slideLayout5.xml +2 -0
  89. data/template/ppt/slideLayouts/slideLayout6.xml +2 -0
  90. data/template/ppt/slideLayouts/slideLayout7.xml +2 -0
  91. data/template/ppt/slideLayouts/slideLayout8.xml +2 -0
  92. data/template/ppt/slideLayouts/slideLayout9.xml +2 -0
  93. data/template/ppt/slideMasters/_rels/slideMaster1.xml.rels +2 -0
  94. data/template/ppt/slideMasters/_rels/slideMaster2.xml.rels +2 -0
  95. data/template/ppt/slideMasters/slideMaster1.xml +487 -0
  96. data/template/ppt/slideMasters/slideMaster2.xml +487 -0
  97. data/template/ppt/slides/_rels/.keep +0 -0
  98. data/template/ppt/tableStyles.xml +2 -0
  99. data/template/ppt/theme/theme1.xml +2 -0
  100. data/template/ppt/theme/theme2.xml +281 -0
  101. data/template/ppt/viewProps.xml +32 -0
  102. metadata +232 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c6950786f5b14d94a599b4a9af20bd5f75932cf43aa4cf420841e7644e3a950b
4
+ data.tar.gz: e3bf349f52e08689febe73e8c3ea10c54b5584b19a71886b72ba812bbebacd12
5
+ SHA512:
6
+ metadata.gz: 731603777ec7098944f2f116249ec27d41cb4ad60538b052bc48fa78be70d1c76a4a8956b811e98d6b73f48e5901746250b940a3a51bf93fc8d1b0c2d4c96559
7
+ data.tar.gz: e0aeb04ee52450dd215b59891c3a2eda2f5c60379a27eed1f466c794a17f36c91163c4a65e079875617c6c50b0e48e8015ee596ed248ce4ec71b4ed5528548ee
data/.codeclimate.yml ADDED
@@ -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 ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .pryrc
19
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in powerpoint.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TODO: Write your name
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ [![version](https://badge.fury.io/rb/powerpoint.svg)](https://badge.fury.io/rb/powerpointk)
2
+ [![downloads](https://ruby-gem-downloads-badge.herokuapp.com/powerpoint?type=total&total_label=downloads)](https://ruby-gem-downloads-badge.herokuapp.com/powerpoint?type=total&total_label=downloads)
3
+
4
+ # 'powerpoint' gem -- for creating PowerPoint Slides in Ruby.
5
+
6
+ 'powerpoint' is a Ruby gem that can generate PowerPoint files(pptx).
7
+
8
+ ## Installation
9
+
10
+ 'powerpoint' can be used from the command line or as part of a Ruby web framework. To install the gem using terminal, run the following command:
11
+
12
+ gem install powerpoint
13
+
14
+ To use it in Rails, add this line to your Gemfile:
15
+
16
+ gem "powerpoint"
17
+
18
+
19
+ ## Basic Usage
20
+
21
+ 'powerpoint' gem can generate a PowerPoint presentaion based on a standard template:
22
+
23
+ ```ruby
24
+ require 'powerpoint'
25
+
26
+ @deck = Powerpoint::Presentation.new
27
+
28
+ # Creating an introduction slide:
29
+ title = 'Bicycle Of the Mind'
30
+ subtitle = 'created by Steve Jobs'
31
+ @deck.add_intro title, subtitle
32
+
33
+ # Creating a text-only slide:
34
+ # Title must be a string.
35
+ # Content must be an array of strings that will be displayed as bullet items.
36
+ title = 'Why Mac?'
37
+ content = ['Its cool!', 'Its light.']
38
+ @deck.add_textual_slide title, content
39
+
40
+ # Creating an image Slide:
41
+ # It will contain a title as string.
42
+ # and an embeded image
43
+ title = 'Everyone loves Macs:'
44
+ image_path = 'samples/images/sample_gif.gif'
45
+ @deck.add_pictorial_slide title, image_path
46
+
47
+ # Specifying coordinates and image size for an embeded image.
48
+ # x and y values define the position of the image on the slide.
49
+ # cx and cy define the width and height of the image.
50
+ # x, y, cx, cy are in points. Each pixel is 12700 points.
51
+ # coordinates parameter is optional.
52
+ coords = {x: 124200, y: 3356451, cx: 2895600, cy: 1013460}
53
+ @deck.add_pictorial_slide title, image_path, coords
54
+
55
+ # Saving the pptx file to the current directory.
56
+ @deck.save('test.pptx')
57
+ ```
58
+
59
+ ## Compatibility
60
+
61
+ 'powerpoint' gem has been tested with LibreOffice (4.2.1.1) and Apache OpenOffice (4.0.1) on Mac OS X Mavericks, Microsoft PowerPoint 2010 on Windows 7 and Google Docs (latest version as of March 2014).
62
+
63
+ ## Contributing
64
+
65
+ Contributions are welcomed. You can fork a repository, add your code changes to the forked branch, ensure all existing unit tests pass, create new unit tests cover your new changes and finally create a pull request.
66
+
67
+ After forking and then cloning the repository locally, install Bundler and then use it to install the development gem dependecies:
68
+
69
+ gem install bundler
70
+ bundle install
71
+
72
+ Once this is complete, you should be able to run the test suite:
73
+
74
+ rake
75
+
76
+
77
+ ## Bug Reporting
78
+
79
+ Please use the [Issues](https://github.com/pythonicrubyist/powerpoint/issues) page to report bugs or suggest new enhancements.
80
+
81
+ ## License
82
+
83
+ Powerpoint has been published under [MIT License](https://github.com/pythonicrubyist/powerpoint/blob/master/LICENSE.txt)
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ # If you want to make this the default task
7
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ module Powerpoint
2
+ def self.decompress_pptx(in_path, out_path)
3
+ Zip::File.open(in_path) do |zip_file|
4
+ zip_file.each do |f|
5
+ f_path = File.join(out_path, f.name)
6
+ FileUtils.mkdir_p(File.dirname(f_path))
7
+ zip_file.extract(f, f_path) unless File.exist?(f_path)
8
+ end
9
+ end
10
+ end
11
+
12
+ def self.compress_pptx(in_path, out_path)
13
+ Zip::File.open(out_path, Zip::File::CREATE) do |zip_file|
14
+ Dir.glob("#{in_path}/**/*", ::File::FNM_DOTMATCH).each do |path|
15
+ zip_path = path.gsub("#{in_path}/","")
16
+ next if zip_path == "." || zip_path == ".." || zip_path.match(/DS_Store/)
17
+ begin
18
+ zip_file.add(zip_path, path)
19
+ rescue Zip::ZipEntryExistsError
20
+ raise "#{out_path} already exists!"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,118 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'tmpdir'
4
+
5
+ module Powerpoint
6
+ class Presentation
7
+ include Powerpoint::Util
8
+
9
+ attr_reader :slides
10
+
11
+ def initialize
12
+ @slides = []
13
+ end
14
+
15
+ def add_intro(title, subtitile = nil)
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
23
+ end
24
+
25
+ def add_extended_intro(title, image_path, image_path_2,subtitle = nil,subtitle_2 = nil, coords = {})
26
+ existing_intro_slide = @slides.select {|s| s.class == Powerpoint::Slide::ExtendedIntro}[0]
27
+ slide = Powerpoint::Slide::ExtendedIntro.new(presentation: self, title: title, subtitle: subtitle, image_path: image_path, image_path_2: image_path_2, subtitle_2: subtitle_2, coords: coords)
28
+ if existing_intro_slide
29
+ @slides[@slides.index(existing_intro_slide)] = slide
30
+ else
31
+ @slides.insert 0, slide
32
+ end
33
+ end
34
+
35
+ def add_textual_slide(title, content = [])
36
+ @slides << Powerpoint::Slide::Textual.new(presentation: self, title: title, content: content)
37
+ end
38
+
39
+ def add_pictorial_slide(title, image_path, coords = {})
40
+ @slides << Powerpoint::Slide::Pictorial.new(presentation: self, title: title, image_path: image_path, coords: coords)
41
+ end
42
+
43
+ def add_text_picture_slide(title, image_path, content = [])
44
+ @slides << Powerpoint::Slide::TextPicSplit.new(presentation: self, title: title, image_path: image_path, content: content)
45
+ end
46
+
47
+ def add_picture_description_slide(title, image_path, content = [])
48
+ @slides << Powerpoint::Slide::DescriptionPic.new(presentation: self, title: title, image_path: image_path, content: content)
49
+ end
50
+
51
+ def add_multiple_image_slide(title, subtitle = nil, page_number, logo, task_icon ,images)
52
+ @slides << Powerpoint::Slide::MultipleImage.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, task_icon: task_icon, logo: logo, images: images)
53
+ end
54
+
55
+ def add_comment_slide(title, subtitle = nil, user, page_number, logo, task_icon ,comments)
56
+ @slides << Powerpoint::Slide::Comment.new(presentation: self, title: title, subtitle: subtitle, user: user, page_number: page_number, task_icon: task_icon, logo: logo, comments: comments)
57
+ end
58
+
59
+ def add_gallery_slide(title, subtitle = nil, question, page_number, logo, task_icon ,images)
60
+ @slides << Powerpoint::Slide::Gallery.new(presentation: self, title: title, subtitle: subtitle, question: question, page_number: page_number, task_icon: task_icon, logo: logo, images: images)
61
+ end
62
+
63
+ def add_concept_slide(title, subtitle = nil, page_number, logo, task_icon, image_information ,images, legend)
64
+ @slides << Powerpoint::Slide::Concept.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, logo: logo, task_icon: task_icon, image_information: image_information, images: images, legend: legend)
65
+ end
66
+
67
+ def add_collage_slide(title, subtitle = nil, page_number, logo, task_icon, image_information ,images)
68
+ @slides << Powerpoint::Slide::Collage.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, logo: logo, task_icon: task_icon, image_information: image_information, images: images)
69
+ end
70
+
71
+ def add_custom_slide(title, subtitle = nil, properties)
72
+ @slides << Powerpoint::Slide::Custom.new(presentation: self, title: title, subtitle: subtitle, properties: properties)
73
+ end
74
+
75
+ def add_dashboard_slide(title, subtitle = nil, page_number, graph_1_title, graph_1_subtitle, graph_2_title, image_1, image_2, image_3, image_4, logo, data)
76
+ @slides << Powerpoint::Slide::Dashboard.new(presentation: self, title: title, subtitle: subtitle, page_number: page_number, graph_1_title: graph_1_title, graph_1_subtitle: graph_1_subtitle, graph_2_title: graph_2_title, image_path: image_1, image_path_2: image_2, image_path_3: image_3, image_path_4: image_4, logo: logo, data: data)
77
+ end
78
+
79
+ def add_dashboard_user_slide(title, subtitle = nil, page_number, logo, images)
80
+ @slides << Powerpoint::Slide::DashboardUser.new(presentation: self, title: title, subtitle: subtitle,page_number: page_number, logo: logo, images: images)
81
+ end
82
+
83
+ def save(path)
84
+ Dir.mktmpdir do |dir|
85
+ extract_path = "#{dir}/extract_#{Time.now.strftime("%Y-%m-%d-%H%M%S")}"
86
+
87
+ # Copy template to temp path
88
+ FileUtils.copy_entry(TEMPLATE_PATH, extract_path)
89
+
90
+ # Remove keep files
91
+ Dir.glob("#{extract_path}/**/.keep").each do |keep_file|
92
+ FileUtils.rm_rf(keep_file)
93
+ end
94
+
95
+ # Render/save generic stuff
96
+ render_view('content_type.xml.erb', "#{extract_path}/[Content_Types].xml")
97
+ render_view('presentation.xml.rel.erb', "#{extract_path}/ppt/_rels/presentation.xml.rels")
98
+ render_view('presentation.xml.erb', "#{extract_path}/ppt/presentation.xml")
99
+ render_view('app.xml.erb', "#{extract_path}/docProps/app.xml")
100
+
101
+ # Save slides
102
+ slides.each_with_index do |slide, index|
103
+ slide.save(extract_path, index + 1)
104
+ end
105
+
106
+ # Create .pptx file
107
+ File.delete(path) if File.exist?(path)
108
+ Powerpoint.compress_pptx(extract_path, path)
109
+ end
110
+
111
+ path
112
+ end
113
+
114
+ def file_types
115
+
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,47 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class Collage
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle,:page_number,:logo, :task_icon, :image_information, :images
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :subtitle,:page_number,:logo, :task_icon, :image_information, :images], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @images = images
17
+ @image_y_scale = image_information[1]
18
+ @image_x_scale = image_information[0]
19
+ @image_x_offset = image_information[2]
20
+ @image_y_offset = image_information[3]
21
+ end
22
+
23
+ def save(extract_path, index)
24
+ @images.each do |image|
25
+ copy_media(extract_path, image)
26
+ end
27
+
28
+ copy_media(extract_path, logo)
29
+ copy_media(extract_path, task_icon)
30
+
31
+ save_rel_xml(extract_path, index)
32
+ save_slide_xml(extract_path, index)
33
+ end
34
+
35
+
36
+ def save_rel_xml(extract_path, index)
37
+ render_view('collage_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
38
+ end
39
+ private :save_rel_xml
40
+
41
+ def save_slide_xml(extract_path, index)
42
+ render_view('collage.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
43
+ end
44
+ private :save_slide_xml
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,39 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class Comment
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle, :user, :page_number, :logo, :task_icon, :comments
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :subtitle, :user, :page_number, :logo, :task_icon, :comments], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+
17
+ end
18
+
19
+ def save(extract_path, index)
20
+
21
+ copy_media(extract_path, logo)
22
+ copy_media(extract_path, task_icon)
23
+
24
+ save_rel_xml(extract_path, index)
25
+ save_slide_xml(extract_path, index)
26
+ end
27
+
28
+ def save_rel_xml(extract_path, index)
29
+ render_view('comment_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
30
+ end
31
+ private :save_rel_xml
32
+
33
+ def save_slide_xml(extract_path, index)
34
+ render_view('comment.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
35
+ end
36
+ private :save_slide_xml
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,48 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class Concept
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle,:page_number,:logo, :task_icon, :image_information, :images, :legend
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :subtitle, :page_number, :logo, :task_icon, :image_information, :images, :legend], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @legend = legend
17
+ @images = images
18
+ @image_y_scale = image_information[1]
19
+ @image_x_scale = image_information[0]
20
+ @image_x_offset = image_information[2]
21
+ @image_y_offset = image_information[3]
22
+ end
23
+
24
+ def save(extract_path, index)
25
+ @images.each do |image|
26
+ copy_media(extract_path, image)
27
+ end
28
+
29
+ copy_media(extract_path, logo)
30
+ copy_media(extract_path, task_icon)
31
+
32
+ save_rel_xml(extract_path, index)
33
+ save_slide_xml(extract_path, index)
34
+ end
35
+
36
+
37
+ def save_rel_xml(extract_path, index)
38
+ render_view('concept_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
39
+ end
40
+ private :save_rel_xml
41
+
42
+ def save_slide_xml(extract_path, index)
43
+ render_view('concept.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
44
+ end
45
+ private :save_slide_xml
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,50 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class Custom
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle, :properties, :coords
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :properties], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @coords = default_coords unless @coords.present?
17
+ properties
18
+ end
19
+
20
+ def save(extract_path, index)
21
+ properties.each do |property|
22
+ if property[:type] == 'image'
23
+ copy_media(extract_path, property[:file_path])
24
+ end
25
+ end
26
+ save_rel_xml(extract_path, index)
27
+ save_slide_xml(extract_path, index)
28
+ end
29
+
30
+ def file_type
31
+ File.extname(image_name).gsub('.', '')
32
+ end
33
+
34
+ def default_coords
35
+ {x: 0, y: 0, cx: pixle_to_pt(50), cy: pixle_to_pt(50)}
36
+ end
37
+ private :default_coords
38
+
39
+ def save_rel_xml(extract_path, index)
40
+ render_view('custom_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
41
+ end
42
+ private :save_rel_xml
43
+
44
+ def save_slide_xml(extract_path, index)
45
+ render_view('custom.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
46
+ end
47
+ private :save_slide_xml
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,45 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class Dashboard
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle,:page_number, :graph_1_title, :graph_1_subtitle, :graph_2_title, :image_path, :image_path_2,:image_path_3,:image_path_4, :image_name, :logo, :data
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :subtitle,:page_number, :graph_1_title, :graph_1_subtitle, :graph_2_title, :image_path, :image_path_2,:image_path_3, :image_path_4, :logo, :data], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @data = data
17
+ @image_name = File.basename(image_path)
18
+ @image_name_2 = File.basename(image_path_2)
19
+ @image_name_3 = File.basename(image_path_3)
20
+ @image_name_4 = File.basename(image_path_4)
21
+ @logo_name = File.basename(logo)
22
+ end
23
+
24
+ def save(extract_path, index)
25
+ copy_media(extract_path, image_path)
26
+ copy_media(extract_path, image_path_2)
27
+ copy_media(extract_path, image_path_3)
28
+ copy_media(extract_path, image_path_4)
29
+ copy_media(extract_path, logo)
30
+ save_rel_xml(extract_path, index)
31
+ save_slide_xml(extract_path, index)
32
+ end
33
+
34
+ def save_rel_xml(extract_path, index)
35
+ render_view('dashboard_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
36
+ end
37
+ private :save_rel_xml
38
+
39
+ def save_slide_xml(extract_path, index)
40
+ render_view('dashboard.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
41
+ end
42
+ private :save_slide_xml
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,40 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class DashboardUser
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle,:page_number,:logo, :images
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :subtitle,:page_number,:logo, :images], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @images = images
17
+ @logo_name = File.basename(logo)
18
+ end
19
+
20
+ def save(extract_path, index)
21
+ @images.each do |image|
22
+ copy_media(extract_path, image[1])
23
+ end
24
+ copy_media(extract_path, logo)
25
+ save_rel_xml(extract_path, index)
26
+ save_slide_xml(extract_path, index)
27
+ end
28
+
29
+ def save_rel_xml(extract_path, index)
30
+ render_view('dashboard_user_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
31
+ end
32
+ private :save_rel_xml
33
+
34
+ def save_slide_xml(extract_path, index)
35
+ render_view('dashboard_user.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
36
+ end
37
+ private :save_slide_xml
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,38 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class ExtendedIntro
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle, :subtitle_2, :coords, :image_path, :image_path_2, :image_name
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :subtitle, :image_path, :image_path_2, :subtitle_2], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @image_name = File.basename(@image_path)
17
+ @image_name_2 = File.basename(@image_path_2)
18
+ end
19
+
20
+ def save(extract_path, index)
21
+ copy_media(extract_path, @image_path)
22
+ copy_media(extract_path, @image_path_2)
23
+ save_rel_xml(extract_path, index)
24
+ save_slide_xml(extract_path, index)
25
+ end
26
+
27
+ def save_rel_xml(extract_path, index)
28
+ render_view('extended_intro_slide_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
29
+ end
30
+ private :save_rel_xml
31
+
32
+ def save_slide_xml(extract_path, index)
33
+ render_view('extended_intro_slide.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
34
+ end
35
+ private :save_slide_xml
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,42 @@
1
+ require 'zip/filesystem'
2
+ require 'fileutils'
3
+ require 'fastimage'
4
+ require 'erb'
5
+
6
+ module Powerpoint
7
+ module Slide
8
+ class Gallery
9
+ include Powerpoint::Util
10
+
11
+ attr_reader :title, :subtitle, :question, :page_number, :logo, :task_icon, :images
12
+
13
+ def initialize(options={})
14
+ require_arguments [:title, :subtitle, :question, :page_number, :logo, :task_icon, :images], options
15
+ options.each {|k, v| instance_variable_set("@#{k}", v)}
16
+ @images = images
17
+ end
18
+
19
+ def save(extract_path, index)
20
+ @images.each do |image|
21
+ copy_media(extract_path, image[0])
22
+ end
23
+
24
+ copy_media(extract_path, logo)
25
+ copy_media(extract_path, task_icon)
26
+
27
+ save_rel_xml(extract_path, index)
28
+ save_slide_xml(extract_path, index)
29
+ end
30
+
31
+ def save_rel_xml(extract_path, index)
32
+ render_view('gallery_rel.xml.erb', "#{extract_path}/ppt/slides/_rels/slide#{index}.xml.rels", index: index)
33
+ end
34
+ private :save_rel_xml
35
+
36
+ def save_slide_xml(extract_path, index)
37
+ render_view('gallery.xml.erb', "#{extract_path}/ppt/slides/slide#{index}.xml")
38
+ end
39
+ private :save_slide_xml
40
+ end
41
+ end
42
+ end