class OoxmlParser::Presentation

Basic class for all parsed pptx data

Attributes

comment_authors[R]

@return [CommentAuthors] authors of presentation

comments[R]

@return [PresentationComments] comments of presentation

relationships[RW]

@return [Relationships] relationships of presentation

slide_layouts[R]

@return [Array<SlideLayout>] list of slide layouts

slide_masters[R]

@return [Array<SlideMasterFile>] list of slide master

slide_size[RW]
slides[RW]
table_styles[RW]

@return [TableStyles] table styles data

theme[RW]

Public Class Methods

new(params = {}) click to toggle source
# File lib/ooxml_parser/pptx_parser/presentation.rb, line 34
def initialize(params = {})
  @slides = []
  @comments = []
  @slide_masters = []
  @slide_layouts = []
  super
end

Public Instance Methods

parse() click to toggle source

Parse data of presentation @return [Presentation] parsed presentation

# File lib/ooxml_parser/pptx_parser/presentation.rb, line 44
def parse
  @content_types = ContentTypes.new(parent: self).parse
  @root_subfolder = 'ppt/'
  root_object.add_to_xmls_stack('ppt/presentation.xml')
  doc = parse_xml(root_object.current_xml)
  @theme = PresentationTheme.new(parent: self).parse('ppt/theme/theme1.xml')
  @table_styles = TableStyles.new(parent: self).parse
  @comment_authors = CommentAuthors.new(parent: self).parse
  @comments = PresentationComments.new(parent: self).parse
  presentation_node = doc.search('//p:presentation').first
  presentation_node.xpath('*').each do |presentation_node_child|
    case presentation_node_child.name
    when 'sldSz'
      @slide_size = SlideSize.new(parent: self).parse(presentation_node_child)
    when 'sldIdLst'
      presentation_node_child.xpath('p:sldId').each do |silde_id_node|
        slide_id = silde_id_node.attr('r:id')
        @slides << Slide.new(parent: self,
                             xml_path: "#{root_object.root_subfolder}/#{root_object.get_link_from_rels(slide_id)}")
                        .parse
      end
    end
  end
  root_object.xmls_stack.pop
  @relationships = Relationships.new(parent: self).parse_file("#{root_object.unpacked_folder}/ppt/_rels/presentation.xml.rels")
  parse_slide_layouts
  parse_slide_masters
  self
end