diff options
Diffstat (limited to 'odk')
-rw-r--r-- | odk/examples/java/Text/GraphicsInserter.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/odk/examples/java/Text/GraphicsInserter.java b/odk/examples/java/Text/GraphicsInserter.java index c49d118b69d6..b4b5b49eaa62 100644 --- a/odk/examples/java/Text/GraphicsInserter.java +++ b/odk/examples/java/Text/GraphicsInserter.java @@ -99,8 +99,8 @@ public class GraphicsInserter { Object oGraphic = null; try { // Creating the service GraphicObject - oGraphic = - xMSFDoc.createInstance("com.sun.star.text.TextGraphicObject"); + oGraphic =xMSFDoc + .createInstance("com.sun.star.text.TextGraphicObject"); } catch ( Exception exception ) { System.out.println( "Could not create instance" ); @@ -142,12 +142,26 @@ public class GraphicsInserter { sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/')); System.out.println( "insert graphic \"" + sUrl + "\""); + com.sun.star.graphic.XGraphicProvider xGraphicProvider = + UnoRuntime.queryInterface(com.sun.star.graphic.XGraphicProvider.class, + xMCF.createInstanceWithContext("com.sun.star.graphic.GraphicProvider", + xContext)); + + + com.sun.star.beans.PropertyValue[] aMediaProps = new com.sun.star.beans.PropertyValue[] { new com.sun.star.beans.PropertyValue() }; + aMediaProps[0].Name = "URL"; + aMediaProps[0].Value = sUrl; + + com.sun.star.graphic.XGraphic xGraphic = + UnoRuntime.queryInterface(com.sun.star.graphic.XGraphic.class, + xGraphicProvider.queryGraphic(aMediaProps)); + // Setting the anchor type xPropSet.setPropertyValue("AnchorType", com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH ); // Setting the graphic url - xPropSet.setPropertyValue( "GraphicURL", sUrl.toString() ); + xPropSet.setPropertyValue( "Graphic", xGraphic ); // Setting the horizontal position xPropSet.setPropertyValue( "HoriOrientPosition", |