easyofd_reader/model/
ofd_document_vo.rs1use super::AnnotionEntity;
8
9#[derive(Debug, Clone)]
15#[deprecated(since = "1.0.0", note = "使用 OfdReader 直接解析替代")]
16#[allow(deprecated)]
17pub struct OfdDocumentVo {
18 pub doc_path: String,
20 pub page_width: f64,
22 pub page_height: f64,
24 pub annotations: Vec<AnnotionEntity>,
26}
27
28#[allow(deprecated)]
29impl OfdDocumentVo {
30 #[must_use]
32 pub fn new(
33 doc_path: impl Into<String>,
34 page_width: f64,
35 page_height: f64,
36 annotations: Vec<AnnotionEntity>,
37 ) -> Self {
38 Self {
39 doc_path: doc_path.into(),
40 page_width,
41 page_height,
42 annotations,
43 }
44 }
45
46 #[must_use]
48 pub fn annotations(&self) -> &[AnnotionEntity] {
49 &self.annotations
50 }
51}
52
53#[allow(deprecated)]
54#[cfg(test)]
55mod tests {
56 #[allow(deprecated)]
57 use super::*;
58
59 #[test]
60 #[allow(deprecated)]
61 fn test_ofd_document_vo_new() {
62 let vo = OfdDocumentVo::new("Doc_0", 210.0, 297.0, vec![]);
63 assert_eq!(vo.doc_path, "Doc_0");
64 assert!((vo.page_width - 210.0).abs() < f64::EPSILON);
65 assert!((vo.page_height - 297.0).abs() < f64::EPSILON);
66 assert!(vo.annotations.is_empty());
67 }
68
69 #[test]
70 #[allow(deprecated)]
71 fn test_ofd_document_vo_with_annotations() {
72 let ann = AnnotionEntity::new("page_0", vec!["<Annot/>".into()]);
73 let vo = OfdDocumentVo::new("Doc_0", 210.0, 297.0, vec![ann]);
74 assert_eq!(vo.annotations().len(), 1);
75 }
76}