Class: Uniword::Wordprocessingml::Body

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/wordprocessingml/body.rb

Overview

Document body - main content container

Generated from OOXML schema: wordprocessingml.yml Element: <w:body>

Instance Method Summary collapse

Instance Method Details

#elementsArray<Paragraph, Table, SectionProperties, StructuredDocumentTag>

Get all elements in body

Returns:



38
39
40
41
42
43
44
45
# File 'lib/uniword/wordprocessingml/body.rb', line 38

def elements
  result = []
  result.concat(paragraphs || [])
  result.concat(structured_document_tags || [])
  result.concat(tables || [])
  result << section_properties if section_properties
  result
end

#sync_element_order_for_serializationObject

Sync element_order with actual paragraphs/tables/SDTs. Called before serialization to ensure programmatically added elements are included. Also called from DocumentRoot#to_xml since lutaml-model may bypass Body#to_xml when Body is a child element.



65
66
67
# File 'lib/uniword/wordprocessingml/body.rb', line 65

def sync_element_order_for_serialization
  sync_element_order
end

#to_xml(options = {}) ⇒ Object

Override to_xml to sync element_order with actual paragraphs/tables/SDTs. When Body is deserialized from XML, lutaml-model stores original elements in element_order. Programmatically added paragraphs/tables/SDTs are in the arrays but not in element_order, so they’d be dropped. This ensures all current paragraphs, tables, and SDTs are represented.

NOTE: lutaml-model’s compiled serializer may bypass this override when Body is serialized as a child of DocumentRoot. The sync_element_order method is also called from DocumentRoot#to_xml.



56
57
58
59
# File 'lib/uniword/wordprocessingml/body.rb', line 56

def to_xml(options = {})
  sync_element_order
  super
end