if (document != null) {
System.out.println("Loaded document");
ITextDocument textDocument = (ITextDocument) document;
ITextContentEnumeration textEnumeration = textDocument
.getTextService().getText().getTextContentEnumeration();
IParagraph[] paragraphs = textEnumeration.getParagraphs();
ITextRange newTextRange = textDocument.getViewCursorService()
.getViewCursor().getStartTextRange();
XTextCursor cursor = newTextRange.getXTextRange().getText()
.createTextCursor();