One small comment, usually, I'd suggest calling OdtDocument.fixCursorPositions after a modification like this... however, this works fine because (p, 0) is walkable for an empty paragraph.