Apache OpenOffice (AOO) Bugzilla – Issue 50692
XText.insertTextContent(XTextRange, XTextContent, boolean) crash-down
Last modified: 2013-02-24 21:09:48 UTC
When inserting a TextContent with XText.insertTextContent(XTextRange, XTextContent, boolean), with an XTextViewCursor as XTextRange, the OOo text document crashes down. The following is the example code: .... try { XTextViewCursorSupplier xTVCS= (XTextViewCursorSupplier) UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController); XTextViewCursor xTextViewCursor= xTVCS.getViewCursor(); XTextCursor xTextCursor = (XTextCursor) XText.createTextCursorByRange(xTextViewCursor.getStart()); Object aField= cMSF.createInstance ("com.sun.star.text.TextField.Annotation"); XPropertySet pSet= (XPropertySet)UnoRuntime.queryInterface (XPropertySet.class, aField); pSet.setPropertyValue("Content", "222222"); com.sun.star.text.XTextField aNote= (com.sun.star.text.XTextField) UnoRuntime.queryInterface(com.sun.star.text.XTextField.class, aField); xText.insertTextContent(xTextCursor.getEnd(), aNote, false); } catch(...){ ... }
sw->liaoyu7879: I ran the following macro with src680_m106 and had no problems to insert an annotation. Could you check the latest build if your problem still persists please. The macro I used, comparable to your java-code: view = thiscomponent.currentController xText = thiscomponent.Text xTextViewCursor = view.ViewCursor xTextCursor = xText.createTextCursorByRange(xTextViewCursor.getStart()) aField= thiscomponent.createInstance("com.sun.star.text.TextField.Annotation") aField.setPropertyValue("Content", "222222") xText.insertTextContent(xTextCursor.getEnd(), aField, false)
I've tested it under OOo1.9.104, and the crash-down didn't occur. So this must have been fixed.