openxml-pptx 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +92 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/build_fixtures +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/zipflip +56 -0
- data/lib/openxml/pptx.rb +52 -0
- data/lib/openxml/pptx/elements.rb +12 -0
- data/lib/openxml/pptx/package.rb +33 -0
- data/lib/openxml/pptx/parts.rb +12 -0
- data/lib/openxml/pptx/parts/image.rb +32 -0
- data/lib/openxml/pptx/parts/presentation.rb +142 -0
- data/lib/openxml/pptx/parts/presentation_properties.rb +38 -0
- data/lib/openxml/pptx/parts/slide.rb +87 -0
- data/lib/openxml/pptx/parts/slide_layout.rb +88 -0
- data/lib/openxml/pptx/parts/slide_master.rb +132 -0
- data/lib/openxml/pptx/parts/theme.rb +61 -0
- data/lib/openxml/pptx/properties.rb +21 -0
- data/lib/openxml/pptx/properties/background.rb +19 -0
- data/lib/openxml/pptx/properties/background_properties.rb +30 -0
- data/lib/openxml/pptx/properties/background_reference.rb +23 -0
- data/lib/openxml/pptx/properties/blip_fill.rb +11 -0
- data/lib/openxml/pptx/properties/color_mapping.rb +11 -0
- data/lib/openxml/pptx/properties/color_mapping_override.rb +11 -0
- data/lib/openxml/pptx/properties/common_slide_data.rb +21 -0
- data/lib/openxml/pptx/properties/connection_shape.rb +16 -0
- data/lib/openxml/pptx/properties/content_part.rb +13 -0
- data/lib/openxml/pptx/properties/control.rb +36 -0
- data/lib/openxml/pptx/properties/control_list.rb +14 -0
- data/lib/openxml/pptx/properties/custom_show.rb +18 -0
- data/lib/openxml/pptx/properties/custom_show_list.rb +14 -0
- data/lib/openxml/pptx/properties/customer_data.rb +13 -0
- data/lib/openxml/pptx/properties/customer_data_container.rb +12 -0
- data/lib/openxml/pptx/properties/customer_data_list.rb +14 -0
- data/lib/openxml/pptx/properties/data_tags.rb +13 -0
- data/lib/openxml/pptx/properties/default_text_style.rb +24 -0
- data/lib/openxml/pptx/properties/embedded_font.rb +18 -0
- data/lib/openxml/pptx/properties/embedded_font_list.rb +14 -0
- data/lib/openxml/pptx/properties/extension.rb +14 -0
- data/lib/openxml/pptx/properties/extension_list.rb +14 -0
- data/lib/openxml/pptx/properties/font.rb +32 -0
- data/lib/openxml/pptx/properties/font_reference.rb +12 -0
- data/lib/openxml/pptx/properties/font_reference_bold.rb +13 -0
- data/lib/openxml/pptx/properties/font_reference_bold_italic.rb +13 -0
- data/lib/openxml/pptx/properties/font_reference_italic.rb +13 -0
- data/lib/openxml/pptx/properties/font_reference_regular.rb +13 -0
- data/lib/openxml/pptx/properties/graphic_frame.rb +20 -0
- data/lib/openxml/pptx/properties/group_shape_properties.rb +34 -0
- data/lib/openxml/pptx/properties/handout_master_id.rb +18 -0
- data/lib/openxml/pptx/properties/handout_master_id_list.rb +14 -0
- data/lib/openxml/pptx/properties/non_visual_connection_shape_drawing_properties.rb +18 -0
- data/lib/openxml/pptx/properties/non_visual_connection_shape_properties.rb +16 -0
- data/lib/openxml/pptx/properties/non_visual_drawing_properties.rb +30 -0
- data/lib/openxml/pptx/properties/non_visual_graphic_frame_drawing_properties.rb +15 -0
- data/lib/openxml/pptx/properties/non_visual_graphic_frame_properties.rb +16 -0
- data/lib/openxml/pptx/properties/non_visual_group_shape_drawing_properties.rb +15 -0
- data/lib/openxml/pptx/properties/non_visual_group_shape_properties.rb +16 -0
- data/lib/openxml/pptx/properties/non_visual_picture_properties.rb +16 -0
- data/lib/openxml/pptx/properties/non_visual_picutre_drawing_properties.rb +18 -0
- data/lib/openxml/pptx/properties/non_visual_properties.rb +29 -0
- data/lib/openxml/pptx/properties/non_visual_shape_drawing_properties.rb +18 -0
- data/lib/openxml/pptx/properties/non_visual_shape_properties.rb +16 -0
- data/lib/openxml/pptx/properties/notes_master_id.rb +18 -0
- data/lib/openxml/pptx/properties/notes_master_id_list.rb +14 -0
- data/lib/openxml/pptx/properties/notes_size.rb +14 -0
- data/lib/openxml/pptx/properties/photo_album.rb +19 -0
- data/lib/openxml/pptx/properties/picture.rb +30 -0
- data/lib/openxml/pptx/properties/placeholder.rb +20 -0
- data/lib/openxml/pptx/properties/shape.rb +34 -0
- data/lib/openxml/pptx/properties/shape_group.rb +18 -0
- data/lib/openxml/pptx/properties/shape_properties.rb +11 -0
- data/lib/openxml/pptx/properties/shape_style.rb +11 -0
- data/lib/openxml/pptx/properties/shape_tree.rb +13 -0
- data/lib/openxml/pptx/properties/shapes_container.rb +18 -0
- data/lib/openxml/pptx/properties/simple_boolean_property.rb +16 -0
- data/lib/openxml/pptx/properties/simple_property_container_property.rb +14 -0
- data/lib/openxml/pptx/properties/slide_id.rb +29 -0
- data/lib/openxml/pptx/properties/slide_id_list.rb +14 -0
- data/lib/openxml/pptx/properties/slide_layout_id.rb +26 -0
- data/lib/openxml/pptx/properties/slide_layout_id_list.rb +14 -0
- data/lib/openxml/pptx/properties/slide_list.rb +14 -0
- data/lib/openxml/pptx/properties/slide_master_id.rb +29 -0
- data/lib/openxml/pptx/properties/slide_master_id_list.rb +14 -0
- data/lib/openxml/pptx/properties/slide_reference.rb +15 -0
- data/lib/openxml/pptx/properties/slide_size.rb +16 -0
- data/lib/openxml/pptx/properties/smart_tags.rb +15 -0
- data/lib/openxml/pptx/properties/text_body.rb +11 -0
- data/lib/openxml/pptx/properties/text_style_body.rb +11 -0
- data/lib/openxml/pptx/properties/text_style_other.rb +11 -0
- data/lib/openxml/pptx/properties/text_style_title.rb +11 -0
- data/lib/openxml/pptx/properties/text_styles.rb +17 -0
- data/lib/openxml/pptx/properties/transform.rb +11 -0
- data/lib/openxml/pptx/properties/transparent_container_property.rb +14 -0
- data/lib/openxml/pptx/relatable_part.rb +100 -0
- data/lib/openxml/pptx/version.rb +5 -0
- data/openxml-pptx.gemspec +33 -0
- metadata +258 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 120407bfe4738770a7f6105ba4b3697eb2b2aa86
|
4
|
+
data.tar.gz: 4b417a38098d237361c41b9f4d981c211471c066
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 82d3bdff0e1f62ebfabeae704d0f6f0d16ed3296614fb00208a161c4006790d22542a914a81d2bd7b1ed0e04c30e706533adac89e4b4ad7b0f9abfb70d36c418
|
7
|
+
data.tar.gz: 233a86b68c2ca5da94adcb9c72fbce453957f25326d9b1afed12c1c37cc231d22bfed16ea8d9bd67644b7b232423c6c3d7b59598f6094206fcdb75d1ea6ea9ad
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in openxml-pptx.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# For development purposes
|
7
|
+
# gem "openxml-package", github: "openxml/openxml-package", branch: "master"
|
8
|
+
# gem "openxml-drawingml", github: "openxml/openxml-drawingml", branch: "master"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
openxml-pptx (0.2.0)
|
5
|
+
openxml-drawingml (>= 0.2.0)
|
6
|
+
openxml-package (>= 0.3.2)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
coderay (1.1.1)
|
12
|
+
diff-lcs (1.3)
|
13
|
+
equivalent-xml (0.6.0)
|
14
|
+
nokogiri (>= 1.4.3)
|
15
|
+
ffi (1.9.18)
|
16
|
+
formatador (0.2.5)
|
17
|
+
guard (2.14.1)
|
18
|
+
formatador (>= 0.2.4)
|
19
|
+
listen (>= 2.7, < 4.0)
|
20
|
+
lumberjack (~> 1.0)
|
21
|
+
nenv (~> 0.1)
|
22
|
+
notiffany (~> 0.0)
|
23
|
+
pry (>= 0.9.12)
|
24
|
+
shellany (~> 0.0)
|
25
|
+
thor (>= 0.18.1)
|
26
|
+
guard-compat (1.2.1)
|
27
|
+
guard-rspec (4.7.3)
|
28
|
+
guard (~> 2.1)
|
29
|
+
guard-compat (~> 1.1)
|
30
|
+
rspec (>= 2.99.0, < 4.0)
|
31
|
+
listen (3.1.5)
|
32
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
33
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
34
|
+
ruby_dep (~> 1.2)
|
35
|
+
lumberjack (1.0.12)
|
36
|
+
method_source (0.8.2)
|
37
|
+
mini_portile2 (2.2.0)
|
38
|
+
nenv (0.3.0)
|
39
|
+
nokogiri (1.8.0)
|
40
|
+
mini_portile2 (~> 2.2.0)
|
41
|
+
notiffany (0.1.1)
|
42
|
+
nenv (~> 0.1)
|
43
|
+
shellany (~> 0.0)
|
44
|
+
openxml-drawingml (0.2.0)
|
45
|
+
nokogiri
|
46
|
+
openxml-package (~> 0.3.2)
|
47
|
+
openxml-package (0.3.2)
|
48
|
+
nokogiri
|
49
|
+
ox
|
50
|
+
rubyzip (~> 1.2.1)
|
51
|
+
ox (2.8.0)
|
52
|
+
pry (0.10.4)
|
53
|
+
coderay (~> 1.1.0)
|
54
|
+
method_source (~> 0.8.1)
|
55
|
+
slop (~> 3.4)
|
56
|
+
rake (10.5.0)
|
57
|
+
rb-fsevent (0.9.8)
|
58
|
+
rb-inotify (0.9.8)
|
59
|
+
ffi (>= 0.5.0)
|
60
|
+
rspec (3.6.0)
|
61
|
+
rspec-core (~> 3.6.0)
|
62
|
+
rspec-expectations (~> 3.6.0)
|
63
|
+
rspec-mocks (~> 3.6.0)
|
64
|
+
rspec-core (3.6.0)
|
65
|
+
rspec-support (~> 3.6.0)
|
66
|
+
rspec-expectations (3.6.0)
|
67
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
68
|
+
rspec-support (~> 3.6.0)
|
69
|
+
rspec-mocks (3.6.0)
|
70
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
71
|
+
rspec-support (~> 3.6.0)
|
72
|
+
rspec-support (3.6.0)
|
73
|
+
ruby_dep (1.5.0)
|
74
|
+
rubyzip (1.2.1)
|
75
|
+
shellany (0.0.1)
|
76
|
+
slop (3.6.0)
|
77
|
+
thor (0.19.4)
|
78
|
+
|
79
|
+
PLATFORMS
|
80
|
+
ruby
|
81
|
+
|
82
|
+
DEPENDENCIES
|
83
|
+
bundler (~> 1.11)
|
84
|
+
equivalent-xml
|
85
|
+
guard
|
86
|
+
guard-rspec
|
87
|
+
openxml-pptx!
|
88
|
+
rake (~> 10.0)
|
89
|
+
rspec
|
90
|
+
|
91
|
+
BUNDLED WITH
|
92
|
+
1.15.4
|
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# Feel free to open issues for suggestions and improvements
|
6
|
+
|
7
|
+
# RSpec files
|
8
|
+
rspec = dsl.rspec
|
9
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
11
|
+
watch(rspec.spec_files)
|
12
|
+
|
13
|
+
# Ruby files
|
14
|
+
ruby = dsl.ruby
|
15
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Bob Lail
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# OpenXml::Pptx
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/openxml-pptx.svg)](https://rubygems.org/gems/openxml-pptx)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/openxml/openxml-pptx.svg)](https://codeclimate.com/github/openxml/openxml-pptx)
|
5
|
+
[![Build Status](https://travis-ci.org/openxml/openxml-pptx.svg)](https://travis-ci.org/openxml/openxml-pptx)
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'openxml-pptx'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install openxml-pptx
|
23
|
+
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
TODO: Write usage instructions here
|
28
|
+
|
29
|
+
|
30
|
+
## Development
|
31
|
+
|
32
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
33
|
+
|
34
|
+
Reference for PresentationML can be found in Part 1 of the Fourth Edition of [ECMA-376](http://www.ecma-international.org/publications/standards/Ecma-376.htm) (the Office Open XML Standard).
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/openxml/openxml-pptx.
|
42
|
+
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/build_fixtures
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "openxml/pptx"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/zipflip
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "zip"
|
4
|
+
require "pathname"
|
5
|
+
require "shellwords"
|
6
|
+
|
7
|
+
# c.f. https://github.com/rubyzip/rubyzip/blob/05916bf89181e1955118fd3ea059f18acac28cc8/samples/example_recursive.rb
|
8
|
+
class ZipFileGenerator
|
9
|
+
|
10
|
+
def initialize(input_dir, output_file)
|
11
|
+
@input_dir = Pathname(input_dir)
|
12
|
+
@output_file = Pathname(output_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
def write
|
16
|
+
@output_file.delete if @output_file.exist?
|
17
|
+
Zip::File.open(@output_file, Zip::File::CREATE) do |io|
|
18
|
+
write_entries entries_in(@input_dir), "", io
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private def write_entries(entries, path, io)
|
23
|
+
entries.each do |entry|
|
24
|
+
zip_file_path = path == "" ? entry : File.join(path, entry)
|
25
|
+
disk_file_path = File.join(@input_dir, zip_file_path)
|
26
|
+
if File.directory?(disk_file_path)
|
27
|
+
io.mkdir zip_file_path
|
28
|
+
write_entries entries_in(disk_file_path), zip_file_path, io
|
29
|
+
else
|
30
|
+
io.get_output_stream(zip_file_path) do |stream|
|
31
|
+
stream.puts File.open(disk_file_path, "rb").read
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private def entries_in(path)
|
38
|
+
entries = Dir.entries(path)
|
39
|
+
entries.delete(".")
|
40
|
+
entries.delete("..")
|
41
|
+
entries.delete(".DS_Store")
|
42
|
+
entries
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
path = Pathname.new(ARGV.shift)
|
50
|
+
|
51
|
+
if path.directory?
|
52
|
+
zf = ZipFileGenerator.new(path, "#{path.basename}.pptx")
|
53
|
+
zf.write
|
54
|
+
else
|
55
|
+
system "unzip #{Shellwords.escape path} -d #{path.basename(".pptx")}"
|
56
|
+
end
|
data/lib/openxml/pptx.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module Pptx
|
3
|
+
MAX_ID = 2**32 - 1
|
4
|
+
SLIDE_ID_RANGE = (256...2_147_483_648)
|
5
|
+
MASTER_LAYOUT_ID_RANGE = (2_147_483_648..MAX_ID)
|
6
|
+
|
7
|
+
ST_SlideLayoutType = %i{ title tx twoColTx tbl txAndChart chartAndTx dgm
|
8
|
+
chart txAndClipArt clipArtAndTx titleOnly blank
|
9
|
+
txAndObj objAndTx objOnly obj txAndMedia mediaAndTx
|
10
|
+
objOverTx txOverObj txAndTwoObj twoObjAndTx twoObjOverTx
|
11
|
+
fourObj vertTx clipArtAndVertTx vertTitleAndTx
|
12
|
+
vertTitleAndTxOverChart twoObj objAndTwoObj
|
13
|
+
twoObjAndObj cust secHead twoTxTwoObj objTx picTx }.freeze
|
14
|
+
|
15
|
+
|
16
|
+
# Part 1, 19.7.17
|
17
|
+
ST_SlideSizeCoordinate = (914_400..51_206_400)
|
18
|
+
|
19
|
+
# Part 1, 19.7.18
|
20
|
+
ST_SlideSizeType = %i{ 35mm A3 A4 B4ISO B4JIS B5ISO B5JIS banner custom
|
21
|
+
hagakiCard ledger letter overhead screen16x10
|
22
|
+
screen16x9 screen4x3 }.freeze
|
23
|
+
|
24
|
+
# Part 1, 19.7.10
|
25
|
+
ST_PlaceholderType = %i{ title body ctrTitle subTitle dt sldNum ftr hdr obj
|
26
|
+
chart tbl clipArt dgm media sldImg pic }.freeze
|
27
|
+
|
28
|
+
# Part 1, 19.7.9
|
29
|
+
ST_PlaceholderSize = %i{ full half quarter }.freeze
|
30
|
+
|
31
|
+
# Part 1, 19.7.2
|
32
|
+
ST_Direction = %i{ horz vert }.freeze
|
33
|
+
|
34
|
+
# Part 1, 19.7.8
|
35
|
+
ST_PhotoAlbumLayout = %i{ 1pic 1picTitle 2pic 2picTitle 4pic 4picTitle fitToSlide }.freeze
|
36
|
+
|
37
|
+
# Part 1, 19.7.7
|
38
|
+
ST_PhotoAlbumFrameShape = (1..7).map { |num| :"frameStyle#{num}" }.freeze
|
39
|
+
|
40
|
+
# Part 1, 20.1.10.10
|
41
|
+
ST_BlackWhiteMode = %i{ clr auto gray ltGray invGray grayWhite blackGray
|
42
|
+
blackWhite black white hidden }.freeze
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
require "openxml-drawingml"
|
48
|
+
require "openxml/pptx/version"
|
49
|
+
require "openxml/pptx/properties"
|
50
|
+
require "openxml/pptx/elements"
|
51
|
+
require "openxml/pptx/parts"
|
52
|
+
require "openxml/pptx/package"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
require "openxml/package"
|
3
|
+
|
4
|
+
module OpenXml
|
5
|
+
module Pptx
|
6
|
+
class Package < OpenXml::Package
|
7
|
+
attr_reader :presentation
|
8
|
+
|
9
|
+
def add_override(part_name, content_type)
|
10
|
+
content_types.add_override "/#{part_name}", content_type
|
11
|
+
end
|
12
|
+
|
13
|
+
def add_default(extension, type)
|
14
|
+
content_types.add_default extension, type
|
15
|
+
end
|
16
|
+
|
17
|
+
# EXTRACT: to openxml-package
|
18
|
+
def has_part?(part)
|
19
|
+
parts.has_value?(part)
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_defaults
|
23
|
+
super
|
24
|
+
@presentation = OpenXml::Pptx::Parts::Presentation.new parent: self
|
25
|
+
add_part presentation.path.to_s, presentation
|
26
|
+
add_part presentation.relationships_path, presentation.relationships
|
27
|
+
add_override presentation.path.to_s, presentation.content_type
|
28
|
+
rels.add_relationship presentation.relationship_type, presentation.path
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module OpenXml
|
2
|
+
module Pptx
|
3
|
+
module Parts
|
4
|
+
class Image < OpenXml::Parts::UnparsedPart
|
5
|
+
attr_reader :path, :content_type, :relationship_type
|
6
|
+
|
7
|
+
def initialize(*args, extension: ".png")
|
8
|
+
super(*args)
|
9
|
+
@path = Pathname.new("ppt/media/image#{extension}")
|
10
|
+
@content_type = IMAGE_TYPES.fetch(extension)
|
11
|
+
@relationship_type = IMAGE_RELATIONSHIP_TYPE
|
12
|
+
end
|
13
|
+
|
14
|
+
def path=(value)
|
15
|
+
@path = Pathname.new(value)
|
16
|
+
end
|
17
|
+
|
18
|
+
IMAGE_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image".freeze
|
19
|
+
|
20
|
+
IMAGE_TYPES = {
|
21
|
+
".jpeg" => "image/jpeg",
|
22
|
+
".jpg" => "image/jpeg",
|
23
|
+
".png" => "image/png",
|
24
|
+
".gif" => "image/gif",
|
25
|
+
".bmp" => "image/bmp",
|
26
|
+
".tiff" => "image/tiff"
|
27
|
+
}.freeze
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|