X-Git-Url: https://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=publishing%2Forg.argeo.publishing.ui%2Fsrc%2Forg%2Fargeo%2Fdocbook%2FDbkUtils.java;h=e153e86c39f226456c0d9f246bff00ddaf1742c5;hp=6a8da8e5d54c88bc4392fd3b8e58894e19047166;hb=1f5f12ce52315e19fb0016527c31127b70dceb5d;hpb=66379d9c0820976853556cc342d833a9918990b5 diff --git a/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/DbkUtils.java b/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/DbkUtils.java index 6a8da8e..e153e86 100644 --- a/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/DbkUtils.java +++ b/publishing/org.argeo.publishing.ui/src/org/argeo/docbook/DbkUtils.java @@ -69,6 +69,12 @@ public class DbkUtils { public static Node insertImageAfter(Node sibling) { try { + + // FIXME make it more robust + if (DocBookTypes.IMAGEDATA.equals(sibling.getName())) { + sibling = sibling.getParent().getParent(); + } + Node parent = sibling.getParent(); Node mediaNode = parent.addNode(DocBookTypes.MEDIAOBJECT, DocBookTypes.MEDIAOBJECT); // TODO optimise? @@ -78,12 +84,18 @@ public class DbkUtils { mediaNode.getName() + "[" + mediaNode.getIndex() + "]"); Node imageNode = mediaNode.addNode(DocBookTypes.IMAGEOBJECT, DocBookTypes.IMAGEOBJECT); - Node infoNode = imageNode.addNode(DocBookTypes.INFO, DocBookTypes.INFO); - Node imageDataNode = JcrUtils.copyBytesAsFile(infoNode, EntityType.box.get(), new byte[0]); - imageDataNode.addMixin(EntityType.box.get()); - imageDataNode.setProperty(EntityNames.SVG_WIDTH, 0); - imageDataNode.setProperty(EntityNames.SVG_LENGTH, 0); - imageDataNode.addMixin(NodeType.MIX_MIMETYPE); + Node imageDataNode = imageNode.addNode(DocBookTypes.IMAGEDATA, DocBookTypes.IMAGEDATA); +// Node infoNode = imageNode.addNode(DocBookTypes.INFO, DocBookTypes.INFO); +// Node fileNode = JcrUtils.copyBytesAsFile(mediaFolder, EntityType.box.get(), new byte[0]); +// fileNode.addMixin(EntityType.box.get()); +// fileNode.setProperty(EntityNames.SVG_WIDTH, 0); +// fileNode.setProperty(EntityNames.SVG_LENGTH, 0); +// fileNode.addMixin(NodeType.MIX_MIMETYPE); +// +// // we assume this is a folder next to the main DocBook document +// // TODO make it more robust and generic +// String fileRef = mediaNode.getName(); +// imageDataNode.setProperty(DocBookNames.DBK_FILEREF, fileRef); return imageDataNode; } catch (RepositoryException e) { throw new JcrException("Cannot insert empty image after " + sibling, e);