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
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/uniword/docx/package_defaults.rb', line 19 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 package.content_types = document.content_types if document.content_types package.footnotes = document.footnotes if document.footnotes package.endnotes = document.endnotes if document.endnotes 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. = document. if document. 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
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/uniword/docx/package_defaults.rb', line 47 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
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/uniword/docx/package_defaults.rb', line 114 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
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/uniword/docx/package_defaults.rb', line 92 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 |