Hello,
Im trying to insert an image (a Gif image) under the cursor (the visual
one, which the user uses for editing) inside the Writer of
OpenOffice.org, but it seems to not work.
Instead, the image is always pasted at the top of the Frame of
OpenWriter. And, despite alle my investigation how to change it, I
could archive to paste the image under the cursor .
Even if I try to change the values inside of :
xPropSet.setPropertyValue("HoriOrientPosition",1000);
to
xPropSet.setPropertyValue("HoriOrientPosition",5000);
it also changes nothing. I don't know how to solve it. What am I doing
wrong here ?
Tank you a lot in advance !
Regards,
- Daniel
Here my code :
====================================
//Creating GraphicObject
Object oGraphic =
xMultiServiceFactory.createInstance("com.sun.star.text.GraphicObject");
//getting actual Cursor
XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class,
xComponent);
XController xController = xModel.getCurrentController();
XTextViewCursorSupplier xViewCursorSupplier =
(XTextViewCursorSupplier) UnoRuntime.queryInterface(
XTextViewCursorSupplier.class, xController);
XTextViewCursor xTextViewCursor =
xViewCursorSupplier.getViewCursor();
// Getting the text
com.sun.star.text.XText xText = xTextDocument.getText();
// Querying for the interface XTextContent on the GraphicObject
com.sun.star.text.XTextContent xTextContent =
(com.sun.star.text.XTextContent) UnoRuntime.queryInterface(
com.sun.star.text.XTextContent.class, oGraphic);
// Inserting the content
xText.insertTextContent(xTextViewCursor, xTextContent, true);
// Querying for the interface XPropertySet on GraphicObject
com.sun.star.beans.XPropertySet xPropSet =
(com.sun.star.beans.XPropertySet)
UnoRuntime.queryInterface(
com.sun.star.beans.XPropertySet.class,
oGraphic);
java.io.File sourceFile = new java.io.File("src/data/picture.gif");
xPropSet.setPropertyValue("AnchorType",
com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH);
// Setting the graphic url
xPropSet.setPropertyValue("GraphicURL", sUrl.toString());
System.out.println("(x,y): (" +
xTextViewCursor.getPosition().X + "," + xTextViewCursor.getPosition().Y
+ ")");
// Setting the horizontal position
xPropSet.setPropertyValue("HoriOrientPosition", new
Integer(xTextViewCursor.getPosition().X));
// Setting the vertical position
xPropSet.setPropertyValue("VertOrientPosition", new
Integer(xTextViewCursor.getPosition().Y));
xPropSet.setPropertyValue("Width", new
Integer(8000));xPropSet.setPropertyValue("Height", new Integer(4000));
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]