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
Instance Method Summary collapse
-
#copy_document_parts_to_package(document, package) ⇒ Object
private
Copy parts from document to package for round-trip preservation.
-
#minimal_content_types ⇒ Object
private
Create minimal content types for a valid DOCX.
-
#minimal_document_rels ⇒ Object
private
Create minimal document relationships for a valid DOCX.
-
#minimal_package_rels ⇒ Object
private
Create minimal package relationships for a valid DOCX.
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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# 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) DOCUMENT_TO_PACKAGE_MAPPINGS.each do |doc_attr, pkg_attr| value = document.send(doc_attr) package.send(:"#{pkg_attr}=", value) if value end 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 end |
#minimal_content_types ⇒ 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.
Create minimal content types for a valid DOCX
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/uniword/docx/package_defaults.rb', line 56 def minimal_content_types ct = Uniword::ContentTypes::Types.new ct.defaults ||= [] ct.defaults << Uniword::ContentTypes::Default.new( extension: "rels", content_type: "application/vnd.openxmlformats-package.relationships+xml", ) ct.defaults << Uniword::ContentTypes::Default.new( extension: "xml", content_type: "application/xml", ) ct.overrides ||= [] ct.overrides << Uniword::ContentTypes::Override.new( part_name: "/word/document.xml", content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", ) ct.overrides << Uniword::ContentTypes::Override.new( part_name: "/word/styles.xml", content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml", ) ct.overrides << Uniword::ContentTypes::Override.new( part_name: "/word/fontTable.xml", content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml", ) ct.overrides << Uniword::ContentTypes::Override.new( part_name: "/word/settings.xml", content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", ) ct.overrides << Uniword::ContentTypes::Override.new( part_name: "/word/webSettings.xml", content_type: "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml", ) ct.overrides << Uniword::ContentTypes::Override.new( part_name: "/docProps/app.xml", content_type: "application/vnd.openxmlformats-officedocument.extended-properties+xml", ) ct.overrides << Uniword::ContentTypes::Override.new( part_name: "/docProps/core.xml", content_type: "application/vnd.openxmlformats-package.core-properties+xml", ) ct end |
#minimal_document_rels ⇒ 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.
Create minimal document relationships for a valid DOCX
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/uniword/docx/package_defaults.rb', line 123 def minimal_document_rels rels = Ooxml::Relationships::PackageRelationships.new rels.relationships ||= [] rels.relationships << Ooxml::Relationships::Relationship.new( id: "rId1", type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", target: "styles.xml", ) rels.relationships << Ooxml::Relationships::Relationship.new( id: "rId2", type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings", target: "settings.xml", ) rels.relationships << Ooxml::Relationships::Relationship.new( id: "rId3", type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings", target: "webSettings.xml", ) rels.relationships << Ooxml::Relationships::Relationship.new( id: "rId4", type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable", target: "fontTable.xml", ) rels end |
#minimal_package_rels ⇒ 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.
Create minimal package relationships for a valid DOCX
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/uniword/docx/package_defaults.rb', line 101 def minimal_package_rels rels = Ooxml::Relationships::PackageRelationships.new rels.relationships ||= [] rels.relationships << Ooxml::Relationships::Relationship.new( id: "rId1", type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", target: "word/document.xml", ) rels.relationships << Ooxml::Relationships::Relationship.new( id: "rId2", type: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", target: "docProps/core.xml", ) rels.relationships << Ooxml::Relationships::Relationship.new( id: "rId3", type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", target: "docProps/app.xml", ) rels end |