Fix #612: The formatter will be invoked by XS, so that the code from templates will be formatted prior to being created.
This formatting goes through WorkBench.ActiveDocument and would overwrite the correct code with the one from the old solution/project.

This is more code than is necessary to fix the bug; I also opted to remove a use of Workbench.ActiveDocument that I consider harmful.
Merge pull request #663 from rojepp/612

Fix #612: Bug in new project creation