Sha256: 5c212f0d99b817a03767d38c21f6045e009b3aeb1e06fc9fe36db56787c88626

Contents?: true

Size: 1.54 KB

Versions: 48

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

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

48 entries across 48 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.33.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.32.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.31.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.30.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.29.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.28.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.27.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.26.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.25.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.24.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.23.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb
ooxml_parser-0.22.0 lib/ooxml_parser/common_parser/common_data/alternate_content/alternate_content.rb