forked from 1b-agent/opencadstudio-upstream
fix(print): complete Windows printer discovery, honor the true default, surface failures; make CTB loading usable (#1261)
Printer enumeration used EnumPrinters level 4 only, which is served from the local registry cache and misses Win11 per-user network printers; an empty result now retries with level 2 (spooler RPC) and merges the resolved default. The dialog's 'System default printer' used to delegate to the shell print verb — the default PDF handler's own printer choice, not the system default; it now resolves GetDefaultPrinterW and dispatches printto naming that printer explicitly. Every dispatch probes OpenPrinterW first, so a printer that vanished between listing and printing produces a clear error instead of ShellExecute's silent nothing, and all SE_ERR_* codes carry readable reasons. Legacy CTB: picking an unparseable table used to swallow the failure (.ok()) — the user saw nothing at all. Load errors now reach the command line, the picker accepts .stb alongside .ctb (the container gains the STBVER1 header; .stb application errors state the actual reason), and a table loaded from anywhere is copied into the user's plot-styles folder so it persists in the dialog, matching AutoCAD. Buffer parsing for both EnumPrinters layouts is unit-tested; the missing-printer path was exercised against the real spooler (existence probe only, no job).
This commit is contained in:
1 parent
02d9273a19
commit
5ea4294d3d
6 files changed
+390
-44
No files matched your search
@@ -8340,7 +8340,7 @@ impl OpenCADStudio {
|
||||
Message::PlotStyleLoad => {
|
||||
Task::perform(crate::io::pick_plot_style(), Message::PlotStyleLoaded)
|
||||
}
|
||||
Message::PlotStyleLoaded(Some(table)) => {
|
||||
Message::PlotStyleLoaded(Ok(Some(table))) => {
|
||||
if table.is_stb {
|
||||
self.command_line.push_error(
|
||||
crate::t!(
|
||||
@@ -8368,7 +8368,14 @@ impl OpenCADStudio {
|
||||
self.plot_dialog.plot_styles = crate::io::plot_style::available_ctb_names();
|
||||
Task::none()
|
||||
}
|
||||
Message::PlotStyleLoaded(None) => Task::none(),
|
||||
// The user closed the file dialog without picking anything.
|
||||
Message::PlotStyleLoaded(Ok(None)) => Task::none(),
|
||||
// A picked table that failed to parse used to vanish silently
|
||||
// (`.ok()` collapsed it into "cancelled"); surface it instead.
|
||||
Message::PlotStyleLoaded(Err(error)) => {
|
||||
self.command_line.push_error(&error);
|
||||
Task::none()
|
||||
}
|
||||
Message::PlotStyleClear => {
|
||||
self.active_plot_style = None;
|
||||
self.plot_dialog.style_name.clear();
|
||||
|
||||
Reference in new issue
Block a user