Fix high memory usage when sorting cells in Calc. (fdo#81501)

Empty columns were being unnecessarily included in the sorting
range which caused extra allocation. This happens when you select
the entire sheet to sort. There was already code to skip empty
trailing cells in rows but not to skip empty columns.

Change-Id: Ieac22647bb13165cbf66cb1a93f567e5169fff6a
Reviewed-on: https://gerrit.libreoffice.org/13294
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit c50d8bf596f527bb53b86dd04da652ed72f2c549)
actually use identical code for both byRow and byCol, fdo#81501 follow-up

Change-Id: I982e03a12dd80be0787f22dce4495065775e7de0
(cherry picked from commit 1e4235f8b2dc693b0fb1edade9db25a631bdbf94)
trim also empty leading column ranges, fdo#81501 follow-up

Change-Id: Ieaeea85149e4b6d263b112205bb17c155e2d12be
(cherry picked from commit c7b57c6c2b15a4b9f65dafb642e3f1da402e62ca)