Class: BerkeleyLibrary::Util::ODS::XML::Office::DocumentContent

Inherits:
ElementNode
  • Object
show all
Defined in:
lib/berkeley_library/util/ods/xml/office/document_content.rb

Constant Summary collapse

OFFICE_VERSION =

Constants

'1.2'.freeze
REQUIRED_NAMESPACES =
Namespace.reject { |ns| ns == Namespace::MANIFEST }

Instance Attribute Summary

Attributes inherited from ElementNode

#doc, #element_name, #namespace

Instance Method Summary collapse

Methods inherited from ElementNode

#add_child, #attributes, #children, #clear_attribute, #element, #ensure_element!, #prefix, #prefixed_attr_name, #set_attribute

Constructor Details

#initialize(doc:) ⇒ DocumentContent


Initializer



26
27
28
29
30
31
# 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

Instance Method Details

#add_table(name, table_style = nil, protected: true) ⇒ Object



48
49
50
51
# 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_stylesObject



44
45
46
# File 'lib/berkeley_library/util/ods/xml/office/document_content.rb', line 44

def automatic_styles
  @automatic_styles ||= Office::AutomaticStyles.new(doc: doc)
end

#bodyObject



57
58
59
# 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

#create_elementObject (protected)



69
70
71
72
73
74
75
# 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

#font_face_declsObject



40
41
42
# 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

#scriptsObject


Accessors and utility methods



36
37
38
# File 'lib/berkeley_library/util/ods/xml/office/document_content.rb', line 36

def scripts
  @scripts ||= Scripts.new(doc: doc)
end

#spreadsheetObject



53
54
55
# File 'lib/berkeley_library/util/ods/xml/office/document_content.rb', line 53

def spreadsheet
  @spreadsheet ||= Office::Spreadsheet.new(doc: doc)
end