Sha256: 822cb4c625eab116bb940681c76be3485200af4befc27ad711f12fdabf1b9625

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `spTree` tag
  class ShapeTree < OOXMLDocumentObject
    # @return [Array] elements of shape tree
    attr_reader :elements

    def initialize(parent: nil)
      @elements = []
      @parent = parent
    end

    # Parse ShapeTree object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [ShapeTree] result of parsing
    def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'sp'
          @elements << DocxShape.new(parent: self).parse(node_child).dup
        when 'pic'
          @elements << DocxPicture.new(parent: self).parse(node_child)
        when 'graphicFrame'
          @elements << GraphicFrame.new(parent: self).parse(node_child)
        when 'grpSp'
          @elements << ShapesGrouping.new(parent: self).parse(node_child)
        when 'cxnSp'
          @elements << ConnectionShape.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.8.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
ooxml_parser-0.8.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
ooxml_parser-0.7.2 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
ooxml_parser-0.7.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
ooxml_parser-0.7.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
ooxml_parser-0.6.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
ooxml_parser-0.5.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb
ooxml_parser-0.5.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/common_slide_data/shape_tree.rb