use std::borrow::Cow;
use crate::model::document::{Document, Section};
pub(super) fn prepare_section<'a>(
section: Cow<'a, Section>,
document: &Document,
) -> Cow<'a, Section> {
if !document.hwpx_origin_keeps_source_lines() || section.raw_provenance_permits_reuse() {
return section;
}
let mut staged = section.into_owned();
super::hwpx::roundtrip::project_exported_line_caches(&mut staged.paragraphs);
for master in &mut staged.section_def.master_pages {
super::hwpx::roundtrip::project_exported_line_caches(&mut master.paragraphs);
}
staged.raw_stream = None;
Cow::Owned(staged)
}