Module: Uniword::Docx::Reconciler::Body
- Included in:
- Uniword::Docx::Reconciler
- Defined in:
- lib/uniword/docx/reconciler/body.rb
Overview
Document body reconciliation.
Handles section properties, headers/footers, and their mc:Ignorable and paragraph backfill.
Instance Method Summary collapse
Instance Method Details
#reconcile_headers_footers ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/uniword/docx/reconciler/body.rb', line 48 def ignorable = Ooxml::Types::McIgnorable.new(FULL_IGNORABLE) (package.document&.headers, ignorable) (package.document&., ignorable) unless allocator rsid = generate_rsid (package.document&.headers, rsid, "hdr") (package.document&., rsid, "ftr") parts = package.document&. parts&.each_with_index do |part, pidx| backfill_paragraphs(part[:content].paragraphs, rsid, "hfp:#{pidx}") end end end |
#reconcile_section_properties ⇒ Object
11 12 13 14 15 16 17 18 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 45 46 |
# File 'lib/uniword/docx/reconciler/body.rb', line 11 def reconcile_section_properties return unless package.document&.body body = package.document.body unless body.section_properties body.section_properties = Wordprocessingml::SectionProperties.new( page_size: Wordprocessingml::PageDefaults.default_page_size, page_margins: Wordprocessingml::PageDefaults.default_page_margins, columns: Wordprocessingml::PageDefaults.default_columns, doc_grid: Wordprocessingml::PageDefaults.default_doc_grid, ) record_fix(FixCodes::SECTION_PROPERTIES_DEFAULTED, "Added default section properties with US Letter page size") return end sect_pr = body.section_properties fixed = false unless sect_pr.page_size sect_pr.page_size = Wordprocessingml::PageDefaults.default_page_size fixed = true end unless sect_pr.page_margins sect_pr.page_margins = Wordprocessingml::PageDefaults.default_page_margins fixed = true end unless sect_pr.columns sect_pr.columns = Wordprocessingml::PageDefaults.default_columns fixed = true end if fixed record_fix(FixCodes::SECTION_PROPERTIES_DEFAULTED, "Filled missing pgSz/pgMar/cols in existing section properties") end end |