Resolves: rhbz#1096747 crash/hang on format-page on html document

Change-Id: I9a989620375eb210e553b84b7a642a0360c8f03f
(cherry picked from commit 655377e90c57bb68e5000f06f76531baf9eeaa37)
(cherry picked from commit 829aa9e03ae570e15af1f754b292709f38f643ea)
Reviewed-on: https://gerrit.libreoffice.org/9650
Tested-by: Michael Stahl <mstahl@redhat.com>
Reviewed-by: Michael Stahl <mstahl@redhat.com>