The currentDocument.getDocument() has two different versions. The one I used - document1.getDocument(), which gets the in memory document without applying changes, and document1.getDocument(true), which applies the changes to the in memory document before retrieving it. Changing to the second version solved the problem.
Kudos to Tommy Valand over at the XPages development forum for solving this one.
Feedback response number WEBB8GBNFF created by Scott Blaylock on 04/27/2011