Write paragraph list settings through shared IDML model

This commit is contained in:
Dylan M. Taylor committed 2026-11-13 07:45:19 -05:00
1 parent fe5c1cd186
commit f4551ac6f3
3 files changed
+54 -81

No files matched your search

Generated
+24 -24
View File
@@ -1242,20 +1242,20 @@ dependencies = [
[[package]]
name = "craft-idml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148#4e452a096552477416284d835e6a4c17903fe148"
source = "git+https://github.com/storytold/craft-libs?rev=eed3c28cf016723d004d6f2c79c61424c15d4558#eed3c28cf016723d004d6f2c79c61424c15d4558"
dependencies = [
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=eed3c28cf016723d004d6f2c79c61424c15d4558)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=eed3c28cf016723d004d6f2c79c61424c15d4558)",
"thiserror 2.0.21",
]
[[package]]
name = "craft-idml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=eed3c28cf016723d004d6f2c79c61424c15d4558#eed3c28cf016723d004d6f2c79c61424c15d4558"
source = "git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641#fbc0fd1db11429350fb48a769c5cde4ace26e641"
dependencies = [
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=eed3c28cf016723d004d6f2c79c61424c15d4558)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=eed3c28cf016723d004d6f2c79c61424c15d4558)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641)",
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641)",
"thiserror 2.0.21",
]
@@ -1653,15 +1653,6 @@ dependencies = [
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148#4e452a096552477416284d835e6a4c17903fe148"
dependencies = [
"quick-xml 0.41.0",
"thiserror 2.0.21",
]
[[package]]
name = "craft-xml"
version = "0.1.0"
@@ -1718,19 +1709,18 @@ dependencies = [
]
[[package]]
name = "craft-zip"
name = "craft-xml"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=19692b6190465671e41967c75d0cd4c439d0c84c#19692b6190465671e41967c75d0cd4c439d0c84c"
source = "git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641#fbc0fd1db11429350fb48a769c5cde4ace26e641"
dependencies = [
"flate2",
"quick-xml 0.41.0",
"thiserror 2.0.21",
"zip 9.1.1",
]
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148#4e452a096552477416284d835e6a4c17903fe148"
source = "git+https://github.com/storytold/craft-libs?rev=19692b6190465671e41967c75d0cd4c439d0c84c#19692b6190465671e41967c75d0cd4c439d0c84c"
dependencies = [
"flate2",
"thiserror 2.0.21",
@@ -1777,6 +1767,16 @@ dependencies = [
"zip 9.1.1",
]
[[package]]
name = "craft-zip"
version = "0.1.0"
source = "git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641#fbc0fd1db11429350fb48a769c5cde4ace26e641"
dependencies = [
"flate2",
"thiserror 2.0.21",
"zip 9.1.1",
]
[[package]]
name = "crc32fast"
version = "1.5.3"
@@ -2021,8 +2021,8 @@ dependencies = [
"craft-prepress",
"craft-print",
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641)",
"designcraft-color",
"designcraft-compose",
"designcraft-doc",
@@ -2103,9 +2103,9 @@ name = "designcraft-idml"
version = "0.20.1"
dependencies = [
"craft-file-formats",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148)",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641)",
"craft-svg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=cc23ffd4d26f3074808e2187d332564817624f8f)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148)",
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641)",
"designcraft-color",
"designcraft-compose",
"designcraft-doc",
@@ -2222,7 +2222,7 @@ version = "0.20.1"
dependencies = [
"craft-docx",
"craft-file-formats",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4e452a096552477416284d835e6a4c17903fe148)",
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=fbc0fd1db11429350fb48a769c5cde4ace26e641)",
"craft-rtf",
"craft-wordmodel",
"craft-xlsx",
+2 -2
View File
@@ -16,10 +16,10 @@ craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4052591363
craft-designcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "19692b6190465671e41967c75d0cd4c439d0c84c", version = "=0.1.0" }
craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
craft-epub = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "4e452a096552477416284d835e6a4c17903fe148", version = "=0.1.0" }
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "fbc0fd1db11429350fb48a769c5cde4ace26e641", version = "=0.1.0" }
craft-indd = { git = "https://github.com/storytold/craft-libs", rev = "47bf5650b0d503b97bfb5e841746c4957897d11f", version = "=0.1.0" }
craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "cc23ffd4d26f3074808e2187d332564817624f8f", version = "=0.1.0", features = ["tree-render", "tree-text"] }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "4e452a096552477416284d835e6a4c17903fe148", version = "=0.1.0" }
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "fbc0fd1db11429350fb48a769c5cde4ace26e641", version = "=0.1.0" }
craft-xml-dtd = { package = "craft-xml", git = "https://github.com/storytold/craft-libs", rev = "f23b0f33f0d00b157476533a43cbbcfd901aa1f1", version = "=0.1.0" }
craft-rtf = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
craft-xlsx = { git = "https://github.com/storytold/craft-libs", rev = "ba24fe2435adb3c81ad6057faf36365fbba736cf", version = "=0.1.0" }
+28 -55
View File
@@ -448,31 +448,38 @@ impl<'a> Ex<'a> {
.collect();
props.push(crate::xml::from_craft(craft_idml::model::TabStopValues::to_list(&values)));
}
if let Some(l) = a.list_type {
el.set(
"BulletsAndNumberingListType",
match l {
n!(a, el, span_space_before, "SpanColumnMinSpaceBefore");
n!(a, el, span_space_after, "SpanColumnMinSpaceAfter");
let list = craft_idml::model::ParagraphListValues {
list_type: a.list_type.map(|list| {
match list {
ListType::None => "NoList",
ListType::Bullets => "BulletList",
ListType::Numbers => "NumberedList",
},
);
}
if let Some(n) = a.number_style {
props.push(p("NumberingFormat", "string", names::numbering_format_out(n)));
}
if let Some(x) = &a.number_expression {
el.set("NumberingExpression", names::list_text_out(x));
}
if let Some(x) = &a.list_separator {
el.set("BulletsTextAfter", names::list_text_out(x));
}
if let Some(c) = a.bullet_char.as_deref().and_then(|s| s.chars().next()) {
props.push(El::new("BulletChar").attr("BulletCharacterType", "UnicodeOnly").attr("BulletCharacterValue", u32::from(c).to_string()));
}
if let Some(b) = a.balance_ragged {
props.push(p("BalanceRaggedLines", "enumeration", if b { "FullyBalanced" } else { "NoBalancing" }));
}
.into()
}),
numbering_format: a.number_style.map(|style| names::numbering_format_out(style).into()),
expression: a.number_expression.as_ref().map(|text| names::list_text_out(text)),
separator: a.list_separator.as_ref().map(|text| names::list_text_out(text)),
bullet_type: a.bullet_char.as_deref().and_then(|text| text.chars().next()).map(|_| "UnicodeOnly".into()),
bullet_value: a.bullet_char.as_deref().and_then(|text| text.chars().next()).map(|character| u32::from(character).to_string()),
balance_ragged: a.balance_ragged.map(|balanced| if balanced { "FullyBalanced" } else { "NoBalancing" }.into()),
level: a.list_level.map(f64::from),
bullet_character_style: a.bullet_char_style.as_ref().map(|style| names::style_self("CharacterStyle", CHAR_BUILTINS, style)),
numbering_character_style: a.number_char_style.as_ref().map(|style| names::style_self("CharacterStyle", CHAR_BUILTINS, style)),
bullet_alignment: a.bullet_align.map(|alignment| names::list_align_out(alignment).into()),
numbering_alignment: a.number_align.map(|alignment| names::list_align_out(alignment).into()),
restart_numbers: a.restart_numbers,
restart_after_level: a.restart_after_level,
restart_after_specific_level: a.restart_after_level.is_some_and(|level| level != 0),
bullet_font: a.bullet_font.clone(),
bullet_font_style: a.bullet_font_style.clone(),
};
for (key, value) in list.to_attrs() {
el.set(&key, value);
}
props.extend(list.to_els().into_iter().map(crate::xml::from_craft));
}
fn para_box_corners(el: &mut El, a: &ParaAttrs) {
@@ -553,39 +560,6 @@ impl<'a> Ex<'a> {
b!(a, el, shading_nonprinting, "ParagraphShadingSuppressPrinting");
}
fn para_list_attrs(&self, el: &mut El, props: &mut Vec<El>, a: &ParaAttrs) {
n!(a, el, span_space_before, "SpanColumnMinSpaceBefore");
n!(a, el, span_space_after, "SpanColumnMinSpaceAfter");
n!(a, el, list_level, "NumberingLevel");
for (k, style) in [("BulletsCharacterStyle", &a.bullet_char_style), ("NumberingCharacterStyle", &a.number_char_style)] {
if let Some(st) = style {
props.push(p(k, "object", names::style_self("CharacterStyle", CHAR_BUILTINS, st)));
}
}
if let Some(v) = a.bullet_align {
el.set("BulletsAlignment", names::list_align_out(v));
}
if let Some(v) = a.number_align {
el.set("NumberingAlignment", names::list_align_out(v));
}
b!(a, el, restart_numbers, "NumberingApplyRestartPolicy");
if let Some(level) = a.restart_after_level {
let (policy, level) = if level == 0 { ("AnyPreviousLevel", 0) } else { ("SpecificPreviousLevel", level) };
props.push(
El::new("NumberingRestartPolicies")
.attr("RestartPolicy", policy)
.attr("LowerLevel", level.to_string())
.attr("UpperLevel", level.to_string()),
);
}
if let Some(f) = &a.bullet_font {
props.push(p("BulletsFont", "string", if f.is_empty() { "$ID/".to_string() } else { f.clone() }));
}
if let Some(f) = a.bullet_font_style.as_ref().filter(|f| !f.is_empty()) {
props.push(p("BulletsFontStyle", "string", f.clone()));
}
}
/// Write paragraph attributes `a`, set over the resolved paragraph style `parent` (`None` for the
/// root style).
pub(super) fn para_attrs(&mut self, el: &mut El, props: &mut Vec<El>, a: &ParaAttrs, parent: Option<&str>) {
@@ -642,7 +616,6 @@ impl<'a> Ex<'a> {
self.para_flow_attrs(el, a);
self.para_columns_and_list_attrs(el, props, a);
self.para_box_attrs(el, props, a);
self.para_list_attrs(el, props, a);
}
}