fdo#77647: Expand reference only when the top of the selected range is...

below the top of the reference range.

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