make sure to check for formula first, fdo#80301

Cherry-picked from 37ac70c117a7b8b9ac66b583a793096c3ad87a11
Change-Id: Ie822d1a154b7b25437ce7e5d09eb399460823acf
Reviewed-on: https://gerrit.libreoffice.org/13081
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>