[Solved] Insert image with option "in background" in writer

The Application Programming Interface and the OASIS Open Document Format

[Solved] Insert image with option "in background" in writer

Postby grosenick » Mon Aug 11, 2008 8:25 am

I think now I've got it: setting the property "Opaque" to Boolean.FALSE has this effect ...

-------------------------------------------

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   Expand viewCollapse view
                // 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());

Thank you for support!
OOo 2.4.X on openSuse 11 + Windows XP
grosenick
 
Posts: 3
Joined: Sat Jul 12, 2008 3:48 pm

Re: [Solved] Insert image with option "in background" in writer

Postby Hagar Delest » Mon Aug 11, 2008 1:56 pm

grosenick wrote:Thank you for support!

You're welcome! :D
Anyway, thanks for the follow up. This post is mainly to remove it from the unanswered posts list!
AOO 4.1.7 on Xubuntu 19.10 and 4.1.5 on Windows 10 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28588
Joined: Sun Oct 07, 2007 9:07 pm
Location: France


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest