Class: OoxmlParser::AlternateContent

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb

Overview

Class for storing fallback graphic elements

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

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

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#choiceChoice

Returns choice data.

Returns:



13
14
15
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb', line 13

def choice
  @choice
end

#office2007_contentObject

Returns the value of attribute office2007_content.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb', line 11

def office2007_content
  @office2007_content
end

#office2010_contentObject

Returns the value of attribute office2010_content.



11
12
13
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb', line 11

def office2010_content
  @office2010_content
end

Instance Method Details

#parse(node) ⇒ AlternateContent

Parse AlternateContent

Parameters:

  • node (Nokogiri::XML:Node)

    with Relationships

Returns:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb', line 18

def parse(node)
  node.xpath('*').each do |node_child|
    begin
      node_child.xpath('w:drawing')
    rescue Nokogiri::XML::XPath::SyntaxError # This mean it is Chart
      case node_child.name
      when 'Choice'
        @office2010_content = ChartStyle.new(parent: self).parse(node_child)
      when 'Fallback'
        @office2007_content = ChartStyle.new(parent: self).parse(node_child)
      end
      next
    end
    case node_child.name
    when 'Choice'
      @office2010_content = DocxDrawing.new(parent: self).parse(node_child.xpath('w:drawing').first) unless node_child.xpath('w:drawing').first.nil?
      @choice = Choice.new(parent: self).parse(node_child)
    when 'Fallback'
      @office2007_content = OldDocxPicture.new(parent: self).parse(node_child.xpath('w:pict').first) unless node_child.xpath('w:pict').first.nil?
    end
  end
  self
end