Class: OoxmlParser::Presentation

Inherits:
CommonDocumentStructure show all
Includes:
PresentationHelpers, SlideLayoutsHelper, SlideMastersHelper
Defined in:
lib/ooxml_parser/pptx_parser/presentation.rb

Overview

Basic class for all parsed pptx data

Instance Attribute Summary collapse

Attributes inherited from CommonDocumentStructure

#content_types, #default_font_size, #default_font_style, #default_font_typeface, #file_path, #root_subfolder, #unpacked_folder, #xmls_stack

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods included from SlideMastersHelper

#slide_masters_files

Methods included from SlideLayoutsHelper

#slide_layouts_files

Methods included from PresentationHelpers

#with_data?

Methods inherited from CommonDocumentStructure

#add_to_xmls_stack, #current_xml, #get_link_from_rels

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(params = {}) ⇒ Presentation

Returns a new instance of Presentation.



34
35
36
37
38
39
40
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 34

def initialize(params = {})
  @slides = []
  @comments = []
  @slide_masters = []
  @slide_layouts = []
  super
end

Instance Attribute Details

#comment_authorsCommentAuthors (readonly)

Returns authors of presentation.

Returns:



26
27
28
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 26

def comment_authors
  @comment_authors
end

#commentsPresentationComments (readonly)

Returns comments of presentation.

Returns:



28
29
30
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 28

def comments
  @comments
end

#relationshipsRelationships

Returns relationships of presentation.

Returns:



22
23
24
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 22

def relationships
  @relationships
end

#slide_layoutsArray<SlideLayout> (readonly)

Returns list of slide layouts.

Returns:

  • (Array<SlideLayout>)

    list of slide layouts



32
33
34
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 32

def slide_layouts
  @slide_layouts
end

#slide_mastersArray<SlideMasterFile> (readonly)

Returns list of slide master.

Returns:



30
31
32
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 30

def slide_masters
  @slide_masters
end

#slide_sizeObject

Returns the value of attribute slide_size.



20
21
22
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 20

def slide_size
  @slide_size
end

#slidesObject

Returns the value of attribute slides.



20
21
22
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 20

def slides
  @slides
end

#table_stylesTableStyles

Returns table styles data.

Returns:



24
25
26
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 24

def table_styles
  @table_styles
end

#themeObject

Returns the value of attribute theme.



20
21
22
# File 'lib/ooxml_parser/pptx_parser/presentation.rb', line 20

def theme
  @theme
end

Instance Method Details

#parsePresentation

Parse data of presentation

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# 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