Sha256: f03aa7e31f2848c441ff32ca812030efab9bce5e251740302e12ac1770a92374

Contents?: true

Size: 1.78 KB

Versions: 8

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `graphicFrame`
  class GraphicFrame < OOXMLDocumentObject
    attr_accessor :properties, :transform, :graphic_data
    # @return [NonVisualShapeProperties] non visual properties
    attr_accessor :non_visual_properties

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

    # Parse GraphicFrame object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [GraphicFrame] result of parsing
    def parse(node)
      node.xpath('*').each do |node_child|
        case node_child.name
        when 'xfrm'
          @transform = DocxShapeSize.new(parent: self).parse(node_child)
        when 'graphic'
          graphic_data = []
          node_child.xpath('*').each do |node_child_child|
            case node_child_child.name
            when 'graphicData'
              node_child_child.xpath('*').each do |graphic_node_child|
                case graphic_node_child.name
                when 'tbl'
                  graphic_data << Table.new(parent: self).parse(graphic_node_child)
                when 'chart'
                  OOXMLDocumentObject.add_to_xmls_stack(OOXMLDocumentObject.get_link_from_rels(graphic_node_child.attribute('id').value))
                  graphic_data << Chart.parse(parent: self)
                  OOXMLDocumentObject.xmls_stack.pop
                when 'oleObj'
                  graphic_data << OleObject.new(parent: self).parse(graphic_node_child)
                end
              end
            end
          end
          @graphic_data = graphic_data
        when 'nvGraphicFramePr'
          @non_visual_properties = NonVisualShapeProperties.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/graphic_frame/graphic_frame.rb
ooxml_parser-0.8.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb
ooxml_parser-0.7.2 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb
ooxml_parser-0.7.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb
ooxml_parser-0.7.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb
ooxml_parser-0.6.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb
ooxml_parser-0.5.1 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb
ooxml_parser-0.5.0 lib/ooxml_parser/pptx_parser/pptx_data/presentation/slide/graphic_frame/graphic_frame.rb