Class: OoxmlParser::DocxGraphic

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb

Overview

Class for parsing ‘graphic` tags

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, #boolean_attribute_value, #initialize, #parse_xml, #with_data?

Methods included from OoxmlObjectAttributeHelper

#attribute_enabled?, #option_enabled?

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#dataObject Also known as: chart

Returns the value of attribute data.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb', line 8

def data
  @data
end

#typeObject

Returns the value of attribute type.



8
9
10
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb', line 8

def type
  @type
end

Instance Method Details

#parse(node) ⇒ DocxGraphic

Parse DocxGraphic

Parameters:

  • node (Nokogiri::XML:Node)

    with NumberingProperties

Returns:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/docx_graphic.rb', line 15

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