diff --git a/Cargo.lock b/Cargo.lock index 935348240..a1e9615e0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1025,7 +1025,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=63196e66f3033a6623eb629af95a104d26986725#63196e66f3033a6623eb629af95a104d26986725" +source = "git+https://github.com/storytold/craft-libs?rev=f428c3d36e0faf3924b76956a01334c051543527#f428c3d36e0faf3924b76956a01334c051543527" dependencies = [ "encoding_rs", "image", diff --git a/Cargo.toml b/Cargo.toml index 9d7380cc3..c089e8ecc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,7 +72,7 @@ craft-audio = { git = "https://github.com/storytold/craft-libs", rev = "010702ee # H.264, HEVC, VP9 and AV1 decoders. craft-video = { git = "https://github.com/storytold/craft-libs", rev = "010702ee9b030844c852939095b1da0d0656a890", version = "=0.1.0", default-features = false, features = ["h264-decode", "hevc-decode", "vp9-decode", "av1-decode", "threads"] } # WMF, EMF and EMF+ reader. -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "f428c3d36e0faf3924b76956a01334c051543527", version = "=0.1.0" } craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "63196e66f3033a6623eb629af95a104d26986725", version = "=0.1.0", default-features = false, features = ["write", "write-simple-text"] } # craft-update: app-specific pretend versions apply to startup and manual checks. craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "63196e66f3033a6623eb629af95a104d26986725", features = ["egui"] } diff --git a/ROADMAP.md b/ROADMAP.md index 9fb711050..8b122c9c7 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,6 +2,7 @@ **Stage: alpha** · next: beta, ~20 points and ~120–210 h away +> **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-20 · **Change:** trivial (progress log: WMF scale and offset mapping records place sub-pictures, #2069; scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) > **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-16 · **Change:** trivial (progress log: every slide as PNG or JPEG from File › Export › Change File Type and Save As, #2019; scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) > **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-14 · **Change:** minor (a slide the show advances to again plays its animations again, #2090; slide-list entries with missing relationships are reported as lost slides and open as repaired copies; the Opus decoder and the Ogg, MP4 and Matroska demuxers come from craft-libs; empty notes slides are kept through PPTX and native saves, #2025; parity scores unchanged) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) > **Last reviewed:** 2026-11-04 · **Last updated:** 2026-11-09 · **Change:** minor (progress log: PowerPoint 97–2003 `.ppt`/`.pot`/`.pps` import, #239) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) @@ -158,6 +159,7 @@ app's JSON control channel (`deckcraft --control PORT`). | Date | What landed | |---|---| +| 2026-11-20 | WMF pictures that draw sub-pictures through the scale and offset mapping records (charts and clip art from older Office versions) place each one in its part of the frame (#2069) | | 2026-11-16 | Export: every slide as its own PNG or JPEG picture from File › Export › Change File Type and File › Save As; the Export… dialog adds JPEG images (all slides) (#2019) | | 2026-11-14 | Slide show: a slide the show advances to again (click, →, Space, automatic advance or a loop) starts over, so its animations play again, as in PowerPoint. Back and links still show it as it was left (#2090) | | 2026-11-11 | PPTX: a slide whose notes slide has empty text retains its notesSlide part and relationship on save and reopen (#2025); empty notes slides survive native round trips | @@ -351,6 +353,7 @@ app's JSON control channel (`deckcraft --control PORT`). | Date | Change | Summary | |---|---|---| +| 2026-11-20 | trivial | Progress log: WMF scale and offset mapping records (#2069); scores unchanged | | 2026-11-16 | trivial | Progress log: export all slides as PNG or JPEG from the File tab (#2019); scores unchanged | | 2026-11-14 | trivial | Progress log: a slide the show advances to again plays its animations again (#2090); parity scores unchanged | | 2026-11-11 | minor | Progress log: empty notes slides preserved on PPTX/native save (#2025); parity scores unchanged | diff --git a/crates/render/src/tests.rs b/crates/render/src/tests.rs index d4b46fc5c..d94b646b0 100644 --- a/crates/render/src/tests.rs +++ b/crates/render/src/tests.rs @@ -3404,3 +3404,65 @@ fn a_shape_whose_outline_is_not_finite_is_not_drawable() { quad.paths[0].path = path; assert!(!crate::geometry::drawable(&quad, m, 100.0, 50.0)); } + +/// A WMF without a placeable header (the frame comes from its window records) holding `records` +/// (function, parameter bytes). +fn wmf_bare(records: &[(u16, Vec)]) -> Vec { + let mut body = Vec::new(); + let mut max_words = 3u32; + for (func, params) in records { + let words = (6 + params.len() as u32).div_ceil(2); + max_words = max_words.max(words); + body.extend(words.to_le_bytes()); + body.extend(func.to_le_bytes()); + body.extend(params); + if params.len() % 2 == 1 { + body.push(0); + } + } + body.extend([3, 0, 0, 0, 0, 0]); + let mut f = Vec::new(); + for v in [1u16, 9, 0x300] { + f.extend(v.to_le_bytes()); + } + f.extend((((18 + body.len()) / 2) as u32).to_le_bytes()); + f.extend(1u16.to_le_bytes()); + f.extend(max_words.to_le_bytes()); + f.extend(0u16.to_le_bytes()); + f.extend(body); + f +} + +#[test] +fn metafile_scaled_viewport_places_each_sub_picture_in_its_half() { + // #2069: an 800 × 400 frame drawn as two sub-pictures. Each saves the DC, halves the viewport + // width with SCALEVIEWPORTEXT, sets its own 400 × 400 window (the second shifted right by its + // window origin), draws a circle and restores the DC: red on the left, blue on the right. + let sub = |origin_x: i32, colorref: u32| { + let mut brush = 0u16.to_le_bytes().to_vec(); + brush.extend(colorref.to_le_bytes()); + brush.extend(0u16.to_le_bytes()); + vec![ + (0x001E, vec![]), // SAVEDC + (0x0103, i16s(&[8])), // SETMAPMODE MM_ANISOTROPIC + (0x0412, i16s(&[1, 1, 2, 1])), // SCALEVIEWPORTEXT y 1/1, x 1/2 + (0x020B, i16s(&[0, origin_x])), // SETWINDOWORG + (0x020C, i16s(&[400, 400])), // SETWINDOWEXT + (0x02FC, brush), // CREATEBRUSHINDIRECT + (0x012D, i16s(&[0])), // SELECTOBJECT + (0x0418, i16s(&[380, 380, 20, 20])), // ELLIPSE + (0x0127, i16s(&[-1])), // RESTOREDC + (0x01F0, i16s(&[0])), // DELETEOBJECT + ] + }; + let mut recs = vec![(0x020B, i16s(&[0, 0])), (0x020C, i16s(&[400, 800]))]; + recs.extend(sub(0, 0x0000_00FF)); + recs.extend(sub(-400, 0x00FF_0000)); + let img = crate::metafile::rasterize(&wmf_bare(&recs), 200).expect("raster"); + assert_eq!(img.dimensions(), (200, 100)); + let red = |p: &image::Rgba| p[0] > 200 && p[1] < 60 && p[2] < 60 && p[3] > 200; + let blue = |p: &image::Rgba| p[2] > 200 && p[0] < 60 && p[1] < 60 && p[3] > 200; + assert!(red(img.get_pixel(50, 50)), "red circle in the left half: {:?}", img.get_pixel(50, 50)); + assert!(blue(img.get_pixel(150, 50)), "blue circle in the right half: {:?}", img.get_pixel(150, 50)); + assert!(img.get_pixel(100, 50)[3] < 128, "the circles don't meet in the middle: {:?}", img.get_pixel(100, 50)); +} diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index f19b4151e..afbc31600 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File-format parity with PowerPoint -> **Last reviewed:** 2026-11-02 · **Last updated:** 2026-11-11 · **Change:** minor (empty notes slides are preserved on save and reopen, #2025; previous: minor, PowerPoint 97–2003 `.ppt`/`.pot`/`.pps` import; previous: trivial, a slide whose relationship is missing is reported in `lostSlides`; previous: minor (cell anchorCtr, vertOverflow/horzOverflow, compatLnSpc, normalizeH, thaiDist, table rtl, run altLang and reflection transforms round-trip; Reuse Slides brings referenced custom table styles; previous: minor (native chart payloads stored in bounded ZIP members; previous: major, community PR wave 2026-10-14: seven owned PPTX corpus files, embedded fonts, EMF/WMF clip regions, threaded comments (#70), chart trendlines and workbooks (#335), SmartArt written as a diagram, tags and custom XML kept, picture export DPI; duplicated rows and headers folded; previous: trivial, lines in scaled groups, #233))) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) +> **Last reviewed:** 2026-11-02 · **Last updated:** 2026-11-20 · **Change:** trivial (WMF scale and offset mapping records place sub-pictures, #2069; previous: minor, empty notes slides are preserved on save and reopen, #2025; previous: minor, PowerPoint 97–2003 `.ppt`/`.pot`/`.pps` import; previous: trivial, a slide whose relationship is missing is reported in `lostSlides`; previous: minor (cell anchorCtr, vertOverflow/horzOverflow, compatLnSpc, normalizeH, thaiDist, table rtl, run altLang and reflection transforms round-trip; Reuse Slides brings referenced custom table styles; previous: minor (native chart payloads stored in bounded ZIP members; previous: major, community PR wave 2026-10-14: seven owned PPTX corpus files, embedded fonts, EMF/WMF clip regions, threaded comments (#70), chart trendlines and workbooks (#335), SmartArt written as a diagram, tags and custom XML kept, picture export DPI; duplicated rows and headers folded; previous: trivial, lines in scaled groups, #233))) · **Target:** Microsoft PowerPoint for Mac 16.113 (Microsoft 365) Every format PowerPoint reads or writes, DeckCraft's support, fidelity and how it is tested. Gaps are itemized in [gaps.md](gaps.md#file-formats). Dimension score: **~58% ready** @@ -54,7 +54,7 @@ intermediate build that required inline `bytes` cannot read the new referenced r |---|---|---|---| | PNG, JPEG, GIF (animated), BMP, TIFF, WebP | yes | yes | `image` 0.25; animated GIFs play since #39 | | SVG | yes (with PNG fallback) | **no** | The PNG fallback shows; SVG files can't be inserted | -| EMF / WMF | yes | partial | Drawn as vectors (paths, pens, pattern and hatch brushes, bitmaps, text in the document's fonts with the file's character advances). Rectangle clip regions (`INTERSECTCLIPRECT`, `EXCLUDECLIPRECT`, `EXTSELECTCLIPRGN`) limit later drawing. EMF+ only pictures play every EMF+ drawing record (brushes incl. gradients and textures, pens, paths, curves, images, strings, transforms, clipping; see `crates/metafile/src/emfplus.rs` for the few exceptions). Legacy OLE objects (VML preview) and ActiveX controls show their pictures | +| EMF / WMF | yes | partial | Drawn as vectors (paths, pens, pattern and hatch brushes, bitmaps, text in the document's fonts with the file's character advances). Rectangle clip regions (`INTERSECTCLIPRECT`, `EXCLUDECLIPRECT`, `EXTSELECTCLIPRGN`) limit later drawing. WMF scale and offset mapping records (`SCALEVIEWPORTEXT`, `SCALEWINDOWEXT`, `OFFSETVIEWPORTORG`, `OFFSETWINDOWORG`) place sub-pictures in their part of the frame (#2069). EMF+ only pictures play every EMF+ drawing record (brushes incl. gradients and textures, pens, paths, curves, images, strings, transforms, clipping; see `crates/metafile/src/emfplus.rs` for the few exceptions). Legacy OLE objects (VML preview) and ActiveX controls show their pictures | | HEIC | yes (macOS) | no | | | Audio: MP3, AAC/M4A, ALAC, WAV, AIFF, CAF, FLAC, Ogg Vorbis, Opus | yes (Ogg/Opus partly) | yes | Pure-Rust decoders in `crates/media`; Opus from craft-audio (craft-libs) | | WMA | yes (Windows) | embedded, not playable | | @@ -119,6 +119,7 @@ the round trip even though DeckCraft doesn't model it. | Date | Change | Summary | |---|---|---| +| 2026-11-20 | trivial | WMF scale and offset mapping records place sub-pictures in their part of the frame: craft-metafile pinned past craft-libs #1816 (#2069) | | 2026-11-09 | minor | PowerPoint 97–2003 `.ppt`/`.pot`/`.pps` open (import only): masters, layouts from title masters, slides, text and styles, shapes, pictures, notes. Saving asks for a new name | | 2026-11-07 | trivial | A slide-list entry whose relationship is missing is reported in `lostSlides` like an unreadable slide part, so the deck opens as a repaired copy; slide lists over 10,000 entries are refused with an import-limit error rather than silently truncated (#1910) | | 2026-11-02 | minor | Optional table RTL direction is read and written as `a:tblPr/@rtl`; native and two PPTX saves preserve true, false and absent values with distinguishable column text |