fdo#72691: Allow overwriting of string value with numeric one.

This can legitimately happen when you have a matrix with a reference to
another cell inside, and the referenced cell originally contained a
string value then later overwritten by a numeric value.

Example.  Put a "Text" in A1, and in B1 put a 1x1 matrix {=A1}.  It
displays "Text" in B1.  Then put 11 in A1.  Prior to this change, B1
would become blank.  With this change, B1 will display 11.

Change-Id: I3feba3a8658e1a5ebf6f9e5ac34de2d579464ddb
(cherry picked from commit 9bf907a8278cecd816368db7b8c4ab745a914a59)
Reviewed-on: https://gerrit.libreoffice.org/8065
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Reviewed-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Tested-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
fdo#73773: Check if the *document* is closing, not the *app*.

Otherwise it would crash if the app has multiple document instances open
and only one of them is being closed.

Change-Id: Ib6e370037ab6097c9c6eff8035249663944b3a6c
(cherry picked from commit 76bdf523981d2bd983dac4e01bc5cc934118a73f)
Reviewed-on: https://gerrit.libreoffice.org/8054
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Tested-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Reviewed-by: Jacobo Aragunde Pérez <jaragunde@igalia.com>