diff --git a/Cargo.lock b/Cargo.lock index b22a72292..c90cbd395 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1242,10 +1242,10 @@ dependencies = [ [[package]] name = "craft-idml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7eb395e3691d5e6e68a8459792d66e246314e929#7eb395e3691d5e6e68a8459792d66e246314e929" +source = "git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1#b0d92234f14937517826880c5f44a290f98c1fb1" dependencies = [ - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=7eb395e3691d5e6e68a8459792d66e246314e929)", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=7eb395e3691d5e6e68a8459792d66e246314e929)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)", + "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)", "thiserror 2.0.21", ] @@ -1656,7 +1656,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7eb395e3691d5e6e68a8459792d66e246314e929#7eb395e3691d5e6e68a8459792d66e246314e929" +source = "git+https://github.com/storytold/craft-libs?rev=8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551#8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551" dependencies = [ "quick-xml 0.41.0", "thiserror 2.0.21", @@ -1665,7 +1665,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551#8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551" +source = "git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1#b0d92234f14937517826880c5f44a290f98c1fb1" dependencies = [ "quick-xml 0.41.0", "thiserror 2.0.21", @@ -1730,7 +1730,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7eb395e3691d5e6e68a8459792d66e246314e929#7eb395e3691d5e6e68a8459792d66e246314e929" +source = "git+https://github.com/storytold/craft-libs?rev=8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551#8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1740,7 +1740,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551#8abfa9d0f14bafbfc3449fc552ffeafb9ca6a551" +source = "git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1#b0d92234f14937517826880c5f44a290f98c1fb1" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2021,7 +2021,7 @@ 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=7eb395e3691d5e6e68a8459792d66e246314e929)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)", "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=f23b0f33f0d00b157476533a43cbbcfd901aa1f1)", "designcraft-color", "designcraft-compose", @@ -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=7eb395e3691d5e6e68a8459792d66e246314e929)", + "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)", "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=7eb395e3691d5e6e68a8459792d66e246314e929)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)", "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=7eb395e3691d5e6e68a8459792d66e246314e929)", + "craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=b0d92234f14937517826880c5f44a290f98c1fb1)", "craft-rtf", "craft-wordmodel", "craft-xlsx", diff --git a/Cargo.toml b/Cargo.toml index 1ea74a112..0a80fd4e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = "7eb395e3691d5e6e68a8459792d66e246314e929", version = "=0.1.0" } +craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "b0d92234f14937517826880c5f44a290f98c1fb1", 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 = "7eb395e3691d5e6e68a8459792d66e246314e929", version = "=0.1.0" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "b0d92234f14937517826880c5f44a290f98c1fb1", 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" } diff --git a/crates/idml/src/export/text_attrs.rs b/crates/idml/src/export/text_attrs.rs index 2b9708465..938b6a4bf 100644 --- a/crates/idml/src/export/text_attrs.rs +++ b/crates/idml/src/export/text_attrs.rs @@ -486,39 +486,30 @@ impl<'a> Ex<'a> { /// 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, a: &ParaAttrs, parent: Option<&str>) { - if let Some(v) = &a.mojikumi { - props.push(p("Mojikumi", if v.starts_with("MojikumiTable/") { "object" } else { "enumeration" }, v)); - } - if let Some(v) = &a.kinsoku_type { - el.set("KinsokuType", v); - } - if let Some(v) = a.kinsoku_hang { - el.set( - "KinsokuHangType", - match v { - designcraft_doc::cjk::KinsokuHang::None => "None", - designcraft_doc::cjk::KinsokuHang::Regular => "KinsokuHangRegular", - designcraft_doc::cjk::KinsokuHang::Force => "KinsokuHangForce", - }, - ); - } - if let Some(v) = a.bunri_kinshi { - el.set("BunriKinshi", bool_s(v)); - } - if let Some(v) = a.rensuuji { - el.set("Rensuuji", bool_s(v)); - } - if let Some(v) = a.treat_ideographic_space_as_space { - el.set("TreatIdeographicSpaceAsSpace", bool_s(v)); - } - cjk_settings_para(el, a); - if let Some(Some(k)) = &a.kinsoku { - props.push(p( - "KinsokuSet", - if k.name.is_empty() { "enumeration" } else { "object" }, - if k.name.is_empty() { "Nothing".into() } else { format!("KinsokuTable/{}", escape_id(&k.name)) }, - )); + let cjk = craft_idml::model::CjkParagraphValues { + kinsoku_hang: a.kinsoku_hang.map(|value| match value { + designcraft_doc::cjk::KinsokuHang::None => "None".into(), + designcraft_doc::cjk::KinsokuHang::Regular => "KinsokuHangRegular".into(), + designcraft_doc::cjk::KinsokuHang::Force => "KinsokuHangForce".into(), + }), + mojikumi: a.mojikumi.clone(), + kinsoku_type: a.kinsoku_type.clone(), + bunri_kinshi: a.bunri_kinshi, + rensuuji: a.rensuuji, + treat_ideographic_space_as_space: a.treat_ideographic_space_as_space, + kinsoku_set: a.kinsoku.as_ref().and_then(Option::as_ref).map(|set| craft_idml::model::CjkParagraphValues::kinsoku_reference(&set.name)), + auto_tcy: a.auto_tcy.map(f64::from), + auto_tcy_include_roman: a.auto_tcy_include_roman, + rotate_single_byte_characters: a.rotate_roman, + allow_arbitrary_hyphenation: a.roman_word_break, + grid_gyoudori: a.grid_gyoudori.map(f64::from), + paragraph_gyoudori: a.paragraph_gyoudori, + }; + let (attributes, properties) = cjk.to_parts(); + for (key, value) in attributes { + el.set(&key, value); } + props.extend(properties.into_iter().map(crate::xml::from_craft)); self.para_nested_styles(props, a, parent); self.para_alignment_attrs(el, a, parent); self.para_flow_attrs(el, a); @@ -527,28 +518,6 @@ impl<'a> Ex<'a> { } } -/// Auto tate-chu-yoko, Japanese composition and grid settings of a paragraph range or style. -fn cjk_settings_para(el: &mut El, a: &ParaAttrs) { - if let Some(v) = a.auto_tcy { - el.set("AutoTcy", v); - } - if let Some(v) = a.auto_tcy_include_roman { - el.set("AutoTcyIncludeRoman", bool_s(v)); - } - if let Some(v) = a.rotate_roman { - el.set("RotateSingleByteCharacters", bool_s(v)); - } - if let Some(v) = a.roman_word_break { - el.set("AllowArbitraryHyphenation", bool_s(v)); - } - if let Some(v) = a.grid_gyoudori { - el.set("GridGyoudori", v); - } - if let Some(v) = a.paragraph_gyoudori { - el.set("ParagraphGyoudori", bool_s(v)); - } -} - impl Ex<'_> { /// Kenten Settings, Kenten Color and Shatai of a character range or style. fn cjk_settings_chars(&self, el: &mut El, props: &mut Vec, a: &CharAttrs) {