From 8a6f9725b03c2ffd255cc582841e7f12f4d1a5ab Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Thu, 22 Oct 2026 01:25:12 -0400 Subject: [PATCH] IDML: test a ruler guide in a column gutter without facing pages (#1096) (#1170) --- crates/idml/src/tests.rs | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/crates/idml/src/tests.rs b/crates/idml/src/tests.rs index 035333da..81cebff7 100644 --- a/crates/idml/src/tests.rs +++ b/crates/idml/src/tests.rs @@ -4194,6 +4194,59 @@ mod liquid_page_rules { } } +/// #1096: a ruler guide inside the gutter of a two-column page, written the way InDesign writes +/// it (a `` child after its `MarginPreference`, with `Properties`/`GuideColor`, `PageIndex` +/// and `GuideZone`), in a document without facing pages. A spread guide sits beside it. +#[test] +fn ruler_guide_in_a_column_gutter_imports_without_facing_pages() { + use designcraft_doc::Orientation::{Horizontal, Vertical}; + let package = |view: &str| { + let prefs = + PREFS.replace(r#"FacingPages="true""#, r#"FacingPages="false""#).replace("", &format!("{view}")); + let spread = SPREAD.replace( + r#" + + "#, + r#" + UseMasterColor + + + + Cyan + + + Cyan + + "#, + ); + assert_ne!(spread, SPREAD, "the fixture's first page was replaced"); + import_idml(&zip_files(&[ + ("designmap.xml", DESIGNMAP), + ("Resources/Graphic.xml", GRAPHIC), + ("Resources/Styles.xml", STYLES), + ("Resources/Preferences.xml", &prefs), + ("MasterSpreads/MasterSpread_m1.xml", MASTER), + ("Spreads/Spread_sp1.xml", &spread), + ("Stories/Story_s1.xml", STORY), + ])) + .unwrap() + }; + let guides = + |d: &Document| d.spreads[0].pages[0].guides.iter().map(|g| (g.orientation, g.position, g.spread, g.layer.is_some())).collect::>(); + // The first page starts at x 0 in our spread coordinates, so the spread's and the page's ruler + // origins agree; no ViewPreference means InDesign's default, the spread. + for view in ["", r#""#, r#""#] { + let first = package(view); + assert!(!first.settings.facing_pages); + assert_eq!(guides(&first), [(Vertical, 180.0, false, true), (Horizontal, 300.0, true, true)], "{view:?}"); + // The guide sits between the page's left margin (20) and right margin (470). + let m = first.spreads[0].pages[0].margin_rect(); + assert!(m.x0 < 180.0 && 180.0 < m.x1); + let back = import_idml(&export_idml(&first)).unwrap(); + assert_eq!(guides(&back), guides(&first), "round trip, {view:?}"); + } +} + /// Cell Options › Text › First Baseline, set by a cell style that a table style applies to its body /// region (cells with `[None]` take it from there) and overridden on one cell. const FIRST_BASELINE_STYLES: &str = r#"