BASIC|Calc: How delete empty cells in all range in one pass

Hi

The next problem is how to quick delete all empty cells in a range.

I wrote the code that delete empty cell in a 3 dimension array:

    for x=0 to max_col
      for y=0 to max_row
        if cell="" then					
    			Doc.Sheets(1).removeRange(CellRangeAddress,com.sun.star.sheet.CellDeleteMode.LEFT)
       end if
     next y
   next x

This is simple example not the whole code but its work.
The problem is that its work weary slow

Is there any other solution to delete empty cells in whole range in one pass?

You may look at this extension, that was also very slow initially; so I had to tweak it to not use removeRange in the loop, and instead move blocks up, and then remove one trailing range.