The Print dialog turned Current page into the range "N" for the page on screen, and ranges read numbers as page labels first. In a document labelled i, ii, iii, 1, 2, viewing the first page printed the fourth, whose label is "1". Current page is now passed as a position, the way Selected pages is, through print::select_listed. A typed range still reads labels first. Adds print_ui::tests::current_page_is_the_viewed_page_not_a_label, which fails before this change.
This commit is contained in:
parent
a9a8ac63b7
commit
a4c53f706f
|
|
@ -129,15 +129,15 @@ impl PrintDraft {
|
|||
return Err("Cut and stack needs Two-sided: Off. Print single-sided sheets.".into());
|
||||
}
|
||||
let range = match self.which {
|
||||
Which::All | Which::Selected => None,
|
||||
Which::Current => Some(self.current_page.saturating_add(1).to_string()),
|
||||
Which::All | Which::Selected | Which::Current => None,
|
||||
Which::Range => Some(self.range.clone()),
|
||||
};
|
||||
let pages = if self.which == Which::Selected {
|
||||
// Positions, not a typed range: a range would read numbers as page labels first.
|
||||
print::select_listed(count, &self.selected, self.subset, self.reverse)
|
||||
} else {
|
||||
print::select_pages(count, range.as_deref(), labels, self.subset, self.reverse)
|
||||
// Selected and Current are positions, not a typed range: a range would read numbers as
|
||||
// page labels first.
|
||||
let pages = match self.which {
|
||||
Which::Selected => print::select_listed(count, &self.selected, self.subset, self.reverse),
|
||||
Which::Current => print::select_listed(count, &[self.current_page], self.subset, self.reverse),
|
||||
Which::All | Which::Range => print::select_pages(count, range.as_deref(), labels, self.subset, self.reverse),
|
||||
}
|
||||
// What the person got wrong about what to print is said in their language: the engine hands
|
||||
// the wording over whole and the page numbers apart from it.
|
||||
|
|
@ -1037,6 +1037,19 @@ mod tests {
|
|||
assert_eq!(PrintDraft::default().job("report.pdf").duplex, Some(spool::Duplex::Off));
|
||||
}
|
||||
|
||||
/// Issue #1308: Current page is the page on screen, even when a later page is labelled with
|
||||
/// its number. A typed range still reads labels first.
|
||||
#[test]
|
||||
fn current_page_is_the_viewed_page_not_a_label() {
|
||||
let labels: Vec<String> = ["i", "ii", "iii", "1", "2"].map(String::from).to_vec();
|
||||
for (current, want) in [(0, vec![0]), (1, vec![1]), (3, vec![3])] {
|
||||
let d = PrintDraft { which: Which::Current, current_page: current, ..PrintDraft::default() };
|
||||
assert_eq!(d.settings(5, &labels).map(|s| s.pages), Ok(want), "viewing page {}", current + 1);
|
||||
}
|
||||
let typed = PrintDraft { which: Which::Range, range: "1".into(), ..PrintDraft::default() };
|
||||
assert_eq!(typed.settings(5, &labels).map(|s| s.pages), Ok(vec![3]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_preview_rasters_stay_within_the_texture_limit() {
|
||||
// Actual size on a 14,400 pt (200 in) page would ask for a raster far past any texture.
|
||||
|
|
|
|||
Loading…
Reference in New Issue