fix build, coverity#1209547 Unchecked dynamic_cast

(cherry picked from commit f4c80aaf3f2b97661ecf1cfd014aaa5ad00da846)

Change-Id: Ibf614156aeafcd74be444cf388e02a9273d38d5f
Reviewed-on: https://gerrit.libreoffice.org/11018
Reviewed-by: David Tardon <dtardon@redhat.com>
Tested-by: David Tardon <dtardon@redhat.com>