mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-13 01:41:18 +00:00
style: fmt and a type alias for clippy
Co-authored-by: Peter Yatsyshin <p.yatsyshin@googlemail.com>
This commit is contained in:
1 parent
96bcdfec1a
commit
65ea96da4c
5 files changed
+23
-12
No files matched your search
@@ -15,8 +15,8 @@ mod hostile_args;
|
||||
mod list_selection;
|
||||
mod model_3d;
|
||||
mod model_render;
|
||||
mod page_actions;
|
||||
mod optimize_content_boundaries;
|
||||
mod page_actions;
|
||||
mod portfolio_info;
|
||||
mod redact_after_stray_q_form;
|
||||
mod redact_text_after_q;
|
||||
|
||||
@@ -1046,7 +1046,13 @@ impl Session {
|
||||
}
|
||||
|
||||
/// Convert the worker snapshot delta and reset requests into permission-checked atomic document edits.
|
||||
pub(crate) fn apply_script_outcome(&mut self, id: DocId, states: &[pdfcraft_js::FieldState], mut o: Outcome, opening: bool) -> Result<Outcome, EditError> {
|
||||
pub(crate) fn apply_script_outcome(
|
||||
&mut self,
|
||||
id: DocId,
|
||||
states: &[pdfcraft_js::FieldState],
|
||||
mut o: Outcome,
|
||||
opening: bool,
|
||||
) -> Result<Outcome, EditError> {
|
||||
if o.execution_refused {
|
||||
o.changed.clear();
|
||||
o.requests.clear();
|
||||
|
||||
@@ -36,8 +36,8 @@ pub mod find_replace;
|
||||
mod history;
|
||||
pub mod js;
|
||||
mod layers;
|
||||
mod live_scripts;
|
||||
pub mod links;
|
||||
mod live_scripts;
|
||||
pub mod model3d;
|
||||
mod object_clip;
|
||||
pub mod ocr;
|
||||
@@ -75,8 +75,8 @@ use std::sync::Arc;
|
||||
pub use links::{
|
||||
MAX_REMOTE_DOCUMENT_BYTES, RemoteDocumentPathError, read_remote_document, remote_document_path_is_absolute, resolve_remote_document_path,
|
||||
};
|
||||
pub use pdfcraft_edit::strip_subset_tag;
|
||||
pub use live_scripts::{MAX_TIMER_RUNS, ScriptRun};
|
||||
pub use pdfcraft_edit::strip_subset_tag;
|
||||
pub use rich_copy::RichCopy;
|
||||
pub use signature_image::{ImageSignaturePreview, SignatureImage};
|
||||
pub use signature_scan::{PhotoRect, ScanError, SignaturePhoto, Turn};
|
||||
|
||||
@@ -98,7 +98,12 @@ pub(crate) fn js_layers(doc: &Document) -> Vec<pdfcraft_js::Layer> {
|
||||
/// A field as scripts see it: as the document has it, but shown as page actions and timers
|
||||
/// left it (its `display` and push button icon), so a button stepping an animation steps from
|
||||
/// the frame on screen.
|
||||
pub(crate) fn live_state(doc: &Document, cos: &pdfcraft_cos::Document, f: &pdfcraft_forms::Field, info: &pdfcraft_js::DocInfo) -> pdfcraft_js::FieldState {
|
||||
pub(crate) fn live_state(
|
||||
doc: &Document,
|
||||
cos: &pdfcraft_cos::Document,
|
||||
f: &pdfcraft_forms::Field,
|
||||
info: &pdfcraft_js::DocInfo,
|
||||
) -> pdfcraft_js::FieldState {
|
||||
let mut s = field_state(cos, f, info);
|
||||
if let Some(d) = doc.live.shown.get(&f.name) {
|
||||
s.display = *d;
|
||||
@@ -145,11 +150,7 @@ pub(crate) fn with_live_view(doc: &Document, config: pdfcraft_render::RenderConf
|
||||
})
|
||||
.flatten()
|
||||
.collect();
|
||||
pdfcraft_render::RenderConfig {
|
||||
annotations: std::sync::Arc::new(annotations),
|
||||
appearances: std::sync::Arc::new(appearances),
|
||||
..config
|
||||
}
|
||||
pdfcraft_render::RenderConfig { annotations: std::sync::Arc::new(annotations), appearances: std::sync::Arc::new(appearances), ..config }
|
||||
}
|
||||
|
||||
/// Draw the viewer with how fields show now.
|
||||
@@ -175,9 +176,12 @@ pub(crate) fn set_layers(doc: &mut Document, layers: &[(usize, bool)]) -> bool {
|
||||
changed
|
||||
}
|
||||
|
||||
/// Push buttons given another icon, by name: the icon's form object (`None`: no icon).
|
||||
type IconChanges = Vec<(String, Option<u64>)>;
|
||||
|
||||
/// The `display` and icon changes in `o`, against the fields as they were (`states`), taken out
|
||||
/// of it: shown in the view instead of written into the document.
|
||||
fn take_view_changes(states: &[pdfcraft_js::FieldState], o: &mut Outcome) -> (Vec<(String, i32)>, Vec<(String, Option<u64>)>) {
|
||||
fn take_view_changes(states: &[pdfcraft_js::FieldState], o: &mut Outcome) -> (Vec<(String, i32)>, IconChanges) {
|
||||
let mut shown = Vec::new();
|
||||
let mut icons = Vec::new();
|
||||
for a in &mut o.changed {
|
||||
|
||||
@@ -205,7 +205,8 @@ fn get_ocgs_turns_a_layer_in_the_view() {
|
||||
let out = pdf(&[
|
||||
"<< /Type /Catalog /Pages 2 0 R /OCProperties << /OCGs [5 0 R] /D << /Order [5 0 R] >> >> >>".into(),
|
||||
"<< /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 200 300] >>".into(),
|
||||
"<< /Type /Page /Parent 2 0 R /Contents 4 0 R /Resources << /Properties << /L1 5 0 R >> >> /AA << /O << /S /JavaScript /JS 6 0 R >> >> >>".into(),
|
||||
"<< /Type /Page /Parent 2 0 R /Contents 4 0 R /Resources << /Properties << /L1 5 0 R >> >> /AA << /O << /S /JavaScript /JS 6 0 R >> >> >>"
|
||||
.into(),
|
||||
"<< /Length 41 >>\nstream\n/OC /L1 BDC 1 0 0 rg 0 0 200 300 re f EMC\nendstream".into(),
|
||||
"<< /Type /OCG /Name (Red) >>".into(),
|
||||
format!("<< /Length {} >>\nstream\n{open}\nendstream", open.len()),
|
||||
|
||||
Reference in new issue
Block a user