Created attachment 33405 [details] Input file with 12 test pictures If a document contains a number of images with "Layout" options different from "Inline with text", they are missing from the output document. Attached is a document with 12 sample images with different layouts : - First row has 3 images "Inline with text". They are kept after save - Second and third row have images with different text alignments Square, Tight, Through, Top/Bottom, Behind and In front of text. These are lost after save. - Fourth row has the same images as first row. They are kept after save. The Java code to reproduce the error only needs to open the file and save it, without modifications : HWPFDocument doc = new HWPFDocument(new FileInputStream(inFile)); FileOutputStream fos = new FileOutputStream(outFile); doc.write(fos); fos.close();
Created attachment 33406 [details] Input file with a single picture The image is also lost if it is alone in the document.
The following testcase illustrates the problem : public void testImageCountLayout() throws Exception { HWPFDocument docA = HWPFTestDataSamples.openSampleFile("Bug58804-picture_single.doc"); ByteArrayOutputStream out = new ByteArrayOutputStream(); docA.write(out); out.close(); HWPFDocument docB = new HWPFDocument(new ByteArrayInputStream(out.toByteArray())); assertNotNull(docA.getPicturesTable()); assertNotNull(docB.getPicturesTable()); PicturesTable picA = docA.getPicturesTable(); PicturesTable picB = docB.getPicturesTable(); List<Picture> picturesA = picA.getAllPictures(); List<Picture> picturesB = picB.getAllPictures(); assertEquals(1, picturesA.size()); assertEquals(1, picturesB.size()); } In this case, the test fails because picturesB is empty where it should be 1.
I tried to take a look, but could not dig deep enough here, there is however now an ignored unit test in TestPictures as of r1726681 which reproduces this problem.