Sha256: 89545f73939ff28b2352b960979c7534ed32667f5a6a0cd0f624cbb4442337e2

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

require_relative 'shape/docx_shape'
require_relative 'picture/docx_picture'
module OoxmlParser
  # Class for parsing `graphic` tags
  class DocxGraphic < OOXMLDocumentObject
    attr_accessor :type, :data

    alias chart data

    # Parse DocxGraphic
    # @param [Nokogiri::XML:Node] node with NumberingProperties
    # @return [DocxGraphic] result of parsing
    def parse(node)
      node.xpath('a:graphicData/*', 'xmlns:a' => 'http://schemas.openxmlformats.org/drawingml/2006/main').each do |node_child|
        case node_child.name
        when 'wsp'
          @type = :shape
          @data = DocxShape.new(parent: self).parse(node_child)
        when 'pic'
          @type = :picture
          @data = DocxPicture.new(parent: self).parse(node_child)
        when 'chart'
          @type = :chart
          @chart_reference = ChartReference.new(parent: self).parse(node_child)
          root_object.add_to_xmls_stack("#{root_object.root_subfolder}/#{root_object.get_link_from_rels(@chart_reference.id)}")
          @data = Chart.new(parent: self).parse
          root_object.xmls_stack.pop
        when 'wgp'
          @type = :group
          @data = ShapesGrouping.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ooxml_parser-0.37.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb
ooxml_parser-0.37.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb
ooxml_parser-0.36.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb
ooxml_parser-0.36.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb
ooxml_parser-0.35.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb
ooxml_parser-0.34.2 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb
ooxml_parser-0.34.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb
ooxml_parser-0.34.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb