The NSTextInputClient protocol expects marked (composed) and selected
text ranges to be relative to the document, not to the current editing
block as Qt typically expects.
Luckily we can use the absolute cursor position to compute an absolute
offset that we can apply to any other positions, such as the selection.
Now that we are computing the ranges correctly we can also use them
during text insertion, when the incoming replacementRange is not valid.
We then transform and sanitize the replacement range to the format that
Qt expects for QInputMethodEvent::setCommitString().
Pick-to: 6.2
Change-Id: I4cb2f7c63adb92e407f38af05adce539c9bed7e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>