Apache OpenOffice (AOO) Bugzilla – Issue 52776
Problem with XTextViewCursor and Image
Last modified: 2013-02-24 21:06:55 UTC
Hi all, I play with OfficeBean and Writer (OOo 2.0), and experience a problem. I would like to create an embedded-image in the document and then position the viewCursor to a specified range. The embedded-image did create successfully, but unfortunately, I could not ask the viewCursor to do anything after that. Whatever operations (gotoStart(), gotoRange(), goRight…) generated the following exception: com.sun.star.uno.RuntimeException: no text selection It seems like the viewCursor is trapped by the image and is no longer available. Here is my code: // Create the image through the dispatch interface (component is an object subclass-ed from OOoBean) OfficeCommand officeCommand = new OfficeCommand((short)10241); officeCommand.appendParameter("FileName", imagePath); officeCommand.appendParameter("FilterName", "<All formats>"); officeCommand.appendParameter("AsLink", new Boolean(false)); officeCommand.appendParameter("Style", "Graphics"); officeCommand.execute(component, component.getXURLTransformer(), component.getXDispatchProvider()); // Ask the viewCursor to go to the Start of the page XTextViewCursorSupplier xTextViewCursorSupplier = (XTextViewCursorSupplier)UnoRuntime.queryInterface (XTextViewCursorSupplier.class, component.getDocument().getCurrentController()); XTextViewCursor cursor = xTextViewCursorSupplier.getViewCursor(); cursor.gotoStart(false); As I remember, the same set of operations worked fine with OOo1.1.x. Could anyone please help me? Thanks in advance. Best regards MuiFull
The RuntimeException appears because the textframe where the embedded graphic should be positioned in is selected and therefore no TextViewCursor which would make movements possible exists. To use the ViewCursor again for moving around, you'll have to change the current selection by using the SelectionSupplier and for example select the anchor of the textframe.
closing