forked from 1b-agent/opencadstudio-upstream
Saving from a non-first paper layout still reopened on the first paper tab: set_saved_active_layout only updated an existing CTAB entry, but documents authored here never carried one, so CTAB was never written and the reader fell back to $TILEMODE (which only records model-vs-paper) → the first paper layout. set_saved_active_layout now creates the CTAB DICTIONARYVAR under the root named-object dictionary when it is absent (updating in place otherwise). The root dictionary is taken from the header handle, or found by scanning for the dictionary that holds ACAD_LAYOUT when a from-scratch document has not populated the header handle yet. The writers persist it (they serialize the document's objects and root-dictionary entries; the root-dict rebuild in CadDocument::build() is not run on save). Adds tests/active_space_roundtrip.rs, including a full DXF save→reload round-trip asserting both $TILEMODE and CTAB survive. Co-Authored-By: Claude Opus 4.8 <[email protected]>