Class: OoxmlParser::Slide

Inherits:
OOXMLDocumentObject show all
Includes:
SlideHelper
Defined in:
lib/ooxml_parser/pptx_parser/presentation/slide.rb

Overview

Class for parsing ‘slide.xml`

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods included from SlideHelper

#content_distribute, #content_horizontal_align, #content_vertical_align, #graphic_frames, #nonempty_elements, #transform_of_object

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #parse_xml

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

#initialize(parent: nil, xml_path: nil) ⇒ Slide

Returns a new instance of Slide.



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

def initialize(parent: nil, xml_path: nil)
  @xml_path = xml_path
  super(parent: parent)
end

Instance Attribute Details

#alternate_contentObject

Returns the value of attribute alternate_content.



16
17
18
# File 'lib/ooxml_parser/pptx_parser/presentation/slide.rb', line 16

def alternate_content
  @alternate_content
end

#common_slide_dataCommonSlideData (readonly)

Returns common slide data.

Returns:



18
19
20
# File 'lib/ooxml_parser/pptx_parser/presentation/slide.rb', line 18

def common_slide_data
  @common_slide_data
end

#nameString (readonly)

Returns name of slide.

Returns:

  • (String)

    name of slide



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

def name
  @name
end

#noteNotes (readonly)

Returns note of slide.

Returns:

  • (Notes)

    note of slide



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

def note
  @note
end

#relationshipsRelationships (readonly)

Returns relationships of slide.

Returns:



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

def relationships
  @relationships
end

#timingObject

Returns the value of attribute timing.



16
17
18
# File 'lib/ooxml_parser/pptx_parser/presentation/slide.rb', line 16

def timing
  @timing
end

#transitionObject

Returns the value of attribute transition.



16
17
18
# File 'lib/ooxml_parser/pptx_parser/presentation/slide.rb', line 16

def transition
  @transition
end

Instance Method Details

#backgroundBackground

Returns background of slide.

Returns:



47
48
49
# File 'lib/ooxml_parser/pptx_parser/presentation/slide.rb', line 47

def background
  @common_slide_data.background
end

#elementsArray

Returns List of elements on slide.

Returns:

  • (Array)

    List of elements on slide



42
43
44
# File 'lib/ooxml_parser/pptx_parser/presentation/slide.rb', line 42

def elements
  @common_slide_data.shape_tree.elements
end

#parseSlide

Parse Slide object

Returns:

  • (Slide)

    result of parsing



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ooxml_parser/pptx_parser/presentation/slide.rb', line 53

def parse
  root_object.add_to_xmls_stack(@xml_path)
  @name = File.basename(@xml_path, '.*')
  node = parse_xml(root_object.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
  root_object.xmls_stack.pop
  @relationships = Relationships.new(parent: self).parse_file("#{root_object.unpacked_folder}#{File.dirname(@xml_path)}/_rels/#{@name}.xml.rels")
  parse_note
  self
end

#with_data?True, False

Returns is slide with data.

Returns:

  • (True, False)

    is slide with data



32
33
34
35
36
37
38
39
# File 'lib/ooxml_parser/pptx_parser/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