use super::AnnotionEntity;
#[derive(Debug, Clone)]
#[deprecated(since = "1.0.0", note = "使用 OfdReader 直接解析替代")]
#[allow(deprecated)]
pub struct OfdDocumentVo {
pub doc_path: String,
pub page_width: f64,
pub page_height: f64,
pub annotations: Vec<AnnotionEntity>,
}
#[allow(deprecated)]
impl OfdDocumentVo {
#[must_use]
pub fn new(
doc_path: impl Into<String>,
page_width: f64,
page_height: f64,
annotations: Vec<AnnotionEntity>,
) -> Self {
Self {
doc_path: doc_path.into(),
page_width,
page_height,
annotations,
}
}
#[must_use]
pub fn annotations(&self) -> &[AnnotionEntity] {
&self.annotations
}
}
#[allow(deprecated)]
#[cfg(test)]
mod tests {
#[allow(deprecated)]
use super::*;
#[test]
#[allow(deprecated)]
fn test_ofd_document_vo_new() {
let vo = OfdDocumentVo::new("Doc_0", 210.0, 297.0, vec![]);
assert_eq!(vo.doc_path, "Doc_0");
assert!((vo.page_width - 210.0).abs() < f64::EPSILON);
assert!((vo.page_height - 297.0).abs() < f64::EPSILON);
assert!(vo.annotations.is_empty());
}
#[test]
#[allow(deprecated)]
fn test_ofd_document_vo_with_annotations() {
let ann = AnnotionEntity::new("page_0", vec!["<Annot/>".into()]);
let vo = OfdDocumentVo::new("Doc_0", 210.0, 297.0, vec![ann]);
assert_eq!(vo.annotations().len(), 1);
}
}