fdo#75386: Totally fix reference update during range move.

It was just not working at all due to multiple reasons.  The
reference update needed to be reworked for formula groups such that
the token array is adjusted only for the top cell but all formula cells
still needed to be processed afterwards.  The bound check also needed
to be done against the old range prior to the move, not the new range
after the move.

During undo, the paint had to be deferred until after the two calls to
DoUndo() else the formula cells would get re-calculated before the
values were placed back to their old positions, causing them to mis-
calculate wrong values.

Change-Id: Iba66f80a413e0539cac5ab619226cd6f7a04f317
(cherry picked from commit 79d03eb090a5f88863c1004ef8b7f483cbecb69d)
Reviewed-on: https://gerrit.libreoffice.org/8352
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Tested-by: Andras Timar <andras.timar@collabora.com>