class OoxmlParser::AlternateContent

Class for storing fallback graphic elements

Attributes

choice[RW]

@return [Choice] choice data

office2007_content[RW]
office2010_content[RW]

Public Instance Methods

parse(node) click to toggle source

Parse AlternateContent @param [Nokogiri::XML:Node] node with Relationships @return [AlternateContent] result of parsing

# 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