Class: OoxmlParser::Slide

Inherits:
OOXMLDocumentObject show all
Includes:
SlideHelper
Defined in:
lib/ooxml_parser/pptx_parser/pptx_data/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

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, unzip_file

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

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

Returns a new instance of Slide.



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

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

Instance Attribute Details

#alternate_contentObject

Returns the value of attribute alternate_content.



14
15
16
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb', line 14

def alternate_content
  @alternate_content
end

#common_slide_dataCommonSlideData (readonly)

Returns common slide data.

Returns:



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

def common_slide_data
  @common_slide_data
end

#nameString (readonly)

Returns name of slide.

Returns:

  • (String)

    name of slide



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

def name
  @name
end

#noteNotes (readonly)

Returns note of slide.

Returns:

  • (Notes)

    note of slide



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

def note
  @note
end

#relationshipsRelationships (readonly)

Returns relationships of slide.

Returns:



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

def relationships
  @relationships
end

#timingObject

Returns the value of attribute timing.



14
15
16
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb', line 14

def timing
  @timing
end

#transitionObject

Returns the value of attribute transition.



14
15
16
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb', line 14

def transition
  @transition
end

Instance Method Details

#backgroundObject



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

def background
  @common_slide_data.background
end

#elementsObject



37
38
39
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb', line 37

def elements
  @common_slide_data.shape_tree.elements
end

#parseSlide

Parse Slide object

Returns:

  • (Slide)

    result of parsing



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb', line 47

def parse
  OOXMLDocumentObject.add_to_xmls_stack(@xml_path)
  @name = File.basename(@xml_path, '.*')
  node = Nokogiri::XML(File.open(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.parse_rels("#{OOXMLDocumentObject.path_to_folder}#{File.dirname(@xml_path)}/_rels/#{@name}.xml.rels")
  parse_note
  self
end

#with_data?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
34
35
# File 'lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide.rb', line 29

def with_data?
  return true unless background.nil?
  elements.each do |current_element|
    return true if current_element.with_data?
  end
  false
end