openxml-pptx 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +92 -0
  6. data/Guardfile +16 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +46 -0
  9. data/Rakefile +6 -0
  10. data/bin/build_fixtures +10 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/bin/zipflip +56 -0
  14. data/lib/openxml/pptx.rb +52 -0
  15. data/lib/openxml/pptx/elements.rb +12 -0
  16. data/lib/openxml/pptx/package.rb +33 -0
  17. data/lib/openxml/pptx/parts.rb +12 -0
  18. data/lib/openxml/pptx/parts/image.rb +32 -0
  19. data/lib/openxml/pptx/parts/presentation.rb +142 -0
  20. data/lib/openxml/pptx/parts/presentation_properties.rb +38 -0
  21. data/lib/openxml/pptx/parts/slide.rb +87 -0
  22. data/lib/openxml/pptx/parts/slide_layout.rb +88 -0
  23. data/lib/openxml/pptx/parts/slide_master.rb +132 -0
  24. data/lib/openxml/pptx/parts/theme.rb +61 -0
  25. data/lib/openxml/pptx/properties.rb +21 -0
  26. data/lib/openxml/pptx/properties/background.rb +19 -0
  27. data/lib/openxml/pptx/properties/background_properties.rb +30 -0
  28. data/lib/openxml/pptx/properties/background_reference.rb +23 -0
  29. data/lib/openxml/pptx/properties/blip_fill.rb +11 -0
  30. data/lib/openxml/pptx/properties/color_mapping.rb +11 -0
  31. data/lib/openxml/pptx/properties/color_mapping_override.rb +11 -0
  32. data/lib/openxml/pptx/properties/common_slide_data.rb +21 -0
  33. data/lib/openxml/pptx/properties/connection_shape.rb +16 -0
  34. data/lib/openxml/pptx/properties/content_part.rb +13 -0
  35. data/lib/openxml/pptx/properties/control.rb +36 -0
  36. data/lib/openxml/pptx/properties/control_list.rb +14 -0
  37. data/lib/openxml/pptx/properties/custom_show.rb +18 -0
  38. data/lib/openxml/pptx/properties/custom_show_list.rb +14 -0
  39. data/lib/openxml/pptx/properties/customer_data.rb +13 -0
  40. data/lib/openxml/pptx/properties/customer_data_container.rb +12 -0
  41. data/lib/openxml/pptx/properties/customer_data_list.rb +14 -0
  42. data/lib/openxml/pptx/properties/data_tags.rb +13 -0
  43. data/lib/openxml/pptx/properties/default_text_style.rb +24 -0
  44. data/lib/openxml/pptx/properties/embedded_font.rb +18 -0
  45. data/lib/openxml/pptx/properties/embedded_font_list.rb +14 -0
  46. data/lib/openxml/pptx/properties/extension.rb +14 -0
  47. data/lib/openxml/pptx/properties/extension_list.rb +14 -0
  48. data/lib/openxml/pptx/properties/font.rb +32 -0
  49. data/lib/openxml/pptx/properties/font_reference.rb +12 -0
  50. data/lib/openxml/pptx/properties/font_reference_bold.rb +13 -0
  51. data/lib/openxml/pptx/properties/font_reference_bold_italic.rb +13 -0
  52. data/lib/openxml/pptx/properties/font_reference_italic.rb +13 -0
  53. data/lib/openxml/pptx/properties/font_reference_regular.rb +13 -0
  54. data/lib/openxml/pptx/properties/graphic_frame.rb +20 -0
  55. data/lib/openxml/pptx/properties/group_shape_properties.rb +34 -0
  56. data/lib/openxml/pptx/properties/handout_master_id.rb +18 -0
  57. data/lib/openxml/pptx/properties/handout_master_id_list.rb +14 -0
  58. data/lib/openxml/pptx/properties/non_visual_connection_shape_drawing_properties.rb +18 -0
  59. data/lib/openxml/pptx/properties/non_visual_connection_shape_properties.rb +16 -0
  60. data/lib/openxml/pptx/properties/non_visual_drawing_properties.rb +30 -0
  61. data/lib/openxml/pptx/properties/non_visual_graphic_frame_drawing_properties.rb +15 -0
  62. data/lib/openxml/pptx/properties/non_visual_graphic_frame_properties.rb +16 -0
  63. data/lib/openxml/pptx/properties/non_visual_group_shape_drawing_properties.rb +15 -0
  64. data/lib/openxml/pptx/properties/non_visual_group_shape_properties.rb +16 -0
  65. data/lib/openxml/pptx/properties/non_visual_picture_properties.rb +16 -0
  66. data/lib/openxml/pptx/properties/non_visual_picutre_drawing_properties.rb +18 -0
  67. data/lib/openxml/pptx/properties/non_visual_properties.rb +29 -0
  68. data/lib/openxml/pptx/properties/non_visual_shape_drawing_properties.rb +18 -0
  69. data/lib/openxml/pptx/properties/non_visual_shape_properties.rb +16 -0
  70. data/lib/openxml/pptx/properties/notes_master_id.rb +18 -0
  71. data/lib/openxml/pptx/properties/notes_master_id_list.rb +14 -0
  72. data/lib/openxml/pptx/properties/notes_size.rb +14 -0
  73. data/lib/openxml/pptx/properties/photo_album.rb +19 -0
  74. data/lib/openxml/pptx/properties/picture.rb +30 -0
  75. data/lib/openxml/pptx/properties/placeholder.rb +20 -0
  76. data/lib/openxml/pptx/properties/shape.rb +34 -0
  77. data/lib/openxml/pptx/properties/shape_group.rb +18 -0
  78. data/lib/openxml/pptx/properties/shape_properties.rb +11 -0
  79. data/lib/openxml/pptx/properties/shape_style.rb +11 -0
  80. data/lib/openxml/pptx/properties/shape_tree.rb +13 -0
  81. data/lib/openxml/pptx/properties/shapes_container.rb +18 -0
  82. data/lib/openxml/pptx/properties/simple_boolean_property.rb +16 -0
  83. data/lib/openxml/pptx/properties/simple_property_container_property.rb +14 -0
  84. data/lib/openxml/pptx/properties/slide_id.rb +29 -0
  85. data/lib/openxml/pptx/properties/slide_id_list.rb +14 -0
  86. data/lib/openxml/pptx/properties/slide_layout_id.rb +26 -0
  87. data/lib/openxml/pptx/properties/slide_layout_id_list.rb +14 -0
  88. data/lib/openxml/pptx/properties/slide_list.rb +14 -0
  89. data/lib/openxml/pptx/properties/slide_master_id.rb +29 -0
  90. data/lib/openxml/pptx/properties/slide_master_id_list.rb +14 -0
  91. data/lib/openxml/pptx/properties/slide_reference.rb +15 -0
  92. data/lib/openxml/pptx/properties/slide_size.rb +16 -0
  93. data/lib/openxml/pptx/properties/smart_tags.rb +15 -0
  94. data/lib/openxml/pptx/properties/text_body.rb +11 -0
  95. data/lib/openxml/pptx/properties/text_style_body.rb +11 -0
  96. data/lib/openxml/pptx/properties/text_style_other.rb +11 -0
  97. data/lib/openxml/pptx/properties/text_style_title.rb +11 -0
  98. data/lib/openxml/pptx/properties/text_styles.rb +17 -0
  99. data/lib/openxml/pptx/properties/transform.rb +11 -0
  100. data/lib/openxml/pptx/properties/transparent_container_property.rb +14 -0
  101. data/lib/openxml/pptx/relatable_part.rb +100 -0
  102. data/lib/openxml/pptx/version.rb +5 -0
  103. data/openxml-pptx.gemspec +33 -0
  104. metadata +258 -0
@@ -0,0 +1,61 @@
1
+ # frozen_string_literals: true
2
+ require "openxml/drawingml/parts/theme"
3
+
4
+ module OpenXml
5
+ module Pptx
6
+ module Parts
7
+ class Theme < OpenXml::DrawingML::Parts::Theme
8
+ include OpenXml::RelatablePart
9
+
10
+ relationship_type "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"
11
+ content_type "application/vnd.openxmlformats-officedocument.theme+xml"
12
+ default_path "ppt/theme/theme.xml"
13
+
14
+ def relationships_path; end
15
+
16
+ # Default theme
17
+ def self.office_theme
18
+ new.tap do |theme|
19
+ theme.theme_name = "Office Theme"
20
+ theme.theme_elements.color_scheme.tap do |scheme|
21
+ scheme.scheme_name = "Office"
22
+ scheme.dark_one.system_color = :windowText
23
+ scheme.dark_one.system_color.last_color = "000000"
24
+ scheme.light_one.system_color = :window
25
+ scheme.light_one.system_color.last_color = "FFFFFF"
26
+ scheme.dark_two.rgb = "44546A"
27
+ scheme.light_two.rgb = "E7E6E6"
28
+ scheme.accent_one.rgb = "4472C4"
29
+ scheme.accent_two.rgb = "ED7D31"
30
+ scheme.accent_three.rgb = "A5A5A5"
31
+ scheme.accent_four.rgb = "FFC000"
32
+ scheme.accent_five.rgb = "5B9BD5"
33
+ scheme.accent_six.rgb = "70AD47"
34
+ scheme.hyperlink.rgb = "0563C1"
35
+ scheme.followed_hyperlink.rgb = "954F72"
36
+ end
37
+ theme.theme_elements.font_scheme.tap do |scheme|
38
+ scheme.scheme_name = "Office"
39
+ scheme.major_font.latin_font = "Calibri Light"
40
+ scheme.major_font.east_asian_font = ""
41
+ scheme.major_font.complex_script_font = ""
42
+ scheme.minor_font.latin_font = "Calibri"
43
+ scheme.minor_font.east_asian_font = ""
44
+ scheme.minor_font.complex_script_font = ""
45
+ end
46
+ theme.theme_elements.format_scheme.tap do |scheme|
47
+ scheme.scheme_name = "Office"
48
+ 3.times do
49
+ scheme.fill_style_list << OpenXml::DrawingML::Properties::FillNone.new(true)
50
+ scheme.line_style_list << OpenXml::DrawingML::Properties::Outline.new
51
+ scheme.effect_style_list << OpenXml::DrawingML::Properties::EffectStyle.new.tap(&:effect_list)
52
+ scheme.background_fill_style_list << OpenXml::DrawingML::Properties::FillNone.new(true)
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,21 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ end
5
+ end
6
+ end
7
+
8
+ require "openxml/properties"
9
+ require "openxml/has_properties"
10
+ require "openxml/has_children"
11
+ require "openxml/has_attributes"
12
+ require "openxml/contains_properties"
13
+ require "openxml/render_when_empty"
14
+
15
+ require "openxml/pptx/properties/simple_boolean_property"
16
+ require "openxml/pptx/properties/simple_property_container_property"
17
+ require "openxml/pptx/properties/transparent_container_property"
18
+
19
+ Dir.glob("#{File.join(File.dirname(__FILE__), "properties", "*.rb")}").each do |file|
20
+ require file
21
+ end
@@ -0,0 +1,19 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class Background < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :bg
8
+
9
+ attribute :bw_mode, one_of: OpenXml::Pptx::ST_BlackWhiteMode
10
+
11
+ property_choice do
12
+ property :background_properties
13
+ property :background_reference
14
+ end
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class BackgroundProperties < OpenXml::Properties::ComplexProperty
5
+ include ContainsProperties
6
+ namespace :p
7
+ tag :bgPr
8
+
9
+ attribute :shade_to_title, displays_as: :shadeToTitle, expects: :boolean
10
+
11
+ property_choice do
12
+ value_property :no_fill, klass: OpenXml::DrawingML::Properties::FillNone
13
+ property :solid_fill, klass: OpenXml::DrawingML::Properties::FillSolid
14
+ property :gradient_fill, klass: OpenXml::DrawingML::Properties::FillGradient
15
+ property :pattern_fill, klass: OpenXml::DrawingML::Properties::FillPattern
16
+ property :blip_fill, klass: OpenXml::DrawingML::Properties::FillBlip
17
+ value_property :inherit_group_fill, klass: OpenXml::DrawingML::Properties::FillGroup
18
+ end
19
+
20
+ property_choice do
21
+ property :effect_list, klass: OpenXml::DrawingML::Properties::EffectList
22
+ property :effect_dag, klass: OpenXml::DrawingML::Properties::EffectDag
23
+ end
24
+
25
+ property :extension_list
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,23 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class BackgroundReference < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :bgRef
8
+
9
+ attribute :index, displays_as: :idx, expects: :positive_integer, required: true
10
+
11
+ property_choice required: true do
12
+ property :component_rgb, klass: OpenXml::DrawingML::Properties::ColorComponentRgb
13
+ value_property :rgb, klass: OpenXml::DrawingML::Properties::ColorHexRgb
14
+ property :hsl, klass: OpenXml::DrawingML::Properties::ColorHsl
15
+ value_property :system_color, klass: OpenXml::DrawingML::Properties::ColorSystemColor
16
+ value_property :scheme_color, klass: OpenXml::DrawingML::Properties::ColorSchemeColor
17
+ value_property :preset_color, klass: OpenXml::DrawingML::Properties::ColorPresetColor
18
+ end
19
+
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,11 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class BlipFill < OpenXml::DrawingML::Properties::FillBlip
5
+ namespace :p
6
+ tag :blipFill
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class ColorMapping < OpenXml::DrawingML::Properties::ColorMapping
5
+ namespace :p
6
+ tag :clrMap
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class ColorMappingOverride < OpenXml::DrawingML::Properties::ColorMappingOverride
5
+ namespace :p
6
+ tag :clrMapOvr
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class CommonSlideData < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ include OpenXml::RenderWhenEmpty
7
+ namespace :p
8
+ tag :cSld
9
+
10
+ attribute :slide_name, displays_as: :name, expects: :string
11
+
12
+ property :background
13
+ property :shape_tree, required: true
14
+ property :customer_data_list
15
+ property :control_list
16
+ property :extension_list
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class ConnectionShape < SimplePropertyContainerProperty
5
+ namespace :p
6
+ tag :cxnSp
7
+
8
+ property :non_visual_connection_shape_properties, required: true
9
+ property :shape_properties, required: true
10
+ property :shape_style
11
+ property :extension_list
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class ContentPart < OpenXml::Properties::ComplexProperty
5
+ namespace :p
6
+ tag :contentPart
7
+
8
+ attribute :rid, displays_as: :id, namespace: :r, expects: :string, required: true
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class Control < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :control
8
+
9
+ attribute :control_name, displays_as: :name, expects: :string
10
+ attribute :show_as_icon, displays_as: :showAsIcon, expects: :boolean
11
+ attribute :rid, displays_as: :id, namespace: :r, expects: :string
12
+ attribute :image_width, displays_as: :imgW, expects: :positive_coordinate
13
+ attribute :image_height, displays_as: :imgH, expects: :positive_coordinate
14
+
15
+ property :extension_list
16
+ property :picture
17
+
18
+ private
19
+
20
+ def positive_coordinate(value)
21
+ message = "Invalid: must be a positive integer or include a unit"
22
+ raise ArgumentError, message unless positive_integer?(value) || positive_universal_measure?(value)
23
+ end
24
+
25
+ def positive_integer?(value)
26
+ value.is_a?(Integer) && value >= 0
27
+ end
28
+
29
+ def positive_universal_measure?(value)
30
+ value.is_a?(String) && value =~ OpenXml::DrawingML::ST_PositiveUniversalMeasure
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,14 @@
1
+ require "openxml/pptx/properties/control"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class ControlList < OpenXml::Properties::ContainerProperty
7
+ namespace :p
8
+ tag :controls
9
+ child_class :control
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class CustomShow < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :custShow
8
+
9
+ attribute :id, expects: :positive_integer, required: true
10
+ attribute :show_name, displays_as: :name, expects: :string, required: true
11
+
12
+ property :slide_list, required: true
13
+ property :extension_list
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ require "openxml/pptx/properties/custom_show"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class CustomShowList < OpenXml::Properties::ContainerProperty
7
+ namespace :p
8
+ tag :custShowLst
9
+ child_class :custom_show
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class CustomerData < OpenXml::Properties::ComplexProperty
5
+ namespace :p
6
+ tag :custData
7
+
8
+ attribute :rid, displays_as: :id, namespace: :r, expects: :string, required: true
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ require "openxml/pptx/properties/customer_data"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class CustomerDataContainer < TransparentContainerProperty
7
+ child_class :customer_data
8
+
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class CustomerDataList < SimplePropertyContainerProperty
5
+ namespace :p
6
+ tag :custDataLst
7
+
8
+ property :data, as: :customer_data_container
9
+ property :tags, as: :data_tags
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class DataTags < OpenXml::Properties::ComplexProperty
5
+ namespace :p
6
+ tag :tags
7
+
8
+ attribute :rid, displays_as: :id, namespace: :r, expects: :string, required: true
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class DefaultTextStyle < SimplePropertyContainerProperty
5
+ namespace :p
6
+ tag :defaultTextStyle
7
+
8
+ property :default_paragraph_properties, klass: OpenXml::DrawingML::Properties::DefaultParagraphProperties
9
+ property :level1_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level1ParagraphProperties
10
+ property :level2_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level2ParagraphProperties
11
+ property :level3_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level3ParagraphProperties
12
+ property :level4_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level4ParagraphProperties
13
+ property :level5_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level5ParagraphProperties
14
+ property :level6_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level6ParagraphProperties
15
+ property :level7_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level7ParagraphProperties
16
+ property :level8_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level8ParagraphProperties
17
+ property :level9_paragraph_properties, klass: OpenXml::DrawingML::Properties::Level9ParagraphProperties
18
+
19
+ property :extension_list
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class EmbeddedFont < SimplePropertyContainerProperty
5
+ namespace :p
6
+ tag :embeddedFont
7
+
8
+ value_property :font, required: true, default_value: "Calibri"
9
+
10
+ property :regular, as: :font_reference_regular
11
+ property :bold, as: :font_reference_bold
12
+ property :italic, as: :font_reference_italic
13
+ property :bold_italic, as: :font_reference_italic
14
+
15
+ end
16
+ end
17
+ end
18
+ end