Class: OoxmlParser::TextBox

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

Overview

Class for working with TextBox (w:txbxContent)

Instance Attribute Summary

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 Method Details

#parse_list(node) ⇒ Array

Parse TextBox List

Parameters:

  • node (Nokogiri::XML:Node)

    with TextBox

Returns:

  • (Array)

    array of elements



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/shape_properties/docx_shape_properties/text_box.rb', line 9

def parse_list(node)
  elements = []
  text_box_content_node = node.xpath('w:txbxContent').first

  text_box_content_node&.xpath('*')&.each_with_index do |textbox_element, i|
    case textbox_element.name
    when 'p'
      textbox_paragraph = DocxParagraph.new
      textbox_paragraph.spacing = Spacing.new(0, 0.35, 1.15, :multiple)
      elements << textbox_paragraph.parse(textbox_element, i, parent: parent)
    when 'tbl'
      elements << Table.new(parent: parent).parse(textbox_element, i)
    end
  end
  elements
end