Sha256: 5e32348ed288f83aac8d89accc8ac8e80bbdaab2541c84c58a38cc0d1b229c7f

Contents?: true

Size: 806 Bytes

Versions: 5

Compression:

Stored size: 806 Bytes

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `txbx` tags
  class OOXMLTextBox < OOXMLDocumentObject
    attr_accessor :elements

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

    # Parse OOXMLTextBox object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [OOXMLTextBox] result of parsing
    def parse(node)
      text_box_content_node = node.xpath('w:txbxContent').first
      text_box_content_node.xpath('*').each_with_index do |node_child, index|
        case node_child.name
        when 'p'
          @elements << DocxParagraph.new(parent: self).parse(node_child, index)
        when 'tbl'
          @elements << Table.new(parent: self).parse(node_child, index)
        end
      end
      self
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ooxml_parser-0.8.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb
ooxml_parser-0.8.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb
ooxml_parser-0.7.2 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb
ooxml_parser-0.7.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb
ooxml_parser-0.7.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb