fdo#39440 rsc: reduce scope of local variables

This addresses some cppcheck warnings.

Change-Id: I69454a75c8ce4aecf9e68f5887f38f8bf6fe6dca
Reviewed-on: https://gerrit.libreoffice.org/13543
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Tested-by: Noel Grandin <noelgrandin@gmail.com>