From dfee7d93b4e863d673c45921f79bb876b5738ea6 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Thu, 8 Mar 2018 09:01:17 +0900 Subject: sw: get rid of FN_UNO_GRAPHIC_U_R_L and "GraphicURL" property MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I6148016658e5bb46fd4f8765a233a434174791fd Reviewed-on: https://gerrit.libreoffice.org/50922 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- qadevOOo/runner/util/WriterTools.java | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'qadevOOo/runner') diff --git a/qadevOOo/runner/util/WriterTools.java b/qadevOOo/runner/util/WriterTools.java index 250ecbf6be45..ad769ca8623a 100644 --- a/qadevOOo/runner/util/WriterTools.java +++ b/qadevOOo/runner/util/WriterTools.java @@ -27,13 +27,19 @@ import com.sun.star.drawing.XDrawPageSupplier; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XMultiComponentFactory; import com.sun.star.text.XText; import com.sun.star.text.XTextContent; import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextDocument; +import com.sun.star.graphic.XGraphic; +import com.sun.star.graphic.XGraphicProvider; +import com.sun.star.graphic.GraphicProvider; + import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; public class WriterTools { public static XTextDocument createTextDoc(XMultiServiceFactory xMSF) { @@ -77,13 +83,27 @@ public class WriterTools { } public static void insertTextGraphic(XTextDocument aDoc, - XMultiServiceFactory xMSF, int hpos, + XMultiServiceFactory xMSF, XComponentContext xContext, int hpos, int vpos, int width, int height, String pic, String name) { try { Object oGObject = xMSF.createInstance( "com.sun.star.text.GraphicObject"); + XGraphicProvider xGraphicProvider = UnoRuntime.queryInterface( + XGraphicProvider.class, + xContext.getServiceManager().createInstanceWithContext( + "com.sun.star.graphic.GraphicProvider", xContext)); + + String fullURL = util.utils.getFullTestURL(pic); + + PropertyValue[] aMediaProps = new PropertyValue[] { new PropertyValue() }; + aMediaProps[0].Name = "URL"; + aMediaProps[0].Value = fullURL; + + XGraphic xGraphic = UnoRuntime.queryInterface(XGraphic.class, + xGraphicProvider.queryGraphic(aMediaProps)); + XText the_text = aDoc.getText(); XTextCursor the_cursor = the_text.createTextCursor(); XTextContent the_content = UnoRuntime.queryInterface( @@ -93,8 +113,7 @@ public class WriterTools { XPropertySet oProps = UnoRuntime.queryInterface( XPropertySet.class, oGObject); - String fullURL = util.utils.getFullTestURL(pic); - oProps.setPropertyValue("GraphicURL", fullURL); + oProps.setPropertyValue("Graphic", xGraphic); oProps.setPropertyValue("HoriOrientPosition", Integer.valueOf(hpos)); oProps.setPropertyValue("VertOrientPosition", Integer.valueOf(vpos)); oProps.setPropertyValue("Width", Integer.valueOf(width)); -- cgit