I am trying to insert a field into a document at the current cursor location with the following code:
Code: Select all
OpenOfficeDoc textDocument = getCurrentClientSite();
OpenOfficeField myNewPlaceholder = textDocument.createUserField(fieldName, fieldValue);
XText xText = textDocument.getXTextDocument().getText();
//GET THE CURRENT LOCATION
XController xController = textDocument.getXTextDocument().getCurrentController();
XTextViewCursorSupplier xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
//INSERT INTO THE TEXT CONTENT
xText.insertTextContent(xTextViewCursorSupplier.getViewCursor().getStart(), myNewPlaceholder.getxDependentTextField(), true);
uno.com.sun.star.uno.RuntimeException: text interface and cursor not related
i tried to figure it out but with no luck.
Can someone please help me why this error is coming.
Thanks,
Arpit