Change ODK example to use Graphic property instead of GraphicURL
Change-Id: I0a8b518a62c35da52008668c6e8cc7d0fd74e1d4
Reviewed-on: https://gerrit.libreoffice.org/51105
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
diff --git a/odk/examples/java/Text/GraphicsInserter.java b/odk/examples/java/Text/GraphicsInserter.java
index c49d118..b4b5b49 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",