Sha256: b7d4315682311d87e11d5c1f0f77524402bff4388a180f9816095f4448954aa6

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

require_relative 'alternate_content/choice'
require_relative 'alternate_content/chart_style'
require_relative 'chart/chart'
require_relative 'drawing/docx_drawing'
require_relative 'picture/old_docx_picture'
module OoxmlParser
  # Class for storing fallback graphic elements
  class AlternateContent < OOXMLDocumentObject
    attr_accessor :office2010_content, :office2007_content
    # @return [Choice] choice data
    attr_accessor :choice

    # Parse AlternateContent
    # @param [Nokogiri::XML:Node] node with Relationships
    # @return [AlternateContent] result of parsing
    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ooxml_parser-0.4.1 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.4.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.3.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.2.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb