Class: OpenXml::Pptx::Parts::Slide

Inherits:
OpenXml::Part
  • Object
show all
Includes:
ContainsProperties, HasAttributes, RelatablePart
Defined in:
lib/openxml/pptx/parts/slide.rb

Constant Summary collapse

LAYOUT_SCHEMA =
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout".freeze

Instance Attribute Summary collapse

Attributes included from RelatablePart

#parent

Instance Method Summary collapse

Methods included from RelatablePart

#add_child_part, #add_override, #add_part, #add_relationship, #content_type, #file_name, included, #indexed_path, #path, #path=, #relationship_type, #relationships, #relationships_by_path, #relationships_path

Constructor Details

#initialize(*_args) ⇒ Slide

Returns a new instance of Slide.



30
31
32
33
# File 'lib/openxml/pptx/parts/slide.rb', line 30

def initialize(*_args)
  super
  @images = []
end

Instance Attribute Details

#imagesObject (readonly)

Returns the value of attribute images.



8
9
10
# File 'lib/openxml/pptx/parts/slide.rb', line 8

def images
  @images
end

Instance Method Details

#add_image(image_part) ⇒ Object



40
41
42
43
44
# File 'lib/openxml/pptx/parts/slide.rb', line 40

def add_image(image_part)
  images.push(image_part)
  index = (parent && parent.next_image_index) || images.count
  add_child_part(image_part, with_index: index)
end

#background_propertiesObject



70
71
72
# File 'lib/openxml/pptx/parts/slide.rb', line 70

def background_properties
  common_slide_data.background.background_properties
end

#build_image_part(path) ⇒ Object



46
47
48
49
50
51
# File 'lib/openxml/pptx/parts/slide.rb', line 46

def build_image_part(path)
  path = Pathname.new(path)
  OpenXml::Pptx::Parts::Image.new(path.read, extension: path.extname).tap do |image|
    add_image(image)
  end
end

#nameObject

Necessary for HasAttributes



36
37
38
# File 'lib/openxml/pptx/parts/slide.rb', line 36

def name
  "slide"
end

#set_slide_layout(layout) ⇒ Object



53
54
55
# File 'lib/openxml/pptx/parts/slide.rb', line 53

def set_slide_layout(layout)
  add_relationship layout.relationship_type, layout.path
end

#shapesObject

Convenience accessors



66
67
68
# File 'lib/openxml/pptx/parts/slide.rb', line 66

def shapes
  common_slide_data.shape_tree.shapes
end

#to_xmlObject



57
58
59
60
61
62
63
# File 'lib/openxml/pptx/parts/slide.rb', line 57

def to_xml
  build_standalone_xml do |xml|
    xml[:p].sld(namespaces.merge(xml_attributes)) do
      property_xml(xml)
    end
  end
end