int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[0] != null)
while (elementStack.size() != 0)
    protected void changeUpdate()    {      // Split up the element at the start offset if necessary.      Element el = getCharacterElement(offset);      Element[] res = split(el, offset, 0, el.getElementIndex(offset));      BranchElement par = (BranchElement) el.getParentElement();      int index = par.getElementIndex(offset);      Edit edit = getEditForParagraphAndIndex(par, index);      if (res[1] != null)        {          Element[] removed;          Element[] added;          if (res[0] == null)            {              removed = new Element[0];              added = new Element[] { res[1] };              index++;            }          else            {              removed = new Element[] { el };              added = new Element[] { res[0], res[1] };            }          edit.addRemovedElements(removed);          edit.addAddedElements(added);        }      int endOffset = offset + length;      el = getCharacterElement(endOffset);      res = split(el, endOffset, 0, el.getElementIndex(endOffset));      par = (BranchElement) el.getParentElement();      if (res[0] != null)        {          Element[] removed;          Element[] added;          if (res[1] == null)            {              removed = new Element[0];              added = new Element[] { res[1] };            }          else            {              removed = new Element[] { el };              added = new Element[] { res[0], res[1] };            }          edit.addRemovedElements(removed);          edit.addAddedElements(added);        }    }