There are bug in StyleCommand undo command due to implementation as proposed in
Bug 87371 - Unintuitive cell border style handling
It leaves style changes behind on undo.
Personally I disagree with this functionality. If you set borders on adjacent cells you have to decide how you want it to work anyway, so I find the way libreOffice does simpler and clearer:
Any style changes is done only to the selected cells.
When painting borders, the cell with widest border wins. If same width, the cell to the left,down wins.
Opinions?