mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-09 04:22:20 +00:00
M12: an XFA caption beside its field wraps in its reserve (XFA 3.3 p. 645) (#5109)
This commit is contained in:
1 parent
9011276f2f
commit
1ec71c1bf0
2 files changed
+18
-2
No files matched your search
@@ -247,10 +247,12 @@ impl Layouter<'_> {
|
||||
match self.caption_reserve(f, inner_w, ctx) {
|
||||
Some((Placement::Top | Placement::Bottom, r)) => ui + r,
|
||||
Some((placement, r)) => {
|
||||
// A check box's caption without a reserve is drawn in all the box leaves.
|
||||
// A check box's caption without a reserve is drawn in all the box leaves; any
|
||||
// other caption beside the widget is as wide as its reserve (XFA 3.3 p. 645), the
|
||||
// width `draw_field` gives it.
|
||||
let w = match auto_check_reserve(f, placement, inner_w, None) {
|
||||
Some(auto) => auto,
|
||||
None => inner_w - r,
|
||||
None => r.min(inner_w),
|
||||
};
|
||||
let cap = f.caption.as_ref().map(|c| {
|
||||
let rich = match &c.value {
|
||||
|
||||
@@ -3030,6 +3030,20 @@ fn a_flowed_subform_is_as_tall_as_its_content_whatever_its_minimum_height() {
|
||||
assert!((top("") - flowed - (216.0 - 14.4)).abs() < 0.01, "{} against {flowed}", top(""));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_caption_beside_a_check_box_wraps_in_its_reserve() {
|
||||
// A 7.5in check box whose right-hand caption reserves 6.5in: two lines of text, not one or
|
||||
// two words to a line in the 1in the box keeps. The field after it follows directly.
|
||||
let words = "Applicant does not authorize the office to permit a participating office access to the application as filed. ".repeat(2);
|
||||
let body = format!(
|
||||
r#"<subform name="body" layout="tb" w="7.5in"><field name="opt" w="7.5in" minH="0.3in"><ui><checkButton/></ui><caption placement="right" reserve="6.5in"><value><text>{words}</text></value></caption></field><field name="who" w="3in" h="0.4in"><ui><textEdit/></ui></field></subform>"#
|
||||
);
|
||||
let form = layout_xml(&one_area_form(r#"layout="tb""#, &body)).unwrap();
|
||||
let w = widgets(&form.pages[0]);
|
||||
let gap = w[1].rect.y - w[0].rect.y;
|
||||
assert!(gap < 72.0, "the check box took {gap}pt");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_form_packet_restores_a_caption_a_script_changed() {
|
||||
let body = r#"<subform name="body" layout="tb" w="7.5in"><field name="bar" w="2in" h="0.3in"><ui><button/></ui><caption><value><text>Show Bar</text></value></caption></field></subform>"#;
|
||||
|
||||
Reference in new issue
Block a user