mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-14 14:22:39 +00:00
Use shared IDML frame fitting values
This commit is contained in:
4 files changed
+33
-38
No files matched your search
Generated
+10
-10
@@ -1242,10 +1242,10 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-idml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f6ae3aa2#4f6ae3aa2d2c89361c09b735de55ed9c976527c3"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=24922d9b9#24922d9b9081918996e37a0693a2f29e68d8f886"
|
||||
dependencies = [
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4f6ae3aa2)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=4f6ae3aa2)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=24922d9b9)",
|
||||
"craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=24922d9b9)",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
@@ -1647,7 +1647,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=40525913633942f84b06d4837a8d90534a55d63f#40525913633942f84b06d4837a8d90534a55d63f"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=24922d9b9#24922d9b9081918996e37a0693a2f29e68d8f886"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"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=4f6ae3aa2#4f6ae3aa2d2c89361c09b735de55ed9c976527c3"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=40525913633942f84b06d4837a8d90534a55d63f#40525913633942f84b06d4837a8d90534a55d63f"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"thiserror 2.0.21",
|
||||
@@ -1720,7 +1720,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=4f6ae3aa2#4f6ae3aa2d2c89361c09b735de55ed9c976527c3"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=24922d9b9#24922d9b9081918996e37a0693a2f29e68d8f886"
|
||||
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=4f6ae3aa2)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=24922d9b9)",
|
||||
"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=4f6ae3aa2)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=24922d9b9)",
|
||||
"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=4f6ae3aa2)",
|
||||
"craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=24922d9b9)",
|
||||
"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=4f6ae3aa2)",
|
||||
"craft-idml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=24922d9b9)",
|
||||
"craft-rtf",
|
||||
"craft-wordmodel",
|
||||
"craft-xlsx",
|
||||
|
||||
+2
-2
@@ -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 = "93d0998383aa150fa50a2ffbf49ef37786e37eca", 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 = "4f6ae3aa2", version = "=0.1.0" }
|
||||
craft-idml = { git = "https://github.com/storytold/craft-libs", rev = "24922d9b9", 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 = "4f6ae3aa2", version = "=0.1.0" }
|
||||
craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "24922d9b9", 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" }
|
||||
|
||||
@@ -61,19 +61,6 @@ pub(super) fn fit_columns(mut columns: Columns, margins: &Margins, page_width: f
|
||||
columns
|
||||
}
|
||||
|
||||
/// A `BaselineFrameGridRelativeOption` value (`TopOfInsetOfBaselineFrameGridRelativeOption`, or a
|
||||
/// short form such as `TopOfInset`); unknown values measure from the top of the page.
|
||||
pub(super) fn frame_grid_relative(v: &str) -> designcraft_doc::FrameGridRelative {
|
||||
use designcraft_doc::FrameGridRelative as R;
|
||||
let v = v.strip_suffix("OfBaselineFrameGridRelativeOption").unwrap_or(v);
|
||||
match v {
|
||||
"TopOfMargin" | "TopMargin" => R::TopMargin,
|
||||
"TopOfFrame" => R::TopOfFrame,
|
||||
"TopOfInset" | "TopInset" => R::TopInset,
|
||||
_ => R::TopOfPage,
|
||||
}
|
||||
}
|
||||
|
||||
/// Text Frame Options from `TextFramePreference` elements: each attribute from the first that sets it.
|
||||
pub(super) fn text_frame_options(prefs: &[&El]) -> TextFrameOptions {
|
||||
let elements: Vec<_> = prefs.iter().map(|pref| crate::xml::to_craft(pref)).collect();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::frame::{Prefs, frame_grid_relative, text_frame_options, text_wrap};
|
||||
use super::frame::{Prefs, text_frame_options, text_wrap};
|
||||
use super::package::uri_to_path;
|
||||
use super::values::{nums, parse_affine, tint};
|
||||
use super::{
|
||||
@@ -172,14 +172,20 @@ impl<'r> Importer<'r> {
|
||||
if let Some(r) = Prefs(&prefs).prop("ColumnRuleStrokeColor") {
|
||||
options.column_rule_color = self.swatch_ref(&r);
|
||||
}
|
||||
if let Some(g) = self.with_style(e, "BaselineFrameGridOption")
|
||||
&& g.get("UseCustomBaselineFrameGrid") == Some("true")
|
||||
{
|
||||
options.baseline_grid = Some(designcraft_doc::FrameBaselineGrid {
|
||||
start: g.num("StartingOffsetForBaselineFrameGrid").unwrap_or(0.0),
|
||||
increment: g.num("BaselineFrameGridIncrement").unwrap_or(12.0),
|
||||
relative_to: g.get("BaselineFrameGridRelativeOption").map(frame_grid_relative).unwrap_or_default(),
|
||||
});
|
||||
if let Some(g) = self.with_style(e, "BaselineFrameGridOption") {
|
||||
let grid = craft_idml::model::BaselineFrameGridOption::from_el(&crate::xml::to_craft(&g));
|
||||
if grid.use_custom {
|
||||
options.baseline_grid = Some(designcraft_doc::FrameBaselineGrid {
|
||||
start: grid.start,
|
||||
increment: grid.increment,
|
||||
relative_to: match grid.relative_to {
|
||||
craft_idml::model::BaselineFrameGridRelative::TopMargin => designcraft_doc::FrameGridRelative::TopMargin,
|
||||
craft_idml::model::BaselineFrameGridRelative::TopOfFrame => designcraft_doc::FrameGridRelative::TopOfFrame,
|
||||
craft_idml::model::BaselineFrameGridRelative::TopInset => designcraft_doc::FrameGridRelative::TopInset,
|
||||
craft_idml::model::BaselineFrameGridRelative::TopOfPage => designcraft_doc::FrameGridRelative::TopOfPage,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
item.content = Content::Text(TextFrame { story, options });
|
||||
self.ctx.threads.push((
|
||||
@@ -210,10 +216,12 @@ impl<'r> Importer<'r> {
|
||||
gr.fill = fill;
|
||||
}
|
||||
if let (Some(ff), Content::Graphic(gr)) = (self.with_style(e, "FrameFittingOption"), &mut item.content) {
|
||||
gr.crop = [ff.num("TopCrop"), ff.num("LeftCrop"), ff.num("BottomCrop"), ff.num("RightCrop")].map(|v| v.unwrap_or(0.0));
|
||||
gr.fit_align = ff.get("FittingAlignment").map_or(4, names::anchor_in);
|
||||
if ff.get("AutoFit") == Some("true") {
|
||||
gr.auto_fit = ff.get("FittingOnEmptyFrame").map_or(designcraft_doc::Fitting::FillProportionally, names::fitting_in);
|
||||
let fitting = craft_idml::model::FrameFittingOption::from_el(&crate::xml::to_craft(&ff));
|
||||
gr.crop = fitting.crop.map(|v| v.unwrap_or(0.0));
|
||||
gr.fit_align = fitting.alignment.as_deref().map_or(4, names::anchor_in);
|
||||
if fitting.auto_fit {
|
||||
gr.auto_fit =
|
||||
fitting.fitting_on_empty_frame.as_deref().map_or(designcraft_doc::Fitting::FillProportionally, names::fitting_in);
|
||||
if gr.auto_fit == designcraft_doc::Fitting::None {
|
||||
gr.auto_fit = designcraft_doc::Fitting::FillProportionally;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user