Refactor DPI settings validity check

Move the validity check for the DPI (>= 50 and <= 500) into its own
(static) function, since we're going to use it repeatedly in the
fallback DPI detection code.

Change-Id: Id5d9b10be385d45549bbb57cfa14939cd51a0324
Reviewed-on: https://gerrit.libreoffice.org/11376
Reviewed-by: Chris Sherlock <chris.sherlock79@gmail.com>
Tested-by: Chris Sherlock <chris.sherlock79@gmail.com>