avoid crash on document ending before contained table ends

Change-Id: I003b7e00673cd5a4b4f0ed5218e2d30cfef04ffb
(cherry picked from commit 5a2123376dc010ca4e3f0a19d7dbbfaeb25ea963)
Reviewed-on: https://gerrit.libreoffice.org/11057
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>