Copying a cell over another one with change recording on could crash, or
destroy the tracked change it had just recorded when the target cell had a
number format.
The root cause was that formulas and formatted numbers overwrite
existing cells and destroy some tracked changes..
The cursor could point to a character that is not exist anymore.
So, first i made some cursor position fix in some key points
to avoid some crashes.
Then disabled tracked changes when a cell with formula is changed.
Every time it was recalculated, it generated a new tracked change.
Normally if we want it to be tracked, we should track the formula inside,
not the visible value .. but we don't have that type of tracked change.
ChgTextToNum() could also generate lost tracked changes:
If we copied a formatted number cell content to an other similar cell,
(for example a currency like $1,000.00 to $10.00)
by replacing the text ... then at first it generated a cell content like
$1,000.00($10.00)
where ($10.00) is a delete change..
Then the ChgTextToNum() reformatted the cell.. and overwritten it with
the $1,000.00 ... so we lost the delete change.
now i changed it so it can keep tracked deletion changes as well
(it was able to store some insert changes)
and then it checked if the format is fine for the real text ..
If it is, then it will leave it.. so tracked changes survive.
If the format is not good, then i keep the old way of working to
replace cell with the new value... and make it 1 insert tracked change
I do this to avoid complex problems.. because at format changes
a lot of things can change.. position of the characters ..
and it could be a confusion where the old delete change should start from.
It would need more planning to figure out a way to handle it.
Side note: in some cases if we modify the value of the formatted number cell
to something that does not fit the format, it can lose the formation
and change to pure text. (so all track changes will work on it)
like if you change this: $1,123,234.00 -> $1,123234.00
(This is not my change. i just mentioned this behavior.)
Signed-off-by: Attila Szűcs <attila.szucs@collabora.com>
Change-Id: I152ec4720ec8e133800186c7e5787fe0f6954fc8
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/13456
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
Reviewed-by: Stephan Bergmann <stephan.bergmann@collabora.com>
(cherry picked from commit 699b9cb056cb283fc2699763e1a2340e12680c3f)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211684
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>