mirror of
https://github.com/storytold/indd-utils.git
synced 2026-11-19 08:40:46 +01:00
feat: write the transform attributes of object styles
Chunk 0x1E234 of an object style holds four u16 flags and four f64: X, Y, height and width of TransformAttributeOption. IDML writes each value whose flag is 1 (36 styles; 2,390 with all flags 0 have none). compare.py --exclude own/, trustworthy pairs: TransformAttrWidth 0 -> 30/30, TransformAttrHeight 0 -> 11/11, TransformAttrX 0 -> 3/3, TransformAttrY 0 -> 1/1; no extra values.
This commit is contained in:
1 parent
3ba72f54ce
commit
129f5b1dca
4 files changed
+47
No files matched your search
@@ -2198,6 +2198,7 @@ counts are matches of 337 unless stated.
|
||||
| 0x1B94D | u16, 1 = true | `ApplyNextParagraphStyle` (below) |
|
||||
| 0x2800 | Anchored object settings, as in the preferences | `AnchoredObjectSetting` (below) |
|
||||
| 0x1B907 | u32 based-on style, flag byte and name, u32 shortcut key | `BasedOn`, `Name`, `KeyboardShortcut` (below) |
|
||||
| 0x1E234 | 52 bytes: u16 flags at 8, 10, 12 and 14, f64 at 16, 24, 32 and 40 | `TransformAttributeOption`: `TransformAttrX`, `TransformAttrY`, `TransformAttrHeight` and `TransformAttrWidth`, each written when its flag is 1 (below) |
|
||||
|
||||
**Settings found in the corpus after 2026-10.** Object styles other
|
||||
than `[None]`, matched by `Self` with their IDML style over the 1,251
|
||||
@@ -2385,6 +2386,17 @@ objects).
|
||||
The other values of object styles come from IDML observation
|
||||
(`idml-values.md`).
|
||||
|
||||
**Transform attributes (chunk 0x1E234).** Over the 1,251 trustworthy
|
||||
pairs after 2026-10, 2,426 object styles have the chunk, 52 bytes each.
|
||||
The u16 at 8, 10, 12 and 14 are 1 exactly where IDML writes
|
||||
`TransformAttrX`, `TransformAttrY`, `TransformAttrHeight` and
|
||||
`TransformAttrWidth`, and the f64 at 16, 24, 32 and 40 are their
|
||||
values: 3 of 3 X, 1 of 1 Y, 11 of 11 height and 30 of 30 width values
|
||||
(36 styles; 2,390 styles have all four flags 0 and no such attribute,
|
||||
though many store values other than 0). Bytes 0–7 and 48–51 are 0 in
|
||||
every chunk. IDML has the element from DOM 13 (`idml-values.md`); the
|
||||
converter writes the values the style sets into it.
|
||||
|
||||
## Master spread names and sections
|
||||
|
||||
Master spread chunk 0x1402: a flag byte and the name prefix (`A`), a flag
|
||||
|
||||
@@ -433,6 +433,21 @@ impl Writer<'_> {
|
||||
if let Some(e) = export::object_export_option(self.doc.version, None, true) {
|
||||
node.children.insert(0, e);
|
||||
}
|
||||
// The transform values the style sets, where IDML has the element
|
||||
// (objects.md, object style settings).
|
||||
let transform: Vec<_> = [
|
||||
"TransformAttrX",
|
||||
"TransformAttrY",
|
||||
"TransformAttrHeight",
|
||||
"TransformAttrWidth",
|
||||
]
|
||||
.into_iter()
|
||||
.zip(os.transform)
|
||||
.filter_map(|(name, v)| Some((name, num(v?))))
|
||||
.collect();
|
||||
if !transform.is_empty() && node.child("TransformAttributeOption").is_some() {
|
||||
node.set(&["TransformAttributeOption"], transform);
|
||||
}
|
||||
let mut attrs = self.item_attr_values(&os.attrs);
|
||||
for (id, name) in [
|
||||
(0x551E, "GradientFillAngle"),
|
||||
|
||||
@@ -312,6 +312,8 @@ pub mod chunk {
|
||||
pub const OBJECT_STYLE_PARAGRAPH_STYLE: u32 = 0x1B946;
|
||||
/// u16 1 when an object style applies the next paragraph style.
|
||||
pub const OBJECT_STYLE_APPLY_NEXT: u32 = 0x1B94D;
|
||||
/// Size and position of an object style's transform attributes.
|
||||
pub const OBJECT_STYLE_TRANSFORM: u32 = 0x1E234;
|
||||
pub const GUIDE: u32 = 0x3308;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,6 +164,9 @@ pub struct ObjectStyle {
|
||||
pub named_grid: Option<Option<u32>>,
|
||||
/// Export settings (chunk 0x28F0).
|
||||
pub export: Option<StyleExport>,
|
||||
/// Transform attributes (chunk 0x1E234): X, Y, height and width, each
|
||||
/// `Some` when the style sets it.
|
||||
pub transform: [Option<f64>; 4],
|
||||
}
|
||||
|
||||
/// Whether `s` has the form of a GUID as styles store it: lowercase
|
||||
@@ -504,10 +507,25 @@ impl<'a> Reader<'a> {
|
||||
}),
|
||||
named_grid: self.applied_named_grid(uid)?,
|
||||
export: self.style_export(uid)?,
|
||||
transform: match self.chunk(uid, chunk::OBJECT_STYLE_TRANSFORM)? {
|
||||
Some(d) => transform_options(self.enc(), &d),
|
||||
None => [None; 4],
|
||||
},
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
/// Chunk 0x1E234 of an object style: u16 flags at 8, 10, 12 and 14 (1 when
|
||||
/// the style sets X, Y, height and width), and those values as f64 at 16,
|
||||
/// 24, 32 and 40. See `docs/format/objects.md`, object style settings.
|
||||
fn transform_options(enc: crate::object::Encoding, d: &[u8]) -> [Option<f64>; 4] {
|
||||
std::array::from_fn(|i| {
|
||||
(enc.u16_at(d, 8 + 2 * i) == Some(1))
|
||||
.then(|| enc.f64_at(d, 16 + 8 * i))
|
||||
.flatten()
|
||||
})
|
||||
}
|
||||
|
||||
/// Anchored object settings (chunk 0x2800, of an anchor, an object style
|
||||
/// or the preferences). See `docs/format/objects.md`, anchored objects.
|
||||
/// A field is `None` where the chunk is too short for it.
|
||||
|
||||
Reference in new issue
Block a user