[Libreoffice-commits] core.git: odk/examples

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Mon Mar 12 23:35:54 UTC 2018


 odk/examples/java/Text/GraphicsInserter.java |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

New commits:
commit 5b87abe06da35ca3a11628674af23460349b439a
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Mon Mar 12 16:54:05 2018 +0900

    Change ODK example to use Graphic property instead of GraphicURL
    
    Change-Id: I0a8b518a62c35da52008668c6e8cc7d0fd74e1d4
    Reviewed-on: https://gerrit.libreoffice.org/51105
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>

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",


More information about the Libreoffice-commits mailing list