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

Registry-driven: every PartDefinition naming both a document and a package attribute is mirrored, honoring the definition's optional to_package_guard predicate (e.g. the lazily-initialized numbering configuration) and to_package_type value constraint (e.g. comments).



40
41
42
43
44
45
46
47
48
# File 'lib/uniword/docx/package_defaults.rb', line 40

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

  Ooxml::PartRegistry.copied_to_package.each do |definition|
    copy_part_to_package(document, package, definition)
  end

  package.allocator = document.allocator if document.allocator
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



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/uniword/docx/package_defaults.rb', line 51

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



76
77
78
# File 'lib/uniword/docx/package_defaults.rb', line 76

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



71
72
73
# File 'lib/uniword/docx/package_defaults.rb', line 71

def minimal_package_rels
  build_minimal_rels(MINIMAL_PACKAGE_REL_PARTS)
end