Repository navigation
Conversation
093cf08 to
77dc432
Compare
Main keeps an unchanged chart's embedded workbook (storytold#355), but a chart made in DeckCraft, or one whose data or options changed, was written with no workbook: no part under ppt/embeddings/, no package relationship, no c:externalData. PowerPoint's Edit Data had nothing to open. - Export: an unchanged chart still goes back with its kept parts; an edited or new chart gets a workbook generated from its data, laid out where the chart part's formulas point (Sheet1, categories in A, one column per series), with its c:externalData. - Scatter series with different X values and multi-series bubble charts get their own columns instead of overlapping ranges. - ChartKept::workbook finds the kept workbook part. - The plain-chart fallback of an Office 2016 chart gets none: the workbook belongs to the chartEx part.
Every chart command clears the original chart part, so any edit (a new title, another chart type, a legend) made the export drop the chart's workbook for a generated one: extra sheets, formulas and formatting were lost even when the data had not changed. - Model: Chart.source, the series formulas of the imported chart part (name, categories or X values, values, bubble sizes) with the data as read. Commands keep it. - Export: when the data still fits the original ranges, the chart part is written with its original formulas. Unchanged data keeps the kept workbook byte for byte; changed data rewrites only the changed cells in it. Every other zip entry is copied as is. - Cells keep their style; a new name in a table header renames the table column; a value typed over a formula replaces it and drops the calculation chain; fullCalcOnLoad is set when the workbook holds formulas. - Series or points added or removed, a category chart turned into a scatter chart (or back), literal data, shared or array formulas, a table column name that would clash or is used by a structured reference: the workbook is generated from the chart data, as before.
77dc432 to
a01e062
Compare
…om (storytold#241) - The wheel turns pages in single-page view: one per notch, one per swipe. - The rail's Page display menu offers Acrobat's view choices. - Preferences: default page display and default zoom. - Fit page and Fit height no longer jump across mixed page sizes.
|
An embedded workbook would let users edit chart data in PowerPoint, closing the high-priority chart interoperability gap. If you would rather not, I can open a PR that credits you, keeps your commits and shows a git range-diff against this one, so you'll still get credit and have visible work. |
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: PPTX export writes a workbook for edited and new charts and updates it in place when the data changes. The chart model gains a field for where the data sits in the chart's workbook, and the data as read from there, kept through edits so that an export compares the chart data with it and either keeps the workbook or updates only the cells that changed. PowerPoint's "Edit Data" opens the embedded workbook, so a chart without one is not editable in PowerPoint; writing a correct embedded .xlsx is the real work. contributors/people.toml gains an entry whose display name differs from the account name and sets sync_github_name = false, a contributor choice. A round trip of a chart through PowerPoint (or at least through the importer) is the proof. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
aiongg
left a comment
There was a problem hiding this comment.
AI-generated review (Opus). Not a maintainer decision.
Changes needed (not certain):
Edited and new charts now get a workbook in the exported PPTX. The imported workbook is kept as is or has only its changed cells rewritten while the data fits its original ranges, and otherwise a workbook is generated where the chart formulas point.
- crates/pptx/src/write/mod.rs:223-245: the unchanged-chart path is the same as before. Edited charts take the original formulas when
chart::sourcefits, and otherwise generated ones. The chartEx fallback gets no workbook (crates/pptx/src/write/shapes.rs:408). - crates/pptx/src/write/mod.rs:209-210: an edited chart stored as a
chartExpart (the newer chart types) still loses its workbook on export, so this change covers plainc:chartSpacecharts only. - crates/pptx/src/write/chart.rs:181: a changed category is always written as inline text. If the category range held numbers or dates, those cells change type.
- crates/pptx/src/write/xlsx.rs:556: the in-place patcher refuses shared and array formulas, unparseable ranges and table headers it cannot rename, and then falls back to a generated workbook. That keeps failures safe, but the module is large to review.
- The default branch has a test asserting that an edited chart exports without its kept workbook (crates/engine/tests/it/chart_native.rs:117-129). This change reverses that, so the test needs updating along with the rebase onto the restructured writer (crates/pptx/src/write.rs).
- docs/gaps.md:182-183 still says editing a chart drops its workbook. It should be updated with this change.
Claims checked:
- verified: Every chart command clears Chart.raw, so any edit made the chart export without a workbook before this change. (crates/engine/src/cmd/insert.rs:1711, 1759, 1796, 1800, 1803 and 1820 set c.raw = None. The old export only warned about the dropped workbook (crates/pptx/src/write/mod.rs:209, still used…
- verified: An unchanged chart keeps the earlier path: its original part plus every kept part under fresh names. (crates/pptx/src/write/mod.rs:223-225 calls chart::kept_chart_xml and then chart::write_kept. crates/pptx/src/write/chart.rs:714-737 keeps the earlier raw-comparison logic.)
- verified: An edited chart whose data still fits its original ranges is written with its original formulas, and its workbook is kept byte for byte when only the presentation changed. (crates/pptx/src/write/chart.rs:138-184 (source) returns the original refs and only data edits. crates/pptx/src/write/mod.rs:26…
- verified: When the data changed, only the cells that changed are rewritten in the kept workbook, and its other sheets, formulas and formatting stay. (crates/pptx/src/write/xlsx.rs:556-620 (patch) patches only the edited sheets and copies other zip entries raw. It also sets fullCalcOnLoad, drops calcChain whe…
- verified: Otherwise (new chart, series or points added or removed), the chart part and a generated workbook laid out where its formulas point are both written from the model. (crates/pptx/src/write/mod.rs:234-238 falls back to new_workbook (mod.rs:247). The formulas come from generated_refs (crates/pptx/src/…
- verified: Charts made in DeckCraft now get a workbook. (crates/pptx/src/write/shapes.rs:408 passes workbook=true for every plain chart, and crates/pptx/src/write/mod.rs:247-250 writes workbook_xlsx when the chart has series. Charts with no series and chartEx charts get none.)
Recommendation: update the pull request; it will be reviewed again.
Reviewed at a01e062.
|
I am refreshing this existing implementation against the current writer layout and checking the stale-workbook engine regression and gap documentation noted in review. Native Mac preservation evidence is recorded separately in #1983. PR #1629 overlaps supported fixed-range in-place workbook edits, so I am checking that coverage before making changes; new-chart/fallback workbook generation remains distinct. I will preserve the original commits and publish a reviewable handoff if branch permissions prevent a direct update. |
|
Publishing correction: The fork-targeted helper linked below is closed. That publishing approach has been withdrawn; local commits and the reported validation are preserved. Any further contribution will stay on this official PR, without a duplicate implementation. A ready review-correction helper is available at pierrevbc#1, targeting this existing chart-workbook branch. It retains all three original commits and merges current main for the writer restructure. The focused implementation comparison against main is linked in its description. Refreshed code also fixes reproduced numeric-category cell-type loss, title-only workbook loss with literal chart data, and unchanged old-native models missing the new source snapshot. All 14 workbook regressions and 2,467 native tests/doctests pass (six ignored); the separate official-toolchain wasm check passes all 23 relevant crates. Fresh Office acceptance is explicitly pending because the reference Mac session is locked; package linkage/data preflight passed and immutable fixtures remain ready for that follow-up. Existing native observations on a01e062 remain in #1983. |
|
Reproduced a workbook-selection issue at exact head Original synthetic chart relationships, in order:
Please preserve the actual externalData relationship ID across raw-invalidating edits and resolve that target instead of taking the first package relationship. Scope: model/PPTX/XLSX roundtrips, four original well-formed ZIP/XML fixtures, identical input bytes. Fresh main |
Problem
Since #355, an unchanged chart keeps the embedded workbook it was read with (and the other parts
its relationships reach, in
Chart.kept) when the presentation is saved as PPTX. What is stilllost:
chart.type,chart.data,chart.options) clearsChart.raw, so after a title change, a new legend or one changed valuethe chart is no longer "unchanged" and is saved without
c:externalDataor a workbook. Edit Datain other presentation apps has nothing to open, and the workbook's other sheets, formulas and
formatting are gone.
Reproduce on
mainwith a public file, not for committing:features/steps/test_files/cht-charts.pptxfrom scanny/python-pptx (commit278b47b), ortest-data/slideshow/aascu.org_hbcu_leadershipsummit_cooper_.pptxfrom apache/poi (slides 6and 7, one chart each).
deckcraft-cli run --in cht-charts.pptx --cmd 'chart.options={"title":"New"}' --export out.pptx(any chart command), or insert a chart and export.
unzip -l out.pptx | grep embeddingsprints nothing for that chart; itschartN.xmlhas noc:externalData.Design
The workbook stays where #355 put it: in
Chart.kept, the package parts an imported chart pointsat. No new media item, no new field for it in the model.
ChartKept::workbook()finds the keptworkbook part (the internal
packageoroleObjecttarget of the chart's relationships).On export,
Exp::chart_rel:original part goes back with every kept part under fresh
keptNnames.Chart.source, commit 2): thechart part is written from the model with its original formulas, and the kept workbook is
written next to it: byte for byte when only the presentation changed (title, type, legend…),
with only the changed cells rewritten when the data changed.
generated from the chart data, laid out where the generated chart part's formulas point, with
its
c:externalData.An Office 2016 chart's plain-chart fallback gets no workbook, as with #355: it belongs to the
chartExpart.What changes
Two commits, then a separate one adding my entry to
contributors/people.toml(
[people.pierrevbc], display name only).1. pptx: write a workbook for edited and new charts
ChartKept::workbook().sheet,
Sheet1, inline strings; categories in column A, one column per series, series names onrow 1) under
ppt/embeddings/workbook{n}.xlsx, apackagerelationship andc:externalData.get columns of their own. Before, every scatter series pointed at column A for its X values and
bubble sizes used
col(i + 2), which overlapped the next series' values.chart_embed.rs: the fixtures strip the workbook the writer now generatesfor a new chart (to stand for a file from an app that writes none);
an_edited_chart_does_not_write_a_stale_workbooknow checks that the stale bytes are notwritten and that the chart gets one workbook of its own data.
2. pptx: update chart workbooks in place instead of rebuilding them
Chart.source: Option<ChartSource>: for each series of an imported chart, theformulas of its name, categories (or X values), values and bubble sizes (
c:f), and the data thechart part cached for them. Commands leave it alone, unlike
raw. Skipped when absent, soexisting
.deckcraftfiles serialize as before.counts, same category or XY family, formulas present), the chart part is written with its
original formulas and the kept workbook is written back byte for byte.
the kept workbook (
crates/pptx/src/write/xlsx.rs, quick-xml and zip, no new dependency, nofile or network I/O). Every other zip entry is copied with its compressed bytes. In the
workbook:
calcChain.xml(with its relationship andcontent type) is dropped so Excel does not repair the file; Excel rebuilds it;
fullCalcOnLoad="1"is set oncalcPrwhen the workbook holds formulas, so formulaselsewhere follow the new values.
were added or removed; a category chart became a scatter or bubble chart (or back); the chart
part held literal data; a formula is not one row or column of one sheet (unions, names, other
workbooks); a target cell holds a shared or array formula; a new table column name is empty,
clashes with another column, or appears in a structured reference; a linked workbook's data
changed; the workbook is an older OLE embedding.
How it was tested
cargo xtask cipasses on this branch, onmainat 9859da3 (all 7 steps: fmt, pdf-deps, clippy-D warnings, 1,687 tests passed and 6 ignored, assets, layers, wasm32 check). On Windows thedeckcraft-ui-eguilib tests sometimes crash with an access violation when run in parallel, onmainas well; the run above usedRUST_TEST_THREADS=1.New and changed tests, all on decks and workbooks built in code:
write::chartunit tests: for 11 chart variants (column, stacked bar, line, pie, radar, combo,scatter with shared and with separate X values, single-series bubble, multi-series bubble with
shared and with separate X values), every cached value in the chart part equals the workbook
cell its formula points to; an unchanged chart keeps its part; edited data leaves that path.
write::xlsxunit tests: formula parsing (quoted sheet names, one row or one column only),cells replaced and inserted in order (including new rows and an empty
sheetData), sharedformulas and implicit positions refused,
calcPrset or inserted at its schema position, tablecolumns renamed.
tests/chart_workbook.rs, on a workbook built by the test (aChart datasheet with a table, atotal in F2, a formula in D5, a
Notessheet with a formula into the first one, shared strings,a calculation chain): title, legend and type changed keep the workbook byte for byte; one value
changed rewrites only that cell and sets
fullCalcOnLoad; a renamed series renames the tablecolumn; a value over a formula drops the formula and the calculation chain; added series or
points and a clashing series name rebuild the workbook; a scatter chart updates in place; a chart
made in DeckCraft gets a generated workbook, updated in place after a re-import.
tests/roundtrip.rsandtests/chart_embed.rs(Charts: keep the embedded workbook when a chart is saved unchanged (#335) #355): workbook bytes across round trips,unchanged charts still keep their parts under
keptNnames, thechartExfallback has none.Checked by hand earlier on the same logic (0.5.0, public decks above, not committed): changing the
title and legend keeps every workbook byte for byte; changing one value changes one cell of one
sheet, every other workbook entry (thumbnail included) staying identical; openpyxl and LibreOffice
read the updated workbooks.
Not verified: PowerPoint's Edit Data and Excel's recalculation on the updated workbooks. That needs
a black-box check on a machine with PowerPoint (AGENTS.md §2).
Known limits
Chart.kept, which a.deckcraftsave doesn't store (Charts: keep the embedded workbook when a chart is saved unchanged (#335) #355): a deck savedas
.deckcraftand reopened has no kept workbook, so an export writes a generated one.formatting, and an edited chart drops the other kept parts (styles, drawings), as with Charts: keep the embedded workbook when a chart is saved unchanged (#335) #355.
before. Only the workbook is kept.
[Name],[@Name]); escaped names in formulasmay be missed.
dimensionand rowspanshints are not updated.Related PRs
ChartKeptand leaves its unchanged-chart path as it is.git merge-treeagainstmainat 9859da3 is clean.