int remainder = doc.size() - removeSize - addPosition; // remainder after the insert
// step 1: initialise the operations for the DOM and annotations:
DocOpBuffer domOp = new DocOpBuffer();
final AnnotationsNormalizer<DocOp> annotOp =
new AnnotationsNormalizer<DocOp>(new UncheckedDocOpBuffer());
if (addPosition > 0) {
annotOp.retain(addPosition);
domOp.retain(addPosition);
}