forked from 1b-agent/opencadstudio-upstream
feat: embed images (OLE2FRAME), print pipeline fixes, plot prefs, community fonts
- IMAGEEMBED: pack raster images into OLE2FRAME entities so a .dwg is self-contained; 'Embed Image' entry in the XREF attach menu; control/MCP op embed_image for external tools; dxf_name for OLE2FRAME queries. - Scene: populate_images_from_document now rebuilds OLE2FRAME and PDF underlay models too (they used to vanish after any XREF op). - Printing: add PRINTER_ENUM_NETWORK pass when listing printers; GDI spooler fallback (hayro raster at 300 DPI + StretchDIBits) for hosts whose PDF handler registers no print verb; DEVMODE orientation with a 90-degree raster rotation fallback for v4 drivers; fix the fit-scale precedence bug that printed blank pages. - PDF export dialogs on Windows use the async file dialog so the native overwrite confirmation no longer deadlocks the UI thread. - Plot dialog: persist the chosen printer (saved on selection) and the picked plot window across sessions; page setups with no device no longer reset the output device. - Community fonts: detect unresolvable .shx references on open and offer a download from the repository's fonts/ folder (contribution guide in fonts/README.md); custom font source URL setting for intranet font servers; downloaded fonts resolve from the per-user fonts directory.
This commit is contained in:
1 parent
1450fdeedf
commit
28efbffd57
27 files changed
+1767
-66
No files matched your search
@@ -781,6 +781,8 @@ impl OpenCADStudio {
|
||||
"set_properties" => self.control_set_record_properties(req)?,
|
||||
"action" => self.control_ui_action(req)?,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
"embed_image" => self.control_embed_image(req)?,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
"save" => {
|
||||
let path = req["path"]
|
||||
.as_str()
|
||||
@@ -1387,4 +1389,40 @@ mod tests {
|
||||
);
|
||||
let _ = std::fs::remove_file(path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn embed_image_op_places_an_ole2frame_and_undoes_it() {
|
||||
let mut app = OpenCADStudio::new_for_test();
|
||||
request(&mut app, json!({"op":"new"}));
|
||||
let img = image::RgbaImage::from_pixel(40, 30, image::Rgba([9, 9, 9, 255]));
|
||||
let path = std::env::temp_dir().join(format!("ocs-embed-{}.png", session_id()));
|
||||
img.save(&path).unwrap();
|
||||
|
||||
let response = request(
|
||||
&mut app,
|
||||
json!({"op":"embed_image","path":path.to_string_lossy(),"at":[0,0,0],"width":20}),
|
||||
);
|
||||
assert_eq!(response["status"], "completed", "{response}");
|
||||
let handle = response["result"]["handle"].as_str().unwrap().to_string();
|
||||
assert_eq!(response["result"]["kind"], "Ole2Frame");
|
||||
let ole_count = |app: &OpenCADStudio| {
|
||||
app.tabs[app.active_tab]
|
||||
.scene
|
||||
.document
|
||||
.entities()
|
||||
.filter(|e| matches!(e, acadrust::EntityType::Ole2Frame(_)))
|
||||
.count()
|
||||
};
|
||||
assert_eq!(ole_count(&app), 1);
|
||||
|
||||
// The entity must be queryable like any other and undoable as one step.
|
||||
let queried =
|
||||
app.automation_op(json!({"op":"entities","type":"OLE2FRAME"}).to_string().as_str());
|
||||
assert_eq!(queried["total"], 1, "{queried}");
|
||||
request(&mut app, json!({"op":"undo"}));
|
||||
assert_eq!(ole_count(&app), 0);
|
||||
let _ = std::fs::remove_file(path);
|
||||
let _ = handle;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user