Avoid some division by zero
The first of which was seen when running under UBSan `instdir/program/soffice
--headless --convert-to pdf` of caolan/id:002485,src:002216,op:havoc,rep:8.jpg
from the crash-testing corpus. The second one (when computing nGrfDPIy) was not
observed, but lets assume that it could happen just as well, and keep the code
symmetric.
Change-Id: Idf9f9a84f3b05c7cfe3c66db753c73d2cbf812be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119650
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>