Ship XDV document views and PDF outline navigation
This commit is contained in:
1 parent
8be7867b37
commit
515dbe6181
13 files changed
+743
-111
No files matched your search
@@ -49,17 +49,18 @@ impl Executor {
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn xdv_destination_special(
|
||||
pub(super) fn xdv_page_special(
|
||||
&mut self,
|
||||
special: &ShipoutSpecial,
|
||||
point: [i64; 2],
|
||||
position: crate::pdf_device::xdv_object::Position,
|
||||
links: &mut crate::pdf_device::links::PageLinks,
|
||||
files: &mut impl SourceProvider,
|
||||
) -> Result<bool, Error> {
|
||||
use crate::pdf_device::xdv_destination::Destination;
|
||||
let data = special.bytes.trim_ascii_start();
|
||||
if let Some(body) = data.strip_prefix(b"pdf:").map(<[u8]>::trim_ascii_start) {
|
||||
if let Some(operands) = xdv_operand(body, b"dest").or_else(|| xdv_operand(body, b"destination")) {
|
||||
let destination = Destination::parse(operands, self.shipped_pages + 1, point)
|
||||
let destination = Destination::parse(operands, position.page, position.coordinates)
|
||||
.map_err(|error| self.error(error, special.span))?;
|
||||
links.xdv_destinations.push(destination);
|
||||
return Ok(true);
|
||||
@@ -73,6 +74,22 @@ impl Executor {
|
||||
return Ok(true);
|
||||
}
|
||||
}
|
||||
let catalog = xdv_operand(body, b"docview");
|
||||
let outline = xdv_operand(body, b"outline").or_else(|| xdv_operand(body, b"out"));
|
||||
if let Some(operands) = catalog.or(outline) {
|
||||
self.reads.insert(Dependency::PdfCatalogState);
|
||||
let navigation = Arc::make_mut(self.state.xdv_navigation.get_or_insert_with(Default::default));
|
||||
let warnings = if catalog.is_some() {
|
||||
navigation.merge_catalog(operands, position, self.limits.tokens)
|
||||
} else {
|
||||
navigation.add_outline(operands, position, self.limits.tokens)
|
||||
}.map_err(|error| self.error(error, special.span))?;
|
||||
for warning in warnings {
|
||||
files.observe_diagnostic(WriteDestination::TerminalAndLog, &warning)
|
||||
.map_err(|error| self.error(error, special.span))?;
|
||||
}
|
||||
return Ok(true);
|
||||
}
|
||||
} else if let Some(body) = data.strip_prefix(b"dvipdfmx:").map(<[u8]>::trim_ascii_start)
|
||||
&& let Some(operands) = xdv_operand(body, b"config")
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user