Repository navigation
NewDocumentFromTemplate: create the drawing from the template, reject stencils (#229) - #235
Merged
Merged
Conversation
… stencils NewDocumentFromTemplate created a blank drawing and then opened the template as a docked stencil (AddEx with visAddStencil + visOpenDocked, flags copied from the 2012 NewStencil helper), so the drawing was never based on the template and, in Visio 2013 and later, an empty stencil was left open. It now calls AddEx with no flags, which gives a drawing with the template's page setup, styles and settings and opens the stencils in its workspace. - null, empty or whitespace template: a blank drawing (as before for null) - a stencil file (.vss/.vssx): ArgumentException before anything is created (it used to fail with an opaque COM error after leaving a blank drawing) - a template that does not exist: throws, with no stray blank drawing Verified against a live Visio 16: Documents.Add(template) and AddEx(...,0,0) open BASFLO_U.vssx and XFUNC_U.vssx and keep the template's landscape page; the old call left an empty Stencil2. 7 new tests (4 failed before the change) across VTest.Scripting, VTest.Models (XML template option) and VTest.PowerShell (New-VisioDocument -Template). Closes #229 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #229.
Client.Document.NewDocumentFromTemplate(and soNew-VisioDocument -Templateand the directed graph XML<documentoptions template="..."/>) did not create the drawing from the template. It created a blank drawing and then opened the template as a separate docked stencil (AddExwithvisAddStencil + visOpenDocked, flags copied from the 2012NewStencilhelper), which left an empty stencil open in Visio 2013 and later.It now calls
AddExwith no flags, so Visio creates the drawing from the template: its page setup, styles and settings apply, and the stencils in the template's workspace open and dock..vss/.vssx):ArgumentException("... is a stencil, not a template ... use -Stencil") before anything is created. Before, it failed with an opaque COM error after leaving a blank drawing open.Evidence (live Visio 16,
BASFLO_U.VSTX)Add("")+AddEx(template, 0, 516, 0)Template, plus an empty "Stencil" document.AddEx(template, 0, 0, 0)orDocuments.Add(template)Templateis set, landscape 11 x 8.5, withBASFLO_U.vssx(15 masters) andXFUNC_U.vssx(7 masters) opened and docked.AddEx(template, 0, 256, 0)(visAddNoWorkspace)AddEx("basflo_u.vssx", 0, 516, 0)Microsoft's
Documents.AddExdocumentation describes the template form the same way (andvisAddStencilas "Adds a new stencil file"). I could not test Visio 2010 itself.Behavior change
Anyone who passed a template used to get a blank drawing and now gets one based on the template, which is what the docs promised. Anyone who passed a stencil got an error and still does, but a clear one. No internal caller passes a template or a stencil (the developer commands pass null).
Testing
VTest.Scripting,VTest.Models(the XMLtemplateoption now checks the drawing is based on the template) andVTest.PowerShell(New-VisioDocument -Template, and the stencil error).Also
NuGet/CHANGELOG.mdandVisioPowerShell/CHANGELOG.md[Unreleased]: Fixed entries. The caveat on the XML option's Added entry is removed.docs/TESTING.md,CLAUDE.mdand the Models docs backlog entry updated.New-VisioDocumentpage).Closes #229
🤖 Generated with Claude Code