Sha256: 3a0fac30030f10e34b00cc0d272d7cde3ef1703e18ba29726fa55dc44a790b79

Contents?: true

Size: 926 Bytes

Versions: 3

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

module OoxmlParser
  # Class for parsing `txbx` tags
  class OOXMLTextBox < OOXMLDocumentObject
    attr_accessor :properties, :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)
        when 'bodyPr'
          @properties = OOXMLShapeBodyProperties.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ooxml_parser-0.6.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb
ooxml_parser-0.5.1 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb
ooxml_parser-0.5.0 lib/ooxml_parser/common_parser/common_data/alternate_content/drawing/graphic/shape/docx_shape/ooxml_text_box.rb