Class: OpenXml::Pptx::Parts::SlideLayout

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

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) ⇒ SlideLayout

Returns a new instance of SlideLayout.



33
34
35
36
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 33

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

Instance Attribute Details

#imagesObject (readonly)

Returns the value of attribute images.



10
11
12
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 10

def images
  @images
end

Instance Method Details

#add_image(image_part) ⇒ Object



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

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



73
74
75
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 73

def background_properties
  common_slide_data.background.background_properties
end

#build_image_part(path) ⇒ Object



53
54
55
56
57
58
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 53

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



39
40
41
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 39

def name
  "slide_layout"
end

#set_slide_master(master) ⇒ Object



43
44
45
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 43

def set_slide_master(master)
  add_relationship master.relationship_type, master.path
end

#shapesObject

Convenience accessors



69
70
71
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 69

def shapes
  common_slide_data.shape_tree.shapes
end

#to_xmlObject



60
61
62
63
64
65
66
# File 'lib/openxml/pptx/parts/slide_layout.rb', line 60

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