Hello allirpa,

On Saturday 07 March 2009, 10:06, allirpa wrote:
> by the way, what's the difference if the image is embedded or displayed?

if you store the image using the embed API, you can use it for any purpose, 
and the user has no way to get rid of it in the UI. An image embedded as text 
graphic object, sure disapears if the user deletes it.

Sure you google and found different ways of embedding a text graphic object.
The way I like the most is the following:

instead of setting the GraphicURL property 
http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextGraphicObject.html#GraphicURL
set the Graphic property
http://api.openoffice.org/docs/common/ref/com/sun/star/text/TextGraphicObject.html#Graphic

Just replace in this example the property name and the object reference
http://svn.services.openoffice.org/opengrok/xref/DEV300_m42/odk/examples/java/Text/GraphicsInserter.java#155

        // Setting the graphic
        XGraphic xGraphic = getGraphicFromURL(
                                         xComponentContext, sGraphicFileURL);
        xPropSet.setPropertyValue("Graphic", xGraphic);

where getGraphicFromURL is

    public XGraphic getGraphicFromURL(
                                   XComponentContext xContext, String sURL ){
        XGraphic xGraphic = null;
        try {
            XGraphicProvider xGraphicProvider =
                    (XGraphicProvider) UnoRuntime.queryInterface(
                        XGraphicProvider.class,
                        xContext.getServiceManager().createInstanceWithContext(
                            "com.sun.star.graphic.GraphicProvider",
                            xContext));
            PropertyValue[] aMediaProperties = new PropertyValue[1];
            aMediaProperties[0] = new PropertyValue();
            aMediaProperties[0].Name = "URL";
            aMediaProperties[0].Value = sURL;
            xGraphic = xGraphicProvider.queryGraphic(aMediaProperties);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return xGraphic;
        }
    }


Regards
-- 
Ariel Constenla-Haile
La Plata, Argentina


"Aus der Kriegsschule des Lebens
                - Was mich nicht umbringt,
        macht mich härter."
                Nietzsche Götzendämmerung, Sprüche und Pfeile, 8.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@api.openoffice.org
For additional commands, e-mail: dev-h...@api.openoffice.org

Reply via email to