Integrate native repeat boxes and PDF bookmarks
This commit is contained in:
1 parent
5163fc9854
commit
38e4822370
33 files changed
+1208
-143
No files matched your search
@@ -5,6 +5,15 @@ use super::links::DestinationId;
|
||||
pub struct PdfCatalog {
|
||||
pub(crate) entries: Vec<u8>,
|
||||
pub(crate) open_action: Option<CatalogAction>,
|
||||
pub(crate) outlines: Vec<PdfOutline<Vec<u8>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub(crate) struct PdfOutline<A> {
|
||||
pub(crate) title: Vec<u8>,
|
||||
pub(crate) attributes: A,
|
||||
pub(crate) action: CatalogAction,
|
||||
pub(crate) count: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
@@ -22,6 +31,32 @@ pub(crate) enum CatalogAction {
|
||||
},
|
||||
}
|
||||
|
||||
impl CatalogAction {
|
||||
pub(crate) fn payload_len(&self) -> usize {
|
||||
fn destination_len(destination: &DestinationId<String>) -> usize {
|
||||
match destination {
|
||||
DestinationId::Name(name) => name.len(),
|
||||
DestinationId::Number(_) => 0,
|
||||
}
|
||||
}
|
||||
|
||||
match self {
|
||||
Self::User(bytes) => bytes.len(),
|
||||
Self::GoTo { target, file, structure, .. } => {
|
||||
let target_len = match target {
|
||||
CatalogTarget::Destination(destination) => destination_len(destination),
|
||||
CatalogTarget::Page { view, .. } => view.len(),
|
||||
};
|
||||
target_len + file.as_ref().map_or(0, Vec::len)
|
||||
+ structure.as_ref().map_or(0, Vec::len)
|
||||
}
|
||||
Self::Thread { destination, file } => {
|
||||
destination_len(destination) + file.as_ref().map_or(0, Vec::len)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
pub(crate) enum CatalogTarget {
|
||||
Destination(DestinationId<String>),
|
||||
|
||||
Reference in new issue
Block a user