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,18 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class NonVisualShapeDrawingProperties < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ include OpenXml::RenderWhenEmpty
7
+ namespace :p
8
+ tag :cNvSpPr
9
+
10
+ attribute :is_textbox, displays_as: :txBox, expects: :boolean
11
+
12
+ property :shape_locks, klass: OpenXml::DrawingML::Properties::ShapeLocks
13
+ property :extension_list, klass: OpenXml::DrawingML::Properties::ExtensionList
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class NonVisualShapeProperties < SimplePropertyContainerProperty
5
+ include OpenXml::RenderWhenEmpty
6
+ namespace :p
7
+ tag :nvSpPr
8
+
9
+ property :non_visual_drawing_properties, required: true
10
+ property :non_visual_shape_drawing_properties, required: true
11
+ property :non_visual_properties, required: true
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class NotesMasterId < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :notesMasterId
8
+
9
+ with_namespace :r do
10
+ attribute :rid, displays_as: :id, expects: :string, required: true
11
+ end
12
+
13
+ property :extension_list
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,14 @@
1
+ require "openxml/pptx/properties/notes_master_id"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class NotesMasterIdList < OpenXml::Properties::ContainerProperty
7
+ namespace :p
8
+ tag :notesMasterIdLst
9
+ child_class :notes_master_id
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class NotesSize < OpenXml::Properties::ComplexProperty
5
+ namespace :p
6
+ tag :notesSz
7
+
8
+ attribute :length, displays_as: :cx, expects: :positive_integer, required: true
9
+ attribute :width, displays_as: :cy, expects: :positive_integer, required: true
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,19 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class PhotoAlbum < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :photoAlbum
8
+
9
+ attribute :black_and_white, displays_as: :bw, expects: :boolean
10
+ attribute :frame, one_of: OpenXml::Pptx::ST_PhotoAlbumFrameShape
11
+ attribute :layout, one_of: OpenXml::Pptx::ST_PhotoAlbumLayout
12
+ attribute :show_captions, expects: :boolean
13
+
14
+ property :extension_list
15
+
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ require "forwardable"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class Picture < SimplePropertyContainerProperty
7
+ extend Forwardable
8
+ namespace :p
9
+ tag :pic
10
+
11
+ property :non_visual_picture_properties, required: true
12
+ property :blip_fill, required: true
13
+ property :shape_properties, required: true
14
+ property :shape_style
15
+ property :extension_list
16
+
17
+ # Convenience Accessors
18
+ def_delegator :non_visual_picture_properties, :non_visual_drawing_properties
19
+ def_delegator :non_visual_drawing_properties, :object_name, :picture_name
20
+ def_delegator :non_visual_drawing_properties, :object_name=, :picture_name=
21
+ def_delegator :non_visual_drawing_properties, :id, :picture_id
22
+ def_delegator :non_visual_drawing_properties, :id=, :picture_id=
23
+ def_delegator :shape_properties, :transform
24
+ def_delegator :transform, :offset
25
+ def_delegator :transform, :extent
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class Placeholder < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :ph
8
+
9
+ attribute :type, one_of: OpenXml::Pptx::ST_PlaceholderType
10
+ attribute :orientation, one_of: OpenXml::Pptx::ST_Direction
11
+ attribute :size, one_of: OpenXml::Pptx::ST_PlaceholderSize
12
+ attribute :index, displays_as: :idx, expects: :positive_integer
13
+ attribute :has_custom_prompt, displays_as: :hasCustomPrompt, expects: :boolean
14
+
15
+ property :extension_list
16
+
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ require "forwardable"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class Shape < OpenXml::Properties::ComplexProperty
7
+ include OpenXml::ContainsProperties
8
+ extend Forwardable
9
+ namespace :p
10
+ tag :sp
11
+
12
+ attribute :use_background_fill, displays_as: :useBgFill, expects: :boolean
13
+
14
+ property :non_visual_shape_properties, required: true
15
+ property :shape_properties, required: true
16
+ property :style, as: :shape_style
17
+ property :text_body
18
+
19
+ property :extension_list
20
+
21
+ # Convenience Accessors
22
+ def_delegator :non_visual_shape_properties, :non_visual_drawing_properties
23
+ def_delegator :non_visual_drawing_properties, :object_name, :shape_name
24
+ def_delegator :non_visual_drawing_properties, :object_name=, :shape_name=
25
+ def_delegator :non_visual_drawing_properties, :id, :shape_id
26
+ def_delegator :non_visual_drawing_properties, :id=, :shape_id=
27
+ def_delegator :shape_properties, :transform
28
+ def_delegator :transform, :offset
29
+ def_delegator :transform, :extent
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,18 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class ShapeGroup < SimplePropertyContainerProperty
5
+ namespace :p
6
+ tag :grpSp
7
+
8
+ property :non_visual_group_shape_properties, required: true
9
+ property :group_shape_properties, required: true
10
+
11
+ property :shapes, as: :shapes_container
12
+
13
+ property :extension_list
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,11 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class ShapeProperties < OpenXml::DrawingML::Properties::ShapeProperties
5
+ namespace :p
6
+ tag :spPr
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class ShapeStyle < OpenXml::DrawingML::Properties::ShapeStyle
5
+ namespace :p
6
+ tag :style
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ require "openxml/pptx/properties/shape_group"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class ShapeTree < ShapeGroup
7
+ namespace :p
8
+ tag :spTree
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ require "openxml/pptx/properties/shape"
2
+ require "openxml/pptx/properties/shape_group"
3
+ require "openxml/pptx/properties/graphic_frame"
4
+ require "openxml/pptx/properties/connection_shape"
5
+ require "openxml/pptx/properties/picture"
6
+ require "openxml/pptx/properties/content_part"
7
+
8
+ module OpenXml
9
+ module Pptx
10
+ module Properties
11
+ class ShapesContainer < TransparentContainerProperty
12
+ child_classes :shape, :shape_group, :graphic_frame, :connection_shape,
13
+ :picture, :content_part
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class SimpleBooleanProperty < OpenXml::Properties::BooleanProperty
5
+
6
+ def to_xml(xml)
7
+ return unless value
8
+ apply_namespace(xml).public_send(tag) do
9
+ yield xml if block_given?
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class SimplePropertyContainerProperty < SimpleBooleanProperty
5
+ include OpenXml::ContainsProperties
6
+
7
+ def initialize(*_args)
8
+ super(true)
9
+ end
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class SlideId < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :sldId
8
+
9
+ attribute :id, expects: :integer, in_range: OpenXml::Pptx::SLIDE_ID_RANGE, required: true
10
+
11
+ with_namespace :r do
12
+ attribute :rid, displays_as: :id, expects: :string, required: true
13
+ end
14
+
15
+ property :extension_list
16
+
17
+ def initialize(*_args)
18
+ super
19
+ generate_id
20
+ end
21
+
22
+ def generate_id
23
+ self.id = object_id % OpenXml::Pptx::SLIDE_ID_RANGE.end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+ require "openxml/pptx/properties/slide_id"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class SlideIdList < OpenXml::Properties::ContainerProperty
7
+ namespace :p
8
+ tag :sldIdLst
9
+ child_class :slide_id
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class SlideLayoutId < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :sldLayoutId
8
+
9
+ attribute :id, expects: :integer, in_range: OpenXml::Pptx::MASTER_LAYOUT_ID_RANGE
10
+ attribute :rid, displays_as: :id, namespace: :r, expects: :string, required: true
11
+
12
+ property :extension_list
13
+
14
+ def initialize(*_args)
15
+ super
16
+ generate_id
17
+ end
18
+
19
+ def generate_id
20
+ self.id = OpenXml::Pptx::MASTER_LAYOUT_ID_RANGE.begin + object_id % OpenXml::Pptx::MASTER_LAYOUT_ID_RANGE.begin
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ require "openxml/pptx/properties/slide_layout_id"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class SlideLayoutIdList < OpenXml::Properties::ContainerProperty
7
+ namespace :p
8
+ tag :sldLayoutIdLst
9
+ child_class :slide_layout_id
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ require "openxml/pptx/properties/slide_reference"
2
+
3
+ module OpenXml
4
+ module Pptx
5
+ module Properties
6
+ class SlideList < OpenXml::Properties::ContainerProperty
7
+ namespace :p
8
+ tag :sldLst
9
+ child_class :slide_reference
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,29 @@
1
+ module OpenXml
2
+ module Pptx
3
+ module Properties
4
+ class SlideMasterId < OpenXml::Properties::ComplexProperty
5
+ include OpenXml::ContainsProperties
6
+ namespace :p
7
+ tag :sldMasterId
8
+
9
+ attribute :id, expects: :integer, in_range: OpenXml::Pptx::MASTER_LAYOUT_ID_RANGE
10
+
11
+ with_namespace :r do
12
+ attribute :rid, displays_as: :id, expects: :string, required: true
13
+ end
14
+
15
+ property :extension_list
16
+
17
+ def initialize(*_args)
18
+ super
19
+ generate_id
20
+ end
21
+
22
+ def generate_id
23
+ self.id = OpenXml::Pptx::MASTER_LAYOUT_ID_RANGE.begin + object_id % OpenXml::Pptx::MASTER_LAYOUT_ID_RANGE.begin
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end