class OoxmlParser::Slide

Class for parsing `slide.xml`

Attributes

alternate_content[RW]
common_slide_data[R]

@return [CommonSlideData] common slide data

name[R]

@return [String] name of slide

note[R]

@return [Notes] note of slide

relationships[R]

@return [Relationships] relationships of slide

timing[RW]
transition[RW]

Public Class Methods

new(parent: nil, xml_path: nil) click to toggle source
Calls superclass method OoxmlParser::OOXMLDocumentObject::new
# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb, line 26
def initialize(parent: nil, xml_path: nil)
  @xml_path = xml_path
  super(parent: parent)
end

Public Instance Methods

background() click to toggle source

@return [Background] background of slide

# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb, line 47
def background
  @common_slide_data.background
end
elements() click to toggle source

@return <Array> List of elements on slide

# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb, line 42
def elements
  @common_slide_data.shape_tree.elements
end
parse() click to toggle source

Parse Slide object @return [Slide] result of parsing

# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb, line 53
def parse
  OOXMLDocumentObject.add_to_xmls_stack(@xml_path)
  @name = File.basename(@xml_path, '.*')
  node = parse_xml(OOXMLDocumentObject.current_xml)
  node.xpath('//p:sld/*').each do |node_child|
    case node_child.name
    when 'cSld'
      @common_slide_data = CommonSlideData.new(parent: self).parse(node_child)
    when 'timing'
      @timing = Timing.new(parent: self).parse(node_child)
    when 'transition'
      @transition = Transition.new(parent: self).parse(node_child)
    when 'AlternateContent'
      @alternate_content = PresentationAlternateContent.new(parent: self).parse(node_child)
    end
  end
  OOXMLDocumentObject.xmls_stack.pop
  @relationships = Relationships.new(parent: self).parse_file("#{OOXMLDocumentObject.path_to_folder}#{File.dirname(@xml_path)}/_rels/#{@name}.xml.rels")
  parse_note
  self
end
with_data?() click to toggle source

@return [True, False] is slide with data

# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb, line 32
def with_data?
  return true unless background.nil?

  elements.each do |current_element|
    return true if current_element.with_data?
  end
  false
end

Private Instance Methods

parse_note() click to toggle source

Parse slide notes if present

# File lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb, line 78
def parse_note
  notes_target = @relationships.target_by_type('notes')
  return nil if notes_target.empty?

  @note = PresentationNotes.new(parent: self).parse("#{OOXMLDocumentObject.path_to_folder}#{File.dirname(@xml_path)}/#{notes_target.first}")
end