fdo#77969: Return 0 in case of matrix consisting of all empty elements.

Change-Id: I225d50445d7f84a17c0b9492c17247e4c1c9ef44
(cherry picked from commit 453ea919e70fa9832f11e3ef042bb80cd86892cc)
Reviewed-on: https://gerrit.libreoffice.org/9189
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>