Restore focus after an undo or redo operation

Recent changes introduced in 26a9252 caused the focus to no longer be
correctly restored after replacing the document root. Prior to the
broken commit, the focus was saved & restored after every operation.
When the cursor was re-added to the document after an undo, the focus
would be reset to the event trap and would be kept in sync after each
operation following.

26a9252 introduced measures to minimise when the focus was restored,
and would only try and save the focus once before a group of ops,
and restore once after the group was complete. As the group of ops
was executed *after* the ODF container had been replaced, the focus
was already lost by the time the group started. Subsequently, the
focus was never restored after the batch was complete.

Fixes issue #397
Don't re-capture focus when the cursor is re-added to the document

Performing the focus capture when a cursor is registered to the document
causes undo/redo to slow down, as the focus gets pulled into the cursor
as soon as the AddCursor op is executed. The focus should not be changed
while executing operations.