Compare commits

...
Author SHA1 Message Date
FredApps 20dc8ccd85 Keep the replacement unsaved workbook prompt active 2026-12-04 18:27:11 +01:00
FredApps 578fa5c4bf Merge remote-tracking branch 'origin/main' into review/grid-5079-fix 2026-12-04 18:25:15 +01:00
Dylan M. Taylor fe6195d207 Merge pull request #5081 from storytold/docs/freebsd-15-1-requirement
docs: document FreeBSD 15.1 minimum for prebuilt packages
2026-12-04 09:48:56 -05:00
Dylan M. Taylor 6ee8f4b6df docs: document FreeBSD 15.1 minimum for prebuilt packages 2026-12-04 09:09:19 -05:00
arnav-hiwarkarandClaude Opus 5.5 e360fe5bcc test(ui): check the unsaved question's order on the OS its footer uses
The order test asked cfg!(windows), but the footer orders by the shell's
OS (os_of), which a test harness need not share with the host.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-04 19:19:28 +05:30
Harrison BoothandFredApps 31f1ad07f4 XLSX: keep a table's query table on save (#2507)
* XLSX: keep a table's query table on save

A table that is the result of a data-connection query now keeps its query table part, its type and connection, and its columns' field ids when saved.

* XLSX: check the query table root and keep its column links on save

A query table part is kept only when its root is queryTable in the SpreadsheetML
namespace. On save each retained queryTableField points at its column's new id,
found through the field id the column keeps, so moved or inserted columns still
read from their own field.

* XLSX: mutate the shared sheet through Arc::make_mut in the query table test

* XLSX: keep query fields through resize and drop orphaned ones on save

A resized table keeps a renamed column's metadata by position before matching
names, and a retained query table part follows its columns' new ids for any
quote style. A field whose column was removed is dropped with the count.

* XLSX: accept a prefixed query table root and whitespace before it

The query table root check reads the local name and the xmlns binding of its
prefix, and skips whitespace-only text before the root.

* Engine: mutate the shared workbook through Arc::make_mut in the resize test

* XLSX: remap query table fields by local name so a prefixed query table keeps its links

* XLSX: remove a duplicated table relationship line after the query table block

* XLSX: fix the table resize test's active sheet index after the main merge

* Import XML parser in query table reader

* Remove unused XML reader imports

* Remove duplicate XLSX writer import

* Initialize query table fields in new tables

* Fill query table fields in test initializers

* Use quick-xml string interfaces for XLSX query fields

* Format query table integration

---------

Co-authored-by: FredApps <[email protected]>
2026-12-04 13:20:54 +01:00
arnav-hiwarkarandClaude Opus 5.5 b3ad9a2a72 test(ui): give the macro question's button lookup a static label
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-04 16:02:27 +05:30
arnav-hiwarkarandClaude Opus 5.5 c2e86e97fd fix(ui): keep the close question's answer when a quit takes it over
Quitting (or the window's close button) while File › Close asks about a workbook reopens the
question as the quit's. The dialog host stores a Cancel for the question it replaces, which the
next pass took as the answer: the prompt state was dropped, and the quit's question then did
nothing when answered. The stale Cancel is now discarded on the takeover.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-04 15:35:34 +05:30
arnav-hiwarkarandClaude Opus 5.5 93a5246ec3 fix(ui): ask about a macro's unsaved steps with the shared dialog
The macro step editor asked its own "Save changes to macro?" with Save, Don't Save and Cancel
drawn right to left. It now shows the shared unsaved-changes question named for the macro
(closing, or quitting while the app quits), in the same order, words and keys as the workbook
question: Save is focused first and answers Enter, Escape cancels, Cmd+D answers Don't Save.
Each asking gets its own area so the question opens again after an answer.

Tests: the editor tests find the question by its shared wording; new tests check the editor's
question order and that Enter saves the draft, and that the workbook question starts on Save
and Enter saves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-04 15:34:37 +05:30
arnav-hiwarkarandClaude Opus 5.5 99d8754611 fix(ui): show the unsaved-changes question only in its own window's pass
A quit that moved on to the next unsaved workbook from inside another window's pass (the
macro editor closing, a Don't Save answer) opened that workbook's question and then drew
it for one frame in the window being drawn, because the check compared against the window
current after the switch. The pass now decides by the window it began drawing.

doc_windows test backend: like eframe, every pass's input lists each open window; without
the child windows listed, the UI runtime dropped a child window's dialog layers and focus
at every frame, so a question in a secondary window could never take its keys. The answer
helper also lets the question show for two frames before the key: the shared dialog takes
Cmd+D only from the pass after one in which it was already the top modal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-04 15:28:49 +05:30
arnav-hiwarkarandClaude Opus 5.5 a2df25c9bd fix(ui): ask about unsaved changes with the shared dialog
Route the engine's saveChanges dialog request to craft_ui::dialog::UnsavedChangesDialog on framework_dialogs with document wording, remove the custom saveChanges dialog and its unused i18n strings, and update UI/doc-window tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-12-04 15:28:49 +05:30
58 changed files with 981 additions and 164 deletions
Generated
+1
View File
@@ -3050,6 +3050,7 @@ dependencies = [
"craft-host",
"craft-keymap",
"craft-print",
"craft-quit",
"craft-theme",
"craft-ui",
"craft-update",
+1
View File
@@ -105,6 +105,7 @@ craft-host = { version = "0.1.0", git = "https://github.com/storytold/craft-libs
craft-keymap = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" }
craft-theme = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" }
craft-print = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["ui"] }
craft-quit = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" }
[workspace.lints.rust]
unsafe_code = "forbid"
+2
View File
@@ -304,6 +304,8 @@ emerge --ask app-office/gridcraft-bin
### FreeBSD
Current prebuilt FreeBSD downloads require FreeBSD 15.1 or later; they are not compatible with FreeBSD 14.x.
| Build | File |
|---|---|
| x86_64 | `gridcraft-<ver>-freebsd-x86_64.tar.gz` |
+4
View File
@@ -810,6 +810,7 @@ fn arrays_do_not_spill_in_tables() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
t.set("C4", "=SEQUENCE(2)");
t.set("E1", "=SEQUENCE(4)");
@@ -839,6 +840,7 @@ fn one_value_array_in_a_table_is_not_a_spill() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
};
let mut t = T::new();
t.wb.sheet_mut(0).unwrap().tables.push(table("B3:C6"));
@@ -1569,6 +1571,7 @@ fn subtotal_skips_filtered_rows() {
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
}],
style: String::new(),
@@ -1580,6 +1583,7 @@ fn subtotal_skips_filtered_rows() {
filter: crit(),
table_type: None,
connection_id: None,
query_table: None,
});
sh.autofilter = Some(AutoFilter { range: gridcraft_core::RangeRef::parse("C1:C7").unwrap(), criteria: crit() });
// Rows 3 and 5 are filtered out; row 9 (outside both filters) is hidden by hand.
+12 -2
View File
@@ -72,9 +72,19 @@ pub(super) fn table_resize(s: &mut Session, p: &Json) -> Result<Json> {
} else {
None
};
// Query field identity follows the surviving physical column, even if its header was renamed.
let query_field_id = c.checked_sub(old.start.col).and_then(|i| old_cols.get(i as usize)).and_then(|x| x.query_field_id);
cols.push(match existing {
Some(x) => TableColumn { name: name.clone(), ..x.clone() },
None => TableColumn { name: name.clone(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None },
Some(x) => TableColumn { name: name.clone(), query_field_id, ..x.clone() },
None => TableColumn {
name: name.clone(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id,
xml: None,
},
});
}
let sheet = cx.sheet_mut(si)?;
+10 -1
View File
@@ -413,7 +413,15 @@ fn forecast_sheet(s: &mut Session, p: &Json) -> Result<Json> {
totals_row: false,
columns: headers
.iter()
.map(|h| TableColumn { name: h.clone(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None })
.map(|h| TableColumn {
name: h.clone(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
})
.collect(),
style: "TableStyleMedium2".into(),
banded_rows: true,
@@ -424,6 +432,7 @@ fn forecast_sheet(s: &mut Session, p: &Json) -> Result<Json> {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
let q = gridcraft_formula::quote_sheet(&sheet_name);
let col_ref = |c: u32| format!("{q}!${0}$2:${0}${end_row}", col_letters(c));
+10 -1
View File
@@ -112,7 +112,15 @@ pub(super) fn insert_table(s: &mut Session, p: &Json) -> Result<Json> {
totals_row: false,
columns: names
.into_iter()
.map(|n| TableColumn { name: n, totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None })
.map(|n| TableColumn {
name: n,
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
})
.collect(),
style,
banded_rows: true,
@@ -123,6 +131,7 @@ pub(super) fn insert_table(s: &mut Session, p: &Json) -> Result<Json> {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
cx.structural = true;
Ok(json!({"table": name, "range": r.a1()}))
+1
View File
@@ -958,6 +958,7 @@ fn shift_table_columns(t: &mut gridcraft_model::Table, at: u32, count: u32, inse
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
};
t.columns.insert((idx + k).min(t.columns.len()), col);
+1
View File
@@ -904,6 +904,7 @@ mod tests {
filter: Vec::new(),
table_type: None,
connection_id: None,
query_table: None,
});
let inputs = vec![("Input".to_string(), place("B2:D2"), true), ("Plain".to_string(), place("B2:D2"), false)];
let env = Env { wb: &wb, active_sheet: 0, inputs: &inputs, output: None, item: None };
+1
View File
@@ -695,6 +695,7 @@ fn grow_right(
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
});
cx.rebuild_deps = true;
+11 -2
View File
@@ -600,8 +600,15 @@ fn migration_preserves_manual_hidden_rows_and_sibling_table_filters_2943() {
{
let wb = std::sync::Arc::make_mut(&mut st.active_mut().unwrap().wb);
let sh = wb.sheet_mut(0).unwrap();
let col =
|name: &str| TableColumn { name: name.into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None };
let col = |name: &str| TableColumn {
name: name.into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
};
sh.tables.push(Table {
id: 1,
name: "LeftTable".into(),
@@ -618,6 +625,7 @@ fn migration_preserves_manual_hidden_rows_and_sibling_table_filters_2943() {
filter: vec![(0, FilterCriterion::Values { values: vec![" ".into()], blanks: false, identities: vec![] })],
table_type: None,
connection_id: None,
query_table: None,
});
sh.tables.push(Table {
id: 2,
@@ -635,6 +643,7 @@ fn migration_preserves_manual_hidden_rows_and_sibling_table_filters_2943() {
filter: vec![(0, FilterCriterion::Values { values: vec!["East".into()], blanks: false, identities: vec![] })],
table_type: None,
connection_id: None,
query_table: None,
});
sh.rows.entry(1).or_default().hidden = true;
sh.rows.entry(2).or_default().hidden = true;
@@ -55,6 +55,31 @@ fn resize_next_to_another_table_still_works() {
assert_eq!(ranges(&s), ["A1:C3", "D1:E2"]);
}
#[test]
fn resize_keeps_a_renamed_column_query_field() {
let mut s = table();
let d = s.doc_mut().unwrap();
let si = d.wb.active_sheet();
std::sync::Arc::make_mut(&mut d.wb).sheet_mut(si).unwrap().tables[0].columns[1].query_field_id = Some(7);
s.execute("range.setValues", json!({"range":"B1", "values":[["Amount"]]})).unwrap();
s.execute("table.resize", json!({"table":"T", "range":"A1:B3"})).unwrap();
let col = &s.doc().unwrap().wb.active().unwrap().tables[0].columns[1];
assert_eq!((col.name.as_str(), col.query_field_id), ("Amount", Some(7)));
}
#[test]
fn resize_preserves_query_fields_only_for_surviving_addresses() {
let mut s = table();
let d = s.doc_mut().unwrap();
let si = d.wb.active_sheet();
let columns = &mut std::sync::Arc::make_mut(&mut d.wb).sheet_mut(si).unwrap().tables[0].columns;
columns[0].query_field_id = Some(3);
columns[1].query_field_id = Some(7);
s.execute("table.resize", json!({"table":"T", "range":"B1:C3"})).unwrap();
let cols = &s.doc().unwrap().wb.active().unwrap().tables[0].columns;
assert_eq!(cols.iter().map(|c| c.query_field_id).collect::<Vec<_>>(), [Some(7), None]);
}
fn sheet(s: &Session) -> &gridcraft_engine::model::Sheet {
s.doc().unwrap().wb.active().unwrap()
}
+8
View File
@@ -60,6 +60,10 @@ pub struct TableColumn {
/// `uniqueName`: the name XML maps know the column by.
#[serde(default)]
pub unique_name: Option<String>,
/// `queryTableFieldId`: the field of the table's query table this column shows. It moves with
/// the column; inserted columns have none.
#[serde(default)]
pub query_field_id: Option<u32>,
/// Binding to an element of an XML map. It moves with the column and goes when the column is
/// deleted; inserted columns are unmapped.
#[serde(default)]
@@ -102,6 +106,10 @@ pub struct Table {
/// The connection (`xl/connections.xml`) an XML table is bound through.
#[serde(default)]
pub connection_id: Option<u32>,
/// The XML of the table's query table part (`xl/queryTables/…`), kept as read so the table
/// stays attached to its data connection. Never refreshed.
#[serde(default)]
pub query_table: Option<String>,
}
impl Table {
+1
View File
@@ -16,6 +16,7 @@ craft-behavior = { workspace = true }
craft-host = { workspace = true }
craft-keymap = { workspace = true }
craft-print = { workspace = true }
craft-quit = { workspace = true }
craft-theme = { workspace = true }
craft-window = { workspace = true }
gridcraft-engine = { workspace = true }
+21 -2
View File
@@ -93,6 +93,7 @@ impl SheetApp {
#[cfg(not(target_arch = "wasm32"))]
updates_rt: Default::default(),
framework_dialogs: Default::default(),
unsaved_prompt: None,
framework_host: crate::framework::host(),
}
}
@@ -205,6 +206,9 @@ impl SheetApp {
let t0 = now_ms();
// A script may have switched windows since the last frame.
self.follow_active_window();
// The window this pass draws: a command run in it may switch to another window, which draws
// in its own pass.
let drawn = self.ui_window();
// This window's key tip request that waited for this frame (its tab or ribbon was just
// shown); any other window's request was dropped before it.
self.ui.keytip_invoke = self.ui.keytip_invoke_next.take();
@@ -267,10 +271,13 @@ impl SheetApp {
widgets::toast(self, &ctx);
// Last, so its resize cursors win over the widgets under the window edges.
ribbon::window_frame(self, &ctx);
// The update flow and the framework dialogs run once per frame, in the root window.
// The update flow runs once per frame, in the root window; the framework dialogs too, unless
// the unsaved-changes question asks about a workbook in another window: they show there.
#[cfg(not(target_arch = "wasm32"))]
if ctx.viewport_id() == egui::ViewportId::ROOT {
#[cfg(not(target_arch = "wasm32"))]
updates_ui::show(self, &ctx);
}
if self.framework_dialogs_here(&ctx, drawn) {
self.run_framework_dialogs(ui);
}
self.flush_viewport_commands(&ctx);
@@ -302,6 +309,18 @@ impl SheetApp {
}
}
/// Whether a modal question is up and owns the keyboard: a GridCraft dialog or the shared
/// unsaved-changes question.
pub fn modal_open(&self) -> bool {
self.dialog.is_some() || self.unsaved_prompt.is_some()
}
/// The name of the open dialog, for automation: a GridCraft dialog's, or `saveChanges` while
/// the shared unsaved-changes question is up.
pub fn open_dialog_name(&self) -> Option<&str> {
self.dialog.as_ref().map(|d| d.name()).or_else(|| self.unsaved_prompt.as_ref().map(|_| "saveChanges"))
}
/// Current selection's top-left cell text as A1 (for the Name Box).
pub fn name_box_text(&self) -> String {
let Some(d) = self.session.active() else { return String::new() };
+2 -1
View File
@@ -335,7 +335,7 @@ impl SheetApp {
"ui.dialog" => {
let name = p.get("name").and_then(Json::as_str).unwrap_or("");
self.open_dialog(name, p.clone());
Ok(json!({"dialog": self.dialog.as_ref().map(|d| d.name())}))
Ok(json!({"dialog": self.open_dialog_name()}))
}
"ui.selectionMode" => {
// `{"mode": "extend"}` (F8), `"add"` (Shift+F8) or `"off"`; `{}` reports the mode.
@@ -481,6 +481,7 @@ impl SheetApp {
}
// The notice AutoSave holds back with: Save asks what the notice says.
"saveLoss" => self.run_or_alert("file.save", json!({})),
"saveChanges" => self.open_unsaved_changes(&params),
// File › Options (`file.options`) and the File tab itself open the Backstage view.
"options" => self.open_backstage(backstage::Page::Options),
"backstage" => {
+1 -1
View File
@@ -4,7 +4,7 @@ impl SheetApp {
pub(super) fn ribbon_keys(&mut self, ctx: &egui::Context) {
let before = self.keytips.prefix().map(str::to_string);
let enabled = self.editor.is_none()
&& self.dialog.is_none()
&& !self.modal_open()
&& self.message.is_none()
&& self.name_box.is_none()
&& !ctx.text_edit_focused()
+82 -7
View File
@@ -1,7 +1,10 @@
use craft_quit::{CloseAnswer, CloseScope};
use craft_ui::dialog::{DialogResult, UnsavedAnswer, UnsavedChangesDialog};
use craft_ui::shell::embed::CloseDecision;
use gridcraft_engine::cmd::file::{SaveLosses, save_losses, xlsx_save_losses};
use super::{AfterSave, Json, PendingSave, SaveAnswer, SaveLossAnswer, SaveRequest, SheetApp, json};
use crate::state::UnsavedPrompt;
impl SheetApp {
/// The root window was asked to close (the close button, Alt+F4, the OS quitting the app): whether it closes
@@ -31,12 +34,11 @@ impl SheetApp {
if !self.session.documents().iter().any(|d| d.is_dirty()) {
return CloseDecision::Close;
}
match self.dialog.as_mut() {
if self.framework_dialogs.is_open::<UnsavedChangesDialog>() {
// Already asking about a workbook (File › Close): answering it now goes on to quit.
Some(d) if d.name() == "saveChanges" => {
d.values.insert("quit".into(), json!(true));
}
_ => self.continue_quit(ctx),
self.promote_unsaved_to_quit();
} else {
self.continue_quit(ctx);
}
CloseDecision::Hold
}
@@ -233,13 +235,86 @@ impl SheetApp {
crate::macro_editor::request_close(self, true);
return;
}
if let Some(d) = self.dialog.as_mut().filter(|d| d.name() == "saveChanges") {
if self.framework_dialogs.is_open::<UnsavedChangesDialog>() {
// Already asking about a workbook (File › Close): answering it goes on to quit.
d.values.insert("quit".into(), json!(true));
self.promote_unsaved_to_quit();
return;
}
self.continue_quit(ctx);
}
/// Opens the shared unsaved-changes dialog on `framework_dialogs` for the active workbook.
pub(crate) fn open_unsaved_changes(&mut self, params: &Json) {
if self.dialog.as_ref().is_some_and(|d| d.name == "macroEditor") {
self.message = Some((
"Macro".into(),
"Close the macro step editor first: it keeps its window until it closes itself, so its steps and debug run are not lost.".into(),
));
return;
}
if let Some(mut old) = self.dialog.take() {
let _ = old.end_pick(self);
}
let Some(doc) = self.session.active().map(|d| d.uid) else { return };
let title = params
.get("title")
.and_then(Json::as_str)
.map(str::to_owned)
.or_else(|| self.session.active().map(|d| d.display_title()))
.unwrap_or_else(|| "this workbook".into());
let quitting = params.get("quit").and_then(Json::as_bool) == Some(true);
let scope = if quitting { CloseScope::Quit } else { CloseScope::Close };
self.unsaved_prompt = Some(UnsavedPrompt { doc, window: self.ui_window(), quitting });
self.framework_dialogs.open(UnsavedChangesDialog::new(scope, title).document_wording(true));
// A replaced question leaves a Cancel result; it is not the new question's answer.
let _ = self.framework_dialogs.take::<UnsavedChangesDialog>();
}
fn promote_unsaved_to_quit(&mut self) {
if let Some(prompt) = self.unsaved_prompt.as_mut()
&& !prompt.quitting
{
prompt.quitting = true;
let title =
self.session.documents().iter().find(|d| d.uid == prompt.doc).map(|d| d.display_title()).unwrap_or_else(|| "this workbook".into());
self.framework_dialogs.open(UnsavedChangesDialog::new(CloseScope::Quit, title).document_wording(true));
// The question it replaced left a Cancel as its result; it was not answered, and the
// quit's question asks on.
let _ = self.framework_dialogs.take::<UnsavedChangesDialog>();
}
}
/// Reads the answer from an open [`UnsavedChangesDialog`] and continues closing or quitting.
pub(crate) fn take_unsaved_changes_dialog(&mut self, ctx: &egui::Context) {
let Some(result) = self.framework_dialogs.take::<UnsavedChangesDialog>() else {
return;
};
let Some(prompt) = self.unsaved_prompt.take() else {
return;
};
let answer = match result {
DialogResult::Ok(UnsavedAnswer { answer: CloseAnswer::DontSave, .. }) => SaveAnswer::DontSave,
DialogResult::Ok(UnsavedAnswer { answer: CloseAnswer::Save, .. }) => SaveAnswer::Save,
DialogResult::Ok(UnsavedAnswer { answer: CloseAnswer::Cancel, .. }) | DialogResult::Cancel | _ => SaveAnswer::Cancel,
};
if answer == SaveAnswer::Cancel {
return;
}
if let Some(w) = prompt.window.filter(|w| self.session.window(*w).is_some())
&& self.ui_window() != Some(w)
{
self.enter_window(w);
}
if self.session.active().map(|d| d.uid) != Some(prompt.doc) {
return;
}
if !self.answer_save_changes(answer, prompt.quitting, ctx) {
let title = self.session.active().map(|d| d.display_title()).unwrap_or_default();
let scope = if prompt.quitting { CloseScope::Quit } else { CloseScope::Close };
self.unsaved_prompt = Some(prompt);
self.framework_dialogs.open(UnsavedChangesDialog::new(scope, title).document_wording(true));
}
}
}
#[cfg(test)]
+1 -1
View File
@@ -258,7 +258,7 @@ pub fn show(app: &mut SheetApp, ui: &mut Ui) {
});
});
bs.text_edit_focused = ctx.text_edit_focused();
if !typing && app.dialog.is_none() && app.message.is_none() && !egui::Popup::is_any_open(&ctx) && crate::framework::consume_escape(&ctx) {
if !typing && !app.modal_open() && app.message.is_none() && !egui::Popup::is_any_open(&ctx) && crate::framework::consume_escape(&ctx) {
out.close = true;
}
if let Some(page) = out.page {
+3 -2
View File
@@ -147,7 +147,8 @@ pub fn inspect(app: &SheetApp, ctx: &egui::Context) -> Json {
"grid": app.grid.cells_rect.map(|c| json!([c.left(), c.top(), c.width(), c.height()])),
"scroll": [v.scroll.x, v.scroll.y],
"editor": app.editor.as_ref().map(|e| editor_json(app, e)),
"dialog": app.dialog.as_ref().map(|d| json!({"name": d.name, "title": d.title, "values": d.values, "tab": d.tab})),
"dialog": app.dialog.as_ref().map(|d| json!({"name": d.name, "title": d.title, "values": d.values, "tab": d.tab}))
.or_else(|| app.unsaved_prompt.as_ref().map(|p| json!({"name": "saveChanges", "values": {"quit": p.quitting}}))),
"backstage": app.backstage.as_ref().map(|b| b.page.id()),
"message": app.message.as_ref().map(|(t, m)| json!({"title": t, "text": m})),
"selectedObject": app.selected_object,
@@ -339,7 +340,7 @@ pub fn handle(app: &mut SheetApp, ctx: &egui::Context, method: &str, p: &Json) -
}
"ui.dialog" => {
app.open_dialog(s("name").unwrap_or(""), p.clone());
ok(json!({"dialog": app.dialog.as_ref().map(|d| d.name.clone())}))
ok(json!({"dialog": app.open_dialog_name()}))
}
"ui.dialog.set" => match app.dialog.as_mut() {
Some(d) => {
-1
View File
@@ -1166,7 +1166,6 @@ impl Dialog {
"formatControl" => return crate::control_ui::open_format(app, &params),
"controlQuestion" => return crate::control_ui::open_question(&params),
"saveCopy" => Dialog::custom("saveCopy", "Save a Copy", json!({"format": p("format")})),
"saveChanges" => Dialog::custom("saveChanges", "Save Changes?", json!({"title": p("title"), "quit": p("quit")})),
"start" => Dialog::custom("start", "GridCraft", json!({})),
"comments" => {
app.grid.pane = None;
-13
View File
@@ -374,19 +374,6 @@ pub fn show(app: &mut SheetApp, ctx: &egui::Context) {
}
}
}
"saveChanges" => {
ui.label(format!("Do you want to save the changes you made to {}?", d.values.get("title").and_then(Json::as_str).unwrap_or("this workbook")));
let quitting = d.values.get("quit").and_then(Json::as_bool) == Some(true);
ui.horizontal(|ui| {
for (label, answer) in
[("Don't Save", crate::SaveAnswer::DontSave), ("Cancel", crate::SaveAnswer::Cancel), ("Save", crate::SaveAnswer::Save)]
{
if ui.button(label).clicked() && app.answer_save_changes(answer, quitting, ui.ctx()) {
open = false;
}
}
});
}
"saveLoss" => {
let lang = app.ui.language;
let pending = d.pending_save();
+3 -3
View File
@@ -529,7 +529,7 @@ pub fn editor_widget(app: &mut SheetApp, ui: &mut egui::Ui, id: egui::Id, font:
let chars_before = ed.text.chars().count();
// A dialog opened over the edit (Paste Name) takes the keyboard until it closes, and the
// editor takes it back afterwards.
let dialog_open = app.dialog.is_some();
let dialog_open = app.modal_open();
if dialog_open && mine {
ed.request_focus = true;
ed.keep_selection = true;
@@ -671,7 +671,7 @@ fn editor_shortcuts(
) -> EditorKeyOutcome {
let mut outcome = EditorKeyOutcome { action: None, arrow: false, cancel: false, to_python: false };
// A message or dialog owns Enter and Escape until it closes.
if !has_focus || !mine || app.message.is_some() || app.dialog.is_some() {
if !has_focus || !mine || app.message.is_some() || app.modal_open() {
return outcome;
}
// Ctrl+Alt+Shift+P turns the edit into Python code.
@@ -864,7 +864,7 @@ fn python_editor(app: &mut SheetApp, ui: &mut egui::Ui, id: egui::Id, width: f32
let Some(mut ed) = app.editor.take() else { return EditorInfo::default() };
// A message box (the code was refused) or a dialog over the edit has the keyboard; the
// editor takes it back when it closes.
let blocked = app.message.is_some() || app.dialog.is_some();
let blocked = app.message.is_some() || app.modal_open();
let mut caret = None;
if blocked {
ed.request_focus = true;
+13
View File
@@ -112,9 +112,22 @@ impl SheetApp {
embed::logic(ctx, || self.close_decision(ctx));
}
/// Whether this pass draws [`SheetApp::framework_dialogs`]: the pass of the window the unsaved-changes
/// question asks about (the window that keeps it, as a GridCraft dialog stays in its window), else the root's.
/// `drawn` is the window the pass began drawing: a question a command in it opened for another window (a quit
/// moving on to the next unsaved workbook) shows in that window's own pass, not for a frame in this one.
pub(crate) fn framework_dialogs_here(&self, ctx: &egui::Context, drawn: Option<u64>) -> bool {
let shown = |w: &u64| self.session.window(*w).is_some_and(|w| !w.hidden);
match self.unsaved_prompt.as_ref().and_then(|p| p.window).filter(shown) {
Some(w) => drawn == Some(w),
None => ctx.viewport_id() == egui::ViewportId::ROOT,
}
}
/// The framework dialogs open on [`SheetApp::framework_dialogs`], once per frame after GridCraft's own UI.
pub(crate) fn run_framework_dialogs(&mut self, ui: &mut egui::Ui) {
self.framework_dialogs.run(ui);
self.take_unsaved_changes_dialog(ui.ctx());
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ fn keyboard_elsewhere(app: &SheetApp, ctx: &egui::Context, resp: &egui::Response
// So do the fill menu (its Esc closes it, not the copy) and the right-drag that opens it (an
// arrow key would move the selection the menu fills from), and a macro's question.
editing
|| app.dialog.is_some()
|| app.modal_open()
|| other_focus
|| app.message.is_some()
|| app.grid.filter_menu.is_some()
+2 -2
View File
@@ -328,7 +328,7 @@ pub(super) fn fill_options_tag(app: &mut SheetApp, ui: &mut egui::Ui, geo: &Geo,
app.grid.fill_tag = None;
return;
}
if app.editor.is_some() || app.dialog.is_some() || app.grid.drag != Drag::None {
if app.editor.is_some() || app.modal_open() || app.grid.drag != Drag::None {
return;
}
let size = vec2(18.0, 18.0);
@@ -471,7 +471,7 @@ pub(super) fn object_menu(app: &mut SheetApp, ui: &mut egui::Ui) {
/// The warning button beside an active cell holding a number stored as text, as in Excel: its
/// menu names the problem and offers Convert to Number for the selection (#1994).
pub(super) fn error_check_tag(app: &mut SheetApp, ui: &mut egui::Ui, geo: &Geo, sh: &Sheet) {
if app.editor.is_some() || app.dialog.is_some() || sh.show_formulas || app.grid.drag != Drag::None {
if app.editor.is_some() || app.modal_open() || sh.show_formulas || app.grid.drag != Drag::None {
return;
}
let Some(active) = app.session.active().map(|d| d.selection.active) else { return };
+1
View File
@@ -171,6 +171,7 @@ fn filter_menu_uses_the_table_whose_header_was_clicked() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
};
let mut sh = Sheet::new("S");
sh.tables.push(table(1, 0, 2));
-3
View File
@@ -574,7 +574,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Zoom Out" => "Σμίκρυνση",
"Dismiss" => "Κλείσιμο",
"OK" => "Εντάξει",
"Don't Save" => "Χωρίς αποθήκευση",
"Open…" => "Άνοιγμα…",
"Show password" => "Εμφάνιση κωδικού πρόσβασης",
"Start a new workbook" => "Δημιουργία νέου βιβλίου εργασίας",
@@ -583,7 +582,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Gradebook" => "Βαθμολόγιο",
"this workbook" => "αυτό το βιβλίο εργασίας",
"This workbook" => "Αυτό το βιβλίο εργασίας",
"Do you want to save the changes you made to {title}?" => "Θέλετε να αποθηκεύσετε τις αλλαγές που κάνατε στο {title};",
"Save a copy as .{format}" => "Αποθήκευση αντιγράφου ως .{format}",
"Select a chart first." => "Επιλέξτε πρώτα ένα γράφημα.",
"Row Height" => "Ύψος γραμμής",
@@ -624,7 +622,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Place Picture over Cells" => "Τοποθέτηση εικόνας πάνω από κελιά",
"Pick From List" => "Επιλογή από λίστα",
"Save a Copy" => "Αποθήκευση αντιγράφου",
"Save Changes?" => "Αποθήκευση αλλαγών;",
"Shift cells right" => "Μετατόπιση κελιών προς τα δεξιά",
"Shift cells down" => "Μετατόπιση κελιών προς τα κάτω",
"Shift cells left" => "Μετατόπιση κελιών προς τα αριστερά",
-3
View File
@@ -445,7 +445,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Calculation settings are saved with the workbook." => "Le impostazioni di calcolo vengono salvate con la cartella di lavoro.",
"OK" => "OK",
"Cancel" => "Annulla",
"Don't Save" => "Non salvare",
"Open…" => "Apri…",
"Show password" => "Mostra password",
"Start a new workbook" => "Crea una nuova cartella di lavoro",
@@ -454,7 +453,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Gradebook" => "Registro dei voti",
"this workbook" => "questa cartella di lavoro",
"This workbook" => "Questa cartella di lavoro",
"Do you want to save the changes you made to {title}?" => "Vuoi salvare le modifiche apportate a {title}?",
"Save a copy as .{format}" => "Salva una copia come .{format}",
"Select a chart first." => "Seleziona prima un grafico.",
"Text Box" => "Casella di testo",
@@ -505,7 +503,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Place Picture over Cells" => "Inserisci immagine sopra le celle",
"Pick From List" => "Scegli dall'elenco",
"Save a Copy" => "Salva una copia",
"Save Changes?" => "Salvare le modifiche?",
"Shift cells right" => "Sposta celle a destra",
"Shift cells down" => "Sposta celle in basso",
"Shift cells left" => "Sposta celle a sinistra",
-3
View File
@@ -462,7 +462,6 @@ pub(super) const CORE: &[(&str, &str)] = &[
pub(super) const DIALOGS: &[(&str, &str)] = &[
("OK", "OK"),
("Cancel", "キャンセル"),
("Don't Save", "保存しない"),
("Open…", "開く…"),
("Show password", "パスワードの表示"),
("Start a new workbook", "新しいブックの作成"),
@@ -471,7 +470,6 @@ pub(super) const DIALOGS: &[(&str, &str)] = &[
("Gradebook", "成績表"),
("this workbook", "このブック"),
("This workbook", "このブック"),
("Do you want to save the changes you made to {title}?", "{title} への変更を保存しますか?"),
("Save a copy as .{format}", ".{format} としてコピーを保存"),
("Select a chart first.", "先にグラフを選択してください。"),
("Text Box", "テキスト ボックス"),
@@ -522,7 +520,6 @@ pub(super) const DIALOGS: &[(&str, &str)] = &[
("Place Picture over Cells", "セルの上に画像を配置"),
("Pick From List", "リストから選択"),
("Save a Copy", "コピーを保存"),
("Save Changes?", "変更を保存しますか?"),
("Shift cells right", "セルを右に移動"),
("Shift cells down", "セルを下に移動"),
("Shift cells left", "セルを左に移動"),
-3
View File
@@ -436,7 +436,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Calculation settings are saved with the workbook." => "Ustawienia obliczeń są zapisywane razem ze skoroszytem.",
"OK" => "OK",
"Cancel" => "Anuluj",
"Don't Save" => "Nie zapisuj",
"Open…" => "Otwórz…",
"Show password" => "Pokaż hasło",
"Start a new workbook" => "Utwórz nowy skoroszyt",
@@ -445,7 +444,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Gradebook" => "Dziennik ocen",
"this workbook" => "ten skoroszyt",
"This workbook" => "Ten skoroszyt",
"Do you want to save the changes you made to {title}?" => "Czy chcesz zapisać zmiany wprowadzone w pliku {title}?",
"Save a copy as .{format}" => "Zapisz kopię jako .{format}",
"Select a chart first." => "Najpierw zaznacz wykres.",
"Text Box" => "Pole tekstowe",
@@ -496,7 +494,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Place Picture over Cells" => "Umieść obraz na komórkach",
"Pick From List" => "Wybierz z listy",
"Save a Copy" => "Zapisz kopię",
"Save Changes?" => "Zapisać zmiany?",
"Shift cells right" => "Przesuń komórki w prawo",
"Shift cells down" => "Przesuń komórki w dół",
"Shift cells left" => "Przesuń komórki w lewo",
-3
View File
@@ -464,7 +464,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Calculation settings are saved with the workbook." => "As configurações de cálculo são salvas com a pasta de trabalho.",
"OK" => "OK",
"Cancel" => "Cancelar",
"Don't Save" => "Não Salvar",
"Open…" => "Abrir…",
"Show password" => "Mostrar senha",
"Start a new workbook" => "Criar uma pasta de trabalho",
@@ -473,7 +472,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Gradebook" => "Boletim de Notas",
"this workbook" => "esta pasta de trabalho",
"This workbook" => "Esta pasta de trabalho",
"Do you want to save the changes you made to {title}?" => "Deseja salvar as alterações feitas em {title}?",
"Save a copy as .{format}" => "Salvar uma cópia como .{format}",
"Select a chart first." => "Selecione um gráfico primeiro.",
"Text Box" => "Caixa de Texto",
@@ -530,7 +528,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Place Picture over Cells" => "Colocar Imagem sobre as Células",
"Pick From List" => "Escolher na Lista",
"Save a Copy" => "Salvar uma Cópia",
"Save Changes?" => "Salvar Alterações?",
"Shift cells right" => "Deslocar células para a direita",
"Shift cells down" => "Deslocar células para baixo",
"Shift cells left" => "Deslocar células para a esquerda",
-3
View File
@@ -442,7 +442,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Calculation settings are saved with the workbook." => "Setările de calcul se salvează împreună cu registrul.",
"OK" => "OK",
"Cancel" => "Anulare",
"Don't Save" => "Nu salva",
"Open…" => "Deschidere…",
"Show password" => "Afișare parolă",
"Start a new workbook" => "Începeți un registru nou",
@@ -451,7 +450,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Gradebook" => "Catalog de note",
"this workbook" => "acest registru",
"This workbook" => "Acest registru",
"Do you want to save the changes you made to {title}?" => "Doriți să salvați modificările făcute în {title}?",
"Save a copy as .{format}" => "Salvare copie ca .{format}",
"Select a chart first." => "Selectați mai întâi o diagramă.",
"Text Box" => "Casetă de text",
@@ -502,7 +500,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Place Picture over Cells" => "Plasare imagine peste celule",
"Pick From List" => "Alegere din listă",
"Save a Copy" => "Salvare copie",
"Save Changes?" => "Salvați modificările?",
"Shift cells right" => "Deplasare celule la dreapta",
"Shift cells down" => "Deplasare celule în jos",
"Shift cells left" => "Deplasare celule la stânga",
-3
View File
@@ -599,8 +599,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Display:" => "Отображать:",
"Distributed" => "Распределённый",
"Divide" => "Разделить",
"Do you want to save the changes you made to {title}?" => "Сохранить изменения в «{title}»?",
"Don't Save" => "Не сохранять",
"Double" => "Двойное",
"Double Accounting" => "Двойное бухгалтерское",
"Doughnut" => "Кольцевая",
@@ -846,7 +844,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Rows" => "Строки",
"Sample" => "Выборка",
"Save (⌘S)" => "Сохранить (⌘S)",
"Save Changes?" => "Сохранить изменения?",
"Save a Copy" => "Сохранить копию",
"Save a copy as .{format}" => "Сохранить копию как .{format}",
"Scatter" => "Точечная",
-3
View File
@@ -440,7 +440,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Calculation settings are saved with the workbook." => "Параметри обчислень зберігаються разом із книгою.",
"OK" => "OK",
"Cancel" => "Cancel",
"Don't Save" => "Don't Save",
"Open…" => "Open…",
"Show password" => "Show password",
"Start a new workbook" => "Start a new workbook",
@@ -449,7 +448,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Gradebook" => "Gradebook",
"this workbook" => "this workbook",
"This workbook" => "This workbook",
"Do you want to save the changes you made to {title}?" => "Do you want to save the changes you made to {title}?",
"Save a copy as .{format}" => "Save a copy as .{format}",
"Select a chart first." => "Спочатку виділіть діаграму.",
"Text Box" => "Напис",
@@ -500,7 +498,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Place Picture over Cells" => "Place Picture over Cells",
"Pick From List" => "Pick From List",
"Save a Copy" => "Save a Copy",
"Save Changes?" => "Save Changes?",
"Shift cells right" => "Shift cells right",
"Shift cells down" => "Shift cells down",
"Shift cells left" => "Shift cells left",
-3
View File
@@ -450,7 +450,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
// Dialogs, menus, context menus and tooltips.
"OK" => "OK",
"Cancel" => "Hủy",
"Don't Save" => "Không lưu",
"Open…" => "Mở…",
"Show password" => "Hiện mật khẩu",
"Start a new workbook" => "Bắt đầu sổ làm việc mới",
@@ -459,7 +458,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Gradebook" => "Sổ điểm",
"this workbook" => "sổ làm việc này",
"This workbook" => "Sổ làm việc này",
"Do you want to save the changes you made to {title}?" => "Bạn có muốn lưu các thay đổi đã thực hiện cho {title} không?",
"Save a copy as .{format}" => "Lưu bản sao dưới dạng .{format}",
"Select a chart first." => "Hãy chọn một biểu đồ trước.",
"Text Box" => "Hộp văn bản",
@@ -510,7 +508,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Place Picture over Cells" => "Đặt ảnh đè lên các ô",
"Pick From List" => "Chọn từ danh sách",
"Save a Copy" => "Lưu bản sao",
"Save Changes?" => "Lưu thay đổi?",
"Shift cells right" => "Dịch các ô sang phải",
"Shift cells down" => "Dịch các ô xuống dưới",
"Shift cells left" => "Dịch các ô sang trái",
+4 -2
View File
@@ -362,9 +362,11 @@ pub struct SheetApp {
/// The update check, the startup prompt and a running self-update (desktop only).
#[cfg(not(target_arch = "wasm32"))]
updates_rt: updates_ui::Runtime,
/// The framework dialogs GridCraft keeps as values (the update dialogs), run once per frame
/// after GridCraft's own UI in the root window's pass.
/// The framework dialogs GridCraft keeps as values (the update dialogs and the unsaved-changes
/// prompt), run once per frame after GridCraft's own UI in the root window's pass.
pub framework_dialogs: craft_ui::dialog::DialogHost,
/// Which workbook and window the open `UnsavedChangesDialog` is asking about.
pub unsaved_prompt: Option<state::UnsavedPrompt>,
/// Who GridCraft is to the framework's dialogs.
framework_host: std::sync::Arc<craft_host::Host>,
}
+18 -21
View File
@@ -18,6 +18,8 @@
use std::collections::BTreeMap;
use craft_quit::{CloseAnswer, CloseScope};
use craft_ui::dialog::UnsavedChangesDialog;
use egui::{Color32, Id, Rect, Sense, Stroke, StrokeKind, Ui, pos2, vec2};
use gridcraft_engine::core::RangeRef;
use gridcraft_engine::macros::policy::{Policy, macro_policy};
@@ -1100,7 +1102,7 @@ fn ref_edit(app: &SheetApp, ui: &mut Ui, d: &mut Dialog, refs: &mut RefPick, key
d.values.insert(key.into(), json!(s));
}
/// Keep changes? (stopping a debugged run) and Save changes? (closing with unsaved edits).
/// Keep changes? (stopping a debugged run) and the unsaved-changes question (closing with unsaved edits).
fn prompts(app: &mut SheetApp, ctx: &egui::Context, ed: &mut Editor, open: &mut bool) {
if ed.ask_stop {
let mut answer: Option<Option<bool>> = None;
@@ -1141,25 +1143,20 @@ fn prompts(app: &mut SheetApp, ctx: &egui::Context, ed: &mut Editor, open: &mut
return;
}
if ed.ask_close {
let mut answer: Option<Option<bool>> = None;
egui::Modal::new(Id::unique("gridcraft.macro_editor.close")).show(ctx, |ui| {
ui.set_width(360.0);
ui.label(egui::RichText::new(format!("Save changes to macro “{}”?", ed.draft.name)).strong());
ui.add_space(8.0);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if ui.button("Cancel").clicked() || crate::framework::escape_pressed(ui.ctx()) {
answer = Some(None);
}
if ui.button("Don't Save").clicked() {
answer = Some(Some(false));
}
if ui.button("Save").clicked() || ui.input(|i| i.key_pressed(egui::Key::Enter)) {
answer = Some(Some(true));
}
});
});
// The shared unsaved-changes question, named for the macro. Each asking gets its own area,
// so the question's own open state starts open every time it is asked.
let scope = if ed.quit { CloseScope::Quit } else { CloseScope::Close };
let asked = Id::unique("gridcraft.macro_editor.close");
let opening = ctx.data(|d| d.get_temp::<u64>(asked)).unwrap_or_default();
let shown = egui::Area::new(asked.with(opening))
.order(egui::Order::Foreground)
.show(ctx, |ui| UnsavedChangesDialog::new(scope, ed.draft.name.clone()).document_wording(true).show(ui));
let answer = shown.inner.answer.map(|a| a.answer);
if answer.is_some() {
ctx.data_mut(|d| d.insert_temp(asked, opening + 1));
}
match answer {
Some(Some(true)) => {
Some(CloseAnswer::Save) => {
ed.ask_close = false;
if save(app, ed) {
*open = false;
@@ -1170,11 +1167,11 @@ fn prompts(app: &mut SheetApp, ctx: &egui::Context, ed: &mut Editor, open: &mut
ed.quit = false;
}
}
Some(Some(false)) => {
Some(CloseAnswer::DontSave) => {
ed.ask_close = false;
*open = false;
}
Some(None) => {
Some(CloseAnswer::Cancel) => {
ed.ask_close = false;
ed.quit = false;
ed.then_close = None;
+1 -1
View File
@@ -167,7 +167,7 @@ pub fn is_hidden(app: &SheetApp, geo: &Geo, sh: &Sheet) -> bool {
d.selection.ranges.len() > 1
|| d.selection.current().is_single()
|| app.editor.is_some()
|| app.dialog.is_some()
|| app.modal_open()
|| app.text_box_editor.is_some()
|| app.grid.context_menu.is_some()
|| geo.paper.is_some()
+9
View File
@@ -19,6 +19,15 @@ pub enum SaveAnswer {
Cancel,
}
/// Which workbook and window an open [`craft_ui::dialog::UnsavedChangesDialog`] is asking about,
/// and whether answering it goes on to quit.
#[derive(Clone, Debug)]
pub struct UnsavedPrompt {
pub doc: u64,
pub window: Option<u64>,
pub quitting: bool,
}
/// How a save held back for an answer goes on.
#[derive(Clone, Debug, PartialEq)]
pub(crate) enum SaveRequest {
+66 -26
View File
@@ -7,6 +7,7 @@
use std::cell::RefCell;
use craft_ui::dialog::UnsavedChangesDialog;
use egui::{Context, RawInput, ViewportCommand, ViewportEvent, ViewportId, ViewportInfo};
use gridcraft_engine::{Session, core::CellRef, core::Value};
use gridcraft_ui_egui::doc_windows::DocWindows;
@@ -18,8 +19,8 @@ thread_local! {
static INFOS: RefCell<egui::ViewportIdMap<ViewportInfo>> = RefCell::new(egui::ViewportIdMap::default());
/// The viewport commands the app sent this frame.
static SENT: RefCell<Vec<(ViewportId, ViewportCommand)>> = const { RefCell::new(Vec::new()) };
/// Input events for the root window's next frame (a key pressed in it).
static EVENTS: RefCell<Vec<egui::Event>> = const { RefCell::new(Vec::new()) };
/// Each viewport's input events for its next pass (a key pressed in that window).
static EVENTS: RefCell<egui::ViewportIdMap<Vec<egui::Event>>> = RefCell::new(egui::ViewportIdMap::default());
}
fn record(mut out: egui::FullOutput) {
@@ -32,6 +33,17 @@ fn record(mut out: egui::FullOutput) {
});
}
/// The events waiting for viewport `id`'s next pass.
fn take_events(id: ViewportId) -> Vec<egui::Event> {
EVENTS.with(|e| e.borrow_mut().remove(&id).unwrap_or_default())
}
/// Presses `key` with `modifiers` in viewport `id`'s next pass.
fn press(id: ViewportId, key: egui::Key, modifiers: egui::Modifiers) {
let event = egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers };
EVENTS.with(|e| e.borrow_mut().entry(id).or_default().push(event));
}
struct Desk {
ctx: Context,
app: SheetApp,
@@ -49,6 +61,7 @@ impl Desk {
let mut input = RawInput { viewport_id: id, ..RawInput::default() };
input.viewports = INFOS.with(|i| i.borrow().clone());
input.viewports.entry(id).or_default().parent = Some(viewport.ids.parent);
input.events = take_events(id);
let mut cb = viewport.viewport_ui_cb;
record(ctx.run_ui(input, |ui| cb(ui)));
});
@@ -68,7 +81,7 @@ impl Desk {
let mut input = RawInput { viewport_id: ViewportId::ROOT, ..RawInput::default() };
input.viewports = INFOS.with(|i| i.borrow().clone());
input.viewports.entry(ViewportId::ROOT).or_default();
input.events = EVENTS.with(|e| std::mem::take(&mut *e.borrow_mut()));
input.events = take_events(ViewportId::ROOT);
let Desk { ctx, app, windows } = self;
let mut act = Some(act);
let out = ctx.clone().run_ui(input, |ui| {
@@ -81,6 +94,15 @@ impl Desk {
app.close_path(&ctx);
windows.show(app, ui);
});
// As eframe's, every pass's input lists each open window: the UI runtime keeps a window's state (the layers
// its dialogs showed, its focus) only while the root's input lists that window.
INFOS.with(|i| {
let mut i = i.borrow_mut();
i.retain(|id, _| out.viewport_output.contains_key(id));
for id in out.viewport_output.keys() {
i.entry(*id).or_default();
}
});
record(out);
// Close buttons are one-shot events.
INFOS.with(|i| i.borrow_mut().values_mut().for_each(|v| v.events.clear()));
@@ -104,15 +126,24 @@ impl Desk {
sent
}
/// Answers the Save Changes question showing in the active window, as its button does.
/// Answers the Save Changes question with its key (Enter Save, Escape Cancel, Cmd+D Don't
/// Save), pressed in the window of the workbook it asks about: the question shows there.
/// The person reads the question first: the shared dialog takes its Cmd+D from the pass after
/// one in which it already showed on top, so a press in the frame right after it opened is
/// not an answer.
fn answer(&mut self, answer: SaveAnswer) -> Vec<(ViewportId, ViewportCommand)> {
let mut sent = self.frame_with(|app, ctx| {
let d = app.dialog.take().unwrap_or_else(|| panic!("no question is showing"));
assert_eq!(d.name(), "saveChanges");
let quitting = d.values.get("quit").and_then(serde_json::Value::as_bool) == Some(true);
app.answer_save_changes(answer, quitting, ctx);
});
sent.extend(self.frames(2));
assert!(self.app.framework_dialogs.is_open::<UnsavedChangesDialog>(), "no question is showing");
let w = self.app.unsaved_prompt.as_ref().and_then(|p| p.window).expect("the question names its window");
let mut sent = self.frames(2);
assert!(self.app.unsaved_prompt.as_ref().is_some_and(|p| p.window == Some(w)), "the question in window {w} waits for its answer");
let (key, modifiers) = match answer {
SaveAnswer::Save => (egui::Key::Enter, egui::Modifiers::NONE),
SaveAnswer::Cancel => (egui::Key::Escape, egui::Modifiers::NONE),
SaveAnswer::DontSave => (egui::Key::D, egui::Modifiers::COMMAND),
};
press(self.viewport(w), key, modifiers);
sent.extend(self.frames(3));
assert!(self.app.unsaved_prompt.as_ref().is_none_or(|p| p.window != Some(w)), "the question in window {w} was answered");
sent
}
@@ -123,9 +154,7 @@ impl Desk {
/// The user presses `key` in the root window.
fn key(&mut self, key: egui::Key) -> Vec<(ViewportId, ViewportCommand)> {
EVENTS.with(|e| {
e.borrow_mut().push(egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers: egui::Modifiers::NONE })
});
press(ViewportId::ROOT, key, egui::Modifiers::NONE);
let mut sent = self.frame_with(|_, _| {});
sent.extend(self.frames(2));
sent
@@ -202,7 +231,7 @@ fn closing_the_last_window_of_an_unsaved_workbook_asks_and_the_app_quits_after()
let w = desk.window_of(0);
let sent = desk.close(w);
assert!(sent_to(&sent, ViewportId::ROOT, &ViewportCommand::CancelClose), "the window stays open to ask: {sent:?}");
assert_eq!(desk.app.dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(desk.app.framework_dialogs.is_open::<UnsavedChangesDialog>());
assert_eq!(desk.app.session.documents().len(), 1);
let sent = desk.answer(SaveAnswer::Cancel);
@@ -244,17 +273,17 @@ fn quit_asks_about_each_unsaved_workbook_in_its_window_and_cancel_stops() {
let sent = desk.frame_with(|app, ctx| app.request_quit(ctx));
assert_eq!(desk.app.session.active_window(), Some(w1), "Book1's window comes forward to ask");
assert!(sent_to(&sent, desk.viewport(w1), &ViewportCommand::Focus), "{sent:?}");
assert_eq!(desk.app.dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(desk.app.framework_dialogs.is_open::<UnsavedChangesDialog>());
let sent = desk.answer(SaveAnswer::Cancel);
assert!(!sent_to(&sent, ViewportId::ROOT, &ViewportCommand::Close), "Cancel stops the quit: {sent:?}");
assert_eq!(desk.app.session.documents().len(), 2);
assert!(desk.app.dialog.is_none());
assert!(!desk.app.framework_dialogs.is_open::<UnsavedChangesDialog>());
desk.frame_with(|app, ctx| app.request_quit(ctx));
let sent = desk.answer(SaveAnswer::DontSave);
assert!(!sent_to(&sent, ViewportId::ROOT, &ViewportCommand::Close), "Book2 is still unsaved: {sent:?}");
assert_eq!(desk.app.session.active_window(), Some(w2), "then Book2's window asks");
assert_eq!(desk.app.dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(desk.app.framework_dialogs.is_open::<UnsavedChangesDialog>());
let sent = desk.answer(SaveAnswer::DontSave);
assert!(sent_to(&sent, ViewportId::ROOT, &ViewportCommand::Close), "both answered: the app quits: {sent:?}");
}
@@ -268,7 +297,7 @@ fn a_quit_question_brings_its_window_to_the_front_from_the_background() {
let w = desk.window_of(0);
let sent = desk.frame_with(|app, ctx| app.request_quit(ctx));
assert_eq!(desk.app.dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(desk.app.framework_dialogs.is_open::<UnsavedChangesDialog>());
for cmd in [ViewportCommand::Visible(true), ViewportCommand::Minimized(false), ViewportCommand::Focus] {
assert!(sent_to(&sent, desk.viewport(w), &cmd), "{cmd:?} missing: {sent:?}");
}
@@ -406,6 +435,20 @@ fn two_windows_on_one_workbook_show_their_own_sheet_and_each_others_edits() {
assert_eq!(d.wb.active().unwrap().value(CellRef::parse("B2").unwrap()), Value::Number(42.0));
}
#[test]
fn replacing_an_unsaved_question_keeps_the_new_answer() {
let mut desk = Desk::new(false);
desk.app.run("cell.set", json!({"cell": "A1", "input": "2"})).unwrap();
desk.frames(2);
desk.app.open_dialog("saveChanges", json!({}));
desk.frames(2);
desk.app.open_dialog("saveChanges", json!({}));
desk.frames(2);
assert!(desk.app.unsaved_prompt.is_some(), "the replaced question's cancel is not the new answer");
desk.answer(SaveAnswer::DontSave);
assert!(desk.app.session.documents().is_empty(), "the new answer closes the workbook");
}
#[test]
fn a_dialog_stays_with_its_window_across_a_switch() {
let mut desk = Desk::new(true);
@@ -517,9 +560,8 @@ fn quit_takes_over_a_workbook_close_waiting_on_the_macro_editor() {
assert!(desk.app.macros.editor.is_none());
// The quit asks about Book2 in its window, as the quit's question, not as a File › Close.
assert_eq!(desk.app.session.active_window(), Some(w2));
let d = desk.app.dialog.as_ref().expect("Book2 is asked about");
assert_eq!(d.name(), "saveChanges");
assert_eq!(d.values.get("quit"), Some(&json!(true)), "{:?}", d.values);
assert!(desk.app.framework_dialogs.is_open::<UnsavedChangesDialog>(), "Book2 is asked about");
assert!(desk.app.unsaved_prompt.as_ref().is_some_and(|p| p.quitting));
assert_eq!(desk.app.session.documents().len(), 2, "nothing closed before the answer");
}
@@ -551,10 +593,8 @@ fn quit_with_a_draft_in_one_window_and_unsaved_cells_in_another_asks_in_order_an
assert!(desk.app.macros.editor.is_none());
// Book2 is asked about next, in its window, as the quit's question.
assert_eq!(desk.app.session.active_window(), Some(w2), "the unsaved workbook's window comes forward");
let d = desk.app.dialog.as_ref().expect("Book2 is asked about");
assert_eq!(d.name(), "saveChanges");
assert_eq!(d.values.get("title").and_then(serde_json::Value::as_str), Some("Book2"));
assert_eq!(d.values.get("quit"), Some(&json!(true)), "{:?}", d.values);
assert!(desk.app.framework_dialogs.is_open::<UnsavedChangesDialog>(), "Book2 is asked about");
assert!(desk.app.unsaved_prompt.as_ref().is_some_and(|p| p.quitting));
assert_eq!(desk.app.session.documents().len(), 2, "nothing closed before the answer");
// Cancel: the quit stops with both windows and workbooks open; the discarded draft stays
// discarded.
+63 -6
View File
@@ -164,7 +164,7 @@ fn save_actions_include_the_cell_draft_and_close_keeps_the_unsaved_prompt() {
choose(&mut h, "Close");
assert!(h.state().backstage.is_none());
assert_eq!(h.state().session.documents().len(), 1);
assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
assert_eq!(h.state().session.active().unwrap().wb.active().unwrap().value(CellRef::new(0, 0)), Value::Number(123.0));
}
@@ -376,23 +376,80 @@ fn closing_the_window_asks_about_every_unsaved_workbook() {
let sent = request_window_close(&mut h);
assert!(sent.contains(&egui::ViewportCommand::CancelClose), "unsaved changes hold the window open: {sent:?}");
assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
let sent = click_commands(&mut h, "Cancel");
assert!(!sent.contains(&egui::ViewportCommand::Close), "Cancel keeps the app open");
assert!(h.state().dialog.is_none());
assert!(!h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
assert_eq!(h.state().session.documents().len(), 2, "Cancel keeps both workbooks");
request_window_close(&mut h);
let sent = click_commands(&mut h, "Don't Save");
assert!(!sent.contains(&egui::ViewportCommand::Close), "the other workbook is still unsaved");
assert_eq!(h.state().session.documents().len(), 1);
assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("saveChanges"), "then it asks about the next one");
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>(), "then it asks about the next one");
let sent = click_commands(&mut h, "Don't Save");
assert!(sent.contains(&egui::ViewportCommand::Close), "once every workbook is answered the window closes: {sent:?}");
let sent = request_window_close(&mut h);
assert!(!sent.contains(&egui::ViewportCommand::CancelClose), "the close that follows is let through");
}
#[test]
fn closing_the_window_while_close_asks_turns_the_question_into_the_quits() {
let mut h = harness(Services::default());
h.state_mut().run("cell.set", serde_json::json!({"cell": "A1", "input": "42"})).unwrap();
h.state_mut().run("file.close", serde_json::json!({})).unwrap();
h.run_steps(3);
assert!(h.query_by_label_contains("before closing?").is_some());
let sent = request_window_close(&mut h);
assert!(sent.contains(&egui::ViewportCommand::CancelClose), "{sent:?}");
assert!(h.query_by_label_contains("before quitting?").is_some(), "the question now asks before quitting");
assert!(h.state().unsaved_prompt.as_ref().is_some_and(|p| p.quitting), "and still waits for its answer");
let sent = click_commands(&mut h, "Don't Save");
assert!(sent.contains(&egui::ViewportCommand::Close), "its answer goes on to quit: {sent:?}");
}
#[test]
fn close_question_names_the_actions_in_the_platform_order() {
let mut h = harness(Services::default());
h.state_mut().run("cell.set", serde_json::json!({"cell": "A1", "input": "42"})).unwrap();
h.state_mut().run("file.close", serde_json::json!({})).unwrap();
h.run_steps(2);
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
let dont_save = h.get_by_role_and_label(egui::accesskit::Role::Button, "Don't Save").rect();
let cancel = h.get_by_role_and_label(egui::accesskit::Role::Button, "Cancel").rect();
let save = h.get_by_role_and_label(egui::accesskit::Role::Button, "Save").rect();
// The order every Craft dialog uses on the platform: Save first on Windows; Don't Save, Cancel, Save elsewhere.
// The footer orders by the OS the craft shell runs on, which need not be the machine running the test.
let platform_order = if craft_ui::runtime::windows::os_of(&h.ctx) == craft_host::target::Os::Windows {
save.min.x < dont_save.min.x && dont_save.min.x < cancel.min.x
} else {
dont_save.min.x < cancel.min.x && cancel.min.x < save.min.x
};
assert!(platform_order, "Don't Save {dont_save:?}, Cancel {cancel:?}, Save {save:?}");
}
#[test]
fn close_question_starts_on_save_and_enter_saves() {
let dir = std::env::temp_dir().join(format!("gridcraft-close-enter-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let path = dir.join("Book.xlsx").to_string_lossy().into_owned();
let mut h = harness(Services::default());
h.state_mut().run("file.save", serde_json::json!({"path": &path})).unwrap();
h.state_mut().run("cell.set", serde_json::json!({"cell": "A1", "input": "42"})).unwrap();
h.state_mut().run("file.close", serde_json::json!({})).unwrap();
h.run_steps(3);
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
// The answer that keeps the edits has the focus first; Don't Save never does.
assert!(h.get_by_role_and_label(egui::accesskit::Role::Button, "Save").is_focused(), "the question starts on Save");
assert!(!h.get_by_role_and_label(egui::accesskit::Role::Button, "Don't Save").is_focused());
h.key_press(egui::Key::Enter);
h.run_steps(4);
assert!(!h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
let (wb, _) = gridcraft_engine::io::open_bytes("Book.xlsx", &std::fs::read(&path).unwrap()).unwrap();
assert_eq!(wb.active().unwrap().value(CellRef::new(0, 0)), Value::Number(42.0), "Enter saved the change before closing");
let _ = std::fs::remove_dir_all(&dir);
}
#[test]
fn closing_the_window_can_save_first_and_a_saved_workbook_closes_at_once() {
let dir = std::env::temp_dir().join(format!("gridcraft-close-window-{}", std::process::id()));
@@ -427,7 +484,7 @@ fn quitting_with_one_of_two_workbooks_unsaved_asks_once() {
let sent = request_window_close(&mut h);
assert!(sent.contains(&egui::ViewportCommand::CancelClose), "{sent:?}");
assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
assert_eq!(h.state().session.active_index(), 0, "the unsaved workbook comes forward");
let sent = click_commands(&mut h, "Cancel");
assert!(!sent.contains(&egui::ViewportCommand::Close), "Cancel stops the quit");
@@ -436,7 +493,7 @@ fn quitting_with_one_of_two_workbooks_unsaved_asks_once() {
request_window_close(&mut h);
let sent = click_commands(&mut h, "Don't Save");
assert!(sent.contains(&egui::ViewportCommand::Close), "the saved workbook isn't asked about: {sent:?}");
assert!(h.state().dialog.is_none());
assert!(!h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
}
/// Book1 has a cell being typed when File › New runs (the macOS menu runs the command directly).
+47 -12
View File
@@ -493,7 +493,7 @@ fn quitting_asks_about_the_editors_unsaved_steps_first() {
let sent = request_window_close(&mut h);
assert!(sent.contains(&egui::ViewportCommand::CancelClose), "{sent:?}");
assert!(!sent.contains(&egui::ViewportCommand::Close), "{sent:?}");
assert!(h.query_by_label_contains("Save changes to macro “Unsaved”").is_some());
assert!(asks_about(&h, "Unsaved"));
// Cancel keeps the app and the draft.
// The formula bar's Cancel button has the same name; the question's is the button drawn last.
h.get_all_by_role_and_label(egui::Role::Button, "Cancel").last().unwrap().click();
@@ -522,7 +522,7 @@ fn quitting_with_the_editor_open_still_asks_about_unsaved_workbooks() {
assert!(h.state().macros.editor.is_none());
assert!(sent.contains(&egui::ViewportCommand::Close), "{sent:?}");
request_window_close(&mut h);
assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
}
#[test]
@@ -634,8 +634,14 @@ fn is_open(h: &Harness, uid: u64) -> bool {
h.state().session.documents().iter().any(|d| d.uid == uid)
}
/// Whether the shared unsaved-changes question is asking about the macro `name`.
fn asks_about(h: &Harness, name: &str) -> bool {
h.query_by_label_contains(&format!("Save changes to macro “{name}”")).is_some()
h.query_by_label_contains(&question_about(name)).is_some()
}
/// The words of the unsaved-changes question that name the macro, closing or quitting.
fn question_about(name: &str) -> String {
format!("the changes you made to “{name}”")
}
#[test]
@@ -687,7 +693,7 @@ fn save_in_the_question_saves_the_macro_then_the_workbook_asks_about_itself() {
// The macro is in the workbook now, which makes it unsaved: closing it goes on and asks.
assert!(h.state().macros.editor.is_none());
assert_eq!(h.state().session.active().unwrap().wb.macros.len(), 1);
assert_eq!(h.state().dialog.as_ref().map(|d| d.name()), Some("saveChanges"));
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
h.get_all_by_role_and_label(egui::Role::Button, "Save").last().unwrap().click();
h.run_steps(4);
assert!(!is_open(&h, book));
@@ -699,6 +705,38 @@ fn save_in_the_question_saves_the_macro_then_the_workbook_asks_about_itself() {
let _ = std::fs::remove_file(&path);
}
#[test]
fn the_editors_question_is_the_shared_one_and_enter_saves_the_draft() {
let mut h = harness();
edited_new_macro(&mut h);
let name = h.state().macros.editor.as_ref().unwrap().draft.name.clone();
let book = h.state().session.active().unwrap().uid;
h.state_mut().run("file.close", json!({})).unwrap();
h.run_steps(3);
assert!(asks_about(&h, &name));
// The question's buttons are drawn last (the formula bar has a Cancel and the editor a Save).
let button = |label: &'static str| h.get_all_by_role_and_label(egui::Role::Button, label).last().unwrap();
let (dont_save, cancel, save) = (button("Don't Save").rect(), button("Cancel").rect(), button("Save").rect());
// The order the workbook's question and every Craft dialog use on the platform: Save first on
// Windows; Don't Save, Cancel, Save elsewhere. The footer orders by the OS the craft shell runs
// on, which need not be the machine running the test.
let platform_order = if craft_ui::runtime::windows::os_of(&h.ctx) == craft_host::target::Os::Windows {
save.min.x < dont_save.min.x && dont_save.min.x < cancel.min.x
} else {
dont_save.min.x < cancel.min.x && cancel.min.x < save.min.x
};
assert!(platform_order, "Don't Save {dont_save:?}, Cancel {cancel:?}, Save {save:?}");
// Save has the focus first and Enter answers it: neither discards the draft.
assert!(button("Save").is_focused(), "the question starts on Save");
assert!(!button("Don't Save").is_focused());
h.key_press(Key::Enter);
h.run_steps(4);
assert!(h.state().macros.editor.is_none());
let wb = &h.state().session.documents().iter().find(|d| d.uid == book).expect("the workbook asks about itself next").wb;
assert_eq!(wb.macros.iter().map(|m| m.steps.len()).collect::<Vec<_>>(), [1], "Enter saved the draft into the workbook");
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
}
#[test]
fn a_draft_that_cannot_be_saved_keeps_its_workbook_open() {
let mut h = harness();
@@ -920,7 +958,7 @@ fn a_close_request_during_the_editors_save_dialog_waits_for_it() {
let r = h.state_mut().run("window.close", json!({"window": home})).unwrap();
assert_eq!(r["closed"], false);
h.run_steps(3);
assert_eq!(h.get_all_by_label_contains("Save changes to macro").count(), 1, "one question");
assert_eq!(h.get_all_by_label_contains(&question_about(&name)).count(), 1, "one question");
assert!(is_open(&h, book1) && is_open(&h, book2));
assert!(h.state().message.is_none(), "{:?}", h.state().message);
let pending = h.state().macros.editor.as_ref().and_then(|e| e.then_close.as_ref()).expect("the close waits");
@@ -954,7 +992,7 @@ fn a_different_close_during_the_editors_question_is_refused_until_it_is_answered
let e = h.state_mut().run("file.close", json!({"document": true})).unwrap_err();
assert!(e.contains("asking whether to save") && e.contains("its window closes"), "{e}");
h.run_steps(2);
assert_eq!(h.get_all_by_label_contains("Save changes to macro").count(), 1, "one question");
assert_eq!(h.get_all_by_label_contains(&question_about(&name)).count(), 1, "one question");
assert!(is_open(&h, book));
assert_eq!(h.state().session.windows().len(), 2);
// Don't Save closes the editor's window alone, as the question was asked for.
@@ -996,7 +1034,6 @@ fn quitting_with_a_draft_in_one_window_and_unsaved_cells_in_another_asks_in_orde
h.state_mut().run("cell.set", json!({"cell": "Z9", "input": "unsaved"})).unwrap();
h.run_steps(2);
let book2 = h.state().session.active().unwrap().uid;
let title2 = h.state().session.active().unwrap().display_title();
let b = h.state().session.active_window().unwrap();
assert_ne!(a, b);
let both_open =
@@ -1016,17 +1053,15 @@ fn quitting_with_a_draft_in_one_window_and_unsaved_cells_in_another_asks_in_orde
request_window_close(&mut h);
// Book2 is asked about next, in its window, as the quit's question.
assert_eq!(h.state().session.active_window(), Some(b), "the unsaved workbook's window comes forward");
let d = h.state().dialog.as_ref().expect("Book2 is asked about");
assert_eq!(d.name(), "saveChanges");
assert_eq!(d.values.get("title").and_then(serde_json::Value::as_str), Some(title2.as_str()));
assert_eq!(d.values.get("quit"), Some(&json!(true)), "{:?}", d.values);
assert!(h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>(), "Book2 is asked about");
assert!(h.state().unsaved_prompt.as_ref().is_some_and(|p| p.quitting));
assert!(both_open(&h));
// Cancel: the quit stops with both windows and workbooks open and Book2's changes kept; the
// draft the person discarded stays discarded.
h.get_all_by_role_and_label(egui::Role::Button, "Cancel").last().unwrap().click();
let sent = step_commands(&mut h);
assert!(!sent.contains(&egui::ViewportCommand::Close) && !h.state().allow_close, "{sent:?}");
assert!(h.state().dialog.is_none());
assert!(!h.state().framework_dialogs.is_open::<craft_ui::dialog::UnsavedChangesDialog>());
assert!(both_open(&h));
assert!(h.state().session.documents().iter().find(|d| d.uid == book2).unwrap().is_dirty());
assert!(h.state().macros.editor.is_none());
+4
View File
@@ -18,6 +18,10 @@
//! original chart part with the style, colour and shape parts behind it, together with the chart
//! as it was read.
//!
//! Table-linked query parts are held by the table model because the table part is rewritten.
//!
//! Table-linked query parts are held by the table model because the table part is rewritten.
//!
//! On write, kept parts get fresh part names where needed and new relationship ids; the `r:id`s in
//! kept XML are rewritten to match. Kept content is conservative:
//! - Anything whose relationship graph reaches a part GridCraft reads and rewrites (worksheets,
+1 -1
View File
@@ -44,7 +44,7 @@ impl KeptOut {
/// A part name for a kept part: its original name when that can't collide with anything
/// written, otherwise a fresh one in the same folder.
pub(super) fn claim(&mut self, original: &str) -> String {
pub(crate) fn claim(&mut self, original: &str) -> String {
let lower = original.to_ascii_lowercase();
let own = OWN_DIRS.iter().any(|d| lower.starts_with(d));
if own && self.used.insert(lower) {
+2 -1
View File
@@ -415,8 +415,9 @@ fn apply_craft_sheet_part(
fn read_sheet_notes_and_tables(cx: &mut Ctx<'_>, sp: &CraftSheetPart, rels: &[Rel], sheet: &mut Sheet) -> Result<(), IoError> {
let tables = cx.pkg.craft_mut().tables(sp).map_err(craft_error)?;
for (_, t) in tables {
for (part, t) in tables {
let mut model = parts::from_craft_table(cx, &t);
parts::read_query_table(cx, &part, &t, &mut model);
model.id = cx.next_object_id();
sheet.tables.push(model);
}
+62
View File
@@ -1,7 +1,11 @@
use quick_xml::Reader;
use quick_xml::events::Event;
use super::{
AutoFilter, CellRef, Comment, Ctx, El, FilterCriterion, HashMap, MAX_COLS, MAX_ROWS, NoteBox, NoteCorner, RangeRef, Sheet, Table, TableColumn,
TotalsFn, XmlColumnPr, from_file, xml,
};
use crate::write::NS_MAIN;
/// `rels` maps relationship ids to relationships (the first of duplicate ids). `budget` counts the
/// cells and bytes this sheet's hyperlinks have copied so far, across `<hyperlinks>` blocks.
@@ -38,6 +42,7 @@ pub(super) fn from_craft_table(cx: &mut Ctx<'_>, t: &craft_xlsx::Table) -> Table
totals_label,
formula: c.calculated_formula.as_ref().map(|(f, _)| from_file(f.trim())),
unique_name: c.unique_name.clone(),
query_field_id: c.query_table_field_id,
xml,
}
})
@@ -61,6 +66,7 @@ pub(super) fn from_craft_table(cx: &mut Ctx<'_>, t: &craft_xlsx::Table) -> Table
filter,
table_type: xml_table.then(|| "xml".to_string()),
connection_id: t.connection_id.filter(|_| xml_table),
query_table: None,
}
}
@@ -176,6 +182,62 @@ pub fn read_autofilter(cx: &mut Ctx<'_>, e: &El) -> Option<AutoFilter> {
Some(AutoFilter { range, criteria })
}
/// Most bytes kept for one table's query table part.
const MAX_QUERY_TABLE: u64 = 1024 * 1024;
/// Keeps the query table part a table of type `queryTable` points to. Without the part the table
/// is written as a plain table, so a file that names none stays valid.
pub(super) fn read_query_table(cx: &mut Ctx<'_>, part: &str, source: &craft_xlsx::Table, t: &mut Table) {
if source.table_type.as_deref() != Some("queryTable") {
return;
}
let target = match cx.pkg.rels(part) {
Ok(rels) => rels.into_iter().find(|r| r.kind == "queryTable" && !r.external).map(|r| r.target),
Err(_) => None,
};
let kept = target.and_then(|n| {
let bytes = cx.pkg.read_limited(&n, MAX_QUERY_TABLE).ok().flatten()?;
// Its own relationships (none in practice) would need to be kept with it.
let own_rels = cx.pkg.rels(&n).ok().is_none_or(|r| !r.is_empty());
let text = String::from_utf8(bytes).ok()?;
(!own_rels && xml::parse(text.as_bytes()).is_ok() && is_query_table_root(&text)).then_some(text)
});
match kept {
Some(text) => {
t.query_table = Some(text);
t.table_type = Some("queryTable".to_string());
t.connection_id = source.connection_id;
}
None => cx.warn(format!("table \"{}\": its query table could not be kept; the table was kept as a plain table", t.name)),
}
}
/// Whether a part's root is `queryTable` in the SpreadsheetML namespace. `El` drops namespaces, so
/// this reads the root start tag itself, for a default or a prefixed namespace binding.
fn is_query_table_root(text: &str) -> bool {
let mut reader = Reader::from_reader(text.as_bytes());
let mut buf = Vec::new();
loop {
match reader.read_event_into(&mut buf) {
Ok(Event::Start(e) | Event::Empty(e)) => {
let raw = e.name();
let raw = raw.as_ref();
let (prefix, local) = raw.split_once(':').unwrap_or(("", raw));
return local == "queryTable"
&& e.attributes().flatten().any(|a| {
let key = a.key.as_ref();
let bound = if prefix.is_empty() { key == "xmlns" } else { key.strip_prefix("xmlns:") == Some(prefix) };
bound && a.value.as_ref() == NS_MAIN
});
}
Ok(Event::Decl(_) | Event::Comment(_) | Event::PI(_) | Event::DocType(_)) => {}
Ok(Event::Text(t)) if t.as_bytes().iter().all(u8::is_ascii_whitespace) => {}
_ => return false,
}
buf.clear();
}
}
pub(super) fn read_threaded(cx: &Ctx<'_>, x: &El, sheet: &mut Sheet) {
let mut by_id: HashMap<String, CellRef> = HashMap::new();
let mut replies: Vec<(String, String, String, String)> = vec![];
+11 -3
View File
@@ -21,8 +21,8 @@ use crate::fmla::text_to_file;
use crate::styles::{color_attrs, dxf_id, dxf_xml};
use crate::tables::{paper_id, px_to_col_width, px_to_pt};
use crate::write::{
CT_CHART, CT_COMMENTS, CT_DRAWING, CT_TABLE, CT_THREADED_COMMENTS, NS_MAIN, NS_REL, NS_THREADED, Out, REL_THREADED_COMMENT, Rels, XML_DECL,
x14_cf_rule_guid,
CT_CHART, CT_COMMENTS, CT_DRAWING, CT_QUERY_TABLE, CT_TABLE, CT_THREADED_COMMENTS, NS_MAIN, NS_REL, NS_THREADED, Out, REL_THREADED_COMMENT, Rels,
XML_DECL, x14_cf_rule_guid,
};
use crate::xml::{encode_xstring, esc, esc_attr, num};
@@ -34,7 +34,8 @@ mod rules;
pub(crate) use parts::password_attrs;
use parts::{
autofilter_xml, comments_xml, protected_ranges_xml, table_columns, table_filter, table_name, table_xml, thread_ids, threaded_xml, vml_xml,
autofilter_xml, comments_xml, protected_ranges_xml, remap_query_fields, table_columns, table_filter, table_name, table_xml, thread_ids,
threaded_xml, vml_xml,
};
use rules::{cf_rule_xml, solid_bar_x14, validation_xml, x14_cf_rule_xml};
@@ -208,6 +209,13 @@ pub fn write_sheet(wb: &Workbook, si: usize, selected: bool, out: &mut Out) -> (
let filter = table_filter(sheet, t);
let xml = table_xml(t, cols, &name, out.table_id, &filter, out);
out.part(&format!("xl/tables/table{n}.xml"), Some(CT_TABLE), xml.into_bytes());
if let Some(query) = &t.query_table {
let path = out.kept.claim(&format!("xl/queryTables/queryTable{n}.xml"));
out.part(&path, Some(CT_QUERY_TABLE), remap_query_fields(query, t).into_bytes());
let mut table_rels = Rels::default();
table_rels.add("queryTable", &format!("/{path}"));
out.part(&format!("xl/tables/_rels/table{n}.xml.rels"), None, table_rels.xml().into_bytes());
}
part.features.table_parts.push(rels.add("table", &format!("../tables/table{n}.xml")));
}
}
+142 -3
View File
@@ -2,6 +2,10 @@ use std::collections::HashMap;
use super::*;
use quick_xml::events::{BytesStart, Event};
use quick_xml::name::ResolveResult;
use quick_xml::{NsReader, Writer};
/// Valid table name: letters, digits, `_` and `.`, starting with a letter, `_` or `\`
/// (Microsoft "Names in formulas" rules).
pub(super) fn table_name(name: &str, used: &mut HashSet<String>, n: u32) -> String {
@@ -131,6 +135,126 @@ pub(super) fn autofilter_xml(range: RangeRef, criteria: &[(u32, FilterCriterion)
s
}
/// Rewrites a retained query table part for the columns as saved. Each `queryTableField` takes its
/// column's new `tableColumn` id, linked through the field id a column keeps
/// (`TableColumn::query_field_id`). A field whose column is gone is dropped, and the count follows.
pub(super) fn remap_query_fields(query: &str, t: &Table) -> String {
let new_id: HashMap<u32, u32> = t.columns.iter().enumerate().filter_map(|(i, c)| Some((c.query_field_id?, u32::try_from(i + 1).ok()?))).collect();
let Some((_, counts)) = walk_query_fields(query, &new_id, None) else { return query.to_string() };
walk_query_fields(query, &new_id, Some(&counts)).map(|(xml, _)| xml).unwrap_or_else(|| query.to_string())
}
/// The only elements we edit are direct SpreadsheetML children of the query-table hierarchy.
/// Extensions can contain unrelated elements with exactly the same local names.
fn query_level(parent: Option<u8>, local: &str, spreadsheet: bool) -> u8 {
if !spreadsheet {
return 0;
}
match (parent, local) {
(None, "queryTable") => 1,
(Some(1), "queryTableRefresh") => 2,
(Some(2), "queryTableFields") => 3,
(Some(3), "queryTableField") => 4,
_ => 0,
}
}
/// First pass counts retained fields in each container; the second writes those counts and fields.
fn walk_query_fields(query: &str, new_id: &HashMap<u32, u32>, counts: Option<&[usize]>) -> Option<(String, Vec<usize>)> {
let mut reader = NsReader::from_reader(query.as_bytes());
let mut writer = Writer::new(Vec::new());
let mut buf = Vec::new();
let mut ancestors = Vec::new();
let mut found = Vec::new();
let mut container = 0usize;
let mut dropped = 0usize;
loop {
buf.clear();
let (namespace, event) = reader.read_resolved_event_into(&mut buf).ok()?;
let spreadsheet = matches!(namespace, ResolveResult::Bound(ns) if ns.as_ref() == NS_MAIN);
if matches!(event, Event::Eof) {
break;
}
if dropped > 0 {
match event {
Event::Start(_) => dropped += 1,
Event::End(_) => dropped -= 1,
_ => {}
}
continue;
}
let empty = matches!(&event, Event::Empty(_));
let out = match event {
Event::Start(e) | Event::Empty(e) => {
let level = query_level(ancestors.last().copied(), e.local_name().as_ref(), spreadsheet);
let mut element = e.to_owned();
if level == 3 {
found.push(0usize);
if let Some(counts) = counts {
element = set_attr(&e, "count", &counts.get(container)?.to_string());
}
container += 1;
} else if level == 4 {
match query_field_el(&e, new_id) {
Some(field) => {
*found.last_mut()? += 1;
element = field;
}
None => {
if !empty {
dropped = 1;
}
continue;
}
}
}
if empty {
Event::Empty(element)
} else {
ancestors.push(level);
Event::Start(element)
}
}
Event::End(e) => {
ancestors.pop()?;
Event::End(e)
}
other => other,
};
writer.write_event(out).ok()?;
}
if !ancestors.is_empty() {
return None;
}
Some((String::from_utf8(writer.into_inner()).ok()?, found))
}
/// A `queryTableField` with its `tableColumnId` set to its column's new id; None when the column is gone.
fn query_field_el(e: &BytesStart, new_id: &HashMap<u32, u32>) -> Option<BytesStart<'static>> {
let id = e.attributes().flatten().find(|a| a.key.as_ref() == "id")?;
let new = new_id.get(&id.value.trim().parse::<u32>().ok()?)?;
Some(set_attr(e, "tableColumnId", &new.to_string()))
}
/// The element with attribute `key` set to `value`, every other attribute kept in order.
fn set_attr(e: &BytesStart, key: &str, value: &str) -> BytesStart<'static> {
let mut out = e.to_owned();
out.clear_attributes();
let mut set = false;
for a in e.attributes().flatten() {
if a.key.as_ref() == key {
out.push_attribute((key, value));
set = true;
} else {
out.push_attribute(a);
}
}
if !set {
out.push_attribute((key, value));
}
out
}
/// The criteria saved in a table's `<autoFilter>`: its own, plus those of a sheet AutoFilter
/// that starts on the table's header row. GridCraft filters a table through the sheet
/// AutoFilter, but a file can't hold a sheet AutoFilter that overlaps a table (the sheet element
@@ -169,10 +293,11 @@ pub(super) fn table_xml(t: &Table, cols: &[String], name: &str, id: u32, filter:
} else {
s.push_str(" totalsRowShown=\"0\"");
}
if let Some(ty) = &t.table_type {
// `queryTable` needs its part: without it the table is plain.
if let Some(ty) = t.table_type.as_ref().filter(|ty| *ty != "queryTable" || t.query_table.is_some()) {
let _ = write!(s, " tableType=\"{}\"", esc_attr(ty));
}
if let Some(c) = t.connection_id {
if let Some(c) = t.connection_id.filter(|_| t.table_type.as_deref() != Some("queryTable") || t.query_table.is_some()) {
let _ = write!(s, " connectionId=\"{c}\"");
}
s.push('>');
@@ -189,6 +314,11 @@ pub(super) fn table_xml(t: &Table, cols: &[String], name: &str, id: u32, filter:
let _ = write!(s, " uniqueName=\"{}\"", esc_attr(u));
}
let _ = write!(s, " name=\"{}\"", esc_attr(&encode_xstring(name)));
if t.query_table.is_some()
&& let Some(f) = col.and_then(|c| c.query_field_id)
{
let _ = write!(s, " queryTableFieldId=\"{f}\"");
}
let totals = col.map(|c| c.totals).unwrap_or_default();
// A hidden Total Row keeps each column's calculation, as Excel's files do: turning the row
// back on restores it (#4296). The reader takes them whether the row is shown or not.
@@ -444,7 +574,15 @@ mod tests {
#[test]
fn repeated_headers_are_renamed_without_retrying_suffixes() {
let col = |n: &str| TableColumn { name: n.into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None };
let col = |n: &str| TableColumn {
name: n.into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
query_field_id: None,
unique_name: None,
xml: None,
};
let mut columns: Vec<TableColumn> = (0..10_000).map(|_| col("Total")).collect();
columns[1] = col("total3");
let t = Table {
@@ -463,6 +601,7 @@ mod tests {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
};
let names = table_columns(&t);
assert_eq!(names.len(), 10_000);
+33 -3
View File
@@ -215,13 +215,22 @@ fn calculated_table_column_keeps_formula_and_cell_value() {
header_row: true,
totals_row: false,
columns: vec![
TableColumn { name: "Input".into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None },
TableColumn {
name: "Input".into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn {
name: "Output".into(),
totals: TotalsFn::None,
totals_label: None,
formula: Some("A2*2".into()),
unique_name: None,
query_field_id: None,
xml: None,
},
],
@@ -234,6 +243,7 @@ fn calculated_table_column_keeps_formula_and_cell_value() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
let bytes = write_xlsx(&wb).unwrap();
let mut pkg = Package::open(&bytes).unwrap();
@@ -263,13 +273,22 @@ fn this_row_references_are_written_in_long_form() {
header_row: true,
totals_row: false,
columns: vec![
TableColumn { name: "Input".into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None },
TableColumn {
name: "Input".into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn {
name: "Output".into(),
totals: TotalsFn::None,
totals_label: None,
formula: Some("[@Input]*2".into()),
unique_name: None,
query_field_id: None,
xml: None,
},
],
@@ -282,6 +301,7 @@ fn this_row_references_are_written_in_long_form() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
let bytes = write_xlsx(&wb).unwrap();
let mut pkg = Package::open(&bytes).unwrap();
@@ -434,13 +454,22 @@ fn implicit_intersection_metadata_distinguishes_table_rows_and_columns() {
header_row: true,
totals_row: false,
columns: vec![
TableColumn { name: "Input".into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None },
TableColumn {
name: "Input".into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn {
name: "Output".into(),
totals: TotalsFn::None,
totals_label: None,
formula: Some("[@Input]*2".into()),
unique_name: None,
query_field_id: None,
xml: None,
},
],
@@ -453,6 +482,7 @@ fn implicit_intersection_metadata_distinguishes_table_rows_and_columns() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
sh.cells.set(at("A2"), Cell::value(Value::Number(3.0)));
sh.cells.set(at("B2"), formula("[@Input]*2", 6.0));
+196
View File
@@ -570,6 +570,202 @@ fn xml_maps_and_their_bindings_survive_a_round_trip() {
);
}
/// A workbook with a table that is the result range of a query on a data connection.
fn query_table_package() -> Vec<u8> {
let types = r#"<?xml version="1.0"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="xml" ContentType="application/xml"/><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/tables/table1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml"/><Override PartName="/xl/connections.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml"/><Override PartName="/xl/queryTables/queryTable1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml"/></Types>"#;
let workbook = format!(
r#"<?xml version="1.0"?><workbook xmlns="{NS_MAIN}" xmlns:r="{NS_R}"><sheets><sheet name="Data" sheetId="1" r:id="rId1"/></sheets></workbook>"#
);
let sheet = format!(
r#"<?xml version="1.0"?><worksheet xmlns="{NS_MAIN}" xmlns:r="{NS_R}"><sheetData><row r="1"><c r="A1" t="inlineStr"><is><t>Id</t></is></c><c r="B1" t="inlineStr"><is><t>Name</t></is></c></row><row r="2"><c r="A2"><v>1</v></c><c r="B2" t="inlineStr"><is><t>x</t></is></c></row></sheetData><tableParts count="1"><tablePart r:id="rId1"/></tableParts></worksheet>"#
);
let table = format!(
r#"<?xml version="1.0"?><table xmlns="{NS_MAIN}" id="1" name="Table_Query" displayName="Table_Query" ref="A1:B2" tableType="queryTable" connectionId="1" totalsRowShown="0"><tableColumns count="2"><tableColumn id="1" uniqueName="Id" name="Id" queryTableFieldId="1"/><tableColumn id="2" uniqueName="Name" name="Name" queryTableFieldId="2"/></tableColumns><tableStyleInfo name="TableStyleMedium2" showFirstColumn="0" showLastColumn="0" showRowStripes="1" showColumnStripes="0"/></table>"#
);
let query = format!(
r#"<?xml version="1.0"?><queryTable xmlns="{NS_MAIN}" name="ExternalData_1" connectionId="1" autoFormatId="16" applyNumberFormats="0"><queryTableRefresh nextId="3"><queryTableFields count="2"><queryTableField id="1" name="Id" tableColumnId="1"/><queryTableField id="2" name="Name" tableColumnId="2"/></queryTableFields></queryTableRefresh></queryTable>"#
);
let root_rels = rels(&[("rId1", "officeDocument", "xl/workbook.xml")]);
let wb_rels = rels(&[("rId1", "worksheet", "worksheets/sheet1.xml"), ("rId2", "connections", "connections.xml")]);
let sheet_rels = rels(&[("rId1", "table", "../tables/table1.xml")]);
let table_rels = rels(&[("rId1", "queryTable", "../queryTables/queryTable1.xml")]);
make_zip(&[
("[Content_Types].xml", types.as_bytes()),
("_rels/.rels", root_rels.as_bytes()),
("xl/workbook.xml", workbook.as_bytes()),
("xl/_rels/workbook.xml.rels", wb_rels.as_bytes()),
("xl/worksheets/sheet1.xml", sheet.as_bytes()),
("xl/worksheets/_rels/sheet1.xml.rels", sheet_rels.as_bytes()),
("xl/tables/table1.xml", table.as_bytes()),
("xl/tables/_rels/table1.xml.rels", table_rels.as_bytes()),
("xl/queryTables/queryTable1.xml", query.as_bytes()),
("xl/connections.xml", CONNECTIONS.as_bytes()),
])
}
#[test]
fn a_table_keeps_its_query_table_on_save() {
let (wb, rep) = read_xlsx(&query_table_package()).unwrap();
assert!(!rep.warnings.iter().any(|w| w.contains("query table")), "{:?}", rep.warnings);
let out = write_xlsx(&wb).unwrap();
let u = Unpacked::new(&out);
u.assert_valid();
let sheet = sheet_part(&u, "Data");
let (_, table) = u.rels(&sheet).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/table")).unwrap();
let t = xml::parse(u.text(&table).as_bytes()).unwrap();
assert_eq!((t.attr("tableType"), t.attr("connectionId")), (Some("queryTable"), Some("1")));
let fields: Vec<_> = t.child("tableColumns").unwrap().kids("tableColumn").map(|c| c.attr("queryTableFieldId")).collect();
assert_eq!(fields, [Some("1"), Some("2")]);
// The table points at its query table, byte for byte, with the content type it needs.
let (_, query) = u.rels(&table).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/queryTable")).unwrap();
assert!(u.text(&query).contains("<queryTableField id=\"2\" name=\"Name\" tableColumnId=\"2\"/>"));
let types = u.text("[Content_Types].xml");
assert!(
types.contains(&format!("PartName=\"/{query}\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml\"")),
"{types}"
);
// The connection it queries is kept too.
assert!(u.parts.contains_key("xl/connections.xml"));
// And it reads back the same.
let (again, _) = read_xlsx(&out).unwrap();
assert_eq!(again.sheets[0].tables[0].query_table, wb.sheets[0].tables[0].query_table);
}
#[test]
fn a_query_table_that_cannot_be_kept_leaves_a_plain_table() {
let mut zip = Unpacked::new(&query_table_package()).parts;
zip.insert("xl/queryTables/queryTable1.xml".to_string(), b"<queryTable".to_vec());
let items: Vec<(&str, &[u8])> = zip.iter().map(|(k, v)| (k.as_str(), v.as_slice())).collect();
let (wb, rep) = read_xlsx(&make_zip(&items)).unwrap();
assert!(rep.warnings.iter().any(|w| w.contains("query table")), "{:?}", rep.warnings);
let u = Unpacked::new(&write_xlsx(&wb).unwrap());
u.assert_valid();
let sheet = sheet_part(&u, "Data");
let (_, table) = u.rels(&sheet).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/table")).unwrap();
let t = xml::parse(u.text(&table).as_bytes()).unwrap();
assert_eq!(t.attr("tableType"), None);
assert!(t.child("tableColumns").unwrap().kids("tableColumn").all(|c| c.attr("queryTableFieldId").is_none()));
}
#[test]
fn a_query_table_with_a_prefixed_root_and_a_formatted_prolog_is_kept() {
let mut zip = Unpacked::new(&query_table_package()).parts;
let query = format!("<?xml version=\"1.0\"?>\n<q:queryTable xmlns:q=\"{NS_MAIN}\" name=\"ExternalData_1\" connectionId=\"1\"/>");
zip.insert("xl/queryTables/queryTable1.xml".to_string(), query.into_bytes());
let items: Vec<(&str, &[u8])> = zip.iter().map(|(k, v)| (k.as_str(), v.as_slice())).collect();
let (wb, rep) = read_xlsx(&make_zip(&items)).unwrap();
assert!(!rep.warnings.iter().any(|w| w.contains("query table")), "{:?}", rep.warnings);
assert!(wb.sheets[0].tables[0].query_table.is_some());
}
#[test]
fn a_query_table_root_outside_the_spreadsheet_namespace_leaves_a_plain_table() {
let mut zip = Unpacked::new(&query_table_package()).parts;
zip.insert("xl/queryTables/queryTable1.xml".to_string(), br#"<?xml version="1.0"?><queryTable name="ExternalData_1"/>"#.to_vec());
let items: Vec<(&str, &[u8])> = zip.iter().map(|(k, v)| (k.as_str(), v.as_slice())).collect();
let (wb, rep) = read_xlsx(&make_zip(&items)).unwrap();
assert!(rep.warnings.iter().any(|w| w.contains("query table")), "{:?}", rep.warnings);
assert_eq!(wb.sheets[0].tables[0].table_type, None);
}
#[test]
fn a_query_table_keeps_its_field_links_when_columns_move() {
let (mut wb, _) = read_xlsx(&query_table_package()).unwrap();
Arc::make_mut(&mut wb.sheets[0]).tables[0].columns.swap(0, 1);
let out = write_xlsx(&wb).unwrap();
let u = Unpacked::new(&out);
u.assert_valid();
let sheet = sheet_part(&u, "Data");
let (_, table) = u.rels(&sheet).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/table")).unwrap();
let (_, query) = u.rels(&table).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/queryTable")).unwrap();
// Id is now the second column, Name the first: each field follows its column to the new id.
let text = u.text(&query);
assert!(text.contains("<queryTableField id=\"1\" name=\"Id\" tableColumnId=\"2\"/>"), "{text}");
assert!(text.contains("<queryTableField id=\"2\" name=\"Name\" tableColumnId=\"1\"/>"), "{text}");
}
#[test]
fn a_prefixed_query_table_keeps_its_field_links_when_columns_move() {
let mut zip = Unpacked::new(&query_table_package()).parts;
let query = format!(
"<?xml version=\"1.0\"?>\n<q:queryTable xmlns:q=\"{NS_MAIN}\" name=\"ExternalData_1\" connectionId=\"1\"><q:queryTableRefresh nextId=\"3\"><q:queryTableFields count=\"2\"><q:queryTableField id=\"1\" name=\"Id\" tableColumnId=\"1\"/><q:queryTableField id=\"2\" name=\"Name\" tableColumnId=\"2\"/></q:queryTableFields></q:queryTableRefresh></q:queryTable>"
);
zip.insert("xl/queryTables/queryTable1.xml".to_string(), query.into_bytes());
let items: Vec<(&str, &[u8])> = zip.iter().map(|(k, v)| (k.as_str(), v.as_slice())).collect();
let (mut wb, _) = read_xlsx(&make_zip(&items)).unwrap();
Arc::make_mut(&mut wb.sheets[0]).tables[0].columns.swap(0, 1);
let out = write_xlsx(&wb).unwrap();
let u = Unpacked::new(&out);
let sheet = sheet_part(&u, "Data");
let (_, table) = u.rels(&sheet).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/table")).unwrap();
let (_, query) = u.rels(&table).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/queryTable")).unwrap();
let text = u.text(&query);
assert!(text.contains("<q:queryTableField id=\"1\" name=\"Id\" tableColumnId=\"2\"/>"), "{text}");
assert!(text.contains("<q:queryTableField id=\"2\" name=\"Name\" tableColumnId=\"1\"/>"), "{text}");
}
#[test]
fn query_table_field_remapping_leaves_extensions_untouched() {
let mut zip = Unpacked::new(&query_table_package()).parts;
let query = format!(
r#"<q:queryTable xmlns:q="{NS_MAIN}" xmlns:x="urn:example"><q:queryTableRefresh><q:queryTableFields count="2"><q:queryTableField id="1" tableColumnId="1"/><q:queryTableField id="2" tableColumnId="2"/><x:queryTableField id="77" tableColumnId="99"/><q:extLst><q:queryTableField id="88" tableColumnId="98"/></q:extLst></q:queryTableFields></q:queryTableRefresh><q:extLst><x:queryTableFields count="42"><x:queryTableField id="99" tableColumnId="97"/></x:queryTableFields><q:queryTableRefresh><q:queryTableFields count="41"><q:queryTableField id="98" tableColumnId="96"/></q:queryTableFields></q:queryTableRefresh></q:extLst></q:queryTable>"#
);
zip.insert("xl/queryTables/queryTable1.xml".to_string(), query.into_bytes());
let items: Vec<(&str, &[u8])> = zip.iter().map(|(k, v)| (k.as_str(), v.as_slice())).collect();
let (mut wb, _) = read_xlsx(&make_zip(&items)).unwrap();
Arc::make_mut(&mut wb.sheets[0]).tables[0].columns.pop();
let u = Unpacked::new(&write_xlsx(&wb).unwrap());
let sheet = sheet_part(&u, "Data");
let (_, table) = u.rels(&sheet).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/table")).unwrap();
let (_, query) = u.rels(&table).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/queryTable")).unwrap();
let text = u.text(&query);
assert!(text.contains(r#"<q:queryTableFields count="1">"#), "{text}");
assert!(!text.contains(r#"id="2" tableColumnId="2""#), "{text}");
for retained in [
r#"<x:queryTableField id="77" tableColumnId="99"/>"#,
r#"<q:queryTableField id="88" tableColumnId="98"/>"#,
r#"<x:queryTableFields count="42"><x:queryTableField id="99" tableColumnId="97"/></x:queryTableFields>"#,
r#"<q:queryTableFields count="41"><q:queryTableField id="98" tableColumnId="96"/></q:queryTableFields>"#,
] {
assert!(text.contains(retained), "missing {retained}: {text}");
}
}
#[test]
fn a_query_field_whose_column_is_gone_is_dropped_on_save() {
let (mut wb, _) = read_xlsx(&query_table_package()).unwrap();
Arc::make_mut(&mut wb.sheets[0]).tables[0].columns.pop();
let out = write_xlsx(&wb).unwrap();
let u = Unpacked::new(&out);
u.assert_valid();
let sheet = sheet_part(&u, "Data");
let (_, table) = u.rels(&sheet).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/table")).unwrap();
let (_, query) = u.rels(&table).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/queryTable")).unwrap();
let text = u.text(&query);
assert!(text.contains("<queryTableField id=\"1\" name=\"Id\" tableColumnId=\"1\"/>"), "{text}");
assert!(!text.contains("name=\"Name\""), "{text}");
assert!(text.contains("<queryTableFields count=\"1\">"), "{text}");
}
#[test]
fn a_query_field_with_single_quoted_attributes_follows_its_column() {
let mut zip = Unpacked::new(&query_table_package()).parts;
let query = String::from_utf8(zip["xl/queryTables/queryTable1.xml"].clone()).unwrap().replace('"', "'");
zip.insert("xl/queryTables/queryTable1.xml".to_string(), query.into_bytes());
let items: Vec<(&str, &[u8])> = zip.iter().map(|(k, v)| (k.as_str(), v.as_slice())).collect();
let (mut wb, _) = read_xlsx(&make_zip(&items)).unwrap();
Arc::make_mut(&mut wb.sheets[0]).tables[0].columns.swap(0, 1);
let out = write_xlsx(&wb).unwrap();
let u = Unpacked::new(&out);
u.assert_valid();
let sheet = sheet_part(&u, "Data");
let (_, table) = u.rels(&sheet).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/table")).unwrap();
let (_, query) = u.rels(&table).into_iter().map(|r| (r.1, r.2)).find(|(ty, _)| ty.ends_with("/queryTable")).unwrap();
let text = u.text(&query);
assert!(text.contains("<queryTableField id=\"1\" name=\"Id\" tableColumnId=\"2\"/>"), "{text}");
assert!(text.contains("<queryTableField id=\"2\" name=\"Name\" tableColumnId=\"1\"/>"), "{text}");
}
/// Where a link with `target`, in a workbook read from `from`, points once saved into `to`.
#[cfg(unix)]
fn rebased(target: &str, from: &str, to: &str) -> String {
+10 -1
View File
@@ -65,7 +65,15 @@ fn workbook() -> Workbook {
totals_row: false,
columns: headers
.iter()
.map(|h| TableColumn { name: (*h).into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None })
.map(|h| TableColumn {
name: (*h).into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
})
.collect(),
style: "TableStyleMedium2".into(),
banded_rows: true,
@@ -76,6 +84,7 @@ fn workbook() -> Workbook {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
wb.names.push(DefinedName { name: "SalesData".into(), scope: None, formula: "Data!$A$1:$F$9".into(), comment: String::new(), hidden: false });
+74 -8
View File
@@ -334,15 +334,25 @@ fn sample() -> Workbook {
totals_label: Some("Total".into()),
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn {
name: "Amount".into(),
totals: TotalsFn::Sum,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn { name: "Amount".into(), totals: TotalsFn::Sum, totals_label: None, formula: None, unique_name: None, xml: None },
TableColumn {
name: "Tax".into(),
totals: TotalsFn::Custom,
totals_label: Some("SUM(R2:R4)".into()),
formula: Some("Q2*0.1".into()),
unique_name: None,
query_field_id: None,
xml: None,
},
],
@@ -358,6 +368,7 @@ fn sample() -> Workbook {
],
table_type: None,
connection_id: None,
query_table: None,
});
let png = b"\x89PNG\r\n\x1a\n0000IHDRfake".to_vec();
s.images.push(Image {
@@ -907,8 +918,24 @@ fn writing_repairs_invalid_models() {
header_row: true,
totals_row: false,
columns: vec![
TableColumn { name: "X".into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None },
TableColumn { name: "x".into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None },
TableColumn {
name: "X".into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn {
name: "x".into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
],
style: String::new(),
banded_rows: true,
@@ -919,6 +946,7 @@ fn writing_repairs_invalid_models() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
s.cells.set(at("B2"), Cell { value: Value::Number(1.0), formula: None, style: StyleId(9999), py: None });
let (back, _) = read_xlsx(&write_xlsx(&wb).unwrap()).unwrap();
@@ -1559,7 +1587,15 @@ fn table_newline_column_and_backslash_name_survive() {
s.set_value(at("A1"), Value::text("Handle\nBars"));
s.set_value(at("B1"), Value::text("Name"));
s.set_value(at("B2"), Value::text("x"));
let col = |n: &str| TableColumn { name: n.into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None };
let col = |n: &str| TableColumn {
name: n.into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
};
s.tables.push(Table {
id: 1,
name: "\\_Prime.1".into(),
@@ -1576,6 +1612,7 @@ fn table_newline_column_and_backslash_name_survive() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
s.cells.set(at("D1"), Cell::formula(Formula::new("COUNTA(\\_Prime.1[Name])")));
let (back, _) = read_xlsx(&write_xlsx(&wb).unwrap()).unwrap();
@@ -1597,6 +1634,7 @@ fn hidden_total_row_keeps_its_calculations() {
totals_label: label.map(str::to_string),
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
};
let mut wb = Workbook::new();
@@ -1621,6 +1659,7 @@ fn hidden_total_row_keeps_its_calculations() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
let bytes = write_xlsx(&wb).unwrap();
let mut xml = String::new();
@@ -1676,9 +1715,18 @@ fn header_and_totals_table_without_data_row_survives() {
totals_label: Some("Total".into()),
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn {
name: "Amount".into(),
totals: TotalsFn::Sum,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
},
TableColumn { name: "Amount".into(), totals: TotalsFn::Sum, totals_label: None, formula: None, unique_name: None, xml: None },
],
style: "TableStyleMedium2".into(),
banded_rows: true,
@@ -1689,6 +1737,7 @@ fn header_and_totals_table_without_data_row_survives() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
let (back, report) = read_xlsx(&write_xlsx(&wb).unwrap()).unwrap();
assert!(report.warnings.is_empty(), "{:?}", report.warnings);
@@ -1974,7 +2023,15 @@ fn a_table_filter_criteria_survive_a_round_trip() {
range: rr("A1:A4"),
header_row: true,
totals_row: false,
columns: vec![TableColumn { name: "Region".into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None }],
columns: vec![TableColumn {
name: "Region".into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
}],
style: "TableStyleMedium2".into(),
banded_rows: true,
banded_cols: false,
@@ -1984,6 +2041,7 @@ fn a_table_filter_criteria_survive_a_round_trip() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
// The dropdown of a table's header cell installs the sheet AutoFilter over the table's
// range, and `data.filterBy` stores its criteria there.
@@ -2013,8 +2071,15 @@ fn a_partial_sheet_filter_is_not_folded_into_a_table() {
for (a, v) in [("A1", "Id"), ("B1", "Region"), ("A2", "1"), ("B2", "East"), ("A3", "2"), ("B3", "West")] {
s.set_value(at(a), Value::text(v));
}
let column =
|name: &str| TableColumn { name: name.into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None };
let column = |name: &str| TableColumn {
name: name.into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
};
s.tables.push(Table {
id: 1,
name: "Sales".into(),
@@ -2031,6 +2096,7 @@ fn a_partial_sheet_filter_is_not_folded_into_a_table() {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
});
s.autofilter = Some(AutoFilter {
range: rr("B1:B3"),
+10 -1
View File
@@ -19,7 +19,15 @@ fn table(range: &str, cols: &[&str]) -> Table {
totals_row: false,
columns: cols
.iter()
.map(|n| TableColumn { name: (*n).into(), totals: TotalsFn::None, totals_label: None, formula: None, unique_name: None, xml: None })
.map(|n| TableColumn {
name: (*n).into(),
totals: TotalsFn::None,
totals_label: None,
formula: None,
unique_name: None,
query_field_id: None,
xml: None,
})
.collect(),
style: String::new(),
banded_rows: true,
@@ -30,6 +38,7 @@ fn table(range: &str, cols: &[&str]) -> Table {
filter: vec![],
table_type: None,
connection_id: None,
query_table: None,
}
}
+1
View File
@@ -20,6 +20,7 @@ pub const CT_WORKSHEET: &str = "application/vnd.openxmlformats-officedocument.sp
pub const CT_DRAWING: &str = "application/vnd.openxmlformats-officedocument.drawing+xml";
pub const CT_CHART: &str = "application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
pub const CT_TABLE: &str = "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
pub const CT_QUERY_TABLE: &str = "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml";
pub const CT_COMMENTS: &str = "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
pub const CT_VBA: &str = "application/vnd.ms-office.vbaProject";
pub const CT_THREADED_COMMENTS: &str = "application/vnd.ms-excel.threadedcomments+xml";
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -38,11 +38,10 @@ No alpha blockers: every core workflow passes the [alpha gate](roadmap.md#alpha-
- **Estimate:** 25–40 h. [target-app-parity.md](target-app-parity.md#performance), [hardware-parity.md](hardware-parity.md)
### 3. Some unmodelled XLSX content is dropped on save (FF)
- **Missing:** slicers and their caches, timelines, the data model, query tables attached to
tables, unmodelled `extLst` entries (among them x14 data bar settings beyond a solid fill,
- **Missing:** slicers and their caches, timelines, unmodelled `extLst` entries (among them x14 data bar settings beyond a solid fill,
icon sets, colour scales and the text rules containsText, notContainsText, beginsWith and
endsWith), chart details. Pass-through (#330) keeps custom XML, external links, connections,
sheet query tables, printer settings, form and ActiveX controls, OLE objects and sheet
sheet query tables and supported table-linked query parts, printer settings, form and ActiveX controls, OLE objects and sheet
backgrounds; x14-only colour-scale, data-bar and icon-set rules with cross-sheet `cfvo` are
still dropped on read with a warning, while the other Excel 2010 conditional format rules
(including cross-sheet cell-value and expression rules) are read and written. In tested
@@ -236,6 +235,7 @@ No alpha blockers: every core workflow passes the [alpha gate](roadmap.md#alpha-
| 2026-10-11 | minor | §7: password-encrypted workbooks open with their password; saving with one remains (#11) |
| 2026-10-11 | minor | §16: comment navigation, Show Comments, Show All Notes and Convert to Comments landed (#281) |
| 2026-10-11 | minor | §7: `.xls` (BIFF8) import of values, formulas and number formats (#121) |
| 2026-10-24 | minor | §3: query tables attached to tables are kept on save |
| 2026-10-11 | minor | §3: XLSX pass-through keeps custom XML, external links, connections, query tables, printer settings, controls and OLE objects (#330, #324) |
| 2026-10-11 | minor | §13: Forecast Sheet landed (#322) |
| 2026-10-11 | minor | §15: ODDFPRICE, ODDFYIELD, ODDLPRICE, ODDLYIELD added (18 functions missing) |
+2 -2
View File
@@ -82,7 +82,7 @@ and upload their artifacts, the environment refuses macOS and Windows, and no re
| Linux aarch64 | `gridcraft-<v>-linux-aarch64.{AppImage,AppImage.zsync,deb,rpm,tar.gz}` | `ubuntu-22.04-arm` |
| Linux riscv64 | `gridcraft-<v>-linux-riscv64.tar.gz` (cross-compiled, glibc >= 2.39; CLI smoke-tested under QEMU) | `ubuntu-24.04` |
| Flatpak x86_64, aarch64 | `gridcraft-<v>-linux-<arch>.flatpak` (repackages the Linux tarball) | `ubuntu-24.04`, `ubuntu-24.04-arm` |
| FreeBSD 14 x86_64 | `gridcraft-<v>-freebsd-x86_64.tar.gz` | FreeBSD 14.3 VM (`freebsd.yml`, called by `release.yml`) |
| FreeBSD 15.1+ x86_64 | `gridcraft-<v>-freebsd-x86_64.tar.gz` | FreeBSD 15.1-STABLE VM (`freebsd.yml`, called by `release.yml`) |
| Web | `gridcraft-web-<v>.zip` (static site; see [`packaging/web/README.md`](../packaging/web/README.md)) | `ubuntu-latest` |
### macOS
@@ -185,7 +185,7 @@ Locally (on Linux): install [nfpm](https://nfpm.goreleaser.com/install/), then
### FreeBSD
GitHub has no FreeBSD runners. `.github/workflows/freebsd.yml` boots a FreeBSD 14.3 VM
GitHub has no FreeBSD runners. `.github/workflows/freebsd.yml` boots a FreeBSD 15.1-STABLE VM
(`vmactions/freebsd-vm`). Run by hand from `release`, it builds and tests the workspace; called
from `release.yml` with `package: true` it runs `packaging/freebsd/package.sh`, which builds the
release binaries and writes `gridcraft-<v>-freebsd-x86_64.tar.gz` (`bin/` + `share/`, extract