Class: Uniword::Ooxml::Relationships::PackageRelationships

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Defined in:
lib/uniword/ooxml/relationships/package_relationships.rb

Overview

Package-level Relationships root element (for _rels/.rels)

Uses package namespace: http://schemas.openxmlformats.org/package/2006/relationships

Class Method Summary collapse

Class Method Details

.generate_package_relsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/uniword/ooxml/relationships/package_relationships.rb', line 34

def self.generate_package_rels
  new(
    relationships: [
      PackageRelationship.new(
        id: "rId3",
        type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
        target: "docProps/app.xml",
      ),
      PackageRelationship.new(
        id: "rId2",
        type: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties",
        target: "docProps/core.xml",
      ),
      PackageRelationship.new(
        id: "rId1",
        type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
        target: "word/document.xml",
      ),
    ],
  )
end

.next_available_rid(relationships) ⇒ PackageRelationships

Generates relationship files (.rels) for DOCX packages

Generate package-level .rels file

Returns:



27
28
29
30
31
32
# File 'lib/uniword/ooxml/relationships/package_relationships.rb', line 27

def self.next_available_rid(relationships)
  max = relationships.relationships.filter_map do |r|
    r.id[/\ArId(\d+)\z/, 1]&.to_i
  end.max || 0
  "rId#{max + 1}"
end