class BerkeleyLibrary::Util::ODS::XML::Office::DocumentContent

Constants

OFFICE_VERSION

Constants

REQUIRED_NAMESPACES

Public Class Methods

new(doc:) click to toggle source

Initializer

# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 26
def initialize(doc:)
  super(:office, 'document-content', doc: doc)

  set_default_attributes!
  add_default_children!
end

Public Instance Methods

add_table(name, table_style = nil, protected: true) click to toggle source
# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 48
def add_table(name, table_style = nil, protected: true)
  new_table = XML::Table::Table.new(name, table_style, styles: automatic_styles, protected: protected)
  new_table.tap { |table| spreadsheet.add_child(table) }
end
automatic_styles() click to toggle source
# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 44
def automatic_styles
  @automatic_styles ||= Office::AutomaticStyles.new(doc: doc)
end
body() click to toggle source
# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 57
def body
  @body ||= Body.new(doc: doc).tap { |body| body.add_child(spreadsheet) }
end
font_face_decls() click to toggle source
# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 40
def font_face_decls
  @font_face_decls ||= Office::FontFaceDecls.new(doc: doc)
end
scripts() click to toggle source

Accessors and utility methods

# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 36
def scripts
  @scripts ||= Scripts.new(doc: doc)
end
spreadsheet() click to toggle source
# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 53
def spreadsheet
  @spreadsheet ||= Office::Spreadsheet.new(doc: doc)
end

Protected Instance Methods

create_element() click to toggle source

Protected ElementNode overrides

# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 69
def create_element
  # Make sure any styles, font faces, etc. needed for the body get created
  # *before* we try to write them to XML
  children.reverse_each(&:ensure_element!)

  super
end

Private Instance Methods

add_default_children!() click to toggle source
# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 87
def add_default_children!
  children << scripts
  children << font_face_decls
  children << automatic_styles
  children << body
end
set_default_attributes!() click to toggle source

Private methods

# File lib/berkeley_library/util/ods/xml/office/document_content.rb, line 82
def set_default_attributes!
  REQUIRED_NAMESPACES.each { |ns| set_attribute(:xmlns, ns.prefix, ns.uri) }
  set_attribute('version', OFFICE_VERSION)
end