InsertHelper { public void insertObject(final OdsDocument document, final Table table, final String frameName, final String objectName, final String objectMediaType, final String objectVersion, final InputStream sourceStream, final SVGRectangle rectangle, final GraphicStyle gs) throws IOException { document.addExtraObject(objectName, objectMediaType, objectVersion); final Map<String, OdsArchiveExplorer.OdsFile> fileByName = new OdsArchiveExplorer(this.fileUtil, sourceStream).explore(); for (final Map.Entry<String, OdsArchiveExplorer.OdsFile> entry : fileByName.entrySet()) { final String name = entry.getKey(); if (name.equals(ManifestElement.META_INF_MANIFEST_XML) || name.equals("mimetype") || name.startsWith("Thumbnails")) { continue; } entry.getValue().addToDocument(document, objectName + "/"); } table.addShape(DrawFrame.builder(frameName, new DrawObject("./" + objectName, Collections.<RangeRef>emptyList()), rectangle) .style(gs).build()); } InsertHelper(final FileUtil fileUtil); static InsertHelper create(); void insertImage(final OdsDocument document, final Table table, final String frameName,
                            final File source, final String destName, final SVGRectangle rectangle); void insertImage(final OdsDocument document, final Table table, final String frameName,
                            final InputStream sourceStream, final String destName,
                            final SVGRectangle rectangle); DrawFillBitmap createDrawFillImage(final OdsDocument document,
                                              final InputStream sourceStream, final String name,
                                              final String href); void insertObject(final OdsDocument document, final Table table, final String frameName,
                             final String objectName, final String objectMediaType,
                             final String objectVersion, final InputStream sourceStream,
                             final SVGRectangle rectangle, final GraphicStyle gs);  }
@Test public void testInsertObject() throws IOException { final byte[] content = (XMLUtil.XML_PROLOG + "\n<root/>").getBytes(CharsetUtil.UTF_8); final byte[] bs = this.createAlmostEmptyZipFile(content); final SVGRectangle rectangle = SVGRectangle.cm(0, 1, 2, 3); final Capture<DrawFrame> df = EasyMock.newCapture(); PowerMock.resetAll(); this.document.addExtraFile("object/content.xml", null, content); this.document.addExtraObject("object", "media/type", "1.0"); this.table.addShape(EasyMock.capture(df)); PowerMock.replayAll(); this.ih.insertObject(this.document, this.table, "frame", "object", "media/type", "1.0", new ByteArrayInputStream(bs), rectangle, GraphicStyle.builder("gs").build()); PowerMock.verifyAll(); TestHelper.assertXMLEquals( "<draw:frame draw:name=\"frame\" draw:z-index=\"0\" draw:style-name=\"gs\" svg:x=\"0cm\" svg:y=\"1cm\" svg:width=\"2cm\" svg:height=\"3cm\">" + "<draw:object xlink:href=\"./object\" draw:notify-on-update-of-ranges=\"\" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>" + "</draw:frame>", df.getValue()); }