Repository navigation
.ai import: the document's graphic styles open in the panel with their objects linked - #5155
Conversation
|
Caution Review failedThe pull request is closed. No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Parse style lists and transparency crates/eps/src/import/ai/read.rs, crates/eps/src/import/ai/read/directives.rs, crates/eps/src/import/ai/style.rs, crates/eps/src/import/ai/style/tests.rs |
The reader stores style-list names in order. The parser accepts bounded, closed strings and records transparency attributes, including blend mode, isolation, and knockout. |
Convert applied styles and record links crates/eps/src/import/ai/read/ops.rs |
The importer converts supported plain styles into appearances, scales strokes and effects where applicable, and records object-to-style names. |
Create document styles and link objects crates/eps/src/import/ai/read/document.rs, crates/eps/src/import/ai/tests.rs, crates/engine/src/cmd/fileio/tests_aiimport.rs, crates/engine/tests/import_fuzz.rs, docs/target-app-parity.md |
Finalization creates readable styles in list order and links nodes when their appearance and transparency match. Tests cover ordering, filtering, name decoding, transparency, and malformed inputs. The parity documentation records the import behavior. |
Scale styles and preserve links in native import crates/eps/src/import/native/build.rs, crates/eps/src/import/native/slots.rs, crates/eps/src/import/tests_native.rs |
Native import scales graphic-style strokes and effects when styles were read. Qualifying text replacements retain style links, with tests covering scaling and text-link behavior. |
Estimated code review effort: 3 (Moderate) | ~30 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant Reader
participant art_style_list
participant graphic_styles
participant Document
Reader->>art_style_list: Parse the Art Style List section
art_style_list-->>Reader: Return ordered style names
Reader->>graphic_styles: Resolve listed names against style definitions
graphic_styles-->>Document: Provide readable styles in list order
Document->>Document: Link nodes with matching appearance and transparency
Suggested reviewers: aiongg, bflatastic
Merge Risk: 
Low · previous review 5b9b2
-
Importing an Illustrator file with an unterminated graphic-style name can fail rather than retain the default styles. This is a bounded risk that can be addressed as a follow-up.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: .ai import now opens the document's graphic styles in the panel, and objects are linked to them. The diff reads the %AI9_BeginArtStyleList style list, replaces the default graphic styles with listed styles, and links objects that use a listed style. The title is concise and specific. It does not mention the gradient/pattern exclusion or the scaling changes, which is acceptable.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 81.25% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 16 functions across 12 files. (1 skipped: 1 unsupported.)
Full details: Description check
-
Explanation
The pull request description includes the required What and why, How it was tested, and Checklist sections. It explains the behavior, scope, implementation limits, tests, commands, CI result, and checklist status. The description is complete and relevant.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
ebe473b to
188754f
Compare
|
Merged, thanks @dotCooCoo! It went in with this round's batch after a full CI run and a live check. The scaled-page caller of |
What and why
Part of #3349.
A document keeps its own graphic styles ("Styles that are saved with the active document appear in the panel when that
document is open and active.",
Graphic Styles panel overview),
and objects stay linked to the style they use until the link is broken ("To break the link to a graphic style, select
the object, and then select Break Link to Graphic Style.",
Apply graphic styles).
Every object also has an unnamed style of its own that the panel doesn't show ("Converts a named style, which is shown
in the Graphic Styles palette, to an anonymous style, which is not.",
AIArtStyleSuite reference). Today a
.aiopened from itsediting data always shows VectorCraft's four default graphic styles, and no object is linked.
With this change the editing-data reader reads the style list (
%AI9_BeginArtStyleList, one PostScript string perstyle in the panel's order):
effects it already reads) comes in, in the list's order, in place of the default graphic styles. It keeps the
opacity, blend mode, isolation and knockout of its blend filter. A name listed twice, an empty name and a name with no
definition are left out. Styles that paint with a gradient or a pattern are left out for now. Without a list, or with
none of its styles read, the defaults stay.
1 (name) XW) is linked to that graphic style when it has the style'sappearance and transparency. This covers paths, groups and type made from the text document (and page type that
replaces a styled text object with the same appearance). A
1that names a style the list doesn't have is theobject's own appearance: it keeps that appearance and links nothing.
6,7and9markers are never links.UserUnitpage, and Large Canvas copies. In a LargeCanvas copy, an object read with an art style now also gets its strokes and effects at the page's size; before, they
stayed at the copy's 1/N scale.
No public source describes the style list or the
XWcodes; the rules above are VectorCraft's reader behavior.How it was tested
New tests build synthetic editing data from scratch:
crates/eps/src/import/ai/tests.rs:listed_styles_replace_the_default_graphic_styles_and_link_their_objects,only_listed_styles_that_are_defined_and_read_come_in_once,a_style_the_list_does_not_have_is_no_link,a_group_with_a_listed_style_is_linked,an_object_whose_transparency_differs_from_its_listed_style_is_not_linked,a_listed_style_keeps_its_transparency_and_links_objects_that_have_it,a_path_with_a_listed_style_that_fills_below_the_contents_is_linked,a_style_name_outside_ascii_links_its_objectsand
without_a_style_list_the_default_graphic_styles_stay.crates/eps/src/import/ai/style/tests.rs:a_style_list_keeps_its_strings_in_order(escapes, nesting, unendedstrings, the name and entry caps).
crates/eps/src/import/tests_native.rs:type_with_a_listed_art_style_is_linked_to_its_graphic_style,graphic_styles_in_the_units_of_a_user_unit_page_come_in_at_the_pages_sizeanda_large_canvas_eps_keeps_its_graphic_styles_at_the_pages_size.crates/engine/src/cmd/fileio/tests_aiimport.rs:an_ai_file_opens_with_the_graphic_styles_of_its_style_list.crates/engine/tests/import_fuzz.rs:ai_style_lists_and_style_links_never_panic(lists of any entries, with orwithout their end, and
XWwith any code and name), and style-list andXWtokens added toarb_ai_token.Each new test, except the fuzz test and
without_a_style_list_the_default_graphic_styles_stay, fails without its partof the change.
Commands run on
5b9b282a8b, based onmainat77274ac5ff:cargo fmt --all -- --checkcargo clippy -p vectorcraft-eps -p vectorcraft-engine --all-targets -- -D warningscargo test -p vectorcraft-eps: 554 passedcargo test -p vectorcraft-engine --lib aiimport: 39 passedcargo xtask brands,layersandassetsThe branch merges cleanly with
mainat5628de96f8. It changes lines next to #5046, #5082, #5102, #5115, #5117, #5142and #5144 (reader fields,
finish,slots.rs, the style tests, the fuzz tokens and the docs list); whichever mergeslater needs those lines merged.
cargo xtask cipassed in this pull request's CI run onebe473bf8b: https://github.com/storytold/vectorcraft/actions/runs/41359256925/job/125005884484Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.Summary by CodeRabbit