use crate::model::control::{DeclaredEquationFrameSource, Equation, EQUATION_LINE_MODE_BIT};
fn frame_signature(equation: &Equation) -> [u8; 32] {
equation.declared_frame_signature()
}
pub(crate) fn retain_unpositioned_host_frame(equation: &mut Equation) {
if equation.font_name.eq_ignore_ascii_case("HYhwpEQ")
&& equation.common.treat_as_char
&& equation.attr & EQUATION_LINE_MODE_BIT == 0
&& equation.common.width > 0
&& equation.common.width <= i32::MAX as u32
&& equation.common.height >= equation.font_size
&& equation.common.height <= i32::MAX as u32
&& equation.font_size > 0
&& !equation.script.trim().is_empty()
&& (1..=100).contains(&equation.baseline)
{
equation.unpositioned_host_frame_seal = Some(DeclaredEquationFrameSource {
signature: frame_signature(equation),
legacy_layout: true,
});
}
}
pub(super) fn retains_unpositioned_host_frame(equation: &Equation) -> bool {
equation
.unpositioned_host_frame_seal
.as_ref()
.is_some_and(|source| source.legacy_layout && source.signature == frame_signature(equation))
}
pub(crate) fn set_generation(
document: &mut crate::model::document::Document,
hangul2024: bool,
) -> bool {
use crate::model::control::Control;
use crate::model::identity::walk::{walk, Node};
let mut changed = false;
for section in &mut document.sections {
walk(&mut section.paragraphs, |node| {
if let Node::Control(Control::Equation(equation)) = node {
if let Some(source) = &mut equation.unpositioned_host_frame_seal {
changed |= source.legacy_layout == hangul2024;
source.legacy_layout = !hangul2024;
}
}
Ok(())
})
.expect("목표 수식 세대 전달은 실패하지 않는다");
}
changed
}