Sha256: 7a8f503e8dc7869275cc0371b1f6654ef79c9c301d04573634e7d468d7cc2668

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require_relative 'form_text_properties/form_text_comb'
require_relative 'form_text_properties/form_text_format'
module OoxmlParser
  # Class for parsing `textFormPr` tag
  class FormTextProperties < OOXMLDocumentObject
    # @return [True, False] specifies if field is multiline
    attr_reader :multiline
    # @return [True, False] specifies if size of field should be autofit
    attr_reader :autofit
    # @return [FormTextComb] parameters of text justification
    attr_reader :comb
    # @return [ValuedChild] characters limit
    attr_reader :maximum_characters
    # @return [FormTextFormat] text format
    attr_reader :format

    # Parse FormTextProperties object
    # @param node [Nokogiri::XML:Element] node to parse
    # @return [FormTextProperties] result of parsing
    def parse(node)
      node.attributes.each do |key, value|
        case key
        when 'multiLine'
          @multiline = option_enabled?(value)
        when 'autoFit'
          @autofit = option_enabled?(value)
        end
      end

      node.xpath('*').each do |node_child|
        case node_child.name
        when 'comb'
          @comb = FormTextComb.new(parent: self).parse(node_child)
        when 'maxCharacters'
          @maximum_characters = ValuedChild.new(:integer, parent: self).parse(node_child)
        when 'format'
          @format = FormTextFormat.new(parent: self).parse(node_child)
        end
      end
      self
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ooxml_parser-0.33.0 lib/ooxml_parser/docx_parser/document_structure/docx_paragraph/sdt/sdt_properties/form_text_properties.rb