Class: OoxmlParser::TextBox

Inherits:
Object
  • Object
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)

Class Method Summary collapse

Class Method Details

.parse_list(node, parent: nil) ⇒ 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 self.parse_list(node, parent: nil)
  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'
      DocumentStructure.default_paragraph_style = DocxParagraph.new
      DocumentStructure.default_paragraph_style.spacing = Spacing.new(0, 0.35, 1.15, :multiple)
      elements << DocumentStructure.default_paragraph_style.dup.parse(textbox_element, i, parent: parent)
    when 'tbl'
      elements << Table.new(parent: parent).parse(textbox_element, i)
    end
  end
  elements
end