| ... | ... | @@ -90,7 +90,7 @@ impl ParagraphTag { |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | pub(crate) fn indentation(level: u32, indents: &[f32], width: f32) -> Result<f32, LayoutError> { |
| 93 | | if indents.len() < 2 || indents.iter().any(|v| !v.is_finite() || *v < 0.0) || level == 0 { |
| 93 | if indents.is_empty() || indents.iter().any(|v| !v.is_finite() || *v < 0.0) || level == 0 { |
| 94 | 94 | return Err(LayoutError::InvalidIndentation); |
| 95 | 95 | } |
| 96 | 96 | let known = (level as usize).min(indents.len() - 1); |
| ... | ... | @@ -536,9 +536,6 @@ pub(crate) fn outline_layout( |
| 536 | 536 | definitions: &BTreeMap<ExGuid, Definition>, |
| 537 | 537 | width: f32, |
| 538 | 538 | ) -> Result<OutlineLayout, LayoutError> { |
| 539 | | if outline.indents.len() < 2 || outline.indents.iter().any(|v| !v.is_finite() || *v < 0.0) { |
| 540 | | return Err(LayoutError::InvalidIndentation); |
| 541 | | } |
| 542 | 539 | if !outline.unsupported.is_empty() { |
| 543 | 540 | return Err(LayoutError::UnsupportedContent); |
| 544 | 541 | } |
| ... | ... | @@ -1125,6 +1122,11 @@ mod tests { |
| 1125 | 1122 | outline.layout(&mut engine, &BTreeMap::new()), |
| 1126 | 1123 | Err(LayoutError::InvalidIndentation) |
| 1127 | 1124 | )); |
| 1125 | // OneNote stores only the level-zero indent for an outline of top-level paragraphs. |
| 1126 | outline.indents = vec![0.0]; |
| 1127 | outline.paragraphs.truncate(1); |
| 1128 | let single = outline.layout(&mut engine, &BTreeMap::new()).unwrap(); |
| 1129 | assert_eq!(single.paragraphs[0].origin[0], 0.0); |
| 1128 | 1130 | } |
| 1129 | 1131 | |
| 1130 | 1132 | #[test] |