fdo#79236: sw: Undo of changing style crashes on invalid item (-1)

Change-Id: Ie0b0791722a0ca8d75b7981362661be0c9706c6d
(cherry picked from commit 732eee2de4d0579eda69fe0ebfa361180fa35456)