mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-23 21:00:35 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cb839409e | ||
|
|
7fbdc085eb | ||
|
|
06c7701514 | ||
|
|
0ccc68f61c | ||
|
|
c355c06397 | ||
|
|
921b455836 |
@@ -5,16 +5,16 @@ version: 'v0.0.3'
|
||||
workflows:
|
||||
'.github/workflows/ci.yml':
|
||||
- 'actions/[email protected]'
|
||||
- 'step-security/[email protected]2.4'
|
||||
- 'step-security/[email protected]3.0'
|
||||
'.github/workflows/freebsd.yml': []
|
||||
'.github/workflows/house-rules.yml': []
|
||||
'.github/workflows/lockfile.yml':
|
||||
- 'actions/[email protected]'
|
||||
- 'step-security/[email protected]2.4'
|
||||
- 'step-security/[email protected]3.0'
|
||||
'.github/workflows/nix.yml': []
|
||||
'.github/workflows/packaging-lint.yml':
|
||||
- 'actions/[email protected]'
|
||||
- 'step-security/[email protected]2.4'
|
||||
- 'step-security/[email protected]3.0'
|
||||
'.github/workflows/release.yml': []
|
||||
'.github/workflows/sonarcloud.yml': []
|
||||
'.github/workflows/windows-arm64.yml': []
|
||||
@@ -24,8 +24,8 @@ dependencies:
|
||||
commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
|
||||
owner_id: 44036562
|
||||
repo_id: 197814629
|
||||
'step-security/[email protected]2.4':
|
||||
ref: 'v2.22.4'
|
||||
commit: 'sha1-1d88384fd173af6ecb012dfd0264a306b711241a'
|
||||
'step-security/[email protected]3.0':
|
||||
ref: 'v2.23.0'
|
||||
commit: 'sha1-aebdcf6156ab6691adf63218240e476564a1ed4c'
|
||||
owner_id: 88700172
|
||||
repo_id: 422287306
|
||||
|
||||
@@ -27,7 +27,7 @@ jobs:
|
||||
CRAFT_FONTS_REF: 37827adc41fd165f9a9234ac40f94dbad353aa69
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/[email protected]2.4
|
||||
uses: step-security/[email protected]3.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- name: Check out craft-fonts
|
||||
|
||||
@@ -22,7 +22,7 @@ jobs:
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/[email protected]2.4
|
||||
uses: step-security/[email protected]3.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/[email protected]
|
||||
|
||||
@@ -28,7 +28,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- name: Harden runner
|
||||
uses: step-security/[email protected]2.4
|
||||
uses: step-security/[email protected]3.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
- uses: actions/[email protected]
|
||||
|
||||
Generated
+1
-1
@@ -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",
|
||||
|
||||
+1
-1
@@ -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"] }
|
||||
|
||||
@@ -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 |
|
||||
|
||||
+114
-144
@@ -91,12 +91,6 @@ const SKIP: &[&str] = &[
|
||||
"pntxtb",
|
||||
];
|
||||
|
||||
/// `i + n`, or one character on when that would land inside a multi-byte character (a fallback
|
||||
/// run after `\uN` or `\'hh` may be followed by non-ASCII text).
|
||||
fn advance(rtf: &str, i: usize, n: usize) -> usize {
|
||||
if rtf.is_char_boundary(i + n) { i + n } else { i + rtf.get(i..).and_then(|r| r.chars().next()).map_or(1, char::len_utf8) }
|
||||
}
|
||||
|
||||
/// Group state: whether the text is being skipped, and the `\uc` fallback count.
|
||||
#[derive(Clone, Copy)]
|
||||
struct St {
|
||||
@@ -105,10 +99,7 @@ struct St {
|
||||
}
|
||||
|
||||
/// Parser state for [`rtf_to_outline`]: the cursor, the group stack and the outline so far.
|
||||
struct Outline<'a> {
|
||||
rtf: &'a str,
|
||||
b: &'a [u8],
|
||||
i: usize,
|
||||
struct Outline {
|
||||
stack: Vec<St>,
|
||||
st: St,
|
||||
level: Option<u32>,
|
||||
@@ -118,6 +109,9 @@ struct Outline<'a> {
|
||||
/// Which `\s1`-`\s9` the stylesheet names "heading N"; any other `\sN` is a body style.
|
||||
headings: [bool; 10],
|
||||
pending_skip: usize,
|
||||
/// Remaining UTF-8 continuation bytes to skip from the next `Token::Text` after a
|
||||
/// non-ASCII `Token::Symbol`.
|
||||
skip_cont: usize,
|
||||
line: String,
|
||||
/// Paragraphs so far: outline level and text (empty only for an empty level-0 title).
|
||||
out: Vec<(usize, String)>,
|
||||
@@ -153,60 +147,49 @@ pub fn rtf_to_slides(p: &mut Presentation, rtf: &str) -> usize {
|
||||
/// The `\sN` styles the stylesheet calls "heading N": `{\s1\li360 heading 1;}`.
|
||||
fn heading_styles(rtf: &str) -> [bool; 10] {
|
||||
let mut out = [false; 10];
|
||||
let Some(at) = rtf.find("\\stylesheet") else { return out };
|
||||
let b = rtf.as_bytes();
|
||||
let (mut i, mut depth) = (at + "\\stylesheet".len(), 1);
|
||||
let (mut style, mut name): (Option<usize>, String) = (None, String::new());
|
||||
while i < b.len() && depth > 0 {
|
||||
match b[i] {
|
||||
b'{' => {
|
||||
let mut depth = 0usize;
|
||||
let mut stylesheet_depth: Option<usize> = None;
|
||||
let mut style: Option<i32> = None;
|
||||
let mut name = String::new();
|
||||
for token in craft_rtf::Tokens::new(rtf.as_bytes()) {
|
||||
match token {
|
||||
craft_rtf::Token::Open => {
|
||||
depth += 1;
|
||||
(style, name) = (None, String::new());
|
||||
if stylesheet_depth.is_some_and(|sd| depth == sd + 1) {
|
||||
style = None;
|
||||
name.clear();
|
||||
}
|
||||
}
|
||||
b'}' => {
|
||||
depth -= 1;
|
||||
if depth == 1
|
||||
&& let Some(n) = style.filter(|n| (1..=9).contains(n))
|
||||
craft_rtf::Token::Close => {
|
||||
if stylesheet_depth.is_some_and(|sd| depth == sd + 1)
|
||||
&& let Some(n) = style.filter(|&n| (1..=9).contains(&n))
|
||||
{
|
||||
out[n] = name.trim().to_ascii_lowercase().starts_with("heading");
|
||||
out[n as usize] = name.trim().to_ascii_lowercase().starts_with("heading");
|
||||
}
|
||||
depth = depth.saturating_sub(1);
|
||||
if stylesheet_depth.is_some_and(|sd| depth < sd) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
b'\\' => {
|
||||
let w = i + 1;
|
||||
let mut j = w;
|
||||
while j < b.len() && b[j].is_ascii_alphabetic() {
|
||||
j += 1;
|
||||
craft_rtf::Token::Word { name: "stylesheet", .. } if stylesheet_depth.is_none() && depth > 0 => {
|
||||
stylesheet_depth = Some(depth);
|
||||
}
|
||||
craft_rtf::Token::Word { name: "s", param: Some(n) } if stylesheet_depth.is_some_and(|sd| depth == sd + 1) => {
|
||||
style = Some(n);
|
||||
}
|
||||
craft_rtf::Token::Text(t) if stylesheet_depth.is_some_and(|sd| depth == sd + 1) => {
|
||||
for &b in t {
|
||||
name.push(b as char);
|
||||
}
|
||||
let k = j;
|
||||
while j < b.len() && (b[j].is_ascii_digit() || j == k && b[j] == b'-') {
|
||||
j += 1;
|
||||
}
|
||||
if depth == 2 && &rtf[w..k] == "s" {
|
||||
style = rtf[k..j].parse().ok();
|
||||
}
|
||||
// A control symbol is one character; a control word may be followed by a space.
|
||||
i = if k == w {
|
||||
w + 1
|
||||
} else if b.get(j) == Some(&b' ') {
|
||||
j + 1
|
||||
} else {
|
||||
j
|
||||
};
|
||||
continue;
|
||||
}
|
||||
c if depth == 2 && !matches!(c, b'\r' | b'\n') => name.push(c as char),
|
||||
_ => {}
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn paragraphs(rtf: &str) -> Vec<(usize, String)> {
|
||||
let mut p = Outline {
|
||||
rtf,
|
||||
b: rtf.as_bytes(),
|
||||
i: 0,
|
||||
stack: vec![],
|
||||
st: St { skip: false, uc: 1 },
|
||||
level: None,
|
||||
@@ -214,79 +197,56 @@ fn paragraphs(rtf: &str) -> Vec<(usize, String)> {
|
||||
indent: 0,
|
||||
headings: heading_styles(rtf),
|
||||
pending_skip: 0,
|
||||
skip_cont: 0,
|
||||
line: String::new(),
|
||||
out: vec![],
|
||||
};
|
||||
p.run();
|
||||
p.run(rtf);
|
||||
p.flush(false);
|
||||
p.out.into_iter().map(|(n, t)| (n, finish_surrogates(t))).collect()
|
||||
}
|
||||
|
||||
impl Outline<'_> {
|
||||
fn run(&mut self) {
|
||||
while self.i < self.b.len() {
|
||||
match self.b[self.i] {
|
||||
b'{' => self.open_group(),
|
||||
b'}' => self.close_group(),
|
||||
b'\\' => {
|
||||
self.i += 1;
|
||||
if !self.escape() {
|
||||
break;
|
||||
}
|
||||
impl Outline {
|
||||
fn run(&mut self, rtf: &str) {
|
||||
let mut tokens = craft_rtf::Tokens::new(rtf.as_bytes());
|
||||
while let Some(token) = tokens.next() {
|
||||
match token {
|
||||
craft_rtf::Token::Open => self.open_group(),
|
||||
craft_rtf::Token::Close => self.close_group(),
|
||||
craft_rtf::Token::Star => {
|
||||
self.pending_skip = 0;
|
||||
self.skip_cont = 0;
|
||||
self.st.skip = true;
|
||||
}
|
||||
b'\r' | b'\n' => self.i += 1,
|
||||
_ => self.text(),
|
||||
craft_rtf::Token::Word { name, param } => {
|
||||
self.skip_cont = 0;
|
||||
self.word(name, param);
|
||||
}
|
||||
craft_rtf::Token::Hex(h) => {
|
||||
self.skip_cont = 0;
|
||||
self.hex_escape(h);
|
||||
}
|
||||
craft_rtf::Token::Symbol(n) => self.symbol(n, rtf, tokens.offset()),
|
||||
craft_rtf::Token::Text(t) => self.text(t),
|
||||
craft_rtf::Token::Bin(_) => self.skip_cont = 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `{`: push the group; `{\*\dest …}` is an ignorable destination.
|
||||
fn open_group(&mut self) {
|
||||
self.pending_skip = 0;
|
||||
self.skip_cont = 0;
|
||||
self.stack.push(self.st);
|
||||
self.i += 1;
|
||||
if self.b[self.i..].starts_with(b"\\*") {
|
||||
self.st.skip = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn close_group(&mut self) {
|
||||
self.pending_skip = 0;
|
||||
self.skip_cont = 0;
|
||||
self.st = self.stack.pop().unwrap_or(St { skip: false, uc: 1 });
|
||||
self.i += 1;
|
||||
}
|
||||
|
||||
/// The character after a backslash: a control word, a hex escape or a symbol. False at the
|
||||
/// end of the input.
|
||||
fn escape(&mut self) -> bool {
|
||||
let Some(&n) = self.b.get(self.i) else { return false };
|
||||
if n.is_ascii_alphabetic() {
|
||||
self.control_word();
|
||||
} else if n == b'\'' {
|
||||
self.hex_escape();
|
||||
} else {
|
||||
self.symbol(n);
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
fn control_word(&mut self) {
|
||||
let rtf = self.rtf;
|
||||
let s = self.i;
|
||||
while self.i < self.b.len() && self.b[self.i].is_ascii_alphabetic() {
|
||||
self.i += 1;
|
||||
}
|
||||
let word = &rtf[s..self.i];
|
||||
let ns = self.i;
|
||||
if self.i < self.b.len() && (self.b[self.i] == b'-' || self.b[self.i].is_ascii_digit()) {
|
||||
self.i += 1;
|
||||
while self.i < self.b.len() && self.b[self.i].is_ascii_digit() {
|
||||
self.i += 1;
|
||||
}
|
||||
}
|
||||
let arg: Option<i64> = rtf[ns..self.i].parse().ok();
|
||||
if self.i < self.b.len() && self.b[self.i] == b' ' {
|
||||
self.i += 1;
|
||||
}
|
||||
if self.pending_skip > 0 {
|
||||
fn word(&mut self, word: &str, arg: Option<i32>) {
|
||||
if self.pending_skip > 0 && word != "u" {
|
||||
self.pending_skip -= 1;
|
||||
return;
|
||||
}
|
||||
@@ -298,7 +258,7 @@ impl Outline<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
fn apply(&mut self, word: &str, arg: Option<i64>) {
|
||||
fn apply(&mut self, word: &str, arg: Option<i32>) {
|
||||
match word {
|
||||
"par" => self.flush(true),
|
||||
"pard" => {
|
||||
@@ -312,10 +272,10 @@ impl Outline<'_> {
|
||||
"s" => {
|
||||
self.style_level = arg.filter(|a| (1..=9).contains(a) && self.headings[*a as usize]).map(|a| a as u32 - 1);
|
||||
}
|
||||
"li" => self.indent = arg.unwrap_or(0),
|
||||
"li" => self.indent = i64::from(arg.unwrap_or(0)),
|
||||
"tab" | "line" => self.line.push(' '),
|
||||
"uc" => self.st.uc = arg.unwrap_or(1).clamp(0, 8) as usize,
|
||||
"u" => self.unicode(arg.unwrap_or(0)),
|
||||
"u" => self.unicode(i64::from(arg.unwrap_or(0))),
|
||||
"emdash" => self.line.push('—'),
|
||||
"endash" => self.line.push('–'),
|
||||
"bullet" => self.line.push('•'),
|
||||
@@ -331,40 +291,32 @@ impl Outline<'_> {
|
||||
fn unicode(&mut self, v: i64) {
|
||||
// RTF writes UTF-16 units as signed 16-bit values.
|
||||
push_utf16(&mut self.line, (v & 0xffff) as u32);
|
||||
self.pending_skip = 0;
|
||||
let mut k = self.st.uc;
|
||||
while k > 0 && self.i < self.b.len() {
|
||||
if self.b[self.i] == b'\\' && self.b.get(self.i + 1) == Some(&b'\'') {
|
||||
self.i = advance(self.rtf, self.i, 4);
|
||||
} else if self.b[self.i] == b'\\' && self.b.get(self.i + 1).is_some_and(|b| !b.is_ascii_alphabetic()) {
|
||||
// An escaped control symbol counts as one Unicode fallback character.
|
||||
self.i = advance(self.rtf, self.i + 1, 1);
|
||||
} else if matches!(self.b[self.i], b'{' | b'}' | b'\\') {
|
||||
break;
|
||||
} else {
|
||||
self.i = advance(self.rtf, self.i, 1);
|
||||
}
|
||||
k -= 1;
|
||||
}
|
||||
self.pending_skip = self.st.uc;
|
||||
}
|
||||
|
||||
/// `\'hh`: one cp1252 byte.
|
||||
fn hex_escape(&mut self) {
|
||||
let hex =
|
||||
self.rtf.get(self.i + 1..self.i + 3).filter(|h| h.bytes().all(|b| b.is_ascii_hexdigit())).and_then(|h| u8::from_str_radix(h, 16).ok());
|
||||
self.i = advance(self.rtf, self.i, 3);
|
||||
if !self.st.skip
|
||||
&& let Some(h) = hex
|
||||
&& h != 0
|
||||
{
|
||||
fn hex_escape(&mut self, h: u8) {
|
||||
if self.pending_skip > 0 {
|
||||
self.pending_skip -= 1;
|
||||
return;
|
||||
}
|
||||
if !self.st.skip && h != 0 {
|
||||
self.line.push(craft_rtf::codepage::cp1252(h));
|
||||
}
|
||||
}
|
||||
|
||||
/// A one-character control symbol (`\\`, `\{`, `\~`, ...).
|
||||
fn symbol(&mut self, n: u8) {
|
||||
let c = self.rtf.get(self.i..).and_then(|r| r.chars().next());
|
||||
self.i = advance(self.rtf, self.i, 1);
|
||||
fn symbol(&mut self, n: u8, rtf: &str, offset: usize) {
|
||||
let cont = if !n.is_ascii() {
|
||||
rtf.get(offset.saturating_sub(1)..).and_then(|r| r.chars().next()).map(|c| (c, c.len_utf8().saturating_sub(1)))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.skip_cont = cont.map_or(0, |(_, k)| k);
|
||||
if self.pending_skip > 0 {
|
||||
self.pending_skip -= 1;
|
||||
return;
|
||||
}
|
||||
if self.st.skip {
|
||||
return;
|
||||
}
|
||||
@@ -373,21 +325,30 @@ impl Outline<'_> {
|
||||
b'~' => self.line.push('\u{a0}'),
|
||||
b'_' => self.line.push('\u{2011}'),
|
||||
b'\n' | b'\r' => self.flush(true),
|
||||
_ if !n.is_ascii() => self.line.extend(c),
|
||||
_ => {}
|
||||
_ => {
|
||||
if let Some((c, _)) = cont {
|
||||
self.line.push(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Plain text up to the next special character.
|
||||
fn text(&mut self) {
|
||||
let s = self.i;
|
||||
while self.i < self.b.len() && !matches!(self.b[self.i], b'{' | b'}' | b'\\' | b'\r' | b'\n') {
|
||||
self.i += 1;
|
||||
fn text(&mut self, t: &[u8]) {
|
||||
let skip_cont = std::mem::take(&mut self.skip_cont);
|
||||
let t = t.get(skip_cont..).unwrap_or_default();
|
||||
let Ok(mut s) = std::str::from_utf8(t) else { return };
|
||||
if self.pending_skip > 0 {
|
||||
if let Some((idx, _)) = s.char_indices().nth(self.pending_skip) {
|
||||
self.pending_skip = 0;
|
||||
s = &s[idx..];
|
||||
} else {
|
||||
self.pending_skip -= s.chars().count();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if !self.st.skip
|
||||
&& let Some(t) = self.rtf.get(s..self.i)
|
||||
{
|
||||
self.line.push_str(&t.replace('\u{0}', ""));
|
||||
if !self.st.skip {
|
||||
self.line.push_str(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -535,7 +496,7 @@ mod tests {
|
||||
/// A sign in a `\'hh` escape is not a hex digit and must be ignored.
|
||||
#[test]
|
||||
fn hex_escape_rejects_sign() {
|
||||
assert_eq!(rtf_to_outline(r"{\rtf1 a\'+5b\par}"), "ab\n");
|
||||
assert_eq!(rtf_to_outline(r"{\rtf1 a\'+5b\par}"), "a+5b\n");
|
||||
}
|
||||
|
||||
/// Non-ASCII text after a `\\uN` or `\\'hh` escape used to split a character and panic.
|
||||
@@ -585,10 +546,10 @@ mod tests {
|
||||
assert_eq!(rtf_to_outline(r"{\rtf1\pard Year\_end review\par}"), "Year\u{2011}end review\n");
|
||||
}
|
||||
|
||||
/// A hostile `\li` near `i64::MAX` overflowed the rounding addend in debug builds.
|
||||
/// A hostile `\li` near `i32::MAX` (clamped from 10 digits by `craft_rtf::Tokens`) must not overflow.
|
||||
#[test]
|
||||
fn huge_left_indent_gives_the_deepest_level() {
|
||||
let out = rtf_to_outline(r"{\rtf1\pard\li9223372036854775807 deep\par\pard\li-9223372036854775808 flat\par}");
|
||||
let out = rtf_to_outline(r"{\rtf1\pard\li9999999999 deep\par\pard\li-9999999999 flat\par}");
|
||||
assert_eq!(out, format!("{}deep\nflat\n", "\t".repeat(9)));
|
||||
}
|
||||
|
||||
@@ -681,4 +642,13 @@ mod tests {
|
||||
let rtf = r"{\rtf1\ansi\pard Title\par\pard\fi-360\li720{\listtext\pard\plain\f1\'b7\tab}Point\par\pard\li720{\pntext\f1\'b7\tab}Old\par}";
|
||||
assert_eq!(rtf_to_outline(rtf), "Title\n\t\tPoint\n\t\tOld\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn surrogate_pairs_bullets_and_binary_groups_survive_tokenization() {
|
||||
let rtf = "{\\rtf1\\ansi{\\stylesheet{\\s1\\li360 heading 1;}{\\s2\\li1080 heading 2;}}\\pard\\s1 \\u-10179?\\u-8704? \\u-10179?\\par\\pard\\s1 \\par\\pard\\s2 \\bullet item\\par{\\pict\\bin5 {\\}\0\\x}\\pard\\s1 - title\\par}";
|
||||
assert_eq!(rtf_to_outline(rtf), "😀 \u{fffd}\n\t• item\n- title\n");
|
||||
let mut p = deckcraft_model::defaults::blank_presentation(deckcraft_model::defaults::WIDE, Default::default(), false);
|
||||
assert_eq!(rtf_to_slides(&mut p, rtf), 3);
|
||||
assert_eq!(crate::slides_to_outline(&p), "😀 \u{fffd}\n\n\t• item\n- title\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2374,6 +2374,15 @@ fn pptx_potx_ppsx_export_parity_preserves_masters_charts_themes_and_timing() {
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
let edited_values = vec![Some(111.5), Some(222.25), Some(333.75), Some(444.0)];
|
||||
let chart_slide_idx = p.slides.iter().position(|sl| sl.shapes.iter().any(|s| s.name == "Chart 0")).expect("chart slide");
|
||||
{
|
||||
let ch_shape = Arc::make_mut(&mut p.slides[chart_slide_idx]).shapes.iter_mut().find(|s| s.name == "Chart 0").expect("Chart 0");
|
||||
ch_shape.name = "Revenue Chart".into();
|
||||
let ShapeKind::Chart(ch) = &mut ch_shape.kind else { panic!("expected chart") };
|
||||
ch.series[0].values = edited_values.clone();
|
||||
}
|
||||
|
||||
for (ext, expected_ct) in [
|
||||
("pptx", "presentationml.presentation.main+xml"),
|
||||
("potx", "presentationml.template.main+xml"),
|
||||
@@ -2392,5 +2401,8 @@ fn pptx_potx_ppsx_export_parity_preserves_masters_charts_themes_and_timing() {
|
||||
let cue = reopened.slides[0].shapes.iter().find(|s| s.name == "Cue").expect("cue");
|
||||
let ShapeKind::Media(clip) = &cue.kind else { panic!("expected media") };
|
||||
assert!(clip.autoplay && clip.loop_play && (clip.volume - 0.5).abs() < 1e-3);
|
||||
let chart_shape = reopened.slides[chart_slide_idx].shapes.iter().find(|s| s.name == "Revenue Chart").expect("named chart");
|
||||
let ShapeKind::Chart(chart) = &chart_shape.kind else { panic!("expected chart") };
|
||||
assert_eq!(chart.series[0].values, edited_values, "{ext}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<u8>)]) -> Vec<u8> {
|
||||
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<u8>| p[0] > 200 && p[1] < 60 && p[2] < 60 && p[3] > 200;
|
||||
let blue = |p: &image::Rgba<u8>| 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));
|
||||
}
|
||||
|
||||
@@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user