Class: OoxmlParser::DocxShape

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

Overview

Class for parsing sp, wsp tags

Direct Known Subclasses

ConnectionShape

Instance Attribute Summary collapse

Attributes inherited from OOXMLDocumentObject

#parent

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, current_xml, dir, encrypted_file?, get_link_from_rels, #initialize, unzip_file

Methods included from OoxmlDocumentObjectHelper

#to_hash

Constructor Details

This class inherits a constructor from OoxmlParser::OOXMLDocumentObject

Instance Attribute Details

#body_propertiesObject

Returns the value of attribute body_properties.



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb', line 9

def body_properties
  @body_properties
end

#non_visual_propertiesObject

Returns the value of attribute non_visual_properties.



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb', line 9

def non_visual_properties
  @non_visual_properties
end

#propertiesObject Also known as: shape_properties

Returns the value of attribute properties.



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb', line 9

def properties
  @properties
end

#styleObject

Returns the value of attribute style.



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb', line 9

def style
  @style
end

#text_bodyObject

Returns the value of attribute text_body.



9
10
11
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb', line 9

def text_body
  @text_body
end

Instance Method Details

#parse(node) ⇒ DocxShape

Parse DocxShape object

Parameters:

  • node (Nokogiri::XML:Element)

    node to parse

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb', line 24

def parse(node)
  node.xpath('*').each do |node_child|
    case node_child.name
    when 'nvSpPr'
      @non_visual_properties = NonVisualShapeProperties.new(parent: self).parse(node_child)
    when 'spPr'
      @properties = DocxShapeProperties.new(parent: self).parse(node_child)
    when 'txbx'
      @text_body = OOXMLTextBox.new(parent: self).parse(node_child)
    when 'txBody'
      @text_body = TextBody.new(parent: self).parse(node_child)
    when 'bodyPr'
      @body_properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
    end
  end
  self
end

#with_data?True, false

Returns if structure contain any user data.

Returns:

  • (True, false)

    if structure contain any user data



14
15
16
17
18
19
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape.rb', line 14

def with_data?
  return true if @text_body.nil?
  return true if @text_body.paragraphs.length > 1
  return true unless @text_body.paragraphs.first.runs.empty?
  false
end