Class: OoxmlParser::OOXMLTextBox

Inherits:
OOXMLDocumentObject show all
Defined in:
lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb

Constant Summary

Constants inherited from OOXMLDocumentObject

OoxmlParser::OOXMLDocumentObject::DEFAULT_DIRECTORY_FOR_MEDIA

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OOXMLDocumentObject

#==, add_to_xmls_stack, copy_file_and_rename_to_zip, copy_media_file, current_xml, dir, encrypted_file?, get_link_from_rels, media_folder, option_enabled?, unzip_file

Constructor Details

#initialize(properties = nil, elements = []) ⇒ OOXMLTextBox

Returns a new instance of OOXMLTextBox.



5
6
7
8
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb', line 5

def initialize(properties = nil, elements = [])
  @properties = properties
  @elements = elements
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



3
4
5
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb', line 3

def elements
  @elements
end

#propertiesObject

Returns the value of attribute properties.



3
4
5
# File 'lib/ooxml_parser/common_parser/common_data/alternate_content/shape/text_body/ooxml_text_box.rb', line 3

def properties
  @properties
end

Class Method Details

.parse(text_body_node) ⇒ Object



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/shape/text_body/ooxml_text_box.rb', line 10

def self.parse(text_body_node)
  text_body = OOXMLTextBox.new
  text_box_content_node = text_body_node.xpath('w:txbxContent').first
  text_box_content_node.xpath('*').each_with_index do |text_body_node_child, index|
    case text_body_node_child.name
    when 'p'
      text_body.elements << DocxParagraph.parse(text_body_node_child, index)
    when 'tbl'
      text_body.elements << Table.parse(text_body_node_child, index)
    when 'bodyPr'
      text_body.properties = OOXMLShapeBodyProperties.parse(text_body_node_child)
    end
  end
  text_body
end