-------------------------------------------
Hello community,
I've successfully inserted com.sun.star.text.GraphicObect to my writer document using the java uno api.
But the image doesn't have the option "in background" set, so the image is in front of the text.
How can I set this option and put the image behind the text? I don't find any property for that.
(I don't want to set the background image of the page)
Futhermore the write gui allows to place the image "from left" of a page and the user can set the distance from the left side of the page.
I only achieved to set the left margin of the image, but this is not the same.
This is my code:
Code: Select all
// iterate pages
do {
Object graphicObject = xWriterFactory.createInstance("com.sun.star.text.GraphicObject");
XTextContent xGOTextContent = (XTextContent)UnoRuntime.queryInterface(XTextContent.class, graphicObject);
XPropertySet xGOProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, graphicObject);
if (logFinest)
helper.dumpPropertySet(xGOProps, "Graphics");
xGOProps.setPropertyValue("GraphicURL", imgUrl.toString());
xGOProps.setPropertyValue("AnchorType", TextContentAnchorType.AT_PAGE);
xGOProps.setPropertyValue("HoriOrient", leftBorder ?
HoriOrientation.LEFT : HoriOrientation.RIGHT);
xGOProps.setPropertyValue("VertOrient", VertOrientation.CENTER);
// OO allows to say "hor. position 5mm from left", but I don't find
// a way to do that with uno. Using LeftMargin has a similar effect
// as long as the image is on the left side of the page ...
if (leftBorder)
xGOProps.setPropertyValue("LeftMargin", new Integer(500)); // == 5mm
else
xGOProps.setPropertyValue("RightMargin", new Integer(500)); // == 5mm
xGOProps.setPropertyValue("TextWrap", WrapTextMode.THROUGHT);
xGOProps.setPropertyValue("Width", new Integer(image.getWidthInMm()));
xGOProps.setPropertyValue("Height", new Integer(image.getHeightInMm()));
// insert the image at the cursor's position (by page number)
viewCursor.getText().insertTextContent(viewCursor, xGOTextContent, false);
} while (pageCursor.jumpToNextPage());