Rewrite getHash to reduce code duplication & improve maintainability.

Instead of each case block repeating the same operations, we build
an intermediate vector of entries to process.

Change-Id: Id111d7938a7802f6f016c2a0d1be0cb062a32110
Reviewed-on: https://gerrit.libreoffice.org/8912
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>