Move this fucntion to ScDBDocFunc.

so that it could be usable from unit test.

Change-Id: Iea10cb473bc17d7e030c018fd2c84fbeccce3e47
fdo#79578: Write test for this first.

Change-Id: I46ccf0954f9397779244132488d93f3162cf04d6
fdo#79578: Properly update formulas upon change in db collection.

Update it to handle formula groups correctly.

Change-Id: I009a7fcf3d3fb17ef6951c50534ca6bc1fffc259