Resolves: fdo#87108 crash on saving fodg

Change-Id: Ib88f0e9b0a3ba229c9e9f6cf20831c16051e3e29
(cherry picked from commit bfd63516c9fd4ec366576f9a0e3c456bc3d530a3)
(cherry picked from commit 2b257feba285840dee91e3c3e7ddc112eb8f684e)
Reviewed-on: https://gerrit.libreoffice.org/13390
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>