fdo#74506 fdo#74291 -Template manager-store selection before calling dialog

It looks like calling a dialog/querybox result in a deselection of
the selected ThumbnailViewItem(s). Therefore lets save this selection
first, before calling such dialog.

Change-Id: I45a1da4307759ca6472f793fff29b1e2507fd5c9
Reviewed-on: https://gerrit.libreoffice.org/7902
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
(cherry picked from commit a411bf38da3668094698c06c8424aa9d68c85702)
Reviewed-on: https://gerrit.libreoffice.org/7925