Module: Uniword::Docx::PackageDefaults::ClassMethods Private

Defined in:
lib/uniword/docx/package_defaults.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Class methods for package construction

Constant Summary collapse

MINIMAL_CT_DEFAULT_PARTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Part kinds in a minimal [Content_Types].xml, emission order.

%i[rels xml].freeze
MINIMAL_CT_OVERRIDE_PARTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[document styles font_table settings web_settings
app_properties core_properties].freeze
MINIMAL_PACKAGE_REL_PARTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Part kinds in a minimal _rels/.rels, in rId order.

%i[document core_properties app_properties].freeze
MINIMAL_DOCUMENT_REL_PARTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Part kinds in a minimal word/_rels/document.xml.rels, in rId order.

%i[styles settings web_settings font_table].freeze

Instance Method Summary collapse

Instance Method Details

#copy_document_parts_to_package(document, package) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Copy parts from document to package for round-trip preservation



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/uniword/docx/package_defaults.rb', line 34

def copy_document_parts_to_package(document, package)
  return unless document.is_a?(Uniword::Wordprocessingml::DocumentRoot)

  package.styles = document.styles_configuration if document.styles_configuration
  package.settings = document.settings if document.settings
  package.font_table = document.font_table if document.font_table
  package.web_settings = document.web_settings if document.web_settings
  package.theme = document.theme if document.theme
  package.core_properties = document.core_properties if document.core_properties
  package.app_properties = document.app_properties if document.app_properties
  package.custom_properties = document.custom_properties if document.custom_properties
  package.document_rels = document.document_rels if document.document_rels
  package.theme_rels = document.theme_rels if document.theme_rels
  package.package_rels = document.package_rels if document.package_rels
  if document.settings_rels
    package.settings_rels = document.settings_rels
  end
  if document.footnotes_rels
    package.footnotes_rels = document.footnotes_rels
  end
  if document.endnotes_rels
    package.endnotes_rels = document.endnotes_rels
  end
  package.content_types = document.content_types if document.content_types
  package.footnotes = document.footnotes if document.footnotes
  package.endnotes = document.endnotes if document.endnotes
  if document.comments.is_a?(Uniword::CommentsPart)
    package.comments = document.comments
  end
  package.allocator = document.allocator if document.allocator

  package.numbering = document.numbering_configuration if document.numbering_configuration_loaded?

  package.chart_parts = document.chart_parts if document.chart_parts
  package.custom_xml_items = document.custom_xml_items if document.custom_xml_items
  package.bibliography_sources = document.bibliography_sources if document.bibliography_sources
  package.embeddings = document.embeddings if document.embeddings
end

#minimal_content_typesObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create minimal content types for a valid DOCX



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/uniword/docx/package_defaults.rb', line 74

def minimal_content_types
  ct = Uniword::ContentTypes::Types.new
  ct.defaults = MINIMAL_CT_DEFAULT_PARTS.map do |key|
    defn = Ooxml::PartRegistry.find_by_key(key)
    Uniword::ContentTypes::Default.new(
      extension: defn.extension,
      content_type: defn.content_type,
    )
  end
  ct.overrides = MINIMAL_CT_OVERRIDE_PARTS.map do |key|
    defn = Ooxml::PartRegistry.find_by_key(key)
    Uniword::ContentTypes::Override.new(
      part_name: defn.part_name,
      content_type: defn.content_type,
    )
  end
  ct
end

#minimal_document_relsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create minimal document relationships for a valid DOCX



99
100
101
# File 'lib/uniword/docx/package_defaults.rb', line 99

def minimal_document_rels
  build_minimal_rels(MINIMAL_DOCUMENT_REL_PARTS)
end

#minimal_package_relsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create minimal package relationships for a valid DOCX



94
95
96
# File 'lib/uniword/docx/package_defaults.rb', line 94

def minimal_package_rels
  build_minimal_rels(MINIMAL_PACKAGE_REL_PARTS)
end